summaryrefslogtreecommitdiffstats
path: root/src/gui/styles
diff options
context:
space:
mode:
authorSami Merila <sami.merila@nokia.com>2010-06-11 12:21:14 (GMT)
committerSami Merila <sami.merila@nokia.com>2010-06-11 12:21:14 (GMT)
commitf96d6a5d7d422847d302f4ed1180b66436683191 (patch)
tree10520bcc53a8680346cebb7ef6652c633867bbcc /src/gui/styles
parentf3d0cf049cc5e1eea57146e11ac5a272a774dad8 (diff)
downloadQt-f96d6a5d7d422847d302f4ed1180b66436683191.zip
Qt-f96d6a5d7d422847d302f4ed1180b66436683191.tar.gz
Qt-f96d6a5d7d422847d302f4ed1180b66436683191.tar.bz2
Stylus menu for Share (QT app) is different from native S60 apps
First part of corrections to make menu items more native like. This fixes: - In Sym^3 "separator items" are drawn automatically between items, using a simple line graphic with theme color and alpha values - highlight for menu item is positioned better - menu items themselves are better positioned - the corners of highlight are now more rounded for Sym^3 devices Task-number: QT-3295 Reviewed-by: Alessandro Portale
Diffstat (limited to 'src/gui/styles')
-rw-r--r--src/gui/styles/qs60style.cpp76
-rw-r--r--src/gui/styles/qs60style_s60.cpp10
2 files changed, 67 insertions, 19 deletions
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index 91d3fa6..9745d9c 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -1762,40 +1762,64 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
if (!styleHint(SH_UnderlineShortcut, menuItem, widget))
text_flags |= Qt::TextHideMnemonic;
- const bool selected = (option->state & State_Selected) && (option->state & State_Enabled);
- if (selected)
- QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, option->rect, flags);
-
QRect iconRect = subElementRect(SE_ItemViewItemDecoration, &optionMenuItem, widget);
QRect textRect = subElementRect(SE_ItemViewItemText, &optionMenuItem, widget);
//todo: move the vertical spacing stuff into subElementRect
const int vSpacing = QS60StylePrivate::pixelMetric(PM_LayoutVerticalSpacing);
+ QStyleOptionMenuItem optionCheckBox;
if (checkable){
const int hSpacing = QS60StylePrivate::pixelMetric(PM_LayoutHorizontalSpacing);
- QStyleOptionMenuItem optionCheckBox;
optionCheckBox.QStyleOptionMenuItem::operator=(*menuItem);
optionCheckBox.rect.setWidth(pixelMetric(PM_IndicatorWidth));
optionCheckBox.rect.setHeight(pixelMetric(PM_IndicatorHeight));
optionCheckBox.rect.moveCenter(QPoint(
optionCheckBox.rect.center().x(),
menuItem->rect.center().y()));
- const int moveByX = optionCheckBox.rect.width() + vSpacing;
+ const int moveByX = optionCheckBox.rect.width() + vSpacing +
+ pixelMetric(PM_DefaultFrameWidth) + 1;
if (optionMenuItem.direction == Qt::LeftToRight) {
- textRect.translate(moveByX, 0);
- iconRect.translate(moveByX, 0);
- iconRect.setWidth(iconRect.width() + vSpacing);
- textRect.setWidth(textRect.width() - moveByX - vSpacing);
+ if (iconRect.isValid()) {
+ iconRect.translate(moveByX, 0);
+ iconRect.setWidth(iconRect.width() + vSpacing);
+ }
+ if (textRect.isValid()) {
+ textRect.translate(moveByX, 0);
+ textRect.setWidth(textRect.width() - moveByX - vSpacing);
+ }
optionCheckBox.rect.translate(vSpacing >> 1, hSpacing >> 1);
} else {
- textRect.setWidth(textRect.width() - moveByX);
- iconRect.setWidth(iconRect.width() + vSpacing);
- iconRect.translate(-optionCheckBox.rect.width() - vSpacing, 0);
+ if (textRect.isValid())
+ textRect.setWidth(textRect.width() - moveByX);
+ if (iconRect.isValid()) {
+ iconRect.setWidth(iconRect.width() + vSpacing);
+ iconRect.translate(-optionCheckBox.rect.width() - vSpacing, 0);
+ }
optionCheckBox.rect.translate(textRect.width() + iconRect.width(), 0);
}
- if (!ignoreCheckMark)
- drawPrimitive(PE_IndicatorMenuCheckMark, &optionCheckBox, painter, widget);
}
+
+ const bool selected = (option->state & State_Selected) && (option->state & State_Enabled);
+ const int spacing = pixelMetric(PM_DefaultFrameWidth) * 2;
+ if (selected) {
+ int start; int end;
+ if (QApplication::layoutDirection() == Qt::LeftToRight) {
+ start = optionMenuItem.rect.left() + spacing;
+ end = qMax(textRect.right(), iconRect.right() + spacing);
+ } else {
+ start = qMax(spacing, qMin(textRect.left(), iconRect.left() - spacing));
+ 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(end, option->rect.bottom() - 1));
+ QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, highlightRect, flags);
+ }
+
+ if (checkable && !ignoreCheckMark)
+ drawPrimitive(PE_IndicatorMenuCheckMark, &optionCheckBox, painter, widget);
+
//draw icon and/or checkState
QPixmap pix = menuItem->icon.pixmap(pixelMetric(PM_SmallIconSize),
enabled ? QIcon::Normal : QIcon::Disabled);
@@ -1806,7 +1830,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
textRect.translate(vSpacing, 0);
else
textRect.translate(-vSpacing, 0);
- textRect.setWidth(textRect.width()-vSpacing);
+ textRect.setWidth(textRect.width() - vSpacing);
}
//draw indicators
@@ -1844,6 +1868,23 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
QCommonStyle::drawItemText(painter, textRect, text_flags,
optionMenuItem.palette, enabled,
optionMenuItem.text, QPalette::Text);
+
+ //In Sym^3, native menu items have "lines" between them
+ if (QS60StylePrivate::isSingleClickUi()) {
+ const QColor lineColorAlpha = QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 15, 0);
+ //native platform sets each color byte to same value for "line 16" which just defines alpha for
+ //menuitem lines; lets use first byte "red".
+ QColor lineColor = optionMenuItem.palette.text().color();
+ if (lineColorAlpha.isValid())
+ lineColor.setAlpha(lineColorAlpha.red());
+ painter->save();
+ painter->setPen(lineColor);
+
+ const int lineStartX = optionMenuItem.rect.left() + (QS60StylePrivate::pixelMetric(PM_FrameCornerWidth) - 2) + spacing;
+ const int lineEndX = optionMenuItem.rect.right() - (QS60StylePrivate::pixelMetric(PM_FrameCornerWidth) - 2) - spacing;
+ painter->drawLine(QPoint(lineStartX, optionMenuItem.rect.bottom()), QPoint(lineEndX, optionMenuItem.rect.bottom()));
+ painter->restore();
+ }
if (!enabled)
painter->restore();
}
@@ -2555,6 +2596,8 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt,
}
}
sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget);
+ //native items have small empty areas at the beginning and end of menu item
+ sz.setWidth(sz.width() + 2 * pixelMetric(PM_MenuHMargin));
if (QS60StylePrivate::isTouchSupported())
//Make itemview easier to use in touch devices
//QCommonStyle does not adjust height with horizontal margin, it only adjusts width
@@ -2996,7 +3039,6 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con
ret.setWidth(indicatorWidth);
}
} else {
- ret = menuItem->rect;
if (!menuItem->icon.isNull())
if (menuItem->direction == Qt::LeftToRight)
ret.adjust(indicatorWidth, 0, 0, 0);
diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp
index e5c74ad..4bb2ea8 100644
--- a/src/gui/styles/qs60style_s60.cpp
+++ b/src/gui/styles/qs60style_s60.cpp
@@ -1023,8 +1023,14 @@ TRect QS60StyleModeSpecifics::innerRectFromElement(QS60StylePrivate::SkinFrameEl
heightShrink = heightShrink >> 1;
break;
case QS60StylePrivate::SF_ListHighlight:
- widthShrink = widthShrink - 2;
- heightShrink = heightShrink - 2;
+ //In Sym^3 devices highlights are less blocky
+ if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0) {
+ widthShrink += 2;
+ heightShrink += 2;
+ } else {
+ widthShrink -= 2;
+ heightShrink -= 2;
+ }
break;
case QS60StylePrivate::SF_PopupBackground:
widthShrink = widthShrink + 5;