Fixing button locking, part I
This commit is contained in:
@@ -260,19 +260,13 @@ void BCAnimatedDelegate::paintSliderIndicator(QPainter* painter, const QStyleOpt
|
|||||||
-option.rect.height() / 2 + 2
|
-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
|
// Mini Progress Bar
|
||||||
painter->setPen(Qt::NoPen);
|
painter->setPen(Qt::NoPen);
|
||||||
painter->setBrush(QColor(0xE0E0E0));
|
painter->setBrush(QColor(0xE0E0E0));
|
||||||
painter->drawRoundedRect(barRect, 2, 2);
|
painter->drawRoundedRect(barRect, 2, 2);
|
||||||
|
|
||||||
QRect fillRect = barRect;
|
QRect fillRect = barRect;
|
||||||
fillRect.setWidth(barRect.width() * value / 100);
|
fillRect.setWidth(barRect.width() * valueX.calcRatio() );
|
||||||
painter->setBrush(QColor(0x0078D4));
|
painter->setBrush(QColor(0x0078D4));
|
||||||
painter->drawRoundedRect(fillRect, 2, 2);
|
painter->drawRoundedRect(fillRect, 2, 2);
|
||||||
|
|
||||||
|
|||||||
@@ -313,14 +313,10 @@ void BCMainWindow::onValueUpdated(BCDevice::ID deviceID, int index, BCValue::Sta
|
|||||||
|
|
||||||
void BCMainWindow::onSyncDeviceView()
|
void BCMainWindow::onSyncDeviceView()
|
||||||
{
|
{
|
||||||
|
|
||||||
Q_ASSERT_X(_currentPanel, "onSyncDeviceView()", "_currentpanel ist null!");
|
Q_ASSERT_X(_currentPanel, "onSyncDeviceView()", "_currentpanel ist null!");
|
||||||
|
|
||||||
qDebug() << " ---Syncing";
|
|
||||||
|
|
||||||
const BCValueList& currentList =_currentPanel->getValueListX();
|
const BCValueList& currentList =_currentPanel->getValueListX();
|
||||||
|
|
||||||
// alle einzeln? echt jetzt?
|
_syncButton->setEnabled( false );
|
||||||
|
|
||||||
for( const BCValuePtr& value : currentList )
|
for( const BCValuePtr& value : currentList )
|
||||||
{
|
{
|
||||||
@@ -336,4 +332,6 @@ void BCMainWindow::onSyncDeviceView()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//_syncButton->setEnabled( true );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ void BCTransmitter::onUpdateValue( BCValuePtrConst valuePtr)
|
|||||||
|
|
||||||
// __fix
|
// __fix
|
||||||
//bc::processEventsFor(150);
|
//bc::processEventsFor(150);
|
||||||
bc::delay_millis(50);
|
bc::delay_millis(150);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,13 +80,11 @@ private:
|
|||||||
TransmitResult readByteValue( uint32_t deviceID, uint8_t registerID );
|
TransmitResult readByteValue( uint32_t deviceID, uint8_t registerID );
|
||||||
TransmitResult readWordValue( uint32_t deviceID, uint8_t registerID );
|
TransmitResult readWordValue( uint32_t deviceID, uint8_t registerID );
|
||||||
|
|
||||||
//using BCDataQueue = QQueue<BCValuePtrConst>;
|
using BCDataQueue = QQueue<BCValuePtrConst>;
|
||||||
|
BCDataQueue _valueQueue;
|
||||||
//BCDataQueue _valueQueue;
|
|
||||||
//QMutex _mutex;
|
//QMutex _mutex;
|
||||||
//std::atomic<bool> _isBusy{ false };
|
//std::atomic<bool> _isBusy{ false };
|
||||||
|
|
||||||
// __fix!
|
|
||||||
BCDriver* _canDriver{};
|
BCDriver* _canDriver{};
|
||||||
BCDriverTinyCan _tinyCanDriver{};
|
BCDriverTinyCan _tinyCanDriver{};
|
||||||
BCDriverDummy _dummyDriver{};
|
BCDriverDummy _dummyDriver{};
|
||||||
|
|||||||
28
bcvalue.cpp
28
bcvalue.cpp
@@ -53,11 +53,37 @@ QString BCValue::formatValues( uint32_t value ) const
|
|||||||
return QString::number(result, 'f', 2);
|
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
|
void BCValue::dumpValue() const
|
||||||
{
|
{
|
||||||
|
|
||||||
qDebug() << "DeviceID: " << deviceID << " Register: " << registerID << " state:" " << state << " << " label: " << label;
|
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() << "indexRow: " << indexRow << " isWord: " << isWord;
|
||||||
qDebug();
|
qDebug();
|
||||||
|
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ public:
|
|||||||
BCValue( BCDevice::ID deviceID_, BC::ID registerID_ );
|
BCValue( BCDevice::ID deviceID_, BC::ID registerID_ );
|
||||||
|
|
||||||
QString formatValues( uint32_t value ) const;
|
QString formatValues( uint32_t value ) const;
|
||||||
|
double calcRatio() const;
|
||||||
void dumpValue() const;
|
void dumpValue() const;
|
||||||
|
|
||||||
mutable States state{BCValue::State::ReadOnly};
|
mutable States state{BCValue::State::ReadOnly};
|
||||||
@@ -107,8 +108,8 @@ public:
|
|||||||
bool isWord{false};
|
bool isWord{false};
|
||||||
QString unitLabel;
|
QString unitLabel;
|
||||||
double factor{1};
|
double factor{1};
|
||||||
OptDouble min;
|
OptDouble optMin;
|
||||||
OptDouble max;
|
OptDouble optMax;
|
||||||
};
|
};
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(BCValue::States)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(BCValue::States)
|
||||||
|
|
||||||
|
|||||||
@@ -212,8 +212,8 @@ std::optional<BCValuePtr> BCXmlLoader::makeValue( BCDevice::ID deviceID, const B
|
|||||||
BCValue& newValue = *newValuePtr.get();
|
BCValue& newValue = *newValuePtr.get();
|
||||||
|
|
||||||
setIfExists( params.Factor, newValue.factor );
|
setIfExists( params.Factor, newValue.factor );
|
||||||
setIfExists( params.Min, newValue.min );
|
setIfExists( params.Min, newValue.optMin );
|
||||||
setIfExists( params.Max, newValue.max );
|
setIfExists( params.Max, newValue.optMax );
|
||||||
setIfExists( params.IsWord, newValue.isWord );
|
setIfExists( params.IsWord, newValue.isWord );
|
||||||
|
|
||||||
newValue.label = params.Label;
|
newValue.label = params.Label;
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ QToolButton:checked
|
|||||||
QToolButton:disabled
|
QToolButton:disabled
|
||||||
{
|
{
|
||||||
color: #A19F9D;
|
color: #A19F9D;
|
||||||
|
background-color: green;/*#0078D4;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -108,28 +109,33 @@ QTableView::item:hover
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QScrollBar::handle:horizontal {
|
QScrollBar::handle:horizontal
|
||||||
|
{
|
||||||
background-color: #C8C6C4;
|
background-color: #C8C6C4;
|
||||||
min-width: 40px;
|
min-width: 40px;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
margin: 2px;
|
margin: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
QScrollBar::handle:horizontal:hover {
|
QScrollBar::handle:horizontal:hover
|
||||||
|
{
|
||||||
background-color: #A19F9D;
|
background-color: #A19F9D;
|
||||||
}
|
}
|
||||||
|
|
||||||
QScrollBar::handle:horizontal:pressed {
|
QScrollBar::handle:horizontal:pressed
|
||||||
|
{
|
||||||
background-color: #8A8886;
|
background-color: #8A8886;
|
||||||
}
|
}
|
||||||
|
|
||||||
QScrollBar::add-line:horizontal,
|
QScrollBar::add-line:horizontal,
|
||||||
QScrollBar::sub-line:horizontal {
|
QScrollBar::sub-line:horizontal
|
||||||
|
{
|
||||||
width: 0px;
|
width: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
QScrollBar::add-page:horizontal,
|
QScrollBar::add-page:horizontal,
|
||||||
QScrollBar::sub-page:horizontal {
|
QScrollBar::sub-page:horizontal
|
||||||
|
{
|
||||||
background: none;
|
background: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user