Warning, /frameworks/purpose/src/plugins/barcode/barcodeplugin_config.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2021 Kai Uwe Broulik <kde@broulik.de> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 2.7 0008 import QtQuick.Window 2.12 0009 import QtQuick.Layouts 1.1 0010 import QtQuick.Controls 2.12 as QQC2 0011 import org.kde.kirigami 2.12 as Kirigami 0012 0013 import org.kde.prison 1.0 as Prison 0014 0015 ColumnLayout { 0016 id: root 0017 0018 property var urls: [] 0019 property string mimeType 0020 property var dummy 0021 0022 Component.onCompleted: { 0023 root.Window.window.minimumWidth = Qt.binding(function() { 0024 return Math.min(Kirigami.Units.gridUnit * 30, 0025 root.implicitWidth + Kirigami.Units.gridUnit * 2); 0026 }); 0027 root.Window.window.minimumHeight = Qt.binding(function() { 0028 return Math.min(Kirigami.Units.gridUnit * 30, 0029 root.implicitHeight + Kirigami.Units.gridUnit * 4); 0030 }); 0031 } 0032 0033 Item { 0034 Layout.fillWidth: true 0035 Layout.fillHeight: true 0036 Layout.preferredWidth: barcodeItem.implicitWidth 0037 Layout.preferredHeight: barcodeItem.implicitHeight 0038 0039 Prison.Barcode { 0040 id: barcodeItem 0041 readonly property bool valid: implicitWidth > 0 && implicitHeight > 0 && implicitWidth <= width && implicitHeight <= height 0042 anchors.fill: parent 0043 barcodeType: Prison.Barcode.QRCode 0044 // Cannot set visible to false as we need it to re-render when changing its size 0045 opacity: valid ? 1 : 0 0046 content: textField.text 0047 } 0048 0049 QQC2.Label { 0050 anchors.fill: parent 0051 horizontalAlignment: Text.AlignHCenter 0052 verticalAlignment: Text.AlignVCenter 0053 text: i18nd("purpose6_barcode", "Type a URL or some text to generate a QR code") 0054 wrapMode: Text.WordWrap 0055 visible: textField.length === 0 0056 } 0057 0058 QQC2.Label { 0059 anchors.fill: parent 0060 horizontalAlignment: Text.AlignHCenter 0061 verticalAlignment: Text.AlignVCenter 0062 text: i18nd("purpose6_barcode", "Creating QR code failed") 0063 wrapMode: Text.WordWrap 0064 visible: textField.length > 0 && barcodeItem.implicitWidth === 0 && barcodeItem.implicitHeight === 0 0065 } 0066 0067 QQC2.Label { 0068 anchors.fill: parent 0069 horizontalAlignment: Text.AlignHCenter 0070 verticalAlignment: Text.AlignVCenter 0071 text: i18nd("purpose6_barcode", "The QR code is too large to be displayed") 0072 wrapMode: Text.WordWrap 0073 visible: textField.length > 0 && (barcodeItem.implicitWidth > barcodeItem.width || barcodeItem.implicitHeight > barcodeItem.height) 0074 } 0075 } 0076 0077 QQC2.TextField { 0078 id: textField 0079 Layout.fillWidth: true 0080 text: root.urls[0] 0081 // Random limit so it doesn't get too large 0082 maximumLength: 250 0083 placeholderText: i18nd("purpose6_barcode", "Type a URL or some text...") 0084 Component.onCompleted: forceActiveFocus() 0085 } 0086 }