Warning, /utilities/skanpage/src/qml/ShareWindow.qml is written in an unsupported language. File is not indexed.
0001 /** 0002 * SPDX-FileCopyrightText: 2021 by Alexander Stippich <a.stippich@gmx.net> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 import QtQuick 0008 import QtQuick.Controls 0009 import QtQuick.Layouts 0010 import QtQuick.Window 0011 0012 import org.kde.kirigami as Kirigami 0013 import org.kde.kirigami.delegates as KD 0014 import org.kde.purpose as Purpose 0015 import org.kde.skanpage 0016 0017 Window { 0018 id: shareWindow 0019 0020 title: i18n("Share") 0021 color: Kirigami.Theme.backgroundColor 0022 0023 flags: Qt.Dialog | Qt.CustomizeWindowHint | Qt.WindowTitleHint 0024 | Qt.WindowCloseButtonHint | Qt.WindowMinimizeButtonHint | Qt.WindowMaximizeButtonHint 0025 0026 minimumHeight: 300 0027 minimumWidth: 300 0028 0029 property int selectedIndex: -1 0030 0031 signal error(var errorText) 0032 0033 ColumnLayout { 0034 anchors.fill: parent 0035 anchors.margins: Kirigami.Units.largeSpacing 0036 0037 RowLayout { 0038 Layout.alignment: Qt.AlignHCenter 0039 Layout.fillWidth: true 0040 0041 Label { 0042 text: i18n("Share as:") 0043 } 0044 0045 ComboBox { 0046 id: formatSelection 0047 0048 property string currentSuffix 0049 model: skanpage.formatModel 0050 textRole: "comment" 0051 valueRole: "name" 0052 onCurrentValueChanged: { 0053 currentSuffix = skanpage.formatModel.getData(formatSelection.currentIndex, FormatModel.SuffixRole) 0054 alternativesModel.inputData = { 0055 'urls': [], 0056 'mimeType': [currentValue] 0057 } 0058 purposeView.reset() 0059 } 0060 } 0061 } 0062 0063 Purpose.PurposeAlternativesModel { 0064 id: alternativesModel 0065 inputData: { 0066 'urls': [], 0067 'mimeType': ["application/pdf"] 0068 } 0069 pluginType: "Export" 0070 } 0071 0072 StackView { 0073 id: purposeView 0074 focus: true 0075 0076 Layout.fillWidth: true 0077 Layout.fillHeight: true 0078 0079 function reset() { 0080 while(purposeView.depth > 1) { 0081 purposeView.pop() 0082 } 0083 } 0084 0085 function proceed(index) { 0086 purposeView.push(waitingComponent) 0087 skanpage.documentModel.createSharingFile(formatSelection.currentSuffix, []) 0088 shareWindow.selectedIndex = index 0089 } 0090 0091 initialItem: ScrollView { 0092 id: alternativesList 0093 0094 contentItem: ListView { 0095 focus: true 0096 model: alternativesModel 0097 0098 implicitHeight: contentHeight 0099 0100 currentIndex: -1 0101 0102 delegate: ItemDelegate { 0103 id: shareDelegate 0104 0105 required property string iconName 0106 required property int index 0107 0108 contentItem: RowLayout { 0109 spacing: Kirigami.Units.smallSpacing 0110 0111 KD.SubtitleDelegate { 0112 text: shareDelegate.display 0113 icon.name: shareDelegate.iconName 0114 } 0115 Kirigami.Icon { 0116 implicitHeight: Kirigami.Units.iconSizes.smallMedium 0117 implicitWidth: Kirigami.Units.iconSizes.smallMedium 0118 source: "arrow-right" 0119 } 0120 } 0121 0122 onClicked: purposeView.proceed(shareDelegate.index) 0123 Keys.onReturnPressed: purposeView.proceed(shareDelegate.index) 0124 Keys.onEnterPressed: purposeView.proceed(shareDelegate.index) 0125 0126 } 0127 } 0128 0129 Component.onCompleted: { 0130 alternativesList.background.visible = true; 0131 } 0132 } 0133 } 0134 0135 Connections { 0136 target: skanpage.documentModel 0137 0138 function onSharingDocumentsCreated(filePaths) { 0139 alternativesModel.inputData = { 0140 'urls': filePaths, 0141 'mimeType': [formatSelection.currentValue] 0142 } 0143 //remove any busy indicator in case there is one 0144 if (purposeView.depth === 2) { 0145 purposeView.pop() 0146 } 0147 purposeView.push(jobComponent, {index: selectedIndex}) 0148 } 0149 } 0150 } 0151 0152 Component { 0153 id: jobComponent 0154 0155 Purpose.JobView { 0156 id: jobView 0157 model: alternativesModel 0158 0159 onStateChanged: { 0160 if (state === Purpose.PurposeJobController.Finished) { 0161 shareWindow.close() 0162 } else if (state === Purpose.PurposeJobController.Error) { 0163 shareWindow.close() 0164 shareWindow.error(jobView.job.errorString) 0165 } else if (state === Purpose.PurposeJobController.Cancelled) { 0166 purposeView.pop(); 0167 } 0168 } 0169 0170 Component.onCompleted: start() 0171 } 0172 } 0173 0174 Component { 0175 id: waitingComponent 0176 0177 Item { 0178 BusyIndicator { 0179 running: true 0180 anchors.centerIn: parent 0181 } 0182 } 0183 } 0184 0185 onVisibleChanged: { 0186 if (visible) { 0187 purposeView.reset() 0188 } 0189 } 0190 }