From 2aef87d8f4d8050856e1f3bb713241ca4ffc2db9 Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 24 Nov 2018 17:17:08 +0100 Subject: GUI changes Play nice with themes, especially dark ones. Most likely the light icons will look crappy with a light theme, but theming support is another thing entirely. Right now I'm using a dark theme, so this is it... --- helper.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'helper.cpp') diff --git a/helper.cpp b/helper.cpp index 5fa3a3b..306a2d1 100644 --- a/helper.cpp +++ b/helper.cpp @@ -10,15 +10,19 @@ namespace Helper { QIcon iconFromQChar(const QChar &c, int pixelSize){ - QPixmap pm(QSize(64,64)); - QPainter p(&pm); - QFont f = p.font(); + QImage img(32, 32, QImage::Format_ARGB32); + img.fill(QColor(0, 0, 0, 0)); + QPainter p(&img); + p.setRenderHint(QPainter::Antialiasing); + p.setRenderHint(QPainter::TextAntialiasing); + p.setRenderHint(QPainter::SmoothPixmapTransform); + p.setPen(qApp->palette().color(QPalette::Text)); + QFont f(qApp->font()); f.setPixelSize(pixelSize); + f.setBold(true); p.setFont(f); - p.fillRect(pm.rect(), qApp->palette().color(QPalette::Window)); - p.setBrush(QBrush(Qt::black)); - p.drawText(pm.rect(), Qt::AlignCenter, c); - return QIcon(pm); + p.drawText(img.rect(), Qt::AlignCenter, c); + return QIcon(QPixmap::fromImage(img)); } QAction* createSeparator(QObject *parent){ -- cgit v1.2.3-70-g09d2