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.
This commit is contained in:
@@ -168,9 +168,10 @@ void TitleBarWidget::updateMinimizeButton()
|
|||||||
|
|
||||||
QIcon TitleBarWidget::iconForButton(const QString &iconName) const
|
QIcon TitleBarWidget::iconForButton(const QString &iconName) const
|
||||||
{
|
{
|
||||||
const bool isFractional = (1.0 * devicePixelRatio() != devicePixelRatioF());
|
|
||||||
QIcon icon(QStringLiteral(":/img/%1.png").arg(iconName));
|
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) {
|
if (isFractional) {
|
||||||
// We don't support 1.5x yet.
|
// We don't support 1.5x yet.
|
||||||
// Linux is the only one affected as Windows and macOS use integral factors.
|
// 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.
|
// Will enable for fractional later.
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
// Not using Qt's sugar syntax, which doesn't support 1.5x anyway when we need it.
|
// 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
|
// 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));
|
icon.addFile(QStringLiteral(":/img/%1-2x.png").arg(iconName));
|
||||||
|
|
||||||
return icon;
|
return icon;
|
||||||
|
|||||||
Reference in New Issue
Block a user