diff options
author | Sami Merila <sami.merila@nokia.com> | 2010-05-03 12:31:26 (GMT) |
---|---|---|
committer | Sami Merila <sami.merila@nokia.com> | 2010-05-03 12:31:26 (GMT) |
commit | fb2c7c62030f1e2bf314fc30b9786de611563116 (patch) | |
tree | 4e861e9ebc78715c5f9b6dcf9381e1bd8bc71ed4 /src/gui/styles | |
parent | b3ff31825d9c3e9d139565024d424eb03299b5f5 (diff) | |
download | Qt-fb2c7c62030f1e2bf314fc30b9786de611563116.zip Qt-fb2c7c62030f1e2bf314fc30b9786de611563116.tar.gz Qt-fb2c7c62030f1e2bf314fc30b9786de611563116.tar.bz2 |
QS60Style: QTabWidget Usability issue with capacitive screens
Normally Qt uses scrollbuttons together at right (for LeftToRight UI)
side of the horizontal QTabBar; for vertical tab bar, scrollbuttons are
displayed below/above the widget.
Using QTabBar's scroll buttons with touch device that has capacitive
screen, is somewhat hard as the touch area for either of the scroll
buttons is somewhat smallish. So user is experiencing frequent wrong
taps. Making the touch area larger, would make the tabbar tab shape
area smaller, so it isn't a very good solution.
Therefore, when QS60Style is in use, QTabWidget draws the scrollbuttons
on either side of the QTabBar.
Task-number: QT-3104
Reviewed-by: Alessandro Portale
Diffstat (limited to 'src/gui/styles')
-rw-r--r-- | src/gui/styles/qs60style.cpp | 66 |
1 files changed, 55 insertions, 11 deletions
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 90b8be3..c0c1cdd 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -1546,18 +1546,35 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); const int tabOverlap = QS60StylePrivate::pixelMetric(PM_TabBarTabOverlap) - borderThickness; - - if (skinElement==QS60StylePrivate::SE_TabBarTabEastInactive|| - skinElement==QS60StylePrivate::SE_TabBarTabEastActive|| - skinElement==QS60StylePrivate::SE_TabBarTabWestInactive|| - skinElement==QS60StylePrivate::SE_TabBarTabWestActive){ - optionTabAdj.rect.adjust(0, 0, 0, tabOverlap); - } else { - if (directionMirrored) - optionTabAdj.rect.adjust(-tabOverlap, 0, 0, 0); + const bool usesScrollButtons = + (widget) ? (qobject_cast<const QTabBar*>(widget))->usesScrollButtons() : false; + const int roomForScrollButton = + usesScrollButtons ? QS60StylePrivate::pixelMetric(PM_TabBarScrollButtonWidth) : 0; + + // adjust for overlapping tabs and scrollbuttons, if necessary + if (skinElement == QS60StylePrivate::SE_TabBarTabEastInactive || + skinElement == QS60StylePrivate::SE_TabBarTabEastActive || + skinElement == QS60StylePrivate::SE_TabBarTabWestInactive || + skinElement == QS60StylePrivate::SE_TabBarTabWestActive){ + if (optionTabAdj.position == QStyleOptionTabV3::Beginning) + optionTabAdj.rect.adjust(0, roomForScrollButton, 0, tabOverlap); + else if (optionTabAdj.position == QStyleOptionTabV3::End) + optionTabAdj.rect.adjust(0, 0, 0, tabOverlap); else - optionTabAdj.rect.adjust(0, 0, tabOverlap, 0); + optionTabAdj.rect.adjust(0, 0, 0, tabOverlap); + } else { + if (directionMirrored) { + if (optionTabAdj.position == QStyleOptionTabV3::Beginning) + optionTabAdj.rect.adjust(-tabOverlap, 0, -roomForScrollButton, 0); + else + optionTabAdj.rect.adjust(-tabOverlap, 0, 0, 0); + } else { + if (optionTabAdj.position == QStyleOptionTabV3::Beginning) + optionTabAdj.rect.adjust(roomForScrollButton, 0, tabOverlap, 0); + else + optionTabAdj.rect.adjust(0, 0, tabOverlap, 0); } + } } QS60StylePrivate::drawSkinElement(skinElement, painter, optionTabAdj.rect, flags); } @@ -1570,7 +1587,10 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, const int borderThickness = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); const int tabOverlap = QS60StylePrivate::pixelMetric(PM_TabBarTabOverlap) - borderThickness; - const QRect windowRect = painter->window(); + const bool usesScrollButtons = + (widget) ? (qobject_cast<const QTabBar*>(widget))->usesScrollButtons() : false; + const int roomForScrollButton = + usesScrollButtons ? QS60StylePrivate::pixelMetric(PM_TabBarScrollButtonWidth) : 0; switch (tab->shape) { case QTabBar::TriangularWest: @@ -1605,6 +1625,17 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, || optionTab.shape == QTabBar::TriangularEast || optionTab.shape == QTabBar::TriangularWest; + //make room for scrollbuttons + if (!verticalTabs) { + if ((tab->position == QStyleOptionTabV3::Beginning && !directionMirrored)) + tr.adjust(roomForScrollButton, 0, 0, 0); + else if ((tab->position == QStyleOptionTabV3::Beginning && directionMirrored)) + tr.adjust(0, 0, -roomForScrollButton, 0); + } else { + if (tab->position == QStyleOptionTabV3::Beginning) + tr.adjust(0, roomForScrollButton, 0, 0); + } + if (verticalTabs) { painter->save(); int newX, newY, newRotation; @@ -2490,6 +2521,19 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget); if (naviPaneSize.height() > sz.height()) sz.setHeight(naviPaneSize.height()); + // Adjust beginning tabbar item size, if scrollbuttons are used. This is to ensure that the + // tabbar item content fits, since scrollbuttons are making beginning tabbar item smaller. + int scrollButtonSize = 0; + if (const QTabBar *tabBar = qobject_cast<const QTabBar *>(widget)) + scrollButtonSize = tabBar->usesScrollButtons() ? pixelMetric(PM_TabBarScrollButtonWidth) : 0; + if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) { + const bool verticalTabs = tab->shape == QTabBar::RoundedEast + || tab->shape == QTabBar::RoundedWest + || tab->shape == QTabBar::TriangularEast + || tab->shape == QTabBar::TriangularWest; + if (tab->position == QStyleOptionTab::Beginning) + sz += QSize(verticalTabs ? 0 : scrollButtonSize, !verticalTabs ? 0 : scrollButtonSize); + } } break; case CT_MenuItem: |