From c545b2e480d29d4a2149ca4cbadd84b6d23542e8 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 26 Jul 2017 10:57:45 -0600 Subject: The account switcher is a control too --- framework/qml/AbstractButton.qml | 10 ++++++++-- framework/qml/InlineAccountSwitcher.qml | 30 ++++++++++-------------------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/framework/qml/AbstractButton.qml b/framework/qml/AbstractButton.qml index 194812da..a964fe2f 100644 --- a/framework/qml/AbstractButton.qml +++ b/framework/qml/AbstractButton.qml @@ -24,6 +24,11 @@ import org.kube.framework 1.0 T.Button { id: root + property color color: Colors.buttonColor + property color textColor: Colors.textColor + property alias horizontalAlignment: label.horizontalAlignment + property alias verticalAlignment: label.verticalAlignment + width: Math.max(Units.gridUnit, contentItem.implicitWidth + leftPadding + rightPadding) height: contentItem.implicitHeight + topPadding + bottomPadding @@ -35,8 +40,7 @@ T.Button { hoverEnabled: true Keys.onReturnPressed: root.clicked() - property color color: Colors.buttonColor - property color textColor: Colors.textColor + font.family: Kube.Font.fontFamily background: Rectangle { color: root.color @@ -64,10 +68,12 @@ T.Button { } contentItem: Label { + id: label text: root.text elide: Text.ElideRight horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter color: root.textColor + font: root.font } } diff --git a/framework/qml/InlineAccountSwitcher.qml b/framework/qml/InlineAccountSwitcher.qml index 67d88637..ae1d0dc7 100644 --- a/framework/qml/InlineAccountSwitcher.qml +++ b/framework/qml/InlineAccountSwitcher.qml @@ -55,32 +55,22 @@ FocusScope { height: Kube.Units.gridUnit Layout.fillHeight: isCurrent - Rectangle { + Kube.TextButton { id: accountLabel - + anchors.top: parent.top + anchors.left: parent.left height: Kube.Units.gridUnit width: parent.width - color: Kube.Colors.textColor + textColor: Kube.Colors.highlightedTextColor activeFocusOnTab: !isCurrent - Keys.onReturnPressed: { - root.currentAccount = model.accountId - } + onClicked: root.currentAccount = model.accountId + text: model.name + font.weight: Font.Bold + font.family: Kube.Font.fontFamily + horizontalAlignment: Text.AlignHLeft + padding: 0 - MouseArea { - anchors.fill: parent - onClicked: { - root.currentAccount = model.accountId - } - } - - Kube.Label{ - anchors.verticalCenter: parent.verticalCenter - text: model.name - font.weight: Font.Bold - color: Kube.Colors.highlightedTextColor - font.underline: accountLabel.activeFocus - } } Kube.FolderListView { -- cgit v1.2.3