diff options
Diffstat (limited to 'src/gui/styles')
-rw-r--r-- | src/gui/styles/qcleanlooksstyle.cpp | 2 | ||||
-rw-r--r-- | src/gui/styles/qcommonstyle.cpp | 4 | ||||
-rw-r--r-- | src/gui/styles/qgtkstyle.cpp | 3 | ||||
-rw-r--r-- | src/gui/styles/qs60style.cpp | 105 | ||||
-rw-r--r-- | src/gui/styles/qs60style_s60.cpp | 10 |
5 files changed, 84 insertions, 40 deletions
diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp index 883f511..ada5293 100644 --- a/src/gui/styles/qcleanlooksstyle.cpp +++ b/src/gui/styles/qcleanlooksstyle.cpp @@ -884,7 +884,7 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, } painter->restore(); break; -#ifndef QT_NO_LINEDIT +#ifndef QT_NO_LINEEDIT case PE_FrameLineEdit: // fall through #endif // QT_NO_LINEEDIT diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp index 4978565..039a6da 100644 --- a/src/gui/styles/qcommonstyle.cpp +++ b/src/gui/styles/qcommonstyle.cpp @@ -762,7 +762,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q #ifndef QT_NO_ITEMVIEWS case PE_PanelItemViewRow: if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) { - QPalette::ColorGroup cg = vopt->state & QStyle::State_Enabled + QPalette::ColorGroup cg = (widget ? widget->isEnabled() : (vopt->state & QStyle::State_Enabled)) ? QPalette::Normal : QPalette::Disabled; if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active)) cg = QPalette::Inactive; @@ -775,7 +775,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q break; case PE_PanelItemViewItem: if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) { - QPalette::ColorGroup cg = vopt->state & QStyle::State_Enabled + QPalette::ColorGroup cg = (widget ? widget->isEnabled() : (vopt->state & QStyle::State_Enabled)) ? QPalette::Normal : QPalette::Disabled; if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active)) cg = QPalette::Inactive; diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp index b59a033..c989bd3 100644 --- a/src/gui/styles/qgtkstyle.cpp +++ b/src/gui/styles/qgtkstyle.cpp @@ -855,9 +855,10 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, key = QLS("a"); GTK_WIDGET_SET_FLAGS(gtkTreeView, GTK_HAS_FOCUS); } + bool isEnabled = (widget ? widget->isEnabled() : (vopt->state & QStyle::State_Enabled)); gtkPainter.paintFlatBox(gtkTreeView, detail, option->rect, option->state & State_Selected ? GTK_STATE_SELECTED : - option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, + isEnabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, GTK_SHADOW_OUT, gtkTreeView->style, key); if (isActive ) GTK_WIDGET_UNSET_FLAGS(gtkTreeView, GTK_HAS_FOCUS); diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 91d3fa6..45bcc00 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -1762,40 +1762,65 @@ 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); - 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; - if (optionMenuItem.direction == Qt::LeftToRight) { - textRect.translate(moveByX, 0); + QStyleOptionMenuItem optionCheckBox; + + //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 >> 1, hSpacing >> 1); - } else { + } + 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); } - if (!ignoreCheckMark) - drawPrimitive(PE_IndicatorMenuCheckMark, &optionCheckBox, painter, widget); + optionCheckBox.rect.translate(textRect.width() + iconRect.width(), 0); } + + const bool selected = (option->state & State_Selected) && (option->state & State_Enabled); + if (selected) { + const int spacing = pixelMetric(PM_DefaultFrameWidth) * 2; + 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 +1831,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 +1869,24 @@ 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); + 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(); + 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(); } @@ -2240,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; @@ -2555,10 +2600,12 @@ 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) + 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: { @@ -2823,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: @@ -2996,7 +3034,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; |