mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-27 21:24:47 +01:00
Some more dark themes & themes switching polishing
This commit is contained in:
parent
0411bba02c
commit
dcd4666f59
@ -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);
|
||||
}
|
||||
|
@ -70,6 +70,8 @@ protected:
|
||||
void clearInfo();
|
||||
void skipColor() {_palette.nextColor();}
|
||||
|
||||
void changeEvent(QEvent *e);
|
||||
|
||||
QList<GraphItem*> _graphs;
|
||||
GraphType _graphType;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user