Fixing button locking, part I

This commit is contained in:
2026-01-06 18:47:08 +01:00
parent 221e0bc8c2
commit a8a947ff0b
8 changed files with 50 additions and 27 deletions

View File

@@ -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);

View File

@@ -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 );
}

View File

@@ -183,7 +183,7 @@ void BCTransmitter::onUpdateValue( BCValuePtrConst valuePtr)
// __fix
//bc::processEventsFor(150);
bc::delay_millis(50);
bc::delay_millis(150);
}

View File

@@ -80,13 +80,11 @@ private:
TransmitResult readByteValue( uint32_t deviceID, uint8_t registerID );
TransmitResult readWordValue( uint32_t deviceID, uint8_t registerID );
//using BCDataQueue = QQueue<BCValuePtrConst>;
//BCDataQueue _valueQueue;
using BCDataQueue = QQueue<BCValuePtrConst>;
BCDataQueue _valueQueue;
//QMutex _mutex;
//std::atomic<bool> _isBusy{ false };
// __fix!
BCDriver* _canDriver{};
BCDriverTinyCan _tinyCanDriver{};
BCDriverDummy _dummyDriver{};

View File

@@ -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();

View File

@@ -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)

View File

@@ -212,8 +212,8 @@ std::optional<BCValuePtr> 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;

View File

@@ -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;
}