Changed styles.

This commit is contained in:
2026-01-11 20:01:33 +01:00
parent 25e752e83b
commit 5c919e4d55
9 changed files with 89 additions and 177 deletions

View File

@@ -47,8 +47,7 @@ BCDeviceView::BCDeviceView(QWidget *parent)
_itemDelegate = new BCValueDelegate( _valueModel.getValueList(), this); _itemDelegate = new BCValueDelegate( _valueModel.getValueList(), this);
setItemDelegateForColumn( 1, _itemDelegate ); setItemDelegateForColumn( 1, _itemDelegate );
/* /*
//#e0e0e0 setStyleSheet( R"(QTableView::item:selected
setStyleSheet( R"(QTableView::item:selected
{ {
background-color: green; background-color: green;
border: none; border: none;

View File

@@ -204,7 +204,7 @@ void BCMainWindow::initStatusBar()
_statusBar->showMessage("Bereit. (Dummy-Treiber eingestellt)"); _statusBar->showMessage("Bereit. (Dummy-Treiber eingestellt)");
//setApplicationStyleSheet(cLightModeStyle); setApplicationStyleSheet(cLightModeStyle);
} }

View File

@@ -111,20 +111,20 @@ public:
//void setDeviceID(BCDevice::ID newDeviceID) { deviceID = newDeviceID; } //void setDeviceID(BCDevice::ID newDeviceID) { deviceID = newDeviceID; }
BC::ID getRegisterID() const noexcept { return registerID; } BC::ID getRegisterID() const noexcept { return registerID; }
void setRegisterID(BC::ID newRegisterID) { registerID = newRegisterID; }
ValueType getValueType() const noexcept { return valueType; } ValueType getValueType() const noexcept { return valueType; }
void setValueType(ValueType newValueType) { valueType = newValueType; }
int getIndexRow() const noexcept { return indexRow; } int getIndexRow() const noexcept { return indexRow; }
void setIndexRow(int newIndexRow) { indexRow = newIndexRow; } void setIndexRow(int newIndexRow) { indexRow = newIndexRow; }
QString getLabel() const { return label; } QString getLabel() const { return label; }
void setLabel(const QString &newLabel) { label = newLabel; }
uint32_t getRawValue() const noexcept { return rawValue; } uint32_t getRawValue() const noexcept { return rawValue; }
void setRawValue(uint32_t newRawValue) const { rawValue = newRawValue; } void setRawValue(uint32_t newRawValue) const { rawValue = newRawValue; }
void setFromDouble( double value )
{}
QString getUnitLabel() const { return unitLabel; } QString getUnitLabel() const { return unitLabel; }
void setUnitLabel(const QString &newUnitLabel) { unitLabel = newUnitLabel; } void setUnitLabel(const QString &newUnitLabel) { unitLabel = newUnitLabel; }

View File

@@ -54,7 +54,6 @@ BCValueDelegate::BCValueDelegate(const BCValueList& valueList, QTableView* view)
} }
QWidget* BCValueDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex& index) const QWidget* BCValueDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex& index) const
{ {
const BCValue& bcValue = *(_valueList[ index.row()].get()); 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 void BCValueDelegate::setEditorData(QWidget *editor, const QModelIndex& index) const
{ {
qDebug() << " setEditorData, warum?"; Q_UNUSED(editor)
/* Q_UNUSED(index)
// Daten vom Model in den Editor laden
const BCValue& bc = *index.data(Qt::EditRole).value<BCValue*>();
QSlider *slider = editor->findChild<QSlider*>("slider"); // tue nix.
QLabel *lblUnit = editor->findChild<QLabel*>("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);
}
*/
} }
@@ -121,43 +104,6 @@ void BCValueDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, c
QStyledItemDelegate::setModelData(editor, model, index); 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 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); painter->drawRoundedRect(barRect, 2, 2);
QRect fillRect = barRect; 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); fillRect.setWidth(barRect.width() * ratio);
painter->setBrush(QColor(0x0078D4)); painter->setBrush(QColor(0x0078D4));
painter->drawRoundedRect(fillRect, 2, 2); painter->drawRoundedRect(fillRect, 2, 2);
@@ -259,56 +208,6 @@ void BCValueDelegate::paintSliderIndicator(QPainter* painter, const QStyleOption
painter->restore(); 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();
*/
} }

View File

@@ -57,8 +57,6 @@ public:
void setEditorData(QWidget *editor, const QModelIndex& index) const override; void setEditorData(QWidget *editor, const QModelIndex& index) const override;
void setModelData(QWidget *editor, QAbstractItemModel *model, 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 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 paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex& index) const override;
void clearAllHighlights(); void clearAllHighlights();

View File

@@ -19,30 +19,8 @@ BCValueEditor::BCValueEditor(const BCValue& bcValue, QWidget *parent )
double ratio = bcValue.calcMinMaxRatio(); double ratio = bcValue.calcMinMaxRatio();
_slider->setRange(0, 100); _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 // Wenn Slider bewegt wird -> Signal nach außen senden
connect(_slider, &QSlider::valueChanged, this, [this](int val) connect(_slider, &QSlider::valueChanged, this, [this](int val)
{ {

View File

@@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>60</width> <width>111</width>
<height>24</height> <height>24</height>
</rect> </rect>
</property> </property>

View File

@@ -60,35 +60,48 @@ QToolButton:disabled {
background-color: transparent; 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: none;
border-left: 1px solid rgba(255, 255, 255, 0.1); outline: none; /* Entfernt den Fokus-Rahmen (gepunktete Linie) */
width: 16px; padding: 0px; /* Entfernt Innenabstand */
border-top-right-radius: 4px; margin: 0px;
border-bottom-right-radius: 4px;
} }
QToolButton::menu-button:hover { /* WICHTIG: Auch die interaktiven Zustände überschreiben,
background-color: rgba(255, 255, 255, 0.1); 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 { QToolButton#_commitButton:pressed
image: url(:/icons/chevron-down-white.svg); {
width: 10px; background-color: rgba(0, 0, 0, 0.06);
height: 10px; border: none;
}
QToolButton#_commitButton:checked
{
background-color: transparent;
border: none;
}
QToolButton#_commitButton:focus
{
border: none;
outline: none;
} }
/* === QTableView === */ /* === QTableView === */
QTableView { QTableView {
background-color: #2b2b2b; background-color: #2b2b2b;
alternate-background-color: #252525;
color: #ffffff; color: #ffffff;
gridline-color: #3d3d3d;
border: 1px solid #3d3d3d; border: 1px solid #3d3d3d;
border-radius: 4px; border-radius: 4px;
selection-background-color: #0078d4; selection-background-color: #0078d4;
@@ -183,7 +196,8 @@ QScrollBar::sub-page:horizontal {
} }
/* === QToolTip === */ /* === QToolTip === */
QToolTip { QToolTip
{
background-color: #323232; background-color: #323232;
color: #ffffff; color: #ffffff;
border: 1px solid #4d4d4d; border: 1px solid #4d4d4d;
@@ -193,7 +207,8 @@ QToolTip {
} }
/* === Corner Widget (zwischen Scrollbars) === */ /* === Corner Widget (zwischen Scrollbars) === */
QTableView QTableCornerButton::section { QTableView QTableCornerButton::section
{
background-color: #323232; background-color: #323232;
border: none; border: none;
border-right: 1px solid #3d3d3d; border-right: 1px solid #3d3d3d;

View File

@@ -60,27 +60,42 @@ QToolButton:disabled {
background-color: transparent; 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: none;
border-left: 1px solid rgba(0, 0, 0, 0.1); outline: none; /* Entfernt den Fokus-Rahmen (gepunktete Linie) */
width: 16px; padding: 0px; /* Entfernt Innenabstand */
border-top-right-radius: 4px; margin: 0px;
border-bottom-right-radius: 4px;
} }
QToolButton::menu-button:hover { /* WICHTIG: Auch die interaktiven Zustände überschreiben,
background-color: rgba(0, 0, 0, 0.05); 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 { QToolButton#_commitButton:pressed
image: url(:/icons/chevron-down-black.svg); {
width: 10px; background-color: rgba(0, 0, 0, 0.06);
height: 10px; border: none;
}
QToolButton#_commitButton:checked
{
background-color: transparent;
border: none;
}
QToolButton#_commitButton:focus {
border: none;
outline: none;
} }
/* === QTableView === */ /* === QTableView === */
@@ -96,7 +111,7 @@ QTableView {
} }
QTableView::item { QTableView::item {
padding: 8px; /*padding: 8px;*/
border: none; border: none;
} }
@@ -109,15 +124,21 @@ QTableView::item:selected {
color: #ffffff; color: #ffffff;
} }
QTableView::item:selected:hover { QTableView::item:selected:hover
{
background-color: #005a9e; background-color: #005a9e;
} }
QTableView::item:selected:!active { QTableView::item:selected:!active
{
background-color: rgba(0, 120, 212, 0.3); background-color: rgba(0, 120, 212, 0.3);
color: #1f1f1f; color: #1f1f1f;
} }
QTableView:focus
{
outline: none;
}
/* === QScrollBar Vertical === */ /* === QScrollBar Vertical === */
QScrollBar:vertical { QScrollBar:vertical {
@@ -216,10 +237,12 @@ QLineEdit:hover {
border: 1px solid #a0a0a0; border: 1px solid #a0a0a0;
} }
/*
QLineEdit:focus { QLineEdit:focus {
border: 1px solid #0078d4; border: 1px solid #0078d4;
border-bottom: 2px solid #0078d4; border-bottom: 2px solid #0078d4;
} }
*/
QLineEdit:disabled { QLineEdit:disabled {
background-color: #fafafa; background-color: #fafafa;