From d264a67d992d6fb0db7326ac6f5f073706d31e8d Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig <jens.bache-wiig@digia.com> Date: Sat, 25 May 2013 08:40:32 -0700 Subject: [PATCH] Pass selected tab rect to style In particular QGtkStyle depends on having the selected tab rect in the style option. Otherwise it cannot draw the tab frame correctly as we pass this information on to gtk. In addition we were not correctly setting the tab position on the frame. Change-Id: I9aa17d6b33f6b283122014994dc92a6afb913f30 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com> --- src/private/TabBar.qml | 9 +++++++++ src/private/qquickstyleitem.cpp | 4 +++- src/styles/Desktop/TabViewStyle.qml | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/private/TabBar.qml b/src/private/TabBar.qml index 1efaaf850..49b10584d 100644 --- a/src/private/TabBar.qml +++ b/src/private/TabBar.qml @@ -79,6 +79,8 @@ FocusScope { property real availableWidth: tabbar.width - leftCorner.width - rightCorner.width + property var __selectedTabRect + function tab(index) { for (var i = 0; i < tabrow.children.length; ++i) { if (tabrow.children[i].tabindex == index) { @@ -154,6 +156,13 @@ FocusScope { hoverEnabled: true focus: true + Binding { + target: tabbar + when: selected + property: "__selectedTabRect" + value: Qt.rect(x, y, width, height) + } + drag.target: tabsMovable ? tabloader : null drag.axis: Drag.XAxis drag.minimumX: drag.active ? 0 : -Number.MAX_VALUE diff --git a/src/private/qquickstyleitem.cpp b/src/private/qquickstyleitem.cpp index 7da0ebdf5..f5e32bba4 100644 --- a/src/private/qquickstyleitem.cpp +++ b/src/private/qquickstyleitem.cpp @@ -368,7 +368,9 @@ void QQuickStyleItem::initStyleOption() if (!m_styleoption) m_styleoption = new QStyleOptionTabWidgetFrame(); QStyleOptionTabWidgetFrame *opt = qstyleoption_cast<QStyleOptionTabWidgetFrame*>(m_styleoption); - opt->shape = hints().contains("South") ? QTabBar::RoundedSouth : QTabBar::RoundedNorth; + + opt->selectedTabRect = m_properties["selectedTabRect"].toRect(); + opt->shape = m_properties["orientation"] == Qt::BottomEdge ? QTabBar::RoundedSouth : QTabBar::RoundedNorth; if (minimum()) opt->selectedTabRect = QRect(value(), 0, minimum(), height()); opt->tabBarSize = QSize(minimum() , height()); diff --git a/src/styles/Desktop/TabViewStyle.qml b/src/styles/Desktop/TabViewStyle.qml index 9cd34705c..455b99dbe 100644 --- a/src/styles/Desktop/TabViewStyle.qml +++ b/src/styles/Desktop/TabViewStyle.qml @@ -61,10 +61,10 @@ Style { anchors.topMargin: 1//stack.baseOverlap z: style == "oxygen" ? 1 : 0 elementType: "tabframe" - hints: control.tabPosition === Qt.TopEdge ? "Top" : "Bottom" value: tabbarItem && tabsVisible && tabbarItem.tab(currentIndex) ? tabbarItem.tab(currentIndex).x : 0 minimum: tabbarItem && tabsVisible && tabbarItem.tab(currentIndex) ? tabbarItem.tab(currentIndex).width : 0 maximum: tabbarItem && tabsVisible ? tabbarItem.width : width + properties: { "selectedTabRect" : tabbarItem.__selectedTabRect, "orientation" : control.tabPosition } Component.onCompleted: { stack.frameWidth = styleitem.pixelMetric("defaultframewidth"); stack.style = style; -- GitLab