From 77c281714d9dea1f3bbc47380d5884bff31402c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Wed, 4 Nov 2009 18:36:52 +0200 Subject: QS60Style: QToolButton indicator will not fit into toolbutton area QToolButton rect does not include reserved area for menu indicator, so drawing the indicator makes the rest of the toolbutton area smaller. Fixed by including the menu indicator area into tool button. Task-number: QTBUG-5266 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 6c56813..c0a1f76 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -2296,6 +2296,9 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); //FIXME properly - style should calculate the location of border frame-part sz += QSize(2*pixelMetric(PM_ButtonMargin), 2*pixelMetric(PM_ButtonMargin)); + if (const QStyleOptionToolButton *toolBtn = qstyleoption_cast(opt)) + if (toolBtn->subControls & SC_ToolButtonMenu) + sz += QSize(pixelMetric(PM_MenuButtonIndicator),0); break; case CT_PushButton: sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); @@ -2579,8 +2582,8 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple break; case CC_ToolButton: if (const QStyleOptionToolButton *toolButton = qstyleoption_cast(option)) { - const int indicatorRect = pixelMetric(PM_MenuButtonIndicator, toolButton, widget) + - 2*pixelMetric(PM_ButtonMargin, toolButton, widget); + const int indicatorRect = pixelMetric(PM_MenuButtonIndicator) + 2*pixelMetric(PM_ButtonMargin); + const int border = pixelMetric(PM_ButtonMargin) + pixelMetric(PM_DefaultFrameWidth); ret = toolButton->rect; const bool popup = (toolButton->features & (QStyleOptionToolButton::MenuButtonPopup | QStyleOptionToolButton::PopupDelay)) @@ -2592,7 +2595,7 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple break; case SC_ToolButtonMenu: if (popup) - ret.adjust(ret.width() - indicatorRect, ret.height() - indicatorRect, 0, 0); + ret.adjust(ret.width() - indicatorRect, border, -pixelMetric(PM_ButtonMargin), -border); break; default: break; @@ -2614,8 +2617,8 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con QRect ret; switch (element) { case SE_LineEditContents: { - // in S60 the input text box doesn't start from line Edit's TL, but - // a bit indented. + // in S60 the input text box doesn't start from line Edit's TL, but + // a bit indented. QRect lineEditRect = opt->rect; const int adjustment = opt->rect.height()>>2; lineEditRect.adjust(adjustment,0,0,0); -- cgit v0.12