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 --- framework/qml/FolderListView.qml | 30 +------- framework/qml/InlineAccountSwitcher.qml | 120 ++++++++++++++++++++++++++++++++ framework/qmldir | 2 +- 3 files changed, 124 insertions(+), 28 deletions(-) create mode 100644 framework/qml/InlineAccountSwitcher.qml (limited to 'framework') 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