diff --git a/qmlUiKirigami/ImageViewer.qml b/qmlUiKirigami/ImageViewer.qml --- a/qmlUiKirigami/ImageViewer.qml +++ b/qmlUiKirigami/ImageViewer.qml @@ -39,6 +39,33 @@ leftPadding: 0 rightPadding: 0 + + KQA.MimeDatabase { + id: mimeDB + } + + actions { + main: Kirigami.Action { + iconName: "document-share" + tooltip: i18n("Share Image") + onTriggered: { + shareDialog.visible = true + shareDialog.inputData = { + "urls": listView.currentItem.currentImageSource, + "mimeType": mimeDB.mimeTypeForUrl( listView.currentItem.currentImageSource).name + } + } + } + left: Kirigami.Action { + iconName: "view-close" + tooltip: i18n("Close Image") + onTriggered: root.state = "closed" + } + right: Kirigami.Action { + iconName: "editimage" + tooltip: i18n("Edit Image") + } + } states: [ State { @@ -63,6 +90,10 @@ target: applicationWindow() visibility: Window.Windowed } + PropertyChanges { + target: shareDialog + visible: false + } }, State { name: "closed" @@ -74,6 +105,10 @@ target: root visible: false } + PropertyChanges { + target: shareDialog + visible: false + } }, State { name: "fullscreen" @@ -86,6 +121,10 @@ focus: true } PropertyChanges { + target: shareDialog + visible: false + } + PropertyChanges { target: applicationWindow() visibility: Window.FullScreen } @@ -169,6 +208,7 @@ delegate: Flickable { id: flick + property alias currentImageSource: image.source width: imageWidth height: imageHeight contentWidth: imageWidth @@ -355,10 +395,17 @@ } } } - - //FIXME: placeholder, will have to use the state machine - Controls.Button { - text: i18n("Back") - onClicked: root.state = "closed" + + ShareDialog { + id: shareDialog + visible: false + inputData: { urls: [] } + onFinished: { + if (error==0 && output.url !== "") { + console.assert(output.url !== undefined); + var resultUrl = output.url; + console.log("Received", resultUrl) + } + } } } diff --git a/qmlUiKirigami/ShareDialog.qml b/qmlUiKirigami/ShareDialog.qml new file mode 100644 --- /dev/null +++ b/qmlUiKirigami/ShareDialog.qml @@ -0,0 +1,67 @@ +/* + * Copyright 2017 by Atul Sharma + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2, 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 Library General Public License for more details + * + * You should have received a copy of the GNU Library 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.7 +import QtQuick.Layouts 1.0 +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.purpose 1.0 as Purpose +import org.kde.kirigami 2.1 as Kirigami + +PlasmaCore.Dialog +{ + id: window + property var inputData + property bool running: false + signal finished(var output, int error, string message) + + hideOnWindowDeactivate: true + mainItem: ColumnLayout { + height: units.gridUnit * 16 + width: units.gridUnit * 16 + + Kirigami.Heading { + text: window.inputData.mimeType ? i18n("Shares for '%1'", window.inputData.mimeType) : "" + } + Purpose.AlternativesView { + id: view + Layout.fillWidth: true + Layout.fillHeight: true + inputData: window.inputData + pluginType: "Export" + onVisibleChanged: { + if (visible) { + view.reset(); + } + } + + delegate: Kirigami.BasicListItem { + label: model.display + icon: "arrow-right" + onClicked: view.createJob (model.index) + Keys.onReturnPressed: view.createJob (model.index) + Keys.onEnterPressed: view.createJob (model.index) + } + + onRunningChanged: window.running = running + onFinished: { + window.finished(output, error, message) + } + } + } +}