From f96d6a5d7d422847d302f4ed1180b66436683191 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Fri, 11 Jun 2010 15:21:14 +0300 Subject: 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 --- src/gui/styles/qs60style.cpp | 76 +++++++++++++++++++++++++++++++--------- src/gui/styles/qs60style_s60.cpp | 10 ++++-- 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; -- cgit v0.12 From 78560390b948127262a9ebb5f4dd355b6c517e94 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 15 Jun 2010 13:49:26 +0300 Subject: Change $${EPOCROOT} to also have drive if EPOCROOT env variable has it Since sbsv2 toolchain supports having sources and SDK on different drives, $${EPOCROOT} needs to contain drive letter to make it work. Reviewed-by: Jason Barron --- qmake/generators/symbian/symbiancommon.cpp | 3 --- qmake/generators/symbian/symmake_sbsv2.cpp | 4 +++- src/s60installs/s60installs.pro | 4 ++-- tools/shared/symbian/epocroot.cpp | 4 ---- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/qmake/generators/symbian/symbiancommon.cpp b/qmake/generators/symbian/symbiancommon.cpp index 58729d2..3a4bdbc 100644 --- a/qmake/generators/symbian/symbiancommon.cpp +++ b/qmake/generators/symbian/symbiancommon.cpp @@ -433,9 +433,6 @@ void SymbianCommonGenerator::generatePkgFile(const QString &iconFile, bool epocB if (from.size() > 1 && from.at(1) == QLatin1Char(':')) from = from.mid(2); from.prepend(zDir); - } else { - if (from.size() > 1 && from.at(1) == QLatin1Char(':')) - from = from.mid(2); } } diff --git a/qmake/generators/symbian/symmake_sbsv2.cpp b/qmake/generators/symbian/symmake_sbsv2.cpp index c2f1d1a..78f6f85 100644 --- a/qmake/generators/symbian/symmake_sbsv2.cpp +++ b/qmake/generators/symbian/symmake_sbsv2.cpp @@ -99,7 +99,9 @@ void SymbianSbsv2MakefileGenerator::writeSbsDeploymentList(const DeploymentList& fromItem.replace("\\", "/"); toItem.replace("\\", "/"); #if defined(Q_OS_WIN) - toItem.prepend(QDir::current().absolutePath().left(2)); // add drive + // add drive if it doesn't have one yet + if (toItem.size() > 1 && toItem[1] != QLatin1Char(':')) + toItem.prepend(QDir::current().absolutePath().left(2)); #endif t << "OPTION DEPLOY_SOURCE " << fromItem << endl; t << "OPTION DEPLOY_TARGET " << toItem << endl; diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro index d751134..ce0f4f1 100644 --- a/src/s60installs/s60installs.pro +++ b/src/s60installs/s60installs.pro @@ -16,8 +16,8 @@ symbian: { # It is also expected that devices newer than those based on S60 5.0 all have sqlite3.dll. contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) { BLD_INF_RULES.prj_exports += \ - "sqlite3.sis $${EPOCROOT}epoc32/data/qt/sis/sqlite3.sis" \ - "sqlite3_selfsigned.sis $${EPOCROOT}epoc32/data/qt/sis/sqlite3_selfsigned.sis" + "sqlite3.sis /epoc32/data/qt/sis/sqlite3.sis" \ + "sqlite3_selfsigned.sis /epoc32/data/qt/sis/sqlite3_selfsigned.sis" symbian-abld|symbian-sbsv2 { sqlitedeployment = \ "; Deploy sqlite onto phone that does not have it already" \ diff --git a/tools/shared/symbian/epocroot.cpp b/tools/shared/symbian/epocroot.cpp index 064e056..ae1dcb1 100644 --- a/tools/shared/symbian/epocroot.cpp +++ b/tools/shared/symbian/epocroot.cpp @@ -105,10 +105,6 @@ static void fixEpocRoot(QString &path) { path.replace("\\", "/"); - if (path.size() > 1 && path[1] == QChar(':')) { - path = path.mid(2); - } - if (!path.size() || path[path.size()-1] != QChar('/')) { path += QChar('/'); } -- cgit v0.12 From 86b13101afe31934eddb0c904ac6d2815cd39e5e Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Tue, 15 Jun 2010 15:34:01 +0300 Subject: Stylus menu for Share (QT app) is different from native S60 apps This is part two of the fix. This fix makes the menu item to be layoutted always with space reserved for checkbox indicator, even if the menu item is not having one (just like native side). Also, the right and left "gap areas" (between menu border and menu item highlight) match the native side more closely now. There is still some difference if using QMenu (instead of QComboBoxListView), since we can't just ignore margin set from widget. Also, the Sym^3 "separator lines" are now started from correct position. Finally, the menu item height now matches the native side. Task-number: QT-3295 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 66 +++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 9745d9c..1a8dd78 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -1768,40 +1768,41 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, //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); - 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 + - pixelMetric(PM_DefaultFrameWidth) + 1; - if (optionMenuItem.direction == Qt::LeftToRight) { - 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 { - 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); + + //Regardless of checkbox visibility, make room for it, this mirrors native implementation, + //where text and icon placement is static regardless of content of menu item. + const int hSpacing = QS60StylePrivate::pixelMetric(PM_LayoutHorizontalSpacing); + 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 + + pixelMetric(PM_DefaultFrameWidth); + if (optionMenuItem.direction == Qt::LeftToRight) { + 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 + pixelMetric(PM_DefaultFrameWidth), hSpacing >> 1); + } else { + 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); } const bool selected = (option->state & State_Selected) && (option->state & State_Enabled); - const int spacing = pixelMetric(PM_DefaultFrameWidth) * 2; if (selected) { + const int spacing = pixelMetric(PM_DefaultFrameWidth) * 2; int start; int end; if (QApplication::layoutDirection() == Qt::LeftToRight) { start = optionMenuItem.rect.left() + spacing; @@ -1872,6 +1873,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, //In Sym^3, native menu items have "lines" between them if (QS60StylePrivate::isSingleClickUi()) { const QColor lineColorAlpha = QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 15, 0); + const int spacing = QS60StylePrivate::pixelMetric(PM_FrameCornerWidth); //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(); @@ -2281,6 +2283,8 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti if (QS60StylePrivate::canDrawThemeBackground(option->palette.base(), widget) && option->palette.window().texture().cacheKey() == QS60StylePrivate::m_themePalette->window().texture().cacheKey()) + //todo: for combobox listviews, the background should include area for menu scrollers, + //but this produces drawing issues as we need to turn clipping off. QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_PopupBackground, painter, option->rect, flags); else commonStyleDraws = true; @@ -2597,11 +2601,11 @@ 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)); + sz.setWidth(sz.width() + 2 * pixelMetric(PM_MenuHMargin) + 2 * QS60StylePrivate::pixelMetric(PM_FrameCornerWidth)); if (QS60StylePrivate::isTouchSupported()) //Make itemview easier to use in touch devices //QCommonStyle does not adjust height with horizontal margin, it only adjusts width - sz.setHeight(sz.height() + 2 * pixelMetric(PM_FocusFrameVMargin)); + sz.setHeight(sz.height() + 2 * pixelMetric(PM_FocusFrameVMargin) - 8); //QCommonstyle adds 8 to height that this style handles through PM values break; #ifndef QT_NO_COMBOBOX case CT_ComboBox: { -- cgit v0.12 From 28ce5c1f2c0dbbfe45b5c3744bf03a2548c12223 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Tue, 15 Jun 2010 16:09:41 +0300 Subject: ComboBox popuplist is not correctly layouted in fullscreen mode This is part two of the fix for issue QTBUG-9913. This corrects the left margin of the ComboBox menu to start from the left screen border (for LetToRight UI Layout), instead of having small margin. Task-number: QTBUG-9913 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 1a8dd78..45bcc00 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -2870,16 +2870,7 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple } break; case SC_ComboBoxListBoxPopup: { - const QRect desktopContent = QApplication::desktop()->availableGeometry(); - - // take the size of this and position bottom above available area - QRect popupRect; - const int width = desktopContent.width() - pixelMetric(PM_LayoutRightMargin) - pixelMetric(PM_LayoutLeftMargin); - popupRect.setWidth(width); - popupRect.setHeight(desktopContent.height()); //combobox resets height anyway based on content - popupRect.setBottom(desktopContent.bottom()); - popupRect.translate(pixelMetric(PM_LayoutLeftMargin), 0); - ret = popupRect; + ret = QApplication::desktop()->availableGeometry(); } break; default: -- cgit v0.12