diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2010-05-07 09:15:32 (GMT) |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2010-05-07 09:15:32 (GMT) |
commit | 695ddc4a13233c8e6f626fa205336f90f8c5a565 (patch) | |
tree | 88da8a1d80219e5788db3f4e138d1d281bb3d816 /src/gui/styles/qs60style.cpp | |
parent | 1824eb63f6b2f8baa26b20c57fc50db84eefaa30 (diff) | |
parent | 67bf465253db71c0eddbc6ffcb811dd65c00b207 (diff) | |
download | Qt-695ddc4a13233c8e6f626fa205336f90f8c5a565.zip Qt-695ddc4a13233c8e6f626fa205336f90f8c5a565.tar.gz Qt-695ddc4a13233c8e6f626fa205336f90f8c5a565.tar.bz2 |
Merge branch '4.7' of git@scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Conflicts:
examples/declarative/dynamic/qml/itemCreation.js
Diffstat (limited to 'src/gui/styles/qs60style.cpp')
-rw-r--r-- | src/gui/styles/qs60style.cpp | 71 |
1 files changed, 58 insertions, 13 deletions
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 90b8be3..20297ae 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; @@ -1636,9 +1667,10 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, alignment |= Qt::TextHideMnemonic; if (!optionTab.icon.isNull()) { QSize iconSize = optionTab.iconSize; - int iconExtent = pixelMetric(PM_TabBarIconSize); - if (iconSize.height() > iconExtent || iconSize.width() > iconExtent) + if (!iconSize.isValid()) { + const int iconExtent = pixelMetric(PM_TabBarIconSize); iconSize = QSize(iconExtent, iconExtent); + } QPixmap tabIcon = optionTab.icon.pixmap(iconSize, (optionTab.state & State_Enabled) ? QIcon::Normal : QIcon::Disabled); if (tab->text.isEmpty()) @@ -2490,6 +2522,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: |