summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles/qcommonstyle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/styles/qcommonstyle.cpp')
-rw-r--r--src/widgets/styles/qcommonstyle.cpp43
1 files changed, 26 insertions, 17 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index cf81f53ad0..140f0ad2f3 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -3724,6 +3724,8 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
btnOpt.state &= ~State_MouseOver;
int bsx = 0;
int bsy = 0;
+ const int buttonIconMetric = proxy()->pixelMetric(PM_TitleBarButtonIconSize, &btnOpt, widget);
+ const QSize buttonIconSize(buttonIconMetric, buttonIconMetric);
if (opt->subControls & QStyle::SC_MdiCloseButton) {
if (opt->activeSubControls & QStyle::SC_MdiCloseButton && (opt->state & State_Sunken)) {
btnOpt.state |= State_Sunken;
@@ -3738,7 +3740,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
}
btnOpt.rect = proxy()->subControlRect(CC_MdiControls, opt, SC_MdiCloseButton, widget);
proxy()->drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget);
- QPixmap pm = proxy()->standardIcon(SP_TitleBarCloseButton).pixmap(qt_getWindow(widget), QSize(16, 16));
+ QPixmap pm = proxy()->standardIcon(SP_TitleBarCloseButton).pixmap(qt_getWindow(widget), buttonIconSize);
proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm);
}
if (opt->subControls & QStyle::SC_MdiNormalButton) {
@@ -3755,7 +3757,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
}
btnOpt.rect = proxy()->subControlRect(CC_MdiControls, opt, SC_MdiNormalButton, widget);
proxy()->drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget);
- QPixmap pm = proxy()->standardIcon(SP_TitleBarNormalButton).pixmap(qt_getWindow(widget), QSize(16, 16));
+ QPixmap pm = proxy()->standardIcon(SP_TitleBarNormalButton).pixmap(qt_getWindow(widget), buttonIconSize);
proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm);
}
if (opt->subControls & QStyle::SC_MdiMinButton) {
@@ -3772,7 +3774,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
}
btnOpt.rect = proxy()->subControlRect(CC_MdiControls, opt, SC_MdiMinButton, widget);
proxy()->drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget);
- QPixmap pm = proxy()->standardIcon(SP_TitleBarMinButton).pixmap(qt_getWindow(widget), QSize(16, 16));
+ QPixmap pm = proxy()->standardIcon(SP_TitleBarMinButton).pixmap(qt_getWindow(widget), buttonIconSize);
proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm);
}
}
@@ -4230,7 +4232,6 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex
if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
switch (sc) {
case SC_GroupBoxFrame:
- // FALL THROUGH
case SC_GroupBoxContents: {
int topMargin = 0;
int topHeight = 0;
@@ -4259,7 +4260,6 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex
break;
}
case SC_GroupBoxCheckBox:
- // FALL THROUGH
case SC_GroupBoxLabel: {
QFontMetrics fontMetrics = groupBox->fontMetrics;
int h = fontMetrics.height();
@@ -4325,7 +4325,7 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex
if (numSubControls == 1)
break;
offset += buttonWidth + 2;
- //FALL THROUGH
+ Q_FALLTHROUGH();
case SC_MdiNormalButton:
// No offset needed if
// 1) There's only one sub control
@@ -4393,6 +4393,13 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid
}
break; }
+ case PM_TitleBarButtonSize:
+ ret = int(QStyleHelper::dpiScaled(16.));
+ break;
+ case PM_TitleBarButtonIconSize:
+ ret = int(QStyleHelper::dpiScaled(16.));
+ break;
+
case PM_ScrollBarSliderMin:
ret = int(QStyleHelper::dpiScaled(9.));
break;
@@ -4845,16 +4852,18 @@ QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
#endif // QT_NO_GROUPBOX
case CT_MdiControls:
if (const QStyleOptionComplex *styleOpt = qstyleoption_cast<const QStyleOptionComplex *>(opt)) {
+ const int buttonSize = proxy()->pixelMetric(PM_TitleBarButtonSize, styleOpt, widget);
int width = 1;
if (styleOpt->subControls & SC_MdiMinButton)
- width += 16 + 1;
+ width += buttonSize + 1;
if (styleOpt->subControls & SC_MdiNormalButton)
- width += 16 + 1;
+ width += buttonSize + 1;
if (styleOpt->subControls & SC_MdiCloseButton)
- width += 16 + 1;
- sz = QSize(width, 16);
+ width += buttonSize + 1;
+ sz = QSize(width, buttonSize);
} else {
- sz = QSize(52, 16);
+ const int buttonSize = proxy()->pixelMetric(PM_TitleBarButtonSize, opt, widget);
+ sz = QSize(1 + 3 * (buttonSize + 1), buttonSize);
}
break;
#ifndef QT_NO_ITEMVIEWS
@@ -4884,7 +4893,7 @@ QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
case CT_ProgressBar:
case CT_TabBarTab:
// just return the contentsSize for now
- // fall through intended
+ Q_FALLTHROUGH();
default:
break;
}
@@ -5902,14 +5911,14 @@ QIcon QCommonStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption
if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
QPlatformTheme::StandardPixmap sp = static_cast<QPlatformTheme::StandardPixmap>(standardIcon);
QIcon retIcon;
- QList<int> sizes = theme->themeHint(QPlatformTheme::IconPixmapSizes).value<QList<int> >();
- Q_FOREACH (int size, sizes) {
+ const QList<QSize> sizes = theme->themeHint(QPlatformTheme::IconPixmapSizes).value<QList<QSize> >();
+ for (const QSize &size : sizes) {
QPixmap mainIcon;
- const QString cacheKey = QLatin1String("qt_mac_constructQIconFromIconRef") + QString::number(standardIcon) + QString::number(size);
+ const QString cacheKey = QLatin1String("qt_mac_constructQIconFromIconRef") + QString::number(standardIcon) + QString::number(size.width());
if (standardIcon >= QStyle::SP_CustomBase) {
- mainIcon = theme->standardPixmap(sp, QSizeF(size, size));
+ mainIcon = theme->standardPixmap(sp, QSizeF(size));
} else if (QPixmapCache::find(cacheKey, mainIcon) == false) {
- mainIcon = theme->standardPixmap(sp, QSizeF(size, size));
+ mainIcon = theme->standardPixmap(sp, QSizeF(size));
QPixmapCache::insert(cacheKey, mainIcon);
}