diff --git a/bcdeviceview.cpp b/bcdeviceview.cpp index 9ac4bdf..2dba40e 100644 --- a/bcdeviceview.cpp +++ b/bcdeviceview.cpp @@ -47,8 +47,7 @@ BCDeviceView::BCDeviceView(QWidget *parent) _itemDelegate = new BCValueDelegate( _valueModel.getValueList(), this); setItemDelegateForColumn( 1, _itemDelegate ); /* - //#e0e0e0 - setStyleSheet( R"(QTableView::item:selected + setStyleSheet( R"(QTableView::item:selected { background-color: green; border: none; diff --git a/bcmainwindow.cpp b/bcmainwindow.cpp index e659433..c75d616 100644 --- a/bcmainwindow.cpp +++ b/bcmainwindow.cpp @@ -204,7 +204,7 @@ void BCMainWindow::initStatusBar() _statusBar->showMessage("Bereit. (Dummy-Treiber eingestellt)"); - //setApplicationStyleSheet(cLightModeStyle); + setApplicationStyleSheet(cLightModeStyle); } diff --git a/bcvalue.h b/bcvalue.h index 33dad9a..fbc3fd7 100644 --- a/bcvalue.h +++ b/bcvalue.h @@ -111,20 +111,20 @@ public: //void setDeviceID(BCDevice::ID newDeviceID) { deviceID = newDeviceID; } BC::ID getRegisterID() const noexcept { return registerID; } - void setRegisterID(BC::ID newRegisterID) { registerID = newRegisterID; } ValueType getValueType() const noexcept { return valueType; } - void setValueType(ValueType newValueType) { valueType = newValueType; } int getIndexRow() const noexcept { return indexRow; } void setIndexRow(int newIndexRow) { indexRow = newIndexRow; } QString getLabel() const { return label; } - void setLabel(const QString &newLabel) { label = newLabel; } uint32_t getRawValue() const noexcept { return rawValue; } void setRawValue(uint32_t newRawValue) const { rawValue = newRawValue; } + void setFromDouble( double value ) + {} + QString getUnitLabel() const { return unitLabel; } void setUnitLabel(const QString &newUnitLabel) { unitLabel = newUnitLabel; } diff --git a/bcvaluedelegate.cpp b/bcvaluedelegate.cpp index 6097abb..6ed45e4 100644 --- a/bcvaluedelegate.cpp +++ b/bcvaluedelegate.cpp @@ -54,7 +54,6 @@ BCValueDelegate::BCValueDelegate(const BCValueList& valueList, QTableView* view) } - QWidget* BCValueDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex& index) const { const BCValue& bcValue = *(_valueList[ index.row()].get()); @@ -79,26 +78,10 @@ QWidget* BCValueDelegate::createEditor(QWidget *parent, const QStyleOptionViewIt void BCValueDelegate::setEditorData(QWidget *editor, const QModelIndex& index) const { - qDebug() << " setEditorData, warum?"; - /* - // Daten vom Model in den Editor laden - const BCValue& bc = *index.data(Qt::EditRole).value(); + Q_UNUSED(editor) + Q_UNUSED(index) - QSlider *slider = editor->findChild("slider"); - QLabel *lblUnit = editor->findChild("lblUnit"); - - if (slider && lblUnit) - { - bool olDriverState = slider->blockSignals(true); - slider->setValue(bc.formattedValue.toInt()); - slider->blockSignals(olDriverState); - lblUnit->setText(QString("%1 %2").arg(bc.formattedValue.toInt()).arg( "mm3")); - } - else - { - QStyledItemDelegate::setEditorData(editor, index); - } -*/ + // tue nix. } @@ -121,43 +104,6 @@ void BCValueDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, c QStyledItemDelegate::setModelData(editor, model, index); } -/* -QSize BCValueDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex& index) const -{ - return QStyledItemDelegate::sizeHint(option,index); - - QStyleOptionViewItem opt = option; - initStyleOption(&opt, index); - opt.text = formatDisplayString(index); - - QStyle *style = opt.widget ? opt.widget->style() : QApplication::style(); - return style->sizeFromContents(QStyle::CT_ItemViewItem, &opt, QSize(), opt.widget); - -} -*/ - -/* -// Cpp -void BCValueDelegate::destroyEditor(QWidget *editor, const QModelIndex &index) const -{ - // 1. Kontext sichern (bevor der Editor gelöscht wird) - // Der Editor ist meist ein Kind des Viewports - QWidget *viewport = editor->parentWidget(); - QRect rect = editor->geometry(); - - // 2. Basis-Implementierung aufrufen - // WICHTIG: Das löscht (delete) den Editor-Pointer! - QStyledItemDelegate::destroyEditor(editor, index); - - // 3. Jetzt den Bereich neu zeichnen ("Dirty Rect") - if (viewport) - { - // Wir nutzen das Rechteck, wo der Editor WAR. - qDebug() << " --- DESTROY: " << viewport->objectName() << " : " << rect; - viewport->update(rect); - } -} -*/ void BCValueDelegate::paint(QPainter *painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { @@ -252,6 +198,9 @@ void BCValueDelegate::paintSliderIndicator(QPainter* painter, const QStyleOption painter->drawRoundedRect(barRect, 2, 2); QRect fillRect = barRect; + // ein wert darf näturlich nie über 100% eingestellt werden + ratio = qBound(0.0,ratio,1.0); + fillRect.setWidth(barRect.width() * ratio); painter->setBrush(QColor(0x0078D4)); painter->drawRoundedRect(fillRect, 2, 2); @@ -259,56 +208,6 @@ void BCValueDelegate::paintSliderIndicator(QPainter* painter, const QStyleOption painter->restore(); - - /// ------- - -/* - // Hintergrund - if (option.state & QStyle::State_Selected) - { - painter->fillRect(option.rect, option.palette.highlight()); - } - else - { - QColor bcColor = option.palette.color(QPalette::Base); - painter->fillRect(option.rect, bcColor); - } -*/ - - - /* - // baby-Slider-Indikator zeichnen - // Anteil zwischen min und max berechnen - double ratio = bcValue.calcMinMaxRatio(); - if( !ratio) - return; - - painter->save(); - painter->setRenderHint(QPainter::Antialiasing); - - QRect barRect = option.rect.adjusted - ( - 8, - option.rect.height() / 2 - 2, - -8, - -option.rect.height() / 2 + 2 - ); - - // Mini Progress Bar - painter->setPen(Qt::NoPen); - QColor disabledText = option.palette.color(QPalette::Disabled, QPalette::Text); - painter->setBrush(disabledText); - - painter->drawRoundedRect(barRect, 2, 2); - - barRect.setWidth(barRect.width() * ratio ); - painter->setBrush(QColor(0x0078D4)); - //painter->setBrush(Qt::green); - //painter->setBrush( ); - painter->drawRoundedRect(barRect, 2, 2); - - painter->restore(); -*/ } diff --git a/bcvaluedelegate.h b/bcvaluedelegate.h index af5e60b..351d400 100644 --- a/bcvaluedelegate.h +++ b/bcvaluedelegate.h @@ -57,8 +57,6 @@ public: void setEditorData(QWidget *editor, const QModelIndex& index) const override; void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex& index) const override; void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex& index) const override; - //void destroyEditor(QWidget *editor, const QModelIndex &index) const override; - //QSize sizeHint(const QStyleOptionViewItem &option,const QModelIndex& index) const override; void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex& index) const override; void clearAllHighlights(); diff --git a/bcvalueeditor.cpp b/bcvalueeditor.cpp index b7920b8..4a01993 100644 --- a/bcvalueeditor.cpp +++ b/bcvalueeditor.cpp @@ -19,30 +19,8 @@ BCValueEditor::BCValueEditor(const BCValue& bcValue, QWidget *parent ) double ratio = bcValue.calcMinMaxRatio(); _slider->setRange(0, 100); - _slider->setValue( bcValue.rawValue * ratio); + _slider->setValue( bcValue.getRawValue() * ratio); - /* - _slider = new QSlider(Qt::Horizontal, this); - _slider->setRange(0, 100); - _slider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - - _slider->setSingleStep(1); - _slider->setPageStep(10); - _slider->setStyle(new BCSliderStyle()); - - _commitButton = new QPushButton(this); - _commitButton->setIcon(style()->standardIcon(QStyle::SP_DialogResetButton)); - _commitButton->setFixedSize(32, 32); - - auto *layout = new QHBoxLayout(this); - // Deine gewünschten Margins für 36px Zeilenhöhe - layout->setContentsMargins(2, 2, 2, 2); - layout->setSpacing(4); - - layout->addWidget(_slider); - layout->addWidget(_commitButton); - setLayout(layout); - */ // Wenn Slider bewegt wird -> Signal nach außen senden connect(_slider, &QSlider::valueChanged, this, [this](int val) { diff --git a/bcvalueeditor.ui b/bcvalueeditor.ui index 4df281b..f394579 100644 --- a/bcvalueeditor.ui +++ b/bcvalueeditor.ui @@ -6,7 +6,7 @@ 0 0 - 60 + 111 24 diff --git a/resources/bc_dark.qss b/resources/bc_dark.qss index fa62ba4..6c6b9b7 100644 --- a/resources/bc_dark.qss +++ b/resources/bc_dark.qss @@ -60,35 +60,48 @@ QToolButton:disabled { background-color: transparent; } -/* ToolButton mit Icon */ -QToolButton[popupMode="1"] { /* MenuButtonPopup */ - padding-right: 20px; -} -QToolButton::menu-button { +/* Basis-Zustand: Alles weg */ +QToolButton#_commitButton { + background: transparent; + background-color: transparent; border: none; - border-left: 1px solid rgba(255, 255, 255, 0.1); - width: 16px; - border-top-right-radius: 4px; - border-bottom-right-radius: 4px; + outline: none; /* Entfernt den Fokus-Rahmen (gepunktete Linie) */ + padding: 0px; /* Entfernt Innenabstand */ + margin: 0px; } -QToolButton::menu-button:hover { - background-color: rgba(255, 255, 255, 0.1); +/* WICHTIG: Auch die interaktiven Zustände überschreiben, + sonst flackert der Standard-Style beim Klicken wieder auf */ + +QToolButton#_commitButton:hover +{ + background-color: rgba(0, 0, 0, 0.03); + border: none; } -QToolButton::menu-arrow { - image: url(:/icons/chevron-down-white.svg); - width: 10px; - height: 10px; +QToolButton#_commitButton:pressed +{ + background-color: rgba(0, 0, 0, 0.06); + border: none; +} + +QToolButton#_commitButton:checked +{ + background-color: transparent; + border: none; +} + +QToolButton#_commitButton:focus +{ + border: none; + outline: none; } /* === QTableView === */ QTableView { background-color: #2b2b2b; - alternate-background-color: #252525; color: #ffffff; - gridline-color: #3d3d3d; border: 1px solid #3d3d3d; border-radius: 4px; selection-background-color: #0078d4; @@ -183,7 +196,8 @@ QScrollBar::sub-page:horizontal { } /* === QToolTip === */ -QToolTip { +QToolTip +{ background-color: #323232; color: #ffffff; border: 1px solid #4d4d4d; @@ -193,7 +207,8 @@ QToolTip { } /* === Corner Widget (zwischen Scrollbars) === */ -QTableView QTableCornerButton::section { +QTableView QTableCornerButton::section +{ background-color: #323232; border: none; border-right: 1px solid #3d3d3d; diff --git a/resources/bc_light.qss b/resources/bc_light.qss index 5e01867..bc8dce6 100644 --- a/resources/bc_light.qss +++ b/resources/bc_light.qss @@ -60,27 +60,42 @@ QToolButton:disabled { background-color: transparent; } -/* ToolButton mit Icon */ -QToolButton[popupMode="1"] { /* MenuButtonPopup */ - padding-right: 20px; -} -QToolButton::menu-button { + +/* Basis-Zustand: Alles weg */ +QToolButton#_commitButton { + background: transparent; + background-color: transparent; border: none; - border-left: 1px solid rgba(0, 0, 0, 0.1); - width: 16px; - border-top-right-radius: 4px; - border-bottom-right-radius: 4px; + outline: none; /* Entfernt den Fokus-Rahmen (gepunktete Linie) */ + padding: 0px; /* Entfernt Innenabstand */ + margin: 0px; } -QToolButton::menu-button:hover { - background-color: rgba(0, 0, 0, 0.05); +/* WICHTIG: Auch die interaktiven Zustände überschreiben, + sonst flackert der Standard-Style beim Klicken wieder auf */ + +QToolButton#_commitButton:hover +{ + background-color: rgba(0, 0, 0, 0.03); + border: none; } -QToolButton::menu-arrow { - image: url(:/icons/chevron-down-black.svg); - width: 10px; - height: 10px; +QToolButton#_commitButton:pressed +{ + background-color: rgba(0, 0, 0, 0.06); + border: none; +} + +QToolButton#_commitButton:checked +{ + background-color: transparent; + border: none; +} + +QToolButton#_commitButton:focus { + border: none; + outline: none; } /* === QTableView === */ @@ -96,7 +111,7 @@ QTableView { } QTableView::item { - padding: 8px; + /*padding: 8px;*/ border: none; } @@ -109,15 +124,21 @@ QTableView::item:selected { color: #ffffff; } -QTableView::item:selected:hover { +QTableView::item:selected:hover +{ background-color: #005a9e; } -QTableView::item:selected:!active { +QTableView::item:selected:!active +{ background-color: rgba(0, 120, 212, 0.3); color: #1f1f1f; } +QTableView:focus + { + outline: none; + } /* === QScrollBar Vertical === */ QScrollBar:vertical { @@ -216,13 +237,15 @@ QLineEdit:hover { border: 1px solid #a0a0a0; } +/* QLineEdit:focus { border: 1px solid #0078d4; border-bottom: 2px solid #0078d4; } +*/ QLineEdit:disabled { background-color: #fafafa; color: #a0a0a0; border: 1px solid #e1e1e1; -} \ No newline at end of file +}