Commit 76d2ff01 authored by Volker Krause's avatar Volker Krause

Add ticket page for showing non-pkpass barcodes

Still needs to be hooked up to the other reservation delegates too.
parent 5548877f
......@@ -60,6 +60,7 @@ qml_lint(
HotelDelegate.qml
PlaceDelegate.qml
RestaurantDelegate.qml
TicketPage.qml
TimelineDelegate.qml
TimelinePage.qml
TrainDelegate.qml
......
/*
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.kirigami 2.0 as Kirigami
import org.kde.prison 1.0 as Prison
import org.kde.itinerary 1.0
import "." as App
Kirigami.Page {
id: root
property variant reservation
ColumnLayout {
anchors.fill: parent
Rectangle {
implicitHeight: barcodeLayout.implicitHeight
implicitWidth: barcodeLayout.implicitWidth
color: "white"
Layout.alignment: Qt.AlignCenter
ColumnLayout {
id: barcodeLayout
anchors.fill: parent
Prison.Barcode {
id: barcode
Layout.alignment: Qt.AlignCenter
Layout.preferredWidth: root.width * 0.8
Layout.preferredHeight: Layout.preferredWidth
Layout.margins: 4
barcodeType:
{
if (reservation == undefined || reservation.reservedTicket == undefined)
return Prison.Barcode.Null;
if (reservation.reservedTicket.ticketToken.startsWith("qrCode:"))
return Prison.Barcode.QRCode;
return Prison.Barcode.Aztec;
}
content:
{
if (barcodeType == Prison.Barcode.Null || reservation == undefined || reservation.reservedTicket == undefined)
return "";
switch (barcodeType) {
case Prison.Barcode.QRCode:
return reservation.reservedTicket.ticketToken.substr(7); // "qrCode:"
case Prison.Barcode.Aztec:
return reservation.reservedTicket.ticketToken.substr(10); // "aztecCode:"
}
return "";
}
}
}
}
}
onBackRequested: pageStack.pop()
}
......@@ -16,6 +16,11 @@
*/
import QtQuick 2.0
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.1 as QQC2
import org.kde.kirigami 2.0 as Kirigami
import org.kde.itinerary 1.0
import "." as App
Item {
property var reservation
......@@ -25,4 +30,16 @@ Item {
readonly property double headerFontScale: 1.25
signal showBoardingPass(var pass, string passId)
function showTicket()
{
applicationWindow().pageStack.push(ticketPageComponent);
applicationWindow().pageStack.currentItem.reservation = reservation;
}
Component {
id: ticketPageComponent
App.TicketPage {
}
}
}
......@@ -83,6 +83,13 @@ App.TimelineDelegate {
place: reservation.reservationFor.arrivalStation
Layout.fillWidth: true
}
QQC2.Button {
Layout.alignment: Qt.AlignHCenter
text: qsTr("🎫 Ticket")
onClicked: root.showTicket()
visible: root.reservation.reservedTicket != undefined && root.reservation.reservedTicket.ticketToken != ""
}
}
}
......@@ -7,6 +7,7 @@
<file>HotelDelegate.qml</file>
<file>PlaceDelegate.qml</file>
<file>RestaurantDelegate.qml</file>
<file>TicketPage.qml</file>
<file>TimelineDelegate.qml</file>
<file>TimelinePage.qml</file>
<file>TrainDelegate.qml</file>
......
......@@ -56,6 +56,15 @@
},
"trainName": "IC",
"trainNumber": "816"
},
"reservedTicket": {
"@type": "Ticket",
"ticketToken": "aztecCode:i0CVXXX007123456789xxxx01/01/1970xxxxxxxxxxxxxxx24/090011223344556677889 DOE JOHN 00000",
"ticketedSeat": {
"@type": "Seat",
"seatNumber": "62",
"seatSection": "17"
}
}
},
{
......
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