Commit 16078ada authored by Volker Krause's avatar Volker Krause

Factor out duplicate pkpass barcode element

parent 7a6e1bbc
......@@ -20,9 +20,10 @@ import QtQuick.Layouts 1.1
import QtQuick.Controls 2.1 as QQC2
import org.kde.kirigami 2.4 as Kirigami
import org.kde.pkpass 1.0 as KPkPass
import org.kde.prison 1.0 as Prison
import "." as App
Item {
id: root
property var pass: null
property string passId
//implicitHeight: frontLayout.implicitHeight
......@@ -208,32 +209,8 @@ Item {
}
// barcode
Rectangle {
implicitHeight: barcodeLayout.implicitHeight
implicitWidth: barcodeLayout.implicitWidth
color: "white"
Layout.alignment: Qt.AlignCenter
ColumnLayout {
id: barcodeLayout
anchors.fill: parent
Prison.Barcode {
Layout.alignment: Qt.AlignCenter
Layout.margins: 4
Layout.preferredWidth: Math.max(implicitWidth, 0.8 * bodyBackground.width)
Layout.preferredHeight: Layout.preferredWidth
barcodeType: pass.barcodes[0].format == KPkPass.Barcode.QR ? Prison.Barcode.QRCode : Prison.Barcode.Aztec
content: pass.barcodes[0].message
}
App.PkPassBarcode { pass: root.pass }
QQC2.Label {
Layout.alignment: Qt.AlignCenter
text: pass.barcodes[0].alternativeText
color: "black"
visible: text.length > 0
}
}
}
// TODO back fields
}
}
......
......@@ -21,7 +21,7 @@ import QtQuick.Controls 2.1 as QQC2
import QtGraphicalEffects 1.0 as Effects
import org.kde.kirigami 2.4 as Kirigami
import org.kde.pkpass 1.0 as KPkPass
import org.kde.prison 1.0 as Prison
import "." as App
Item {
id: root
......@@ -194,32 +194,7 @@ Item {
}
// barcode
Rectangle {
implicitHeight: barcodeLayout.implicitHeight
implicitWidth: barcodeLayout.implicitWidth
color: "white"
Layout.alignment: Qt.AlignCenter
ColumnLayout {
id: barcodeLayout
anchors.fill: parent
Prison.Barcode {
Layout.alignment: Qt.AlignCenter
Layout.margins: 4
Layout.preferredWidth: Math.max(implicitWidth, 0.8 * bodyBackground.width)
Layout.preferredHeight: Layout.preferredWidth
barcodeType: pass.barcodes[0].format == KPkPass.Barcode.QR ? Prison.Barcode.QRCode : Prison.Barcode.Aztec
content: pass.barcodes[0].message
}
QQC2.Label {
Layout.alignment: Qt.AlignCenter
text: pass.barcodes[0].alternativeText
color: "black"
visible: text.length > 0
}
}
}
App.PkPassBarcode { pass: root.pass }
// footer
Image {
......
/*
Copyright (C) 2018 Volker Krause <vkrause@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.5
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.1 as QQC2
import org.kde.pkpass 1.0 as KPkPass
import org.kde.prison 1.0 as Prison
Rectangle {
property var pass
implicitHeight: barcodeLayout.implicitHeight
implicitWidth: barcodeLayout.implicitWidth
color: "white"
radius: 6
Layout.alignment: Qt.AlignCenter
ColumnLayout {
id: barcodeLayout
anchors.fill: parent
Prison.Barcode {
Layout.alignment: Qt.AlignCenter
Layout.margins: 4
Layout.preferredWidth: Math.max(implicitWidth, 0.8 * bodyBackground.width)
Layout.preferredHeight: Layout.preferredWidth
barcodeType: pass.barcodes[0].format == KPkPass.Barcode.QR ? Prison.Barcode.QRCode : Prison.Barcode.Aztec
content: pass.barcodes[0].message
}
QQC2.Label {
Layout.alignment: Qt.AlignCenter
text: pass.barcodes[0].alternativeText
color: "black"
visible: text.length > 0
}
}
}
......@@ -21,6 +21,7 @@
<file>HotelDelegate.qml</file>
<file>HotelPage.qml</file>
<file>ImportDialog.qml</file>
<file>PkPassBarcode.qml</file>
<file>PkPassPage.qml</file>
<file>PlaceDelegate.qml</file>
<file>PlaceEditor.qml</file>
......
......@@ -3,6 +3,7 @@
<file>pkpassviewer.qml</file>
<file alias="BoardingPass.qml">../src/app/BoardingPass.qml</file>
<file alias="EventTicket.qml">../src/app/EventTicket.qml</file>
<file alias="PkPassBarcode.qml">../src/app/PkPassBarcode.qml</file>
<file alias="PkPassPage.qml">../src/app/PkPassPage.qml</file>
<file alias="images/flight.svg">../src/app/images/flight.svg</file>
</qresource>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment