Windows style: Scale more native metrics per monitor
Fix a few places that were overlooked in
change 29c6e39086
.
Most notably, fixes MDI subwindow titles disappearing
when moving windows between monitors.
Task-number: QTBUG-49374
Change-Id: Ie6ffabc4909064e649a3820d9aa952f3991ef06b
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
parent
2aea77dbcb
commit
d0012ad64c
@ -1175,9 +1175,9 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
|||||||
case CE_MenuItem:
|
case CE_MenuItem:
|
||||||
if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
|
if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
|
||||||
// windows always has a check column, regardless whether we have an icon or not
|
// windows always has a check column, regardless whether we have an icon or not
|
||||||
const qreal devicePixelRatio = QWindowsXPStylePrivate::devicePixelRatio(widget);
|
const qreal factor = QWindowsXPStylePrivate::nativeMetricScaleFactor(widget);
|
||||||
int checkcol = qRound(qreal(25) / devicePixelRatio);
|
int checkcol = qRound(qreal(25) * factor);
|
||||||
const int gutterWidth = qRound(qreal(3) / devicePixelRatio);
|
const int gutterWidth = qRound(qreal(3) * factor);
|
||||||
{
|
{
|
||||||
XPThemeData theme(widget, 0, QWindowsXPStylePrivate::MenuTheme,
|
XPThemeData theme(widget, 0, QWindowsXPStylePrivate::MenuTheme,
|
||||||
MENU_POPUPCHECKBACKGROUND, MBI_HOT);
|
MENU_POPUPCHECKBACKGROUND, MBI_HOT);
|
||||||
@ -2166,8 +2166,9 @@ QRect QWindowsVistaStyle::subControlRect(ComplexControl control, const QStyleOpt
|
|||||||
const bool isToolTitle = false;
|
const bool isToolTitle = false;
|
||||||
const int height = tb->rect.height();
|
const int height = tb->rect.height();
|
||||||
const int width = tb->rect.width();
|
const int width = tb->rect.width();
|
||||||
int buttonWidth = GetSystemMetrics(SM_CXSIZE) / QWindowsStylePrivate::devicePixelRatio(widget)
|
const int buttonWidth =
|
||||||
- int(QStyleHelper::dpiScaled(4));
|
qRound(qreal(GetSystemMetrics(SM_CXSIZE)) * QWindowsStylePrivate::nativeMetricScaleFactor(widget)
|
||||||
|
- QStyleHelper::dpiScaled(4));
|
||||||
|
|
||||||
const int frameWidth = proxy()->pixelMetric(PM_MdiSubWindowFrameWidth, option, widget);
|
const int frameWidth = proxy()->pixelMetric(PM_MdiSubWindowFrameWidth, option, widget);
|
||||||
const bool sysmenuHint = (tb->titleBarFlags & Qt::WindowSystemMenuHint) != 0;
|
const bool sysmenuHint = (tb->titleBarFlags & Qt::WindowSystemMenuHint) != 0;
|
||||||
|
@ -2098,7 +2098,7 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op
|
|||||||
themeNumber = QWindowsXPStylePrivate::StatusTheme;
|
themeNumber = QWindowsXPStylePrivate::StatusTheme;
|
||||||
partId = SP_GRIPPER;
|
partId = SP_GRIPPER;
|
||||||
XPThemeData theme(0, p, themeNumber, partId, 0);
|
XPThemeData theme(0, p, themeNumber, partId, 0);
|
||||||
QSize size = (theme.size() / QWindowsStylePrivate::devicePixelRatio(widget)).toSize();
|
QSize size = (theme.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize();
|
||||||
size.rheight()--;
|
size.rheight()--;
|
||||||
if (const QStyleOptionSizeGrip *sg = qstyleoption_cast<const QStyleOptionSizeGrip *>(option)) {
|
if (const QStyleOptionSizeGrip *sg = qstyleoption_cast<const QStyleOptionSizeGrip *>(option)) {
|
||||||
switch (sg->corner) {
|
switch (sg->corner) {
|
||||||
@ -2169,7 +2169,7 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op
|
|||||||
QWindowsXPStylePrivate::ToolBarTheme,
|
QWindowsXPStylePrivate::ToolBarTheme,
|
||||||
TP_SPLITBUTTONDROPDOWN);
|
TP_SPLITBUTTONDROPDOWN);
|
||||||
if (theme.isValid()) {
|
if (theme.isValid()) {
|
||||||
const QSize size = (theme.size() / QWindowsStylePrivate::devicePixelRatio(widget)).toSize();
|
const QSize size = (theme.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize();
|
||||||
mbiw = size.width();
|
mbiw = size.width();
|
||||||
mbih = size.height();
|
mbih = size.height();
|
||||||
}
|
}
|
||||||
@ -2632,10 +2632,11 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op
|
|||||||
QRect QWindowsXPStylePrivate::scrollBarGripperBounds(QStyle::State flags, const QWidget *widget, XPThemeData *theme)
|
QRect QWindowsXPStylePrivate::scrollBarGripperBounds(QStyle::State flags, const QWidget *widget, XPThemeData *theme)
|
||||||
{
|
{
|
||||||
const bool horizontal = flags & QStyle::State_Horizontal;
|
const bool horizontal = flags & QStyle::State_Horizontal;
|
||||||
const QMargins contentsMargin = (theme->margins(theme->rect, TMT_SIZINGMARGINS)
|
const qreal factor = QWindowsStylePrivate::nativeMetricScaleFactor(widget);
|
||||||
/ QWindowsStylePrivate::devicePixelRatio(widget)).toMargins();
|
const QMargins contentsMargin =
|
||||||
|
(theme->margins(theme->rect, TMT_SIZINGMARGINS) * factor).toMargins();
|
||||||
theme->partId = horizontal ? SBP_GRIPPERHORZ : SBP_GRIPPERVERT;
|
theme->partId = horizontal ? SBP_GRIPPERHORZ : SBP_GRIPPERVERT;
|
||||||
const QSize size = (theme->size() / QWindowsStylePrivate::devicePixelRatio(widget)).toSize();
|
const QSize size = (theme->size() * factor).toSize();
|
||||||
|
|
||||||
const int hSpace = theme->rect.width() - size.width();
|
const int hSpace = theme->rect.width() - size.width();
|
||||||
const int vSpace = theme->rect.height() - size.height();
|
const int vSpace = theme->rect.height() - size.height();
|
||||||
@ -3793,12 +3794,13 @@ QSize QWindowsXPStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt
|
|||||||
{
|
{
|
||||||
XPThemeData buttontheme(widget, 0, QWindowsXPStylePrivate::ButtonTheme, BP_PUSHBUTTON, PBS_NORMAL);
|
XPThemeData buttontheme(widget, 0, QWindowsXPStylePrivate::ButtonTheme, BP_PUSHBUTTON, PBS_NORMAL);
|
||||||
if (buttontheme.isValid()) {
|
if (buttontheme.isValid()) {
|
||||||
const qreal devicePixelRatio = QWindowsXPStylePrivate::devicePixelRatio(widget);
|
const qreal factor = QWindowsXPStylePrivate::nativeMetricScaleFactor(widget);
|
||||||
const QMarginsF borderSize = buttontheme.margins() / devicePixelRatio;
|
const QMarginsF borderSize = buttontheme.margins() * factor;
|
||||||
if (!borderSize.isNull()) {
|
if (!borderSize.isNull()) {
|
||||||
const qreal margin = qreal(2) / devicePixelRatio;
|
const qreal margin = qreal(2) * factor;
|
||||||
sz.rwidth() += qRound(borderSize.left() + borderSize.right() - margin);
|
sz.rwidth() += qRound(borderSize.left() + borderSize.right() - margin);
|
||||||
sz.rheight() += int(borderSize.bottom() + borderSize.top() - margin + devicePixelRatio - 1);
|
sz.rheight() += int(borderSize.bottom() + borderSize.top() - margin
|
||||||
|
+ qreal(1) / factor - 1);
|
||||||
}
|
}
|
||||||
const int textMargins = 2*(proxy()->pixelMetric(PM_FocusFrameHMargin) + 1);
|
const int textMargins = 2*(proxy()->pixelMetric(PM_FocusFrameHMargin) + 1);
|
||||||
sz += QSize(qMax(pixelMetric(QStyle::PM_ScrollBarExtent, option, widget)
|
sz += QSize(qMax(pixelMetric(QStyle::PM_ScrollBarExtent, option, widget)
|
||||||
@ -4072,7 +4074,7 @@ QIcon QWindowsXPStyle::standardIcon(StandardPixmap standardIcon,
|
|||||||
XPThemeData theme(0, 0, QWindowsXPStylePrivate::WindowTheme,
|
XPThemeData theme(0, 0, QWindowsXPStylePrivate::WindowTheme,
|
||||||
WP_RESTOREBUTTON, RBS_NORMAL);
|
WP_RESTOREBUTTON, RBS_NORMAL);
|
||||||
if (theme.isValid()) {
|
if (theme.isValid()) {
|
||||||
const QSize size = (themeSize.size() / QWindowsStylePrivate::devicePixelRatio(widget)).toSize();
|
const QSize size = (themeSize.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize();
|
||||||
QPixmap pm(size);
|
QPixmap pm(size);
|
||||||
pm.fill(Qt::transparent);
|
pm.fill(Qt::transparent);
|
||||||
QPainter p(&pm);
|
QPainter p(&pm);
|
||||||
|
Loading…
Reference in New Issue
Block a user