From a8a947ff0b1f1f85823fe091e1553ff658d8c866 Mon Sep 17 00:00:00 2001 From: "PANIK\\chris" Date: Tue, 6 Jan 2026 18:47:08 +0100 Subject: [PATCH] Fixing button locking, part I --- bcanimateddelegate.cpp | 8 +------- bcmainwindow.cpp | 8 +++----- bctransmitter.cpp | 2 +- bctransmitter.h | 6 ++---- bcvalue.cpp | 28 +++++++++++++++++++++++++++- bcvalue.h | 5 +++-- bcxmlloader.cpp | 4 ++-- resources/bionxcontrol.qss | 16 +++++++++++----- 8 files changed, 50 insertions(+), 27 deletions(-) diff --git a/bcanimateddelegate.cpp b/bcanimateddelegate.cpp index d04e83d..ca8e6c3 100644 --- a/bcanimateddelegate.cpp +++ b/bcanimateddelegate.cpp @@ -260,19 +260,13 @@ void BCAnimatedDelegate::paintSliderIndicator(QPainter* painter, const QStyleOpt -option.rect.height() / 2 + 2 ); - //QRect barRect = option.rect; - // Text - //painter->setPen(option.state & QStyle::State_Selected ? option.palette.highlightedText().color() : Qt::black); - //painter->drawText(textRect, Qt::AlignVCenter | Qt::AlignLeft, - // QString::number(value)); - // Mini Progress Bar painter->setPen(Qt::NoPen); painter->setBrush(QColor(0xE0E0E0)); painter->drawRoundedRect(barRect, 2, 2); QRect fillRect = barRect; - fillRect.setWidth(barRect.width() * value / 100); + fillRect.setWidth(barRect.width() * valueX.calcRatio() ); painter->setBrush(QColor(0x0078D4)); painter->drawRoundedRect(fillRect, 2, 2); diff --git a/bcmainwindow.cpp b/bcmainwindow.cpp index 4e551d4..990d0a5 100644 --- a/bcmainwindow.cpp +++ b/bcmainwindow.cpp @@ -313,14 +313,10 @@ void BCMainWindow::onValueUpdated(BCDevice::ID deviceID, int index, BCValue::Sta void BCMainWindow::onSyncDeviceView() { - Q_ASSERT_X(_currentPanel, "onSyncDeviceView()", "_currentpanel ist null!"); - - qDebug() << " ---Syncing"; - const BCValueList& currentList =_currentPanel->getValueListX(); - // alle einzeln? echt jetzt? + _syncButton->setEnabled( false ); for( const BCValuePtr& value : currentList ) { @@ -336,4 +332,6 @@ void BCMainWindow::onSyncDeviceView() } + //_syncButton->setEnabled( true ); + } diff --git a/bctransmitter.cpp b/bctransmitter.cpp index a17ed4c..d8d83b9 100644 --- a/bctransmitter.cpp +++ b/bctransmitter.cpp @@ -183,7 +183,7 @@ void BCTransmitter::onUpdateValue( BCValuePtrConst valuePtr) // __fix //bc::processEventsFor(150); - bc::delay_millis(50); + bc::delay_millis(150); } diff --git a/bctransmitter.h b/bctransmitter.h index 5f414f6..a307a7f 100644 --- a/bctransmitter.h +++ b/bctransmitter.h @@ -80,13 +80,11 @@ private: TransmitResult readByteValue( uint32_t deviceID, uint8_t registerID ); TransmitResult readWordValue( uint32_t deviceID, uint8_t registerID ); - //using BCDataQueue = QQueue; - - //BCDataQueue _valueQueue; + using BCDataQueue = QQueue; + BCDataQueue _valueQueue; //QMutex _mutex; //std::atomic _isBusy{ false }; - // __fix! BCDriver* _canDriver{}; BCDriverTinyCan _tinyCanDriver{}; BCDriverDummy _dummyDriver{}; diff --git a/bcvalue.cpp b/bcvalue.cpp index 12bcb4a..13c36a4 100644 --- a/bcvalue.cpp +++ b/bcvalue.cpp @@ -53,11 +53,37 @@ QString BCValue::formatValues( uint32_t value ) const return QString::number(result, 'f', 2); } + +double BCValue::calcRatio() const +{ + return 0.33; + + double ratio = 0; + + if( optMin.has_value() && optMax.has_value() ) + { + + double min = optMin.value(); + double max = optMax.value(); + + double range = max - min; + + // Safety: Division durch Null verhindern (wenn min == max) + if (std::abs(range) < 1e-9) + return ratio; + + // Die eigentliche Formel + ratio = ((rawValue - min) / range); + //ratio = (int) qBound( min,ratio, max); + } + return ratio; +} + void BCValue::dumpValue() const { qDebug() << "DeviceID: " << deviceID << " Register: " << registerID << " state:" " << state << " << " label: " << label; - qDebug() << "visibleValue: " << visibleValue << " min: " << min << " max: " << max << " factor: " << factor << " ValueType: " << (char)valueType << " "; + qDebug() << "visibleValue: " << visibleValue << " min: " << optMin << " max: " << optMax << " factor: " << factor << " ValueType: " << (char)valueType << " "; qDebug() << "indexRow: " << indexRow << " isWord: " << isWord; qDebug(); diff --git a/bcvalue.h b/bcvalue.h index 118f563..2223238 100644 --- a/bcvalue.h +++ b/bcvalue.h @@ -94,6 +94,7 @@ public: BCValue( BCDevice::ID deviceID_, BC::ID registerID_ ); QString formatValues( uint32_t value ) const; + double calcRatio() const; void dumpValue() const; mutable States state{BCValue::State::ReadOnly}; @@ -107,8 +108,8 @@ public: bool isWord{false}; QString unitLabel; double factor{1}; - OptDouble min; - OptDouble max; + OptDouble optMin; + OptDouble optMax; }; Q_DECLARE_OPERATORS_FOR_FLAGS(BCValue::States) diff --git a/bcxmlloader.cpp b/bcxmlloader.cpp index fabd87f..25d6667 100644 --- a/bcxmlloader.cpp +++ b/bcxmlloader.cpp @@ -212,8 +212,8 @@ std::optional BCXmlLoader::makeValue( BCDevice::ID deviceID, const B BCValue& newValue = *newValuePtr.get(); setIfExists( params.Factor, newValue.factor ); - setIfExists( params.Min, newValue.min ); - setIfExists( params.Max, newValue.max ); + setIfExists( params.Min, newValue.optMin ); + setIfExists( params.Max, newValue.optMax ); setIfExists( params.IsWord, newValue.isWord ); newValue.label = params.Label; diff --git a/resources/bionxcontrol.qss b/resources/bionxcontrol.qss index ada3b5d..787cbdf 100644 --- a/resources/bionxcontrol.qss +++ b/resources/bionxcontrol.qss @@ -86,6 +86,7 @@ QToolButton:checked QToolButton:disabled { color: #A19F9D; + background-color: green;/*#0078D4;*/ } @@ -108,28 +109,33 @@ QTableView::item:hover } -QScrollBar::handle:horizontal { +QScrollBar::handle:horizontal + { background-color: #C8C6C4; min-width: 40px; border-radius: 6px; margin: 2px; } -QScrollBar::handle:horizontal:hover { +QScrollBar::handle:horizontal:hover +{ background-color: #A19F9D; } -QScrollBar::handle:horizontal:pressed { +QScrollBar::handle:horizontal:pressed +{ background-color: #8A8886; } QScrollBar::add-line:horizontal, -QScrollBar::sub-line:horizontal { +QScrollBar::sub-line:horizontal +{ width: 0px; } QScrollBar::add-page:horizontal, -QScrollBar::sub-page:horizontal { +QScrollBar::sub-page:horizontal +{ background: none; }