From 545536fab55a838d688e8a26b03b4e01a17422e7 Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Sat, 3 Oct 2020 13:21:06 +0100 Subject: [PATCH] Support high-res icons when on 1.5x scaling and Qt >= 5.15.2 Icons look nice now on linux with 1.5x. Windows and macOS don't use fractional scaling, so not affected Fixes #11 Will open a separate bug report to get high-res docking indicators. --- src/private/widgets/TitleBarWidget.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/private/widgets/TitleBarWidget.cpp b/src/private/widgets/TitleBarWidget.cpp index cb7333eb..1509d5e6 100644 --- a/src/private/widgets/TitleBarWidget.cpp +++ b/src/private/widgets/TitleBarWidget.cpp @@ -168,9 +168,10 @@ void TitleBarWidget::updateMinimizeButton() QIcon TitleBarWidget::iconForButton(const QString &iconName) const { - const bool isFractional = (1.0 * devicePixelRatio() != devicePixelRatioF()); QIcon icon(QStringLiteral(":/img/%1.png").arg(iconName)); +#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2) + const bool isFractional = (1.0 * devicePixelRatio() != devicePixelRatioF()); if (isFractional) { // We don't support 1.5x yet. // Linux is the only one affected as Windows and macOS use integral factors. @@ -178,9 +179,12 @@ QIcon TitleBarWidget::iconForButton(const QString &iconName) const // Will enable for fractional later. return icon; } - +#else // Not using Qt's sugar syntax, which doesn't support 1.5x anyway when we need it. // Simply add the high-res files and Qt will pick them when needed + + icon.addFile(QStringLiteral(":/img/%1-1.5x.png").arg(iconName)); +#endif icon.addFile(QStringLiteral(":/img/%1-2x.png").arg(iconName)); return icon;