Warning, /pim/itinerary/src/app/EventTicket.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2018 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 0008 import QtQuick.Layouts 0009 import QtQuick.Controls as QQC2 0010 import QtQuick.Effects as Effects 0011 import org.kde.kirigami as Kirigami 0012 import org.kde.pkpass as KPkPass 0013 import org.kde.itinerary 0014 0015 Item { 0016 id: root 0017 property var pass: null 0018 property string passId 0019 implicitHeight: bodyBackground.implicitHeight 0020 implicitWidth: 332 //Math.max(topLayout.implicitWidth, 332) 0021 0022 property color defaultTextColor: Kirigami.Theme.textColor 0023 0024 /** Double tap on the barcode to request scan mode. */ 0025 signal scanModeToggled() 0026 0027 Rectangle { 0028 id: bodyBackground 0029 color: Util.isValidColor(pass.backgroundColor) ? pass.backgroundColor : Kirigami.Theme.backgroundColor 0030 //implicitHeight: topLayout.implicitHeight + 2 * topLayout.anchors.margins 0031 width: parent.width 0032 0033 Image { 0034 id: backgroundImage 0035 source: passId !== "" ? "image://org.kde.pkpass/" + passId + "/background" : "" 0036 fillMode: backgroundImage.implicitHeight < parent.implicitHeight ? Image.TileVertically : Image.PreserveAspectCrop 0037 verticalAlignment: Image.AlignTop 0038 horizontalAlignment: Image.AlignHCenter 0039 x: -(width - bodyBackground.width) / 2 0040 y: 0 0041 visible: false 0042 height: parent.implicitHeight 0043 width: root.implicitWidth 0044 } 0045 Effects.MultiEffect { 0046 anchors.fill: backgroundImage 0047 source: backgroundImage 0048 autoPaddingEnabled: false 0049 blurEnabled: true 0050 blur: 1.0 0051 blurMax: 32 0052 } 0053 0054 ColumnLayout { 0055 id: topLayout 0056 spacing: 10 0057 anchors.fill: parent 0058 anchors.margins: 6 0059 // HACK to break binding loop on implicitHeight 0060 onImplicitHeightChanged: bodyBackground.implicitHeight = implicitHeight + 2 * topLayout.anchors.margins 0061 0062 0063 ColumnLayout { 0064 id: bodyLayout 0065 spacing: 10 0066 0067 // header 0068 GridLayout { 0069 id: headerLayout 0070 rows: 2 0071 columns: pass.headerFields.length + 2 0072 Layout.fillWidth: true 0073 0074 Image { 0075 Layout.rowSpan: 2 0076 Layout.maximumHeight: 60 0077 Layout.maximumWidth: 150 0078 Layout.preferredWidth: paintedWidth 0079 fillMode: Image.PreserveAspectFit 0080 source: passId !== "" ? "image://org.kde.pkpass/" + passId + "/logo" : "" 0081 sourceSize.height: 1 // ??? seems necessary to trigger high dpi scaling... 0082 mipmap: true 0083 } 0084 0085 QQC2.Label { 0086 Layout.rowSpan: 2 0087 Layout.fillWidth: pass ? true : false 0088 text: pass ? pass.logoText : "" 0089 color: Util.isValidColor(pass.foregroundColor) ? pass.foregroundColor : root.defaultTextColor 0090 } 0091 0092 Repeater { 0093 model: pass.headerFields 0094 delegate: QQC2.Label { 0095 text: modelData.label 0096 color: Util.isValidColor(pass.labelColor) ? pass.labelColor : root.defaultTextColor 0097 Layout.row: 0 0098 Layout.column: index + 2 0099 } 0100 } 0101 Repeater { 0102 model: pass.headerFields 0103 delegate: QQC2.Label { 0104 text: modelData.valueDisplayString 0105 color: Util.isValidColor(pass.foregroundColor) ? pass.foregroundColor : root.defaultTextColor 0106 Layout.row: 1 0107 Layout.column: index + 2 0108 } 0109 } 0110 } 0111 0112 // strip image 0113 Image { 0114 id: stripImage 0115 source: passId !== "" ? "image://org.kde.pkpass/" + passId + "/strip" : "" 0116 sourceSize.height: 1 // ??? seems necessary to trigger high dpi scaling... 0117 Layout.alignment: Qt.AlignCenter 0118 Layout.preferredWidth: Math.min(320, stripImage.implicitWidth); // 320 as per spec 0119 Layout.preferredHeight: (Layout.preferredWidth / stripImage.implicitWidth) * stripImage.implicitHeight 0120 fillMode: Image.PreserveAspectFit 0121 } 0122 0123 // primary fields 0124 GridLayout { 0125 id: primaryFieldLayout 0126 rows: 2 0127 columns: pass.primaryFields.length 0128 Layout.fillWidth: true 0129 0130 Repeater { 0131 model: pass.primaryFields 0132 delegate: QQC2.Label { 0133 Layout.fillWidth: true 0134 color: Util.isValidColor(pass.labelColor) ? pass.labelColor : root.defaultTextColor 0135 text: modelData.label 0136 horizontalAlignment: modelData.textAlignment 0137 } 0138 } 0139 Repeater { 0140 model: pass.primaryFields 0141 delegate: QQC2.Label { 0142 Layout.fillWidth: true 0143 color: Util.isValidColor(pass.foregroundColor) ? pass.foregroundColor : root.defaultTextColor 0144 text: modelData.valueDisplayString 0145 horizontalAlignment: modelData.textAlignment 0146 } 0147 } 0148 } 0149 0150 // secondary fields 0151 GridLayout { 0152 id: secFieldsLayout 0153 rows: 2 0154 columns: pass.secondaryFields.length 0155 Layout.fillWidth: true 0156 0157 Repeater { 0158 model: pass.secondaryFields 0159 delegate: QQC2.Label { 0160 Layout.fillWidth: true 0161 color: Util.isValidColor(pass.labelColor) ? pass.labelColor : root.defaultTextColor 0162 text: modelData.label 0163 horizontalAlignment: modelData.textAlignment 0164 } 0165 } 0166 Repeater { 0167 model: pass.secondaryFields 0168 delegate: QQC2.Label { 0169 Layout.fillWidth: true 0170 color: Util.isValidColor(pass.foregroundColor) ? pass.foregroundColor : root.defaultTextColor 0171 text: modelData.valueDisplayString 0172 horizontalAlignment: modelData.textAlignment 0173 } 0174 } 0175 } 0176 0177 // auxiliary fields 0178 GridLayout { 0179 id: auxFieldsLayout 0180 rows: 2 0181 columns: pass.auxiliaryFields.length 0182 Layout.fillWidth: true 0183 0184 Repeater { 0185 model: pass.auxiliaryFields 0186 delegate: QQC2.Label { 0187 Layout.fillWidth: true 0188 color: Util.isValidColor(pass.labelColor) ? pass.labelColor : root.defaultTextColor 0189 text: modelData.label 0190 horizontalAlignment: modelData.textAlignment 0191 } 0192 } 0193 Repeater { 0194 model: pass.auxiliaryFields 0195 delegate: QQC2.Label { 0196 Layout.fillWidth: true 0197 color: Util.isValidColor(pass.foregroundColor) ? pass.foregroundColor : root.defaultTextColor 0198 text: modelData.valueDisplayString 0199 horizontalAlignment: modelData.textAlignment 0200 } 0201 } 0202 } 0203 } 0204 0205 // barcode 0206 PkPassBarcode { 0207 maximumWidth: root.implicitWidth * 0.8 0208 pass: root.pass 0209 TapHandler { 0210 onDoubleTapped: scanModeToggled() 0211 } 0212 } 0213 0214 // footer 0215 Image { 0216 source: passId !== "" ? "image://org.kde.pkpass/" + passId + "/footer" : "" 0217 sourceSize.height: 1 // ??? seems necessary to trigger high dpi scaling... 0218 Layout.alignment: Qt.AlignCenter 0219 } 0220 0221 // back fields 0222 Kirigami.Separator { 0223 Layout.fillWidth: true 0224 visible: pass.backFields.length > 0 0225 } 0226 Repeater { 0227 model: pass.backFields 0228 ColumnLayout { 0229 QQC2.Label { 0230 Layout.fillWidth: true 0231 color: Util.isValidColor(pass.labelColor) ? pass.labelColor : root.defaultTextColor 0232 text: modelData.label 0233 wrapMode: Text.WordWrap 0234 horizontalAlignment: modelData.textAlignment 0235 } 0236 QQC2.Label { 0237 Layout.fillWidth: true 0238 color: Util.isValidColor(pass.foregroundColor) ? pass.foregroundColor : root.defaultTextColor 0239 linkColor: Util.isValidColor(pass.foregroundColor) ? color : Kirigami.Theme.linkColor 0240 text: Util.textToHtml(modelData.valueDisplayString) 0241 textFormat: Util.isRichText(modelData.valueDisplayString) ? Text.StyledText : Text.AutoText 0242 wrapMode: Text.WordWrap 0243 horizontalAlignment: modelData.textAlignment 0244 onLinkActivated: Qt.openUrlExternally(link) 0245 } 0246 } 0247 } 0248 } 0249 0250 Rectangle { 0251 id: notchMask 0252 width: parent.width / 4 0253 height: width 0254 radius: width / 2 0255 color: Kirigami.Theme.backgroundColor 0256 x: parent.width/2 - radius 0257 y: -radius * 1.5 0258 } 0259 } 0260 0261 Component.onCompleted: { 0262 if (backgroundImage.status !== Image.Ready) 0263 return; 0264 root.defaultTextColor = Util.isDarkImage(pass.background()) ? "#eff0f1" : "#232629"; 0265 } 0266 }