Warning, /frameworks/purpose/src/quick/JobView.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2020 Nicolas Fella <nicolas.fella@gmx.de> 0003 SPDX-License-Identifier: LGPL-2.1-or-later 0004 */ 0005 0006 import QtQuick 2.10 0007 import QtQuick.Controls 2.10 0008 import QtQuick.Layouts 1.1 0009 0010 import org.kde.purpose 1.0 0011 import org.kde.kirigami 2.10 as Kirigami 0012 0013 Item { 0014 0015 property alias model: jobController.model 0016 property alias index: jobController.index 0017 0018 readonly property alias state: jobController.state 0019 readonly property alias job: jobController.job 0020 0021 implicitHeight: mainLoader.implicitHeight 0022 0023 function start() { 0024 jobController.configure() 0025 } 0026 0027 PurposeJobController { 0028 id: jobController 0029 } 0030 0031 Loader { 0032 id: mainLoader 0033 anchors.fill: parent 0034 0035 sourceComponent: { 0036 switch (jobController.state) { 0037 case PurposeJobController.Configuring: return configuring 0038 case PurposeJobController.Running: return running 0039 return undefined 0040 } 0041 } 0042 } 0043 0044 Component { 0045 id: running 0046 0047 Item { 0048 BusyIndicator { 0049 running: true 0050 anchors.centerIn: parent 0051 } 0052 } 0053 } 0054 0055 Component { 0056 id: configuring 0057 0058 ColumnLayout { 0059 Loader { 0060 id: configLoader 0061 0062 Layout.leftMargin: Kirigami.Units.largeSpacing 0063 Layout.rightMargin: Kirigami.Units.largeSpacing 0064 Layout.topMargin: Kirigami.Units.largeSpacing 0065 0066 Layout.fillHeight: true 0067 Layout.fillWidth: true 0068 0069 Component.onCompleted: setSource(jobController.configuration.configSourceCode, jobController.configuration.data) 0070 0071 onItemChanged: { 0072 var initialData = jobController.configuration.data; 0073 for(var i in jobController.configuration.neededArguments) { 0074 var arg = jobController.configuration.neededArguments[i] 0075 if (arg in configLoader.item) { 0076 item[arg+"Changed"].connect(dataHasChanged); 0077 initialData[arg] = item[arg]; 0078 } else { 0079 console.warn("property not found", arg); 0080 } 0081 } 0082 jobController.configuration.data = initialData; 0083 } 0084 0085 function dataHasChanged() 0086 { 0087 var jobData = jobController.configuration.data; 0088 for(var i in jobController.configuration.neededArguments) { 0089 var arg = jobController.configuration.neededArguments[i] 0090 if (arg in configLoader.item) { 0091 jobData[arg] = configLoader.item[arg]; 0092 } else 0093 console.warn("property not found", arg); 0094 } 0095 jobController.configuration.data = jobData; 0096 } 0097 } 0098 0099 Label { 0100 textFormat: Text.PlainText 0101 Layout.fillWidth: true 0102 Layout.fillHeight: true 0103 horizontalAlignment: Text.AlignHCenter 0104 verticalAlignment: Text.AlignVCenter 0105 visible: configLoader.status === Loader.Error 0106 wrapMode: Text.WordWrap 0107 text: configLoader.status === Loader.Error 0108 ? i18nd("libpurpose_quick", "Failed to load the configuration page for this action:\n\n%1", configLoader.sourceComponent.errorString()) 0109 : "" 0110 } 0111 0112 // Not using a DialogButtonBox because it doesn't let us customize 0113 // the buttons and conditionally disable any of them, which we want 0114 RowLayout { 0115 Layout.leftMargin: Kirigami.Units.largeSpacing 0116 Layout.rightMargin: Kirigami.Units.largeSpacing 0117 Layout.bottomMargin: Kirigami.Units.largeSpacing 0118 Layout.alignment: Qt.AlignRight 0119 0120 Button { 0121 text: i18nd("libpurpose_quick", "Send") 0122 icon.name: "document-send" 0123 enabled: jobController.configuration 0124 && jobController.configuration.isReady 0125 onClicked: jobController.startJob() 0126 } 0127 0128 Button { 0129 text: i18nd("libpurpose_quick", "Cancel") 0130 icon.name: "dialog-cancel" 0131 onClicked: jobController.cancel() 0132 } 0133 } 0134 } 0135 } 0136 }