Warning, /utilities/qrca/src/contents/ui/QrCodeEncoderPage.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2019 Jonah BrĂ¼chert <jbb@kaidan.im> 0003 * 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 0007 import QtQuick 2.0 0008 import QtQuick.Controls 2.3 as Controls 0009 import QtMultimedia 5.9 0010 import org.kde.kirigami 2.7 as Kirigami 0011 import QtQuick.Layouts 1.3 0012 import org.kde.qrca 1.0 0013 import org.kde.prison 1.0 as Prison 0014 0015 import QtQuick.Dialogs 0016 0017 Kirigami.ScrollablePage { 0018 title: i18n("Create QR-Code") 0019 0020 Loader { 0021 id: shareSheetLoader 0022 0023 active: false 0024 source: "ShareSheet.qml" 0025 } 0026 0027 FileDialog { 0028 id: fileDialog 0029 defaultSuffix: "png" 0030 nameFilters: [ i18n("Image files (*.png *.jpg)"), i18n("All files (*)") ] 0031 } 0032 0033 actions: [ 0034 Kirigami.Action { 0035 text: i18n("Save") 0036 icon.name: "document-save" 0037 enabled: inputText.length > 0 0038 onTriggered: { 0039 fileDialog.accepted.connect(() => { 0040 codeView.grabToImage((result) => { 0041 const s = result.saveToFile(fileDialog.fileUrl.toString().replace("file://", "")) 0042 if (!s) { 0043 showPassiveNotification(i18n("QR-Code could not be saved")) 0044 } 0045 0046 fileDialog.accepted.disconnect() 0047 }) 0048 }) 0049 fileDialog.open() 0050 } 0051 }, 0052 Kirigami.Action { 0053 text: i18n("Share") 0054 icon.name: "document-share" 0055 visible: Qt.platform.os !== "android" // Purpose doesn't work properly on Android 0056 enabled: inputText.length > 0 0057 onTriggered: { 0058 shareSheetLoader.active = true 0059 codeView.grabToImage((result) => { 0060 const saveLocation = Qrca.newQrCodeSaveLocation() 0061 const s = result.saveToFile(saveLocation) 0062 if (!s) { 0063 showPassiveNotification(i18n("QR-Code could not be saved to temporary location")) 0064 } 0065 0066 shareSheetLoader.item.url = saveLocation 0067 shareSheetLoader.item.open() 0068 }) 0069 } 0070 } 0071 ] 0072 0073 ColumnLayout { 0074 spacing: 50 0075 0076 Prison.Barcode { 0077 id: codeView 0078 Layout.fillWidth: true 0079 Layout.alignment: Qt.AlignCenter 0080 Layout.maximumWidth: Kirigami.Units.gridUnit * 16 0081 Layout.preferredHeight: width 0082 barcodeType: Prison.Barcode.QRCode 0083 content: inputText.text.length > 0 ? inputText.text: "https://www.kde.org" 0084 } 0085 0086 Kirigami.ActionTextField { 0087 id: inputText 0088 placeholderText: "Enter text" 0089 text: Qrca.encodeText ? Qrca.encodeText : "" 0090 Layout.fillWidth: true 0091 rightActions: [ 0092 Kirigami.Action { 0093 icon.name: "edit-clear" 0094 enabled: inputText.text.length > 0 0095 onTriggered: inputText.text = "" 0096 } 0097 ] 0098 } 0099 } 0100 }