diff options
Diffstat (limited to 'src/widgets/styles/qcommonstyle.cpp')
-rw-r--r-- | src/widgets/styles/qcommonstyle.cpp | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 10dfad2754..9aec4f3aa4 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -100,6 +100,9 @@ #if QT_CONFIG(wizard) #include <qwizard.h> #endif +#if QT_CONFIG(filedialog) +#include <qsidebar_p.h> +#endif #include <qfileinfo.h> #include <qdir.h> #if QT_CONFIG(settings) @@ -3071,7 +3074,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, } d->cachedOption = new QStyleOptionViewItem(*vopt); } - if (sr == SE_ViewItemCheckIndicator) + if (sr == SE_ItemViewItemCheckIndicator) r = d->checkRect; else if (sr == SE_ItemViewItemDecoration) r = d->decorationRect; @@ -4293,8 +4296,10 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex int topMargin = 0; int topHeight = 0; int verticalAlignment = proxy()->styleHint(SH_GroupBox_TextLabelVerticalAlignment, groupBox, widget); - if (groupBox->text.size() || (groupBox->subControls & QStyle::SC_GroupBoxCheckBox)) { - topHeight = groupBox->fontMetrics.height(); + bool hasCheckBox = groupBox->subControls & QStyle::SC_GroupBoxCheckBox; + if (groupBox->text.size() || hasCheckBox) { + int checkBoxHeight = hasCheckBox ? proxy()->pixelMetric(PM_IndicatorHeight, groupBox, widget) : 0; + topHeight = qMax(groupBox->fontMetrics.height(), checkBoxHeight); if (verticalAlignment & Qt::AlignVCenter) topMargin = topHeight / 2; else if (verticalAlignment & Qt::AlignTop) @@ -4319,20 +4324,24 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex case SC_GroupBoxCheckBox: case SC_GroupBoxLabel: { QFontMetrics fontMetrics = groupBox->fontMetrics; - int h = fontMetrics.height(); + int th = fontMetrics.height(); int tw = fontMetrics.size(Qt::TextShowMnemonic, groupBox->text + QLatin1Char(' ')).width(); int marg = (groupBox->features & QStyleOptionFrame::Flat) ? 0 : 8; ret = groupBox->rect.adjusted(marg, 0, -marg, 0); - ret.setHeight(h); int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, opt, widget); + int indicatorHeight = proxy()->pixelMetric(PM_IndicatorHeight, opt, widget); int indicatorSpace = proxy()->pixelMetric(PM_CheckBoxLabelSpacing, opt, widget) - 1; bool hasCheckBox = groupBox->subControls & QStyle::SC_GroupBoxCheckBox; - int checkBoxSize = hasCheckBox ? (indicatorWidth + indicatorSpace) : 0; + int checkBoxWidth = hasCheckBox ? (indicatorWidth + indicatorSpace) : 0; + int checkBoxHeight = hasCheckBox ? indicatorHeight : 0; + + int h = qMax(th, checkBoxHeight); + ret.setHeight(h); // Adjusted rect for label + indicatorWidth + indicatorSpace QRect totalRect = alignedRect(groupBox->direction, groupBox->textAlignment, - QSize(tw + checkBoxSize, h), ret); + QSize(tw + checkBoxWidth, h), ret); // Adjust totalRect if checkbox is set if (hasCheckBox) { @@ -4340,15 +4349,14 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex int left = 0; // Adjust for check box if (sc == SC_GroupBoxCheckBox) { - int indicatorHeight = proxy()->pixelMetric(PM_IndicatorHeight, opt, widget); left = ltr ? totalRect.left() : (totalRect.right() - indicatorWidth); - int top = totalRect.top() + qMax(0, fontMetrics.height() - indicatorHeight) / 2; + int top = totalRect.top() + (h - checkBoxHeight) / 2; totalRect.setRect(left, top, indicatorWidth, indicatorHeight); // Adjust for label } else { - left = ltr ? (totalRect.left() + checkBoxSize - 2) : totalRect.left(); - totalRect.setRect(left, totalRect.top(), - totalRect.width() - checkBoxSize, totalRect.height()); + left = ltr ? (totalRect.left() + checkBoxWidth - 2) : totalRect.left(); + int top = totalRect.top() + (h - th) / 2; + totalRect.setRect(left, top, totalRect.width() - checkBoxWidth, th); } } ret = totalRect; @@ -4724,9 +4732,16 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid break; case PM_TabBarIconSize: - case PM_ListViewIconSize: ret = proxy()->pixelMetric(PM_SmallIconSize, opt, widget); break; + case PM_ListViewIconSize: +#if QT_CONFIG(filedialog) + if (qobject_cast<const QSidebar *>(widget)) + ret = int(QStyleHelper::dpiScaled(24.)); + else +#endif + ret = proxy()->pixelMetric(PM_SmallIconSize, opt, widget); + break; case PM_ButtonIconSize: case PM_SmallIconSize: |