Warning, /pim/merkuro/src/contacts/applet/package/contents/ui/QrCodePage.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org> 0002 // SPDX-FileCopyrightText: 2022 Carl Schwan <car@carlschwan.eu> 0003 // SPDX-License-Identifier: GPL-2.0-or-later 0004 0005 import QtQuick 2.15 0006 import QtQml 2.15 0007 import QtQuick.Layouts 1.15 0008 import org.kde.plasma.core 2.0 as PlasmaCore 0009 import org.kde.plasma.extras 2.0 as PlasmaExtras 0010 import org.kde.plasma.components 3.0 as PlasmaComponents3 0011 import org.kde.plasma.plasmoid 2.0 0012 import org.kde.plasma.extras 2.0 as PlasmaExtras 0013 import org.kde.kquickcontrolsaddons 2.0 0014 import org.kde.merkuro.contact 1.0 0015 import org.kde.prison 1.0 as Prison 0016 0017 ColumnLayout { 0018 id: barcodeView 0019 0020 property string qrCodeData 0021 property string title: i18n("QR Code") 0022 0023 Keys.onPressed: { 0024 if (event.key == Qt.Key_Escape) { 0025 stack.pop() 0026 event.accepted = true; 0027 } 0028 } 0029 property var header: PlasmaExtras.PlasmoidHeading { 0030 RowLayout { 0031 anchors.fill: parent 0032 PlasmaComponents3.Button { 0033 Layout.fillWidth: true 0034 icon.name: "go-previous-view" 0035 text: i18n("Return to Contact") 0036 onClicked: stack.pop() 0037 } 0038 0039 Component { 0040 id: menuItemComponent 0041 PlasmaComponents3.MenuItem { } 0042 } 0043 0044 PlasmaComponents3.Menu { 0045 id: menu 0046 x: configureButton.x 0047 y: configureButton.y + configureButton.height 0048 onClosed: configureButton.checked = false 0049 0050 Component.onCompleted: { 0051 [ 0052 {text: i18n("QR Code"), type: Prison.Barcode.QRCode}, 0053 {text: i18n("Data Matrix"), type: Prison.Barcode.DataMatrix}, 0054 {text: i18nc("Aztec barcode", "Aztec"), type: Prison.Barcode.Aztec} 0055 ].forEach((item) => { 0056 let menuItem = menuItemComponent.createObject(menu, { 0057 text: item.text, 0058 checkable: true, 0059 checked: Qt.binding(() => { 0060 return barcodeItem.barcodeType === item.type; 0061 }) 0062 }); 0063 menuItem.clicked.connect(() => { 0064 barcodeItem.barcodeType = item.type; 0065 Plasmoid.configuration.barcodeType = item.type; 0066 }); 0067 menu.addItem(menuItem); 0068 }); 0069 } 0070 } 0071 PlasmaComponents3.ToolButton { 0072 id: configureButton 0073 checkable: true 0074 icon.name: "configure" 0075 onClicked: menu.open() 0076 0077 PlasmaComponents3.ToolTip { 0078 text: i18n("Change the QR code type") 0079 } 0080 } 0081 } 0082 } 0083 Item { 0084 Layout.fillWidth: parent 0085 Layout.fillHeight: parent 0086 Layout.topMargin: PlasmaCore.Units.smallSpacing 0087 0088 Prison.Barcode { 0089 id: barcodeItem 0090 readonly property bool valid: implicitWidth > 0 && implicitHeight > 0 && implicitWidth <= width && implicitHeight <= height 0091 content: qrCodeData 0092 anchors.fill: parent 0093 barcodeType: Plasmoid.configuration.barcodeType 0094 // Cannot set visible to false as we need it to re-render when changing its size 0095 opacity: valid ? 1 : 0 0096 } 0097 0098 PlasmaComponents3.Label { 0099 anchors.fill: parent 0100 horizontalAlignment: Text.AlignHCenter 0101 verticalAlignment: Text.AlignVCenter 0102 text: i18n("Creating QR code failed") 0103 wrapMode: Text.WordWrap 0104 visible: barcodeItem.implicitWidth === 0 && barcodeItem.implicitHeight === 0 0105 } 0106 0107 PlasmaComponents3.Label { 0108 anchors.fill: parent 0109 horizontalAlignment: Text.AlignHCenter 0110 verticalAlignment: Text.AlignVCenter 0111 text: i18n("The QR code is too large to be displayed") 0112 wrapMode: Text.WordWrap 0113 visible: barcodeItem.implicitWidth > barcodeItem.width || barcodeItem.implicitHeight > barcodeItem.height 0114 } 0115 } 0116 }