From 2676cc1485a3236ca7f0142dc3ff97f42797408b Mon Sep 17 00:00:00 2001 From: Caroline Chao <caroline.chao@digia.com> Date: Tue, 19 Mar 2013 12:22:29 +0100 Subject: [PATCH] TabBar: add elide property The elide mode set is Text.ElideRight. Change-Id: I384e598e5133782207038b2762b8400da4931639 Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com> --- src/private/TabBar.qml | 2 ++ src/styles/Desktop/TabViewStyle.qml | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/private/TabBar.qml b/src/private/TabBar.qml index 266d20e1a..25914f1cb 100644 --- a/src/private/TabBar.qml +++ b/src/private/TabBar.qml @@ -75,6 +75,8 @@ FocusScope { property int tabOverlap: styleItem ? styleItem.tabOverlap : 0 property int tabBaseOverlap: styleItem ? styleItem.tabBaseOverlap : 0 + property int elide: Text.ElideRight + function tab(index) { for (var i = 0; i < tabrow.children.length; ++i) { if (tabrow.children[i].tabindex == index) { diff --git a/src/styles/Desktop/TabViewStyle.qml b/src/styles/Desktop/TabViewStyle.qml index d2ba2280f..aff9cc10f 100644 --- a/src/styles/Desktop/TabViewStyle.qml +++ b/src/styles/Desktop/TabViewStyle.qml @@ -71,11 +71,12 @@ Style { } property Component tab: Item { + id: item property string tabpos: control.count === 1 ? "only" : index === 0 ? "beginning" : index === control.count - 1 ? "end" : "middle" property string selectedpos: nextSelected ? "next" : previousSelected ? "previous" : "" property int tabHSpace: __barstyle.pixelMetric("tabhspace"); property int tabVSpace: __barstyle.pixelMetric("tabvspace"); - implicitWidth: Math.max(50, textitem.width) + tabHSpace + 2 + implicitWidth: Math.max(50, styleitem.textWidth(title)) + tabHSpace + 2 implicitHeight: Math.max(styleitem.font.pixelSize + tabVSpace + 6, 0) StyleItem { @@ -89,7 +90,7 @@ Style { hints: [tabPosition, tabpos, selectedpos] selected: tab.selected - text: title + text: elidedText(title, tabbarItem.elide, width - item.tabHSpace) hover: tab.hover hasFocus: tabbarItem.activeFocus && selected anchors.margins: paintMargins -- GitLab