Purpose

JobDialog.qml
1/*
2 SPDX-FileCopyrightText: 2015 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
3 SPDX-FileCopyrightText: 2024 ivan tkachenko <me@ratijas.tk>
4
5 SPDX-License-Identifier: LGPL-2.1-or-later
6*/
7
8pragma ComponentBehavior: Bound
9
10import QtQuick
11import QtQuick.Controls as QQC2
12import QtQuick.Layouts
13
14import org.kde.kirigami as Kirigami
15import org.kde.purpose as Purpose
16import org.kde.purpose.private.widgets as PurposeWidgets
17
18QQC2.ApplicationWindow {
19 id: window
20
21 flags: Qt.Dialog
22 title: i18n("Send File")
23 visible: true
24
25 width: Math.max(screen.width / 6, Kirigami.Units.gridUnit * 16)
26 height: Math.max(screen.height / 4, Kirigami.Units.gridUnit * 20)
27
28 minimumWidth: Kirigami.Units.gridUnit * 16
29 minimumHeight: Kirigami.Units.gridUnit * 10
30
31 property PurposeWidgets.Menu menu
32 property Purpose.PurposeAlternativesModel model
33 property int index
34
35 function start(): void {
36 jobView.start();
37 }
38
39 function cancel(): void {
40 window.menu.finished({}, 1 /* KIO::ERR_USER_CANCELED */, i18nd("libpurpose6_widgets", "Configuration cancelled"));
41 window.close();
42 }
43
44 onClosing: {
45 if (jobView.state === Purpose.PurposeJobController.Configuring
46 || jobView.state === Purpose.PurposeJobController.Running) {
47 window.cancel();
48 }
49 }
50
51 Purpose.JobView {
52 id: jobView
53
54 anchors.fill: parent
55
56 model: window.model
57 index: window.index
58
59 onStateChanged: {
60 switch (state) {
61 case Purpose.PurposeJobController.Finished:
62 case Purpose.PurposeJobController.Error:
63 console.log(job.errorString);
64 window.menu.finished(job.output, job.error, job.errorString);
65 window.close();
66 break;
67 case Purpose.PurposeJobController.Cancelled:
68 window.cancel();
69 break;
70 default:
71 break;
72 }
73 }
74 }
75}
Q_SCRIPTABLE QString start(QString train="")
QString i18nd(const char *domain, const char *text, const TYPE &arg...)
QWidget * window(QObject *job)
KGuiItem cancel()
bool close()
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Mar 28 2025 11:58:09 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.