summaryrefslogtreecommitdiffstats
path: root/src/gui/styles
diff options
context:
space:
mode:
authorSami Merila <sami.merila@nokia.com>2010-05-07 13:24:18 (GMT)
committerSami Merila <sami.merila@nokia.com>2010-05-07 13:24:18 (GMT)
commit48ec7771d853eeeef211be7def3ebc5ff0badc3e (patch)
treec03913beabebbbfeceabc881702373d968fedcd4 /src/gui/styles
parenta8c89b5d316ca8215611048f79d330a0c604ad27 (diff)
downloadQt-48ec7771d853eeeef211be7def3ebc5ff0badc3e.zip
Qt-48ec7771d853eeeef211be7def3ebc5ff0badc3e.tar.gz
Qt-48ec7771d853eeeef211be7def3ebc5ff0badc3e.tar.bz2
QS60Style: QTreeView branch indicators are drawn incorrectly in RtoL
QS60Style tries to rotate branch graphics around the x-axis, when it is running in RtoL UI direction. This makes the "L-shaped" branch indicators to point to too high at the item view item. Branch indicators should be mirrored across the x-axis to make them look fine. Task-number: QTBUG-9844 Reviewed-by: Alessandro Portale
Diffstat (limited to 'src/gui/styles')
-rw-r--r--src/gui/styles/qs60style.cpp70
-rw-r--r--src/gui/styles/qs60style_p.h2
-rw-r--r--src/gui/styles/qs60style_s60.cpp8
3 files changed, 46 insertions, 34 deletions
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index 00e064f..8bae18e 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -2354,41 +2354,43 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
#endif
QCommonStyle::drawPrimitive(element, option, painter, widget);
} else {
- const bool rightLine = option->state & State_Item;
- const bool downLine = option->state & State_Sibling;
- const bool upLine = option->state & (State_Open | State_Children | State_Item | State_Sibling);
-
- QS60StyleEnums::SkinParts skinPart;
- bool drawSkinPart = false;
- if (rightLine && downLine && upLine) {
- skinPart = QS60StyleEnums::SP_QgnIndiHlLineBranch;
- drawSkinPart = true;
- } else if (rightLine && upLine) {
- skinPart = QS60StyleEnums::SP_QgnIndiHlLineEnd;
- drawSkinPart = true;
- } else if (upLine && downLine) {
- skinPart = QS60StyleEnums::SP_QgnIndiHlLineStraight;
- drawSkinPart = true;
- }
-
- if (drawSkinPart)
- QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags);
+ if (const QStyleOptionViewItemV2 *vopt = qstyleoption_cast<const QStyleOptionViewItemV2 *>(option)) {
+ const bool rightLine = option->state & State_Item;
+ const bool downLine = option->state & State_Sibling;
+ const bool upLine = option->state & (State_Open | State_Children | State_Item | State_Sibling);
+ QS60StylePrivate::SkinElementFlags adjustedFlags = flags;
+
+ QS60StyleEnums::SkinParts skinPart;
+ bool drawSkinPart = false;
+ if (rightLine && downLine && upLine) {
+ skinPart = QS60StyleEnums::SP_QgnIndiHlLineBranch;
+ drawSkinPart = true;
+ } else if (rightLine && upLine) {
+ skinPart = QS60StyleEnums::SP_QgnIndiHlLineEnd;
+ drawSkinPart = true;
+ } else if (upLine && downLine) {
+ skinPart = QS60StyleEnums::SP_QgnIndiHlLineStraight;
+ drawSkinPart = true;
+ }
- if (option->state & State_Children) {
- QS60StyleEnums::SkinParts skinPart =
- (option->state & State_Open) ? QS60StyleEnums::SP_QgnIndiHlColSuper : QS60StyleEnums::SP_QgnIndiHlExpSuper;
- int minDimension = qMin(option->rect.width(), option->rect.height());
- QRect iconRect(option->rect.topLeft(), QSize(minDimension, minDimension));
- const int magicTweak = 3;
- int resizeValue = minDimension >> 1;
- if (!QS60StylePrivate::isTouchSupported()) {
- minDimension += resizeValue; // Adjust the icon bigger because of empty space in svg icon.
- iconRect.setSize(QSize(minDimension, minDimension));
- const int verticalMagic = (option->rect.width() <= option->rect.height()) ? magicTweak : 0;
- resizeValue = verticalMagic - resizeValue;
+ if (option->direction == Qt::RightToLeft)
+ adjustedFlags |= QS60StylePrivate::SF_Mirrored_X_Axis;
+
+ if (drawSkinPart)
+ QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, adjustedFlags);
+
+ if (option->state & State_Children) {
+ QS60StyleEnums::SkinParts skinPart =
+ (option->state & State_Open) ? QS60StyleEnums::SP_QgnIndiHlColSuper : QS60StyleEnums::SP_QgnIndiHlExpSuper;
+ const QRect selectionRect = subElementRect(SE_ItemViewItemCheckIndicator, vopt, widget);
+ const int minDimension = qMin(option->rect.width(), option->rect.height());
+ const int magicTweak = (option->direction == Qt::RightToLeft) ? -3 : 3; //@todo: magic
+ //The branch indicator icon in S60 is supposed to be superimposed on top of branch lines.
+ QRect iconRect(QPoint(option->rect.left() + magicTweak, selectionRect.top() + 1), QSize(minDimension, minDimension));
+ if (!QS60StylePrivate::isTouchSupported())
+ iconRect.translate(0, -4); //@todo: magic
+ QS60StylePrivate::drawSkinPart(skinPart, painter, iconRect, adjustedFlags);
}
- iconRect.translate(magicTweak, resizeValue);
- QS60StylePrivate::drawSkinPart(skinPart, painter, iconRect, flags);
}
}
break;
@@ -3001,7 +3003,7 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con
}
break;
case SE_ItemViewItemCheckIndicator:
- if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
+ if (const QStyleOptionViewItemV2 *vopt = qstyleoption_cast<const QStyleOptionViewItemV2 *>(opt)) {
const QListWidget *listItem = qobject_cast<const QListWidget *>(widget);
const bool singleSelection = listItem &&
diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h
index 9dd3810..d8c31f8 100644
--- a/src/gui/styles/qs60style_p.h
+++ b/src/gui/styles/qs60style_p.h
@@ -476,6 +476,8 @@ public:
SF_StateDisabled = 0x0020,
SF_ColorSkinned = 0x0040, // pixmap is colored with foreground pen color
SF_Animation = 0x0080,
+ SF_Mirrored_X_Axis = 0x0100,
+ SF_Mirrored_Y_Axis = 0x0200
};
enum CacheClearReason {
diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp
index d0da13f..c0ecc5d 100644
--- a/src/gui/styles/qs60style_s60.cpp
+++ b/src/gui/styles/qs60style_s60.cpp
@@ -654,6 +654,14 @@ QPixmap QS60StyleModeSpecifics::fromFbsBitmap(CFbsBitmap *icon, CFbsBitmap *mask
pixmap = QPixmap::fromImage(iconImage);
}
+ if ((flags & QS60StylePrivate::SF_Mirrored_X_Axis) ||
+ (flags & QS60StylePrivate::SF_Mirrored_Y_Axis)) {
+ QImage iconImage = pixmap.toImage().mirrored(
+ flags & QS60StylePrivate::SF_Mirrored_X_Axis,
+ flags & QS60StylePrivate::SF_Mirrored_Y_Axis);
+ pixmap = QPixmap::fromImage(iconImage);
+ }
+
return pixmap;
}