From 757258042f1b41fe1ea1b4c77994173ac11e2e5c Mon Sep 17 00:00:00 2001 From: Michael Bohlender Date: Thu, 19 Jan 2017 20:05:22 +0100 Subject: some account switcher changes. needs visual brushup --- components/mail/contents/ui/main.qml | 25 +++-- components/package/contents/ui/AccountSwitcher.qml | 116 +++++++++++++-------- 2 files changed, 88 insertions(+), 53 deletions(-) (limited to 'components') diff --git a/components/mail/contents/ui/main.qml b/components/mail/contents/ui/main.qml index c79a656b..8190d59b 100644 --- a/components/mail/contents/ui/main.qml +++ b/components/mail/contents/ui/main.qml @@ -185,13 +185,25 @@ Controls2.ApplicationWindow { } } + KubeComponents.AccountSwitcher { + id: accountSwitcher + + anchors { + top: newMailButton.bottom + topMargin: Kirigami.Units.smallSpacing + } + + width: parent.width + height: Kirigami.Units.gridUnit * 2 + } + KubeComponents.FolderListView { id: folderListView anchors { - top: newMailButton.bottom + top: accountSwitcher.bottom topMargin: Kirigami.Units.smallSpacing - bottom: accountSwitcher.top + bottom: parent.bottom left: parent.left right: parent.right } @@ -199,15 +211,6 @@ Controls2.ApplicationWindow { focus: true accountId: accountSwitcher.accountId } - - KubeComponents.AccountSwitcher { - id: accountSwitcher - - anchors.bottom: parent.bottom - - width: parent.width - height: Kirigami.Units.gridUnit * 2 - } } KubeComponents.MailListView { diff --git a/components/package/contents/ui/AccountSwitcher.qml b/components/package/contents/ui/AccountSwitcher.qml index 6d1c0aa2..616286f0 100644 --- a/components/package/contents/ui/AccountSwitcher.qml +++ b/components/package/contents/ui/AccountSwitcher.qml @@ -29,53 +29,95 @@ 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 -Controls2.Button { +Item { id: accountSwitcher property variant accountId + property variant accountName + + width: parent.width + + clip: true KubeFramework.FolderController { id: folderController } - text: "Accounts" + KubeAccounts.AccountsModel { + id: accountsModel + } + + Text { + anchors { + left: parent.left + leftMargin: Kirigami.Units.smallSpacing + bottom: parent.bottom + } - onClicked: { - popup.open() - focus = false + text: accountName + color: Kirigami.Theme.backgroundColor + font.weight: Font.DemiBold + } + + MouseArea { + anchors.fill: parent + + acceptedButtons: Qt.LeftButton | Qt.RightButton + + onClicked: { + if (mouse.button == Qt.RightButton) { + contextMenu.popup() + } else { + popup.open() + focus = false + } + } + } + + Controls.Menu { + id: contextMenu + title: "Edit" + + Controls.MenuItem { + text: "Synchronize" + onTriggered: { + folderController.synchronizeAction.execute() + } + } } Controls2.Popup { id: popup - height: 300 - width: 600 - - x: 0 - y: - popup.height + height: listView.count == 0 ? Kirigami.Units.gridUnit * 2 : Kirigami.Units.gridUnit * 2 + listView.count * Kirigami.Units.gridUnit * 3 + width: parent.width modal: true focus: true closePolicy: Controls2.Popup.CloseOnEscape | Controls2.Popup.CloseOnPressOutsideParent - Item { - id: footer - anchors { - bottom: parent.bottom - left: parent.left - right: parent.right - margins: Kirigami.Units.largeSpacing - } - - height: Kirigami.Units.gridUnit + Kirigami.Units.smallSpacing * 1 - width: listView.width +// Controls2.Button { +// anchors { +// verticalCenter: parent.verticalCenter +// left: parent.left +// } +// +// //iconName: "view-refresh" +// text: "Sync" +// enabled: folderController.synchronizeAction.enabled +// onClicked: { +// folderController.synchronizeAction.execute() +// popup.close() +// } +// } Controls2.Button { + id: newAccountButton anchors { - verticalCenter: parent.verticalCenter - right: parent.right + horizontalCenter: parent.horizontalCenter + bottom: parent.bottom } text: "Create new Account" @@ -86,36 +128,19 @@ Controls2.Button { } } - Controls2.Button { - anchors { - verticalCenter: parent.verticalCenter - left: parent.left - } - - //iconName: "view-refresh" - text: "Sync" - enabled: folderController.synchronizeAction.enabled - onClicked: { - folderController.synchronizeAction.execute() - popup.close() - } - } - } - ListView { id: listView anchors { top: parent.top - bottom: footer.top + bottom: newAccountButton.top left: parent.left right: parent.right - margins: Kirigami.Units.smallSpacing } clip: true - model: KubeAccounts.AccountsModel { } + model: accountsModel delegate: Kirigami.AbstractListItem { id: accountDelegate @@ -141,6 +166,13 @@ Controls2.Button { value: model.accountId } + QtQml.Binding { + target: accountSwitcher + property: "accountName" + when: listView.currentIndex == index + value: model.name + } + RowLayout { anchors { verticalCenter: parent.verticalCenter -- cgit v1.2.3