From 3a964f3bb0ba7b25c88a6fa7a9c0d4bbb88b57e9 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 1 Sep 2011 16:17:56 +0300 Subject: Fix center aligned layouts for Symbian. Default layout bottom margin for Symbian was double that of top margin, causing center aligning to fail noticeably for smaller layouts. Made default margins more sensible. Task-number: QTBUG-14704 Reviewed-by: Sami Merila --- src/gui/styles/qs60style.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index e9f7a86..20406e6 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -101,12 +101,12 @@ const int QS60StylePrivate::m_numberOfLayouts = const short QS60StylePrivate::data[][MAX_PIXELMETRICS] = { // *** generated pixel metrics *** -{5,0,-909,0,0,2,0,2,-1,7,12,22,15,15,7,198,-909,-909,-909,20,13,2,0,0,21,7,18,30,3,3,1,-909,-909,0,1,0,0,12,20,15,15,18,18,1,115,18,0,-909,-909,-909,-909,0,0,16,2,-909,0,0,-909,16,-909,-909,-909,-909,32,18,55,24,55,4,4,4,9,13,-909,5,51,11,5,0,3,3,6,8,3,3,-909,2,-909,-909,-909,-909,5,5,3,1,106,30,30}, -{5,0,-909,0,0,1,0,2,-1,8,14,22,15,15,7,164,-909,-909,-909,19,15,2,0,0,21,8,27,28,4,4,1,-909,-909,0,7,6,0,13,23,17,17,21,21,7,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,65,27,65,3,3,5,10,15,-909,5,58,13,5,0,4,4,7,9,4,4,-909,2,-909,-909,-909,-909,6,6,3,1,106,30,30}, -{7,0,-909,0,0,2,0,5,-1,25,69,46,37,37,9,258,-909,-909,-909,23,19,11,0,0,32,25,72,44,5,5,2,-909,-909,0,7,21,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,25,2,-909,0,0,-909,25,-909,-909,-909,-909,87,27,77,35,77,3,3,6,8,19,-909,7,74,19,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1,135,30,30}, -{7,0,-909,0,0,2,0,5,-1,25,68,46,37,37,9,258,-909,-909,-909,31,19,13,0,0,32,25,60,52,5,5,2,-909,-909,0,7,32,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,26,2,-909,0,0,-909,26,-909,-909,-909,-909,87,27,96,35,96,3,3,6,8,19,-909,7,74,22,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1,135,30,30}, -{7,0,-909,0,0,2,0,2,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,7,32,30,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,6,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,5,6,8,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1,106,30,30}, -{9,0,-909,0,0,2,0,5,-1,30,99,76,51,51,25,352,-909,-909,-909,29,25,7,0,0,43,34,42,76,7,7,2,-909,-909,0,9,14,0,23,39,30,30,37,37,9,391,40,0,-909,-909,-909,-909,0,0,29,2,-909,0,0,-909,29,-909,-909,-909,-909,115,37,96,48,96,2,2,9,1,25,-909,9,101,24,9,0,7,7,7,16,7,7,-909,3,-909,-909,-909,-909,9,9,3,1,184,30,30} +{5,0,-909,0,0,2,0,2,-1,7,12,22,15,15,7,198,-909,-909,-909,20,13,2,0,0,21,7,18,30,3,3,1,-909,-909,0,1,0,0,12,20,15,15,18,18,1,115,18,0,-909,-909,-909,-909,0,0,16,2,-909,0,0,-909,16,-909,-909,-909,-909,32,18,55,24,55,4,4,4,9,13,-909,5,51,11,5,0,3,3,6,3,3,3,-909,2,-909,-909,-909,-909,5,5,3,1,106,30,30}, +{5,0,-909,0,0,1,0,2,-1,8,14,22,15,15,7,164,-909,-909,-909,19,15,2,0,0,21,8,27,28,4,4,1,-909,-909,0,7,6,0,13,23,17,17,21,21,7,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,65,27,65,3,3,5,10,15,-909,5,58,13,5,0,4,4,7,4,4,4,-909,2,-909,-909,-909,-909,6,6,3,1,106,30,30}, +{7,0,-909,0,0,2,0,5,-1,25,69,46,37,37,9,258,-909,-909,-909,23,19,11,0,0,32,25,72,44,5,5,2,-909,-909,0,7,21,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,25,2,-909,0,0,-909,25,-909,-909,-909,-909,87,27,77,35,77,3,3,6,8,19,-909,7,74,19,7,0,5,5,8,5,5,5,-909,3,-909,-909,-909,-909,7,7,3,1,135,30,30}, +{7,0,-909,0,0,2,0,5,-1,25,68,46,37,37,9,258,-909,-909,-909,31,19,13,0,0,32,25,60,52,5,5,2,-909,-909,0,7,32,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,26,2,-909,0,0,-909,26,-909,-909,-909,-909,87,27,96,35,96,3,3,6,8,19,-909,7,74,22,7,0,5,5,8,5,5,5,-909,3,-909,-909,-909,-909,7,7,3,1,135,30,30}, +{7,0,-909,0,0,2,0,2,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,7,32,30,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,6,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,5,6,8,5,6,5,-909,2,-909,-909,-909,-909,5,5,3,1,106,30,30}, +{9,0,-909,0,0,2,0,5,-1,30,99,76,51,51,25,352,-909,-909,-909,29,25,7,0,0,43,34,42,76,7,7,2,-909,-909,0,9,14,0,23,39,30,30,37,37,9,391,40,0,-909,-909,-909,-909,0,0,29,2,-909,0,0,-909,29,-909,-909,-909,-909,115,37,96,48,96,2,2,9,1,25,-909,9,101,24,9,0,7,7,7,7,7,7,-909,3,-909,-909,-909,-909,9,9,3,1,184,30,30} // *** End of generated data *** }; @@ -2506,11 +2506,13 @@ int QS60Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const metricValue = QS60StylePrivate::pixelMetric(PM_LayoutLeftMargin); } - if (widget && (metric == PM_LayoutTopMargin || metric == PM_LayoutLeftMargin || metric == PM_LayoutRightMargin)) - if (widget->windowType() == Qt::Dialog) - //double the layout margins (except bottom) for dialogs, it is very close to real value + if (widget && (metric == PM_LayoutTopMargin || metric == PM_LayoutBottomMargin + || metric == PM_LayoutRightMargin || metric == PM_LayoutLeftMargin)) + if (widget->windowType() == Qt::Dialog) { + //double the layout margins for dialogs, it is very close to real value //without having to define custom pixel metric metricValue *= 2; + } #if defined(Q_WS_S60) if (metric == PM_TabBarTabOverlap && (QSysInfo::s60Version() > QSysInfo::SV_S60_5_2)) -- cgit v0.12 From d2114c84ecdae5746227fc9e6301027213565daf Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 2 Sep 2011 11:57:34 +0300 Subject: Remove whitespace from S60 style codes. Reviewed-by: TrustMe --- src/gui/styles/qs60style.cpp | 28 ++++++++++++++-------------- src/gui/styles/qs60style_s60.cpp | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 20406e6..48363de 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -1520,9 +1520,9 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, if (tabOverlap > borderThickness) tabOverlap -= borderThickness; - const bool usesScrollButtons = + const bool usesScrollButtons = (widget) ? (qobject_cast(widget))->usesScrollButtons() : false; - const int roomForScrollButton = + const int roomForScrollButton = usesScrollButtons ? QS60StylePrivate::pixelMetric(PM_TabBarScrollButtonWidth) : 0; // adjust for overlapping tabs and scrollbuttons, if necessary @@ -1563,9 +1563,9 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, int tabOverlap = pixelMetric(PM_TabBarTabOverlap); if (tabOverlap > borderThickness) tabOverlap -= borderThickness; - const bool usesScrollButtons = + const bool usesScrollButtons = (widget) ? (qobject_cast(widget))->usesScrollButtons() : false; - const int roomForScrollButton = + const int roomForScrollButton = usesScrollButtons ? QS60StylePrivate::pixelMetric(PM_TabBarScrollButtonWidth) : 0; switch (tab->shape) { @@ -1771,7 +1771,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, //highlight and then it needs one to separate it whatever is shown after it (text/icon/both). const int moveByX = optionCheckBox.rect.width() + 2 * vSpacing; optionCheckBox.rect.moveCenter(QPoint( - optionCheckBox.rect.center().x() + moveByX >> 1, + optionCheckBox.rect.center().x() + moveByX >> 1, menuItem->rect.center().y())); if (optionMenuItem.direction != Qt::LeftToRight) @@ -1785,11 +1785,11 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, const int end = optionMenuItem.rect.right() - spacing; //-1 adjustment to avoid highlight being on top of possible separator item const QRect highlightRect = QRect( - QPoint(start, option->rect.top()), + QPoint(start, option->rect.top()), QPoint(end, option->rect.bottom() - 1)); QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, highlightRect, flags); } - + if (checkable && !ignoreCheckMark) drawPrimitive(PE_IndicatorMenuCheckMark, &optionCheckBox, painter, widget); @@ -2072,8 +2072,8 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti if ((qstyleoption_cast(option) && (qobject_cast(widget) || qobject_cast(widget)))) QS60StylePrivate::drawSkinElement( - QS60StylePrivate::isWidgetPressed(widget) ? - QS60StylePrivate::SE_ListItemPressed : + QS60StylePrivate::isWidgetPressed(widget) ? + QS60StylePrivate::SE_ListItemPressed : QS60StylePrivate::SE_ListHighlight, painter, option->rect, flags); } else { commonStyleDraws = true; @@ -2831,9 +2831,9 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple // Normally spinbuttons should be side-by-side, but if spinbox grows very big // and spinbuttons reach their maximum size, they can be deployed one top of the other. const bool sideBySide = (buttonSize.height() * 2 < spinbox->rect.height()) ? false : true; - const int y = frameThickness + spinbox->rect.y() + + const int y = frameThickness + spinbox->rect.y() + (spinbox->rect.height() - (sideBySide ? 1 : 2) * buttonSize.height()) / 2; - const int x = spinbox->rect.x() + + const int x = spinbox->rect.x() + spinbox->rect.width() - frameThickness - (sideBySide ? 2 : 1) * buttonSize.width(); switch (scontrol) { @@ -2845,8 +2845,8 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple case SC_SpinBoxDown: if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) return QRect(); - ret = QRect(x + (sideBySide ? buttonSize.width() : 0), - y + (sideBySide ? 0 : buttonSize.height()), + ret = QRect(x + (sideBySide ? buttonSize.width() : 0), + y + (sideBySide ? 0 : buttonSize.height()), buttonSize.width(), buttonSize.height()); break; case SC_SpinBoxEditField: @@ -3780,7 +3780,7 @@ QIcon QS60Style::standardIconImplementation(StandardPixmap standardIcon, const QS60StylePrivate::SkinElementFlags flags = adjustedFlags; const int iconDimension = QS60StylePrivate::pixelMetric(metric); - const QRect iconSize = (!option) ? + const QRect iconSize = (!option) ? QRect(0, 0, iconDimension * iconWidthMultiplier, iconDimension * iconHeightMultiplier) : option->rect; const QPixmap cachedPixMap(QS60StylePrivate::cachedPart(part, iconSize.size(), 0, flags)); return cachedPixMap.isNull() ? diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index 489ad09..e58b463 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -110,7 +110,7 @@ typedef struct { TDrawType drawType; // Determines which native drawing routine is used to draw this item. int supportInfo; // Defines the S60 versions that use the default graphics. // These two, define new graphics that are used in releases other than partMapEntry.supportInfo defined releases. - // In general, these are given in numeric form to allow style compilation in earlier + // In general, these are given in numeric form to allow style compilation in earlier // native releases that do not contain the new graphics. int newMajorSkinId; int newMinorSkinId; -- cgit v0.12