diff --git a/src/GUI/graphview.cpp b/src/GUI/graphview.cpp index 7831c750..0efb9d85 100644 --- a/src/GUI/graphview.cpp +++ b/src/GUI/graphview.cpp @@ -521,3 +521,14 @@ void GraphView::setSliderColor(const QColor &color) _slider->setColor(color); _sliderInfo->setColor(color); } + +void GraphView::changeEvent(QEvent *e) +{ + if (e->type() == QEvent::PaletteChange) { + _message->setBrush(QPalette().brush(QPalette::Disabled, + QPalette::WindowText)); + setBackgroundBrush(QBrush(palette().brush(QPalette::Base))); + } + + QGraphicsView::changeEvent(e); +} diff --git a/src/GUI/graphview.h b/src/GUI/graphview.h index 7f2f9877..83f8557d 100644 --- a/src/GUI/graphview.h +++ b/src/GUI/graphview.h @@ -70,6 +70,8 @@ protected: void clearInfo(); void skipColor() {_palette.nextColor();} + void changeEvent(QEvent *e); + QList _graphs; GraphType _graphType; diff --git a/src/GUI/stylecombobox.cpp b/src/GUI/stylecombobox.cpp index 8811b6e1..cebed5ca 100644 --- a/src/GUI/stylecombobox.cpp +++ b/src/GUI/stylecombobox.cpp @@ -9,28 +9,32 @@ #define ARRAY_SIZE(a) (sizeof(a) / sizeof(*a)) + +static Qt::PenStyle styles[] = {Qt::SolidLine, Qt::DashLine, Qt::DotLine, + Qt::DashDotLine, Qt::DashDotDotLine}; + +QIcon StyleComboBox::icon(Qt::PenStyle style) +{ + QPixmap pm(iconSize()); + pm.fill(Qt::transparent); + + QBrush brush(QPalette().brush(QPalette::Active, QPalette::WindowText)); + QPen pen(brush, pm.height() / LINE_WIDTH_RATIO, style); + + QPainter painter(&pm); + painter.setPen(pen); + painter.drawLine(0, pm.height() / 2, pm.width(), pm.height() / 2); + + return QIcon(pm); +} + StyleComboBox::StyleComboBox(QWidget *parent) : QComboBox(parent) { - Qt::PenStyle styles[] = {Qt::SolidLine, Qt::DashLine, Qt::DotLine, - Qt::DashDotLine, Qt::DashDotDotLine}; - QSize is = iconSize(); setIconSize(QSize(MIN_LINE_LENGTH, is.height())); - is = iconSize(); - for (size_t i = 0; i < ARRAY_SIZE(styles); i++) { - QPixmap pm(is); - pm.fill(Qt::transparent); - - QBrush brush(Qt::black); - QPen pen(brush, is.height() / LINE_WIDTH_RATIO, styles[i]); - - QPainter painter(&pm); - painter.setPen(pen); - painter.drawLine(0, is.height() / 2, is.width(), is.height() / 2); - - addItem(QIcon(pm), QString(), QVariant((int)styles[i])); - } + for (size_t i = 0; i < ARRAY_SIZE(styles); i++) + addItem(icon(styles[i]), QString(), QVariant((int)styles[i])); } void StyleComboBox::setValue(Qt::PenStyle value) @@ -42,3 +46,12 @@ void StyleComboBox::setValue(Qt::PenStyle value) } } } + +void StyleComboBox::changeEvent(QEvent *e) +{ + if (e->type() == QEvent::PaletteChange) + for (int i = 0; i < count(); i++) + setItemIcon(i, icon(styles[i])); + + QComboBox::changeEvent(e); +} diff --git a/src/GUI/stylecombobox.h b/src/GUI/stylecombobox.h index c31a6d10..9eb6cecc 100644 --- a/src/GUI/stylecombobox.h +++ b/src/GUI/stylecombobox.h @@ -11,6 +11,12 @@ public: StyleComboBox(QWidget *parent = 0); void setValue(Qt::PenStyle value); + +protected: + void changeEvent(QEvent *e); + +private: + QIcon icon(Qt::PenStyle style); }; #endif // STYLECOMBOBOX_H