Windows11/VistaStyle: pass dpr to QIcon::pixmap()
Pass the correct devicePixelRatio to QIcon::pixmap() to make sure the best pixmap is used for the current dpr. Change-Id: I70014b649457cee819228fa0ead7beb7de944471 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io> (cherry picked from commit e34db561cfa61f409313c80311d9890d115c0d8e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
e30e358ce6
commit
07ff65b33d
@ -665,11 +665,11 @@ void QWindows11Style::drawComplexControl(ComplexControl control, const QStyleOpt
|
|||||||
titlebar->icon.paint(painter, iconRect);
|
titlebar->icon.paint(painter, iconRect);
|
||||||
} else {
|
} else {
|
||||||
QStyleOption tool = *titlebar;
|
QStyleOption tool = *titlebar;
|
||||||
QPixmap pm = proxy()->standardIcon(SP_TitleBarMenuButton, &tool, widget).pixmap(16, 16);
|
const auto extent = proxy()->pixelMetric(PM_SmallIconSize, &tool, widget);
|
||||||
tool.rect = iconRect;
|
const auto dpr = QStyleHelper::getDpr(widget);
|
||||||
painter->save();
|
const auto icon = proxy()->standardIcon(SP_TitleBarMenuButton, &tool, widget);
|
||||||
|
const auto pm = icon.pixmap(QSize(extent, extent), dpr);
|
||||||
proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pm);
|
proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pm);
|
||||||
painter->restore();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2786,7 +2786,9 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
QPalette::ColorRole textRole = disabled ? QPalette::Text : QPalette::ButtonText;
|
QPalette::ColorRole textRole = disabled ? QPalette::Text : QPalette::ButtonText;
|
||||||
QPixmap pix = mbi->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), QIcon::Normal);
|
const auto dpr = QStyleHelper::getDpr(widget);
|
||||||
|
const auto extent = proxy()->pixelMetric(PM_SmallIconSize, option, widget);
|
||||||
|
const auto pix = mbi->icon.pixmap(QSize(extent, extent), dpr, QIcon::Normal);
|
||||||
|
|
||||||
int alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
|
int alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
|
||||||
if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget))
|
if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget))
|
||||||
@ -3084,7 +3086,6 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
|||||||
else
|
else
|
||||||
stateId = CS_INACTIVE;
|
stateId = CS_INACTIVE;
|
||||||
|
|
||||||
int titleHeight = rect.height() - 2;
|
|
||||||
rect = rect.adjusted(-fw, -fw, fw, 0);
|
rect = rect.adjusted(-fw, -fw, fw, 0);
|
||||||
|
|
||||||
QWindowsThemeData theme(widget, painter, themeNumber, 0, stateId);
|
QWindowsThemeData theme(widget, painter, themeNumber, 0, stateId);
|
||||||
@ -3101,7 +3102,9 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
|||||||
QIcon ico = widget->windowIcon();
|
QIcon ico = widget->windowIcon();
|
||||||
bool hasIcon = (ico.cacheKey() != QApplication::windowIcon().cacheKey());
|
bool hasIcon = (ico.cacheKey() != QApplication::windowIcon().cacheKey());
|
||||||
if (hasIcon) {
|
if (hasIcon) {
|
||||||
QPixmap pxIco = ico.pixmap(titleHeight);
|
const auto titleHeight = rect.height() - 2;
|
||||||
|
const auto dpr = QStyleHelper::getDpr(widget);
|
||||||
|
const auto pxIco = ico.pixmap(QSize(titleHeight, titleHeight), dpr);
|
||||||
if (!verticalTitleBar && dwOpt->direction == Qt::RightToLeft)
|
if (!verticalTitleBar && dwOpt->direction == Qt::RightToLeft)
|
||||||
painter->drawPixmap(rect.width() - titleHeight - pxIco.width(), rect.bottom() - titleHeight - 2, pxIco);
|
painter->drawPixmap(rect.width() - titleHeight - pxIco.width(), rect.bottom() - titleHeight - 2, pxIco);
|
||||||
else
|
else
|
||||||
@ -3681,11 +3684,11 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle
|
|||||||
theme.partId = partId;
|
theme.partId = partId;
|
||||||
theme.stateId = stateId;
|
theme.stateId = stateId;
|
||||||
if (theme.size().isEmpty()) {
|
if (theme.size().isEmpty()) {
|
||||||
int iconSize = proxy()->pixelMetric(PM_SmallIconSize, tb, widget);
|
const auto extent = proxy()->pixelMetric(PM_SmallIconSize, tb, widget);
|
||||||
QPixmap pm = proxy()->standardIcon(SP_TitleBarMenuButton, tb, widget).pixmap(iconSize, iconSize);
|
const auto dpr = QStyleHelper::getDpr(widget);
|
||||||
painter->save();
|
const auto icon = proxy()->standardIcon(SP_TitleBarMenuButton, tb, widget);
|
||||||
|
const auto pm = icon.pixmap(QSize(extent, extent), dpr);
|
||||||
drawItemPixmap(painter, theme.rect, Qt::AlignCenter, pm);
|
drawItemPixmap(painter, theme.rect, Qt::AlignCenter, pm);
|
||||||
painter->restore();
|
|
||||||
} else {
|
} else {
|
||||||
d->drawBackground(theme);
|
d->drawBackground(theme);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user