Files
BionxControl/bcvalueslider.cpp

86 lines
2.3 KiB
C++
Raw Permalink Normal View History

2026-02-09 16:03:09 +01:00
/***************************************************************************
2026-01-10 22:18:54 +01:00
2026-02-09 16:03:09 +01:00
BionxControl
© 2025 -2026 christoph holzheuer
christoph.holzheuer@gmail.com
2026-01-11 11:37:52 +01:00
2026-02-09 16:03:09 +01:00
Using:
2026-01-10 22:18:54 +01:00
2026-02-09 16:03:09 +01:00
mhs_can_drv.c
© 2011 - 2023 by MHS-Elektronik GmbH & Co. KG, Germany
Klaus Demlehner, klaus@mhs-elektronik.de
@see www.mhs-elektronik.de
Based on Bionx data type descriptions from:
BigXionFlasher USB V 0.2.4 rev. 97
© 2011-2013 by Thomas Koenig <info@bigxionflasher.org>
@see www.bigxionflasher.org
Bionx Bike Info
© 2018 Thorsten Schmidt (tschmidt@ts-soft.de)
@see www.ts-soft.de
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
@see https://github.com/bikemike/bionx-bikeinfo
***************************************************************************/
#include <QPushButton>
#include <bcvalueslider.h>
BCValueSlider::BCValueSlider( QWidget *parent )
2026-01-18 18:52:30 +01:00
: QWidget(parent)
2026-01-10 22:18:54 +01:00
{
2026-01-11 11:37:52 +01:00
setupUi(this);
2026-01-10 22:18:54 +01:00
2026-01-11 14:48:51 +01:00
// wir wollen ja modern sein
2026-03-29 23:30:42 +02:00
//_sliderStyle = std::make_unique<BCValueSliderStyle>();
//_slider->setStyle(_sliderStyle.get());
2026-01-10 22:18:54 +01:00
setAutoFillBackground(true);
2026-01-11 14:48:51 +01:00
2026-01-11 11:37:52 +01:00
QSizePolicy sp = _commitButton->sizePolicy();
sp.setRetainSizeWhenHidden(true); // <--- Das ist der magische Schalter
_commitButton->setSizePolicy(sp);
2026-01-10 22:18:54 +01:00
// Wenn Slider bewegt wird -> Signal nach außen senden
connect(_slider, &QSlider::valueChanged, this, [this](int val)
2026-03-29 23:30:42 +02:00
{
emit valueChanged(val);
});
2026-01-10 22:18:54 +01:00
// Wenn Reset gedrückt wird -> Slider auf 0 (löst auch valueChanged aus)
2026-01-11 11:37:52 +01:00
connect(_commitButton, &QPushButton::clicked, this, [this]()
2026-03-29 23:30:42 +02:00
{
emit valueCommited( value() );
});
2026-01-18 18:52:30 +01:00
2026-01-10 22:18:54 +01:00
}
2026-02-09 16:03:09 +01:00
int BCValueSlider::value() const
2026-01-10 22:18:54 +01:00
{
return _slider->value();
}
2026-02-09 16:03:09 +01:00
void BCValueSlider::setValueAndRange( const BCValue::ValueRange& params )
2026-01-10 22:18:54 +01:00
{
2026-01-21 17:07:00 +01:00
_slider->setRange( params.min, params.max);
2026-01-11 14:48:51 +01:00
// Block Signals verhindern Endlosschleifen, falls das Model
2026-01-10 22:18:54 +01:00
// das Widget während des Updates neu setzt (passiert manchmal bei Live-Updates).
2026-01-21 17:07:00 +01:00
if (params.value != _slider->value())
2026-01-10 22:18:54 +01:00
{
bool blocked = _slider->blockSignals(true);
2026-01-21 17:07:00 +01:00
_slider->setValue(params.value);
2026-01-10 22:18:54 +01:00
_slider->blockSignals(blocked);
}
2026-01-19 16:44:52 +01:00
}
2026-01-22 22:16:19 +01:00