diff options
author | Sami Merila <sami.merila@nokia.com> | 2011-03-25 12:59:53 (GMT) |
---|---|---|
committer | Sami Merila <sami.merila@nokia.com> | 2011-03-25 12:59:53 (GMT) |
commit | e147be52c60185822fc00a2d19fe2c1337976485 (patch) | |
tree | 539a066e83f736ec967ae247d6438c8b1f1d08c2 /src/gui/styles | |
parent | d2293aaf51740e579ca4d77b702fbfb983b8f009 (diff) | |
download | Qt-e147be52c60185822fc00a2d19fe2c1337976485.zip Qt-e147be52c60185822fc00a2d19fe2c1337976485.tar.gz Qt-e147be52c60185822fc00a2d19fe2c1337976485.tar.bz2 |
QS60Style: draw QComboBox menu correctly
Note that this fix only corrects the issues #2 and #3 highlighted
in the report. These are:
a) no longer is a "background" line drawn after last item
b) combobox background is adjusted bigger so that
first and last item
The remaining issue will be fixed as a separate commit (for separate
JIRA task).
Task-number: QTBUG-16858
Reviewed-by: Dmitry Trofimov
Diffstat (limited to 'src/gui/styles')
-rw-r--r-- | src/gui/styles/qs60style.cpp | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 59c69c3..aa68c23 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -1866,20 +1866,26 @@ 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(); - 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(); + int diff = widget->geometry().bottom() - optionMenuItem.rect.bottom(); + if (const QComboBox *cb = qobject_cast<const QComboBox*>(widget)) + diff = cb->view()->geometry().bottom() - optionMenuItem.rect.bottom(); + + // Skip drawing the horizontal line for the last menu item. + if (diff > optionMenuItem.rect.height()) { + 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 horizontalMargin = 2 * QS60StylePrivate::pixelMetric(PM_FrameCornerWidth) - QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); + const int lineStartX = optionMenuItem.rect.left() + horizontalMargin; + const int lineEndX = optionMenuItem.rect.right() - horizontalMargin; + painter->drawLine(QPoint(lineStartX, optionMenuItem.rect.bottom()), QPoint(lineEndX, optionMenuItem.rect.bottom())); + painter->restore(); + } } if (!enabled) painter->restore(); @@ -2274,13 +2280,15 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti #endif //QT_NO_MENU ) { //Need extra check since dialogs have their own theme background - if (QS60StylePrivate::canDrawThemeBackground(option->palette.base(), widget) && - QS60StylePrivate::equalToThemePalette(option->palette.window().texture().cacheKey(), QPalette::Window)) - //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 + if (QS60StylePrivate::canDrawThemeBackground(option->palette.base(), widget) + && QS60StylePrivate::equalToThemePalette(option->palette.window().texture().cacheKey(), QPalette::Window)) { + // Add margin area to the background, to avoid background being cut for first and last item. + const int verticalMenuAdjustment = QS60StylePrivate::pixelMetric(PM_MenuVMargin); + const QRect adjustedMenuRect = option->rect.adjusted(0, -verticalMenuAdjustment, 0, verticalMenuAdjustment); + QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_PopupBackground, painter, adjustedMenuRect, flags); + } else { commonStyleDraws = true; + } } break; case PE_FrameWindow: |