summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorAlessandro Portale <alessandro.portale@nokia.com>2010-03-22 20:14:39 (GMT)
committerAlessandro Portale <alessandro.portale@nokia.com>2010-03-22 20:35:20 (GMT)
commita260a77d9d6b7856278e2ee9b42623c469479d4e (patch)
treec15e6eecd1d92c41914e9fa00cb73349297e8aea /src/gui
parent8ae437dc2011d293fde1641ce0fa633fe1a2b00e (diff)
downloadQt-a260a77d9d6b7856278e2ee9b42623c469479d4e.zip
Qt-a260a77d9d6b7856278e2ee9b42623c469479d4e.tar.gz
Qt-a260a77d9d6b7856278e2ee9b42623c469479d4e.tar.bz2
Fixing keypad navigation focus frame
The QFocusFrame drawing code in QS60Style incorrectly assumed that PM_LayoutSpacing is always equal to PM_FocusFrameMargin. When these values diverged, the focus frame broke as described in task QTBUG-8036. The fix makes the drawing more robust. The focus frame width is never thicker than PM_LayoutSpacing and PM_FocusFrameMargin. And instead of drawing a roundRect with calculated pen width, we are now filling a roundRect. That makes the focusFrame more apparent. Task-number: QTBUG-8036 Reviewed-by: Sami Merila
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/styles/qs60style.cpp37
1 files changed, 17 insertions, 20 deletions
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index 750e19f..86812a6 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -1964,11 +1964,6 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
case CE_MenuScroller:
break;
case CE_FocusFrame: {
- // The pen width should nearly fill the layoutspacings around the widget
- const int penWidth =
- qMin(pixelMetric(QS60Style::PM_LayoutVerticalSpacing), pixelMetric(QS60Style::PM_LayoutHorizontalSpacing))
- - 2; // But keep 1 pixel distance to the focus widget and 1 pixel to the adjacent widgets
-
#ifdef QT_KEYPAD_NAVIGATION
bool editFocus = false;
if (const QFocusFrame *focusFrame = qobject_cast<const QFocusFrame*>(widget)) {
@@ -1979,25 +1974,27 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
#else
const qreal opacity = 0.5;
#endif
- // Because of Qts coordinate system, we need to tweak the rect by .5 pixels, otherwise it gets blurred.
- const qreal rectAdjustment = (penWidth % 2) ? -.5 : 0;
-
- // Make sure that the pen stroke is inside the rect
- const QRectF adjustedRect =
- QRectF(option->rect).adjusted(
- rectAdjustment + penWidth,
- rectAdjustment + penWidth,
- -rectAdjustment - penWidth,
- -rectAdjustment - penWidth
- );
-
- const qreal roundRectRadius = penWidth * goldenRatio;
+ // We need to reduce the focus frame size if LayoutSpacing is smaller than FocusFrameMargin
+ // Otherwise, we would overlay adjacent widgets.
+ const int frameHeightReduction =
+ qMin(0, pixelMetric(QStyle::PM_LayoutVerticalSpacing)
+ - pixelMetric(QStyle::PM_FocusFrameVMargin));
+ const int frameWidthReduction =
+ qMin(0, pixelMetric(QStyle::PM_LayoutHorizontalSpacing)
+ - pixelMetric(QStyle::PM_FocusFrameHMargin));
+ const int rounding =
+ qMin(pixelMetric(QStyle::PM_FocusFrameVMargin),
+ pixelMetric(QStyle::PM_LayoutVerticalSpacing));
+ const QRect frameRect =
+ option->rect.adjusted(-frameWidthReduction, -frameHeightReduction,
+ frameWidthReduction, frameHeightReduction);
+ QPainterPath framePath;
+ framePath.addRoundedRect(frameRect, rounding, rounding);
painter->save();
painter->setRenderHint(QPainter::Antialiasing);
painter->setOpacity(opacity);
- painter->setPen(QPen(option->palette.color(QPalette::Text), penWidth));
- painter->drawRoundedRect(adjustedRect, roundRectRadius, roundRectRadius);
+ painter->fillPath(framePath, option->palette.color(QPalette::Text));
painter->restore();
}
break;