From 3e1bddbcfd0f3a2a01c4b83ae030c8d77e2c89bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Mon, 1 Apr 2024 21:00:56 +0200 Subject: [PATCH] Fixed line style combo box rendering on retina displays --- src/GUI/stylecombobox.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/GUI/stylecombobox.cpp b/src/GUI/stylecombobox.cpp index ef685b7e..8c585c04 100644 --- a/src/GUI/stylecombobox.cpp +++ b/src/GUI/stylecombobox.cpp @@ -13,15 +13,18 @@ static Qt::PenStyle styles[] = {Qt::SolidLine, Qt::DashLine, Qt::DotLine, QIcon StyleComboBox::icon(Qt::PenStyle style) { - QPixmap pm(iconSize()); + qreal ratio(devicePixelRatioF()); + QSize size(iconSize()); + QPixmap pm(size * ratio); + pm.setDevicePixelRatio(ratio); pm.fill(Qt::transparent); QBrush brush(QPalette().brush(QPalette::Active, QPalette::WindowText)); - QPen pen(brush, pm.height() / LINE_WIDTH_RATIO, style); + QPen pen(brush, size.height() / LINE_WIDTH_RATIO, style); QPainter painter(&pm); painter.setPen(pen); - painter.drawLine(0, pm.height() / 2, pm.width(), pm.height() / 2); + painter.drawLine(0, size.height() / 2, size.width(), size.height() / 2); return QIcon(pm); }