From 5f4646af29bc4d8b876080ff0e3f18d0ad45c9f9 Mon Sep 17 00:00:00 2001 From: Michael Bohlender Date: Sat, 21 Jan 2017 13:37:25 +0100 Subject: move aacount switcher to the top again --- components/package/contents/ui/AccountSwitcher.qml | 128 +++++++++------------ 1 file changed, 53 insertions(+), 75 deletions(-) (limited to 'components/package/contents') diff --git a/components/package/contents/ui/AccountSwitcher.qml b/components/package/contents/ui/AccountSwitcher.qml index 616286f0..eb5702e0 100644 --- a/components/package/contents/ui/AccountSwitcher.qml +++ b/components/package/contents/ui/AccountSwitcher.qml @@ -1,20 +1,20 @@ /* - Copyright (C) 2016 Michael Bohlender, - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ + * Copyright (C) 2017 Michael Bohlender, + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ import QtQuick 2.4 import QtQuick.Layouts 1.1 @@ -29,7 +29,7 @@ import org.kube.framework.domain 1.0 as KubeFramework import org.kube.framework.accounts 1.0 as KubeAccounts import org.kube.components 1.0 as KubeComponents -Item { +Controls.ToolButton { id: accountSwitcher property variant accountId @@ -37,8 +37,6 @@ Item { width: parent.width - clip: true - KubeFramework.FolderController { id: folderController } @@ -47,76 +45,55 @@ Item { id: accountsModel } - Text { - anchors { - left: parent.left - leftMargin: Kirigami.Units.smallSpacing - bottom: parent.bottom - } - text: accountName - color: Kirigami.Theme.backgroundColor - font.weight: Font.DemiBold + onClicked: { + popup.open() } - MouseArea { - anchors.fill: parent + Controls2.Popup { + id: popup - acceptedButtons: Qt.LeftButton | Qt.RightButton + height: listView.count == 0 ? Kirigami.Units.gridUnit * 4 : Kirigami.Units.gridUnit * 2 + listView.count * Kirigami.Units.gridUnit * 3 + width: Kirigami.Units.gridUnit * 20 - onClicked: { - if (mouse.button == Qt.RightButton) { - contextMenu.popup() - } else { - popup.open() - focus = false - } - } - } + y: accountSwitcher.height - Controls.Menu { - id: contextMenu - title: "Edit" + modal: true + focus: true + closePolicy: Controls2.Popup.CloseOnEscape | Controls2.Popup.CloseOnPressOutsideParent - Controls.MenuItem { - text: "Synchronize" - onTriggered: { - folderController.synchronizeAction.execute() + Item { + id: buttons + anchors { + bottom: parent.bottom } - } - } - Controls2.Popup { - id: popup + height: Kirigami.Units.gridUnit * 2 + width: parent.width - height: listView.count == 0 ? Kirigami.Units.gridUnit * 2 : Kirigami.Units.gridUnit * 2 + listView.count * Kirigami.Units.gridUnit * 3 - width: parent.width + Controls2.Button { - modal: true - focus: true - closePolicy: Controls2.Popup.CloseOnEscape | Controls2.Popup.CloseOnPressOutsideParent + anchors { + left: parent.left + bottom: parent.bottom + } -// Controls2.Button { -// anchors { -// verticalCenter: parent.verticalCenter -// left: parent.left -// } -// -// //iconName: "view-refresh" -// text: "Sync" -// enabled: folderController.synchronizeAction.enabled -// onClicked: { -// folderController.synchronizeAction.execute() -// popup.close() -// } -// } + + //iconName: "view-refresh" + text: "Sync" + enabled: folderController.synchronizeAction.enabled + onClicked: { + folderController.synchronizeAction.execute() + popup.close() + } + } Controls2.Button { id: newAccountButton anchors { - horizontalCenter: parent.horizontalCenter + right: parent.right bottom: parent.bottom } @@ -127,13 +104,14 @@ Item { popup.close() } } + } ListView { id: listView anchors { top: parent.top - bottom: newAccountButton.top + bottom: buttons.top left: parent.left right: parent.right } @@ -187,9 +165,9 @@ Item { accountId: model.accountId } -// Kirigami.Icon { -// source: model.icon -// } + // Kirigami.Icon { + // source: model.icon + // } Controls2.Label { text: model.name -- cgit v1.2.3