From c685ac89abed2b1cb61c63f361f414d6f9852cb9 Mon Sep 17 00:00:00 2001 From: Michael Bohlender Date: Wed, 16 Nov 2016 19:17:33 +0100 Subject: port composer to qqc2 popup --- components/mail/contents/ui/main.qml | 76 ++++--- components/package/contents/ui/Composer.qml | 243 ---------------------- components/package/contents/ui/FocusComposer.qml | 254 ++++++++++++++++++++--- 3 files changed, 270 insertions(+), 303 deletions(-) delete mode 100644 components/package/contents/ui/Composer.qml (limited to 'components') diff --git a/components/mail/contents/ui/main.qml b/components/mail/contents/ui/main.qml index c891ea5f..c4340465 100644 --- a/components/mail/contents/ui/main.qml +++ b/components/mail/contents/ui/main.qml @@ -86,6 +86,35 @@ Controls2.ApplicationWindow { } //END Actions + //BEGIN ActionHandler + + //TODO + /* + KubeAction.ActionHandler { + actionId: "org.kde.kube.actions.reply" + function isReady(context) { + return context.mail ? true : false; + } + + function handler(context) { + var component = composerComponent.createObject(app) + component.loadMessage(context.mail, false) + } + } + + KubeAction.ActionHandler { + actionId: "org.kde.kube.actions.edit" + function isReady(context) { + return context.mail && context.isDraft; + } + function handler(context) { + var component= composerComponent.createObject(app, {"draftMessage": context.mail}) + component.loadMessage(context.mail, true) + } + } + */ + //END ActionHandler + //BEGIN Shortcuts Shortcut { sequence: StandardKey.Refresh @@ -218,38 +247,6 @@ Controls2.ApplicationWindow { height: parent.height width: mailView.width - Component { - id: composerComponent - - KubeComponents.FocusComposer { - id: composer - anchors.fill: parent - } - } - - KubeAction.ActionHandler { - actionId: "org.kde.kube.actions.reply" - function isReady(context) { - return context.mail ? true : false; - } - - function handler(context) { - var component = composerComponent.createObject(app) - component.loadMessage(context.mail, false) - } - } - - KubeAction.ActionHandler { - actionId: "org.kde.kube.actions.edit" - function isReady(context) { - return context.mail && context.isDraft; - } - function handler(context) { - var component= composerComponent.createObject(app, {"draftMessage": context.mail}) - component.loadMessage(context.mail, true) - } - } - Button { id: newMailButton @@ -257,7 +254,7 @@ Controls2.ApplicationWindow { text: "New Email" tooltip: "compose new email" onClicked: { - composerComponent.createObject(app) + composer.open() } } @@ -305,4 +302,17 @@ Controls2.ApplicationWindow { } } //END ToolBar + + //BEGIN Composer + KubeComponents.FocusComposer { + id: composer + + height: app.height * 0.85 + width: app.width * 0.85 + + x: app.width * 0.075 + y: toolbar.y + toolbar.height + } + //END Composer + } diff --git a/components/package/contents/ui/Composer.qml b/components/package/contents/ui/Composer.qml deleted file mode 100644 index ebc414f7..00000000 --- a/components/package/contents/ui/Composer.qml +++ /dev/null @@ -1,243 +0,0 @@ -/* - 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. -*/ - -import QtQuick 2.4 -import QtQuick.Controls 1.4 -import QtQuick.Layouts 1.1 -import QtQuick.Dialogs 1.0 - -import org.kde.kirigami 1.0 as Kirigami - -import org.kube.framework.domain 1.0 as KubeFramework - - -Item { - id: root - - function loadMessage(message, loadAsDraft) { - composer.loadMessage(message, loadAsDraft) - } - - function send() { - composer.send() - } - - function saveAsDraft() { - composer.saveAsDraft() - } - - function clear() { - composer.clear(); - } - - KubeFramework.ComposerController { - id: composer - } - - ColumnLayout { - - anchors.fill: parent - - TextField { - id: subject - - Layout.fillWidth: true - - placeholderText: "Enter Subject..." - - text: composer.subject - - onTextChanged: { - composer.subject = text; - } - } - - GridLayout { - - columns: 2 - - Kirigami.Label { - text: "To" - } - - RowLayout { - Layout.fillWidth: true - - TextField { - id: to - - Layout.fillWidth: true - - text: composer.to - - onTextChanged: { - composer.to = text; - } - } - } - - Kirigami.Label { - text: "Cc" - - visible: cc.visible - } - - TextField { - id: cc - - Layout.fillWidth: true - - visible: false - - text: composer.cc - - onTextChanged: { - composer.cc = text; - } - } - - Kirigami.Label { - text: "Bcc" - - visible: bcc.visible - } - - TextField { - id: bcc - - Layout.fillWidth: true - - visible : false - - text: composer.bcc - - onTextChanged: { - composer.bcc = text; - } - } - } - - RowLayout { - Kirigami.Label { - text: "Sending as" - } - - ComboBox { - id: identityCombo - model: composer.identityModel - textRole: "displayName" - - Layout.fillWidth: true - - onCurrentIndexChanged: { - composer.currentIdentityIndex = currentIndex - } - } - - Button { - id: ccButton - - text: "Cc" - - onClicked: { - cc.visible = true - ccButton.visible = false - } - } - - Button { - id: bccButton - - text: "Bcc" - - onClicked: { - bcc.visible = true - bccButton.visible = false - } - } - } - - Item { - - Layout.fillWidth: true - - height: subject.height * 1.5 - - Button { - - anchors { - bottom: parent.bottom - right: parent.right - } - - text: "Attach" - - onClicked: { - fileDialog.open(); - } - } - } - - RowLayout { - - Layout.fillWidth: true - - Repeater { - - model: composer.attachments - - delegate: Kirigami.Label { - id: name - - text: modelData - - Rectangle { - - anchors.fill: parent - - color: "lightsteelblue" - } - } - } - } - - TextArea { - id: content - - text: composer.body - - onTextChanged: { - composer.body = text; - } - - Layout.fillWidth: true - Layout.fillHeight: true - } - } - - FileDialog { - id: fileDialog - - title: "Please choose a file" - - onAccepted: { - console.log("You chose: " + fileDialog.fileUrl) - composer.addAttachment(fileDialog.fileUrl); - } - } -} diff --git a/components/package/contents/ui/FocusComposer.qml b/components/package/contents/ui/FocusComposer.qml index 9129dba9..c22983f5 100644 --- a/components/package/contents/ui/FocusComposer.qml +++ b/components/package/contents/ui/FocusComposer.qml @@ -17,25 +17,48 @@ */ import QtQuick 2.4 -import QtQuick.Controls 1.4 import QtQuick.Layouts 1.1 +import QtQuick.Controls 1.4 as Controls +import QtQuick.Controls 2.0 as Controls2 import org.kde.kirigami 1.0 as Kirigami -import org.kube.components 1.0 as KubeComponents +import org.kube.framework.domain 1.0 as KubeFramework -KubeComponents.OverlayDialog { +Controls2.Popup { id: root + //Controler + KubeFramework.ComposerController { + id: composer + } + + //BEGIN functions function loadMessage(message, loadAsDraft) { - composer.loadMessage(message, loadAsDraft); + composer.loadMessage(message, loadAsDraft) + } + + function send() { + composer.send() + } + + function saveAsDraft() { + composer.saveAsDraft() } + function clear() { + composer.clear(); + } + //END functions + + modal: true + focus: true + closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent + Item { - anchors.centerIn: parent - height: root.height * 0.8 - width: root.width * 0.8 + height: parent.height + width: parent.width ColumnLayout { @@ -44,45 +67,222 @@ KubeComponents.OverlayDialog { margins: Kirigami.Units.largeSpacing } - Composer { - id: composer + ColumnLayout { - Layout.fillWidth: true - Layout.fillHeight: true - } + anchors.fill: parent + + Controls.TextField { + id: subject - RowLayout { + Layout.fillWidth: true - Button { + placeholderText: "Enter Subject..." - text: "Discard" + text: composer.subject - onClicked: { - root.destroy() + onTextChanged: { + composer.subject = text; + } + } + + GridLayout { + + columns: 2 + + Kirigami.Label { + text: "To" + } + + RowLayout { + Layout.fillWidth: true + + Controls.TextField { + id: to + + Layout.fillWidth: true + + text: composer.to + + onTextChanged: { + composer.to = text; + } + } + } + + Kirigami.Label { + text: "Cc" + + visible: cc.visible + } + + Controls.TextField { + id: cc + + Layout.fillWidth: true + + visible: false + + text: composer.cc + + onTextChanged: { + composer.cc = text; + } + } + + Kirigami.Label { + text: "Bcc" + + visible: bcc.visible + } + + Controls.TextField { + id: bcc + + Layout.fillWidth: true + + visible : false + + text: composer.bcc + + onTextChanged: { + composer.bcc = text; + } + } + } + + RowLayout { + Kirigami.Label { + text: "Sending as" + } + + Controls.ComboBox { + id: identityCombo + model: composer.identityModel + textRole: "displayName" + + Layout.fillWidth: true + + onCurrentIndexChanged: { + composer.currentIdentityIndex = currentIndex + } + } + + Controls.Button { + id: ccButton + + text: "Cc" + + onClicked: { + cc.visible = true + ccButton.visible = false + } + } + + Controls.Button { + id: bccButton + + text: "Bcc" + + onClicked: { + bcc.visible = true + bccButton.visible = false + } } } Item { + Layout.fillWidth: true + + height: subject.height * 1.5 + + Controls.Button { + + anchors { + bottom: parent.bottom + right: parent.right + } + + text: "Attach" + + onClicked: { + fileDialog.open(); + } + } } + RowLayout { + + Layout.fillWidth: true + + Repeater { + + model: composer.attachments - Button { + delegate: Kirigami.Label { + id: name - text: "Save as Draft" + text: modelData - onClicked: { - composer.saveAsDraft() - root.destroy() + Rectangle { + + anchors.fill: parent + + color: "lightsteelblue" + } + } } } - Button { - text: "Send" + Controls.TextArea { + id: content + + text: composer.body + + onTextChanged: { + composer.body = text; + } + + Layout.fillWidth: true + Layout.fillHeight: true + } + + RowLayout { + id: bottomBar + + width: parent.width + + Controls.Button { + + text: "Discard" + + onClicked: { + root.close() + } + } + + Item { + Layout.fillWidth: true + } + + + Controls.Button { + + text: "Save as Draft" + + onClicked: { + saveAsDraft() + root.close() + } + } + + Controls.Button { + text: "Send" - onClicked: { - composer.send() - root.destroy() + onClicked: { + send() + root.close() + } } } } -- cgit v1.2.3