From 1f0bc11f4fe1fb96d25f88fc01c7300e700a82b8 Mon Sep 17 00:00:00 2001 From: Michael Bohlender Date: Fri, 21 Apr 2017 13:05:40 +0200 Subject: initial inline account switcher --- components/kube/contents/ui/Kube.qml | 205 ++++++++------------------------ framework/qml/FolderListView.qml | 30 +---- framework/qml/InlineAccountSwitcher.qml | 120 +++++++++++++++++++ framework/qmldir | 2 +- 4 files changed, 171 insertions(+), 186 deletions(-) create mode 100644 framework/qml/InlineAccountSwitcher.qml diff --git a/components/kube/contents/ui/Kube.qml b/components/kube/contents/ui/Kube.qml index ab80d188..2dbc58b0 100644 --- a/components/kube/contents/ui/Kube.qml +++ b/components/kube/contents/ui/Kube.qml @@ -101,7 +101,7 @@ Controls2.ApplicationWindow { //Model Kube.AccountsModel { id: currentAccountModel - accountId: accountSwitcher.accountId + accountId: accountFolderview.accountId } //BEGIN Shortcuts @@ -204,172 +204,61 @@ Controls2.ApplicationWindow { } } - Item { - id: accountName - - Kube.FolderController { - id: accountNameFolderController - accountId: accountSwitcher.accountId - } - - Menu { - id: contextMenu - title: "Edit" - - MenuItem { - text: "Synchronize" - onTriggered: { - accountNameFolderController.synchronizeAction.execute() - } - } - } + Kube.InlineAccountSwitcher { + id: accountFolderview anchors { top: newMailButton.bottom - topMargin: Kube.Units.smallSpacing - left: parent.left - leftMargin: Kube.Units.largeSpacing - } - - width: parent.width - height: Kube.Units.gridUnit * 2 - - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.RightButton - onClicked: { - contextMenu.popup() - } - } - - Repeater { - model: currentAccountModel - Row { - spacing: Kube.Units.smallSpacing - anchors { - bottom: parent.bottom - left: parent.left - leftMargin: Kube.Units.smallSpacing - } - Layout.fillHeight: true - - Kube.Label{ - text: model.name - font.weight: Font.Bold - color: Kube.Colors.highlightedTextColor - } - - Kube.Icon { - id: statusIcon - visible: false - iconName: "" - states: [ - State { - name: "busy"; when: model.status == Kube.AccountsModel.BusyStatus - PropertyChanges { target: statusIcon; iconName: Kube.Icons.busy_inverted; visible: true } - }, - State { - name: "error"; when: model.status == Kube.AccountsModel.ErrorStatus - PropertyChanges { target: statusIcon; iconName: Kube.Icons.error_inverted; visible: true } - }, - State { - name: "checkmark"; when: model.status == Kube.AccountsModel.ConnectedStatus - PropertyChanges { target: statusIcon; iconName: Kube.Icons.connected_inverted; visible: true } - }, - State { - name: "disconnected"; when: model.status == Kube.AccountsModel.OfflineStatus - PropertyChanges { target: statusIcon; iconName: Kube.Icons.noNetworkConnection_inverted; visible: true } - } - ] - } - } - } - } - - Kube.FolderListView { - id: folderListView - - anchors { - top: accountName.bottom - topMargin: Kube.Units.smallSpacing - bottom: statusBar.top - left: parent.left - right: parent.right - leftMargin: Kube.Units.largeSpacing - } - - focus: true - accountId: accountSwitcher.accountId - } - - Item { - id: statusBar - anchors { - topMargin: Kube.Units.smallSpacing - bottom: outbox.top - left: parent.left - right: parent.right - } - - height: Kube.Units.gridUnit - - Repeater { - model: currentAccountModel - Kube.Label { - id: statusText - anchors.centerIn: parent - visible: false - color: Kube.Colors.highlightedTextColor - states: [ - State { - name: "disconnected"; when: model.status == Kube.AccountsModel.OfflineStatus - PropertyChanges { target: statusText; text: "Offline"; visible: true } - } - ] - } - } - } - - Kube.Outbox { - id: outbox - - anchors { - bottom: toolBar.top - left: parent.left - right: parent.right - } - height: Kube.Units.gridUnit * 1.5 - } - - - Item { - id: toolBar - - anchors { + topMargin: Kube.Units.largeSpacing bottom: parent.bottom - left: parent.left + left: newMailButton.left right: parent.right } - height: Kube.Units.gridUnit * 2 - - RowLayout { - anchors.centerIn: parent - - spacing: Kube.Units.largeSpacing - - Kube.AccountSwitcher { - id: accountSwitcher - iconName: Kube.Icons.menu_inverted - height: Kube.Units.gridUnit * 1.5 - width: height - } - } } } +//TODO bring back status bar and outbox +// Item { +// id: statusBar +// anchors { +// topMargin: Kube.Units.smallSpacing +// bottom: outbox.top +// left: parent.left +// right: parent.right +// } +// +// height: Kube.Units.gridUnit +// +// Repeater { +// model: currentAccountModel +// Kube.Label { +// id: statusText +// anchors.centerIn: parent +// visible: false +// color: Kube.Colors.highlightedTextColor +// states: [ +// State { +// name: "disconnected"; when: model.status == Kube.AccountsModel.OfflineStatus +// PropertyChanges { target: statusText; text: "Offline"; visible: true } +// } +// ] +// } +// } +// } +// +// Kube.Outbox { +// id: outbox +// +// anchors { +// bottom: toolBar.top +// left: parent.left +// right: parent.right +// } +// height: Kube.Units.gridUnit * 1.5 +// } Kube.MailListView { id: mailListView - parentFolder: folderListView.currentFolder + parentFolder: accountFolderview.currentFolder width: Kube.Units.gridUnit * 20 height: parent.height Layout.maximumWidth: app.width * 0.4 @@ -381,8 +270,8 @@ Controls2.ApplicationWindow { id: mailView mail: mailListView.currentMail Layout.fillWidth: true - hideTrash: !folderListView.isTrashFolder - hideNonTrash: folderListView.isTrashFolder + hideTrash: !accountFolderview.isTrashFolder + hideNonTrash: accountFolderview.isTrashFolder } } } diff --git a/framework/qml/FolderListView.qml b/framework/qml/FolderListView.qml index 11e29662..4082e08d 100644 --- a/framework/qml/FolderListView.qml +++ b/framework/qml/FolderListView.qml @@ -21,7 +21,6 @@ import QtQuick.Controls 1.4 import QtQuick.Controls.Styles 1.4 import QtQuick.Layouts 1.1 -import org.kde.kirigami 1.0 as Kirigami import org.kube.framework 1.0 as Kube Rectangle { @@ -42,18 +41,6 @@ Rectangle { } } - Menu { - id: contextMenu - title: "Edit" - - MenuItem { - text: "Synchronize" - onTriggered: { - folderController.synchronizeAction.execute() - } - } - } - TreeView { id: treeView @@ -80,29 +67,18 @@ Rectangle { root.currentFolder = model.data(currentIndex, Kube.FolderListModel.DomainObject) root.isTrashFolder = model.data(currentIndex, Kube.FolderListModel.Trash) folderController.synchronizeAction.execute() + console.error(model.data) } alternatingRowColors: false headerVisible: false - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.RightButton - onClicked: { - var index = parent.indexAt(mouse.x, mouse.y) - if (index.valid) { - folderController.folder = treeView.model.data(index, Kube.FolderListModel.DomainObject) - contextMenu.popup() - } - } - } - style: TreeViewStyle { rowDelegate: Rectangle { color: styleData.selected ? Kube.Colors.highlightColor : Kube.Colors.textColor - height: Kirigami.Units.gridUnit * 1.5 + height: Kube.Units.gridUnit * 1.5 width: 20 } @@ -157,7 +133,7 @@ Rectangle { Kube.Label { anchors { verticalCenter: parent.verticalCenter - leftMargin: Kirigami.Units.smallSpacing + leftMargin: Kube.Units.smallSpacing } text: styleData.value diff --git a/framework/qml/InlineAccountSwitcher.qml b/framework/qml/InlineAccountSwitcher.qml new file mode 100644 index 00000000..b7e70746 --- /dev/null +++ b/framework/qml/InlineAccountSwitcher.qml @@ -0,0 +1,120 @@ +/* + * 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 +import org.kube.framework 1.0 as Kube + +Rectangle { + id: root + + property string currentAccount: null + property var currentFolder: null + property bool isTrashFolder: false + + Kube.AccountsModel { + id: accountsModel + } + + color: Kube.Colors.textColor + + ColumnLayout { + anchors.fill: parent + + Repeater { + model: accountsModel + + delegate: Item { + id: accountDelagte + + height: Kube.Units.gridUnit + width: root.width + Layout.fillHeight: model.accountId == root.currentAccount + + Rectangle { + id: accountLabel + + height: Kube.Units.gridUnit + width: parent.width + + color: Kube.Colors.textColor + + MouseArea { + anchors.fill: parent + onClicked: { + root.currentAccount = model.accountId + } + } + + Row { + spacing: Kube.Units.smallSpacing + anchors.verticalCenter: parent.verticalCenter + Layout.fillHeight: true + + Kube.Label{ + text: model.name + font.weight: Font.Bold + color: Kube.Colors.highlightedTextColor + } + + Kube.Icon { + id: statusIcon + visible: false + iconName: "" + states: [ + State { + name: "busy"; when: model.status == Kube.AccountsModel.BusyStatus + PropertyChanges { target: statusIcon; iconName: Kube.Icons.busy_inverted; visible: true } + }, + State { + name: "error"; when: model.status == Kube.AccountsModel.ErrorStatus + PropertyChanges { target: statusIcon; iconName: Kube.Icons.error_inverted; visible: true } + }, + State { + name: "checkmark"; when: model.status == Kube.AccountsModel.ConnectedStatus + PropertyChanges { target: statusIcon; iconName: Kube.Icons.connected_inverted; visible: true } + }, + State { + name: "disconnected"; when: model.status == Kube.AccountsModel.OfflineStatus + PropertyChanges { target: statusIcon; iconName: Kube.Icons.noNetworkConnection_inverted; visible: true } + } + ] + } + } + } + + Kube.FolderListView { + anchors { + top: accountLabel.bottom + left: parent.left + right: parent.right + bottom: parent.bottom + } + + accountId: model.accountId + visible: model.accountId == root.currentAccount + + onCurrentFolderChanged: { + root.currentFolder = currentFolder + root.isTrashFolder = isTrashFolder + } + } + } + } + } +} diff --git a/framework/qmldir b/framework/qmldir index 1cc25b18..35d1cb62 100644 --- a/framework/qmldir +++ b/framework/qmldir @@ -6,6 +6,7 @@ ConversationView 1.0 ConversationView.qml FolderListView 1.0 FolderListView.qml MailListView 1.0 MailListView.qml AccountSwitcher 1.0 AccountSwitcher.qml +InlineAccountSwitcher 1.0 InlineAccountSwitcher.qml NewAccountDialog 1.0 NewAccountDialog.qml EditAccountDialog 1.0 EditAccountDialog.qml OverlayDialog 1.0 OverlayDialog.qml @@ -24,5 +25,4 @@ singleton Icons 1.0 Icons.qml singleton Units 1.0 Units.qml singleton Font 1.0 Font.qml - plugin frameworkplugin -- cgit v1.2.3