From 3079176a87a77095ddbc320c6c07e1fad46596dd Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich <gabriel.dedietrich@digia.com> Date: Thu, 21 Mar 2013 20:06:03 +0100 Subject: [PATCH] TabBar: Tweaky, tweaky little style... Tweaky, tweaky, shine on Mac! Change-Id: Ic338b1474f1cbaeedda11be00a2bfbdbf7388adb Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com> --- src/private/qstyleitem.cpp | 11 +++++++++-- src/styles/Desktop/TabViewStyle.qml | 13 ++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/private/qstyleitem.cpp b/src/private/qstyleitem.cpp index 831e8e965..8a21e50f1 100644 --- a/src/private/qstyleitem.cpp +++ b/src/private/qstyleitem.cpp @@ -303,7 +303,7 @@ void QStyleItem::initStyleOption() opt->selectedPosition = QStyleOptionTab::NextIsSelected; else if (selectedPosition == QLatin1String("previous")) opt->selectedPosition = QStyleOptionTab::PreviousIsSelected; - else + else opt->selectedPosition = QStyleOptionTab::NotAdjacent; } @@ -1100,7 +1100,14 @@ void QStyleItem::paint(QPainter *painter) qApp->style()->drawComplexControl(QStyle::CC_ToolButton, qstyleoption_cast<QStyleOptionComplex*>(m_styleoption), painter); break; case Tab: - qApp->style()->drawControl(QStyle::CE_TabBarTab, m_styleoption, painter); + if (style() == "mac") { + m_styleoption->rect.translate(0, 1); // Unhack QMacStyle's hack + qApp->style()->drawControl(QStyle::CE_TabBarTabShape, m_styleoption, painter); + m_styleoption->rect.translate(0, -1); + qApp->style()->drawControl(QStyle::CE_TabBarTabLabel, m_styleoption, painter); + } else { + qApp->style()->drawControl(QStyle::CE_TabBarTab, m_styleoption, painter); + } break; case Frame: qApp->style()->drawControl(QStyle::CE_ShapedFrame, m_styleoption, painter); diff --git a/src/styles/Desktop/TabViewStyle.qml b/src/styles/Desktop/TabViewStyle.qml index f659b706d..e9249b02b 100644 --- a/src/styles/Desktop/TabViewStyle.qml +++ b/src/styles/Desktop/TabViewStyle.qml @@ -83,12 +83,13 @@ Style { id: styleitem elementType: "tab" - paintMargins: 2 + paintMargins: style === "mac" ? 0 : 2 anchors.fill: parent - anchors.rightMargin: -paintMargins + (style == "mac" ? -1 : 0) + anchors.topMargin: style === "mac" ? 2 : 0 + anchors.rightMargin: -paintMargins anchors.bottomMargin: -1 - anchors.leftMargin: -paintMargins + anchors.leftMargin: -paintMargins + (style === "mac" && selected ? -1 : 0) properties: { "hasFrame" : true } hints: [tabPosition, tabpos, selectedpos] @@ -96,12 +97,6 @@ Style { text: elidedText(title, tabbarItem.elide, width - item.tabHSpace) hover: tab.hover hasFocus: tabbarItem.activeFocus && selected - - Text { - id: textitem - visible: false - text: styleitem.text - } } } } -- GitLab