Warning, /network/neochat/src/qml/ShareDialog.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  * SPDX-FileCopyrightText: 2017 Atul Sharma <atulsharma406@gmail.com>
0003  * SPDX-FileCopyrightText: 2021 Carl Schwan <carl@carlschwan.eu>
0004  *
0005  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0006  */
0007 
0008 import QtQuick
0009 import QtQuick.Layouts
0010 import QtQuick.Controls as QQC2
0011 import org.kde.purpose as Purpose
0012 import org.kde.notification
0013 import org.kde.kirigami as Kirigami
0014 
0015 Kirigami.Page {
0016     id: root
0017 
0018     leftPadding: 0
0019     rightPadding: 0
0020     topPadding: 0
0021     bottomPadding: 0
0022 
0023     property alias index: jobView.index
0024     property alias model: jobView.model
0025 
0026     QQC2.Action {
0027         shortcut: 'Escape'
0028         onTriggered: root.closeDialog()
0029     }
0030 
0031     Notification {
0032         id: sharingFailed
0033         eventId: "sharingFailed"
0034         text: i18n("Sharing failed")
0035         urgency: Notification.NormalUrgency
0036     }
0037 
0038     Notification {
0039         id: sharingSuccess
0040         eventId: "sharingSuccess"
0041         flags: Notification.Persistent
0042     }
0043 
0044     Component.onCompleted: jobView.start()
0045 
0046     contentItem: Purpose.JobView {
0047         id: jobView
0048         onStateChanged: {
0049             if (state === Purpose.PurposeJobController.Finished) {
0050                 if (jobView.job.output.url !== "") {
0051                     // Show share url
0052                     // TODO no needed anymore in purpose > 5.90
0053                     sharingSuccess.text = i18n("Shared url for image is <a href='%1'>%1</a>", jobView.output.url);
0054                     sharingSuccess.sendEvent();
0055                     Clipboard.saveText(jobView.output.url);
0056                 }
0057                 root.closeDialog();
0058             } else if (state === Purpose.PurposeJobController.Error) {
0059                 // Show failure notification
0060                 sharingFailed.sendEvent();
0061                 root.closeDialog();
0062             } else if (state === Purpose.PurposeJobController.Cancelled) {
0063                 // Do nothing
0064                 root.closeDialog();
0065             }
0066         }
0067     }
0068 }