Changed styles.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -204,7 +204,7 @@ void BCMainWindow::initStatusBar()
|
||||
|
||||
_statusBar->showMessage("Bereit. (Dummy-Treiber eingestellt)");
|
||||
|
||||
//setApplicationStyleSheet(cLightModeStyle);
|
||||
setApplicationStyleSheet(cLightModeStyle);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
@@ -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<BCValue*>();
|
||||
Q_UNUSED(editor)
|
||||
Q_UNUSED(index)
|
||||
|
||||
QSlider *slider = editor->findChild<QSlider*>("slider");
|
||||
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);
|
||||
}
|
||||
*/
|
||||
// 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();
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>60</width>
|
||||
<width>111</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user