Warning, /utilities/qrca/src/contents/ui/ShareSheet.qml is written in an unsupported language. File is not indexed.

0001 /***************************************************************************
0002  *                                                                         *
0003  *   SPDX-FileCopyrightText: 2019 Nicolas Fella <nicolas.fella@gmx.de>                   *
0004  *                                                                         *
0005  *   SPDX-License-Identifier: GPL-2.0-or-later
0006  *                                                                         *
0007  ***************************************************************************/
0008 
0009 import QtQuick.Controls 2.1 as Controls
0010 import QtQuick.Layouts 1.7
0011 import QtQuick 2.7
0012 
0013 import org.kde.kirigami 2.5 as Kirigami
0014 import org.kde.purpose 1.0 as Purpose
0015 import org.kde.qrca 1.0
0016 
0017 Kirigami.OverlaySheet {
0018     id: inputSheet
0019 
0020     property var url
0021     property bool running: false
0022     property bool errorOccured: false
0023 
0024     leftPadding: 0
0025     rightPadding: 0
0026 
0027     header: Kirigami.Heading {
0028         text: i18n("Share Qr-Code")
0029         leftPadding: Kirigami.Units.largeSpacing
0030     }
0031 
0032     Purpose.AlternativesView {
0033         id: view
0034         clip: true
0035         pluginType: "Export"
0036         implicitWidth: Kirigami.Units.gridUnit * 20
0037         implicitHeight: Kirigami.Units.gridUnit * 10
0038 
0039         delegate: Controls.ItemDelegate {
0040             text: model.display
0041             icon.name: model.iconName
0042             width: ListView.view.width
0043             onClicked: view.createJob(model.index)
0044             Keys.onReturnPressed: view.createJob(model.index)
0045             Keys.onEnterPressed: view.createJob(model.index)
0046         }
0047 
0048         Controls.BusyIndicator {
0049             visible: inputSheet.running
0050             anchors.fill: parent
0051         }
0052 
0053         Kirigami.Heading {
0054             anchors.centerIn: parent
0055             width: parent.width - Kirigami.Units.gridUnit * 2
0056             text: i18n("Sharing Failed")
0057             horizontalAlignment: Text.AlignHCenter
0058             visible: errorOccured
0059         }
0060 
0061         onRunningChanged: inputSheet.running = running
0062         onFinished: {
0063             if (error === 0 && output.url && output.url.length !== 0) {
0064                 // no error, display notification
0065                 const resultUrl = output.url;
0066                 NotificationManager.showNotification(resultUrl);
0067                 Clipboard.content = resultUrl;
0068             }
0069             if (error === 0) {
0070                 inputSheet.close();
0071                 return;
0072             }
0073             errorOccured = true;
0074         }
0075     }
0076 
0077     onVisibleChanged: {
0078         errorOccured = false;
0079         if (visible) {
0080             view.inputData = {
0081                 "urls": [inputSheet.url.toString()],
0082                 "title": i18n("Share QR-Code"),
0083                 "mimeType": "image"
0084             }
0085         } else {
0086             view.reset()
0087         }
0088     }
0089 }
0090