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

0001 // SPDX-FileCopyrightText: 2017 Atul Sharma <atulsharma406@gmail.com>
0002 // SPDX-FileCopyrightText: 2021 Carl Schwan <carl@carlschwan.eu>
0003 // SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
0004 // SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 
0006 import QtQuick
0007 import QtQuick.Layouts
0008 import QtQuick.Controls 2 as QQC2
0009 import org.kde.purpose 1.0 as Purpose
0010 import org.kde.notification 1.0
0011 import org.kde.kirigami 2 as Kirigami
0012 
0013 Kirigami.Page {
0014     id: window
0015 
0016     leftPadding: 0
0017     rightPadding: 0
0018     topPadding: 0
0019     bottomPadding: 0
0020 
0021     globalToolBarStyle: Kirigami.ApplicationHeaderStyle.None
0022 
0023     property alias index: jobView.index
0024     property alias model: jobView.model
0025 
0026     QQC2.Action {
0027         shortcut: 'Escape'
0028         onTriggered: window.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                 window.closeDialog()
0051             } else if (state === Purpose.PurposeJobController.Error) {
0052                 // Show failure notification
0053                 sharingFailed.sendEvent();
0054 
0055                 window.closeDialog()
0056             } else if (state === Purpose.PurposeJobController.Cancelled) {
0057                 // Do nothing
0058                 window.closeDialog()
0059             }
0060         }
0061     }
0062 }