From 74703d12ef6f72a057f11957181b6cf6f4730e2d Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 24 Apr 2017 15:34:31 +0200 Subject: Added the Fabric as an in application message bus --- framework/qml/ConversationView.qml | 16 ++++++++++++++++ framework/qml/FolderListView.qml | 16 ++++++++-------- framework/qml/InlineAccountSwitcher.qml | 6 ------ framework/qml/MailListView.qml | 32 +++++++++++++++++++------------- framework/qml/Messages.qml | 31 +++++++++++++++++++++++++++++++ 5 files changed, 74 insertions(+), 27 deletions(-) create mode 100644 framework/qml/Messages.qml (limited to 'framework/qml') diff --git a/framework/qml/ConversationView.qml b/framework/qml/ConversationView.qml index bdcd0aa0..85712a5a 100644 --- a/framework/qml/ConversationView.qml +++ b/framework/qml/ConversationView.qml @@ -37,6 +37,22 @@ Rectangle { property bool hideTrash: true; property bool hideNonTrash: false; + + Kube.Listener { + filter: Kube.Messages.mailSelection + onMessageReceived: { + root.mail = message.mail + } + } + + Kube.Listener { + filter: Kube.Messages.folderSelection + onMessageReceived: { + root.hideTrash = !message.trash + root.hideNonTrash = message.trash + } + } + onCurrentIndexChanged: { markAsReadTimer.restart(); } diff --git a/framework/qml/FolderListView.qml b/framework/qml/FolderListView.qml index 4082e08d..78d3c5d0 100644 --- a/framework/qml/FolderListView.qml +++ b/framework/qml/FolderListView.qml @@ -26,18 +26,18 @@ import org.kube.framework 1.0 as Kube Rectangle { id: root - property variant currentFolder: null property variant accountId - property bool isTrashFolder: false color: Kube.Colors.textColor Kube.FolderController { id: folderController - Binding on folder { - //!! checks for the availability of the type - when: !!root.currentFolder - value: root.currentFolder + } + Kube.Listener { + id: controllerListener + filter: Kube.Messages.folderSelection + onMessageReceived: { + folderController.folder = message.folder } } @@ -64,8 +64,8 @@ Rectangle { onCurrentIndexChanged: { model.fetchMore(currentIndex) - root.currentFolder = model.data(currentIndex, Kube.FolderListModel.DomainObject) - root.isTrashFolder = model.data(currentIndex, Kube.FolderListModel.Trash) + Kube.Fabric.postMessage(Kube.Messages.folderSelection, {"folder":model.data(currentIndex, Kube.FolderListModel.DomainObject), + "trash":model.data(currentIndex, Kube.FolderListModel.Trash)}) folderController.synchronizeAction.execute() console.error(model.data) } diff --git a/framework/qml/InlineAccountSwitcher.qml b/framework/qml/InlineAccountSwitcher.qml index b7e70746..b5b4bb9f 100644 --- a/framework/qml/InlineAccountSwitcher.qml +++ b/framework/qml/InlineAccountSwitcher.qml @@ -24,8 +24,6 @@ Rectangle { id: root property string currentAccount: null - property var currentFolder: null - property bool isTrashFolder: false Kube.AccountsModel { id: accountsModel @@ -109,10 +107,6 @@ Rectangle { accountId: model.accountId visible: model.accountId == root.currentAccount - onCurrentFolderChanged: { - root.currentFolder = currentFolder - root.isTrashFolder = isTrashFolder - } } } } diff --git a/framework/qml/MailListView.qml b/framework/qml/MailListView.qml index 96e266bb..5adc3f98 100644 --- a/framework/qml/MailListView.qml +++ b/framework/qml/MailListView.qml @@ -25,26 +25,25 @@ import org.kube.framework 1.0 as Kube Item { id: root - property variant parentFolder - property variant currentMail: null + //InterfaceProperties + property string filterString + //Private properties + property variant parentFolder: null property bool isDraft : false property bool isImportant : false property bool isTrash : false property bool isUnread : false - property int currentIndex - property string filterString - onParentFolderChanged: { - currentMail = null + Kube.Listener { + filter: Kube.Messages.folderSelection + onMessageReceived: { + parentFolder = message.folder + Kube.Fabric.postMessage(Kube.Messages.mailSelection, {"mail":null}) + } } Kube.MailController { id: mailController - Binding on mail { - //!! checks for the availability of the type - when: !!root.currentMail - value: root.currentMail - } unread: root.isUnread trash: root.isTrash important: root.isImportant @@ -52,6 +51,14 @@ Item { operateOnThreads: mailListModel.isThreaded } + Kube.Listener { + id: controllerListener + filter: Kube.Messages.mailSelection + onMessageReceived: { + mailController.mail = message.mail + } + } + Shortcut { sequence: StandardKey.Delete onActivated: mailController.moveToTrashAction.execute() @@ -93,9 +100,8 @@ Item { } //END keyboard nav - currentIndex: root.currentIndex onCurrentItemChanged: { - root.currentMail = currentItem.currentData.domainObject; + Kube.Fabric.postMessage(Kube.Messages.mailSelection, {"mail":currentItem.currentData.mail}) root.isDraft = currentItem.currentData.draft; root.isTrash = currentItem.currentData.trash; root.isImportant = currentItem.currentData.important; diff --git a/framework/qml/Messages.qml b/framework/qml/Messages.qml new file mode 100644 index 00000000..3241af0b --- /dev/null +++ b/framework/qml/Messages.qml @@ -0,0 +1,31 @@ +/* + 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. +*/ + +pragma Singleton + +import QtQuick 2.7 + +Item { + //Selections + property string folderSelection: "currentFolder" + property string mailSelection: "currentMail" + + //Actions + property string moveToTrash: "moveToTrash" +} + -- cgit v1.2.3