Commit aaab5db2 authored by Volker Krause's avatar Volker Krause

Add bus trip details page

This also obsoletes the old generic ticket page.
parent c6d9c6c6
......@@ -87,17 +87,20 @@ App.TimelineDelegate {
QQC2.Button {
Layout.alignment: Qt.AlignHCenter
text: root.passId !== "" ? qsTr("Boarding Pass") : qsTr("🎫 Ticket")
onClicked: {
if (root.passId !== "")
showBoardingPass();
else
showTicket();
}
visible: root.passId !== "" || (root.reservation.reservedTicket != undefined && root.reservation.reservedTicket.ticketToken != "")
text: qsTr("Boarding Pass")
onClicked: showBoardingPass();
visible: root.passId !== ""
icon.source: root.passId !== "" ? "image://org.kde.pkpass/" + passId + "/icon" : ""
}
}
}
Component {
id: detailsComponent
App.BusPage {
reservation: root.reservation
}
}
onClicked: applicationWindow().pageStack.push(detailsComponent);
}
/*
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.kitinerary 1.0
import org.kde.itinerary 1.0
import "." as App
App.DetailsPage {
id: root
title: qsTr("Bus Ticket")
GridLayout {
id: grid
width: root.width
columns: 2
QQC2.Label {
Layout.columnSpan: 2
Layout.fillWidth: true
text: reservation.reservationFor.busName + " " + reservation.reservationFor.busNumber
horizontalAlignment: Qt.AlignHCenter
font.bold: true
}
// ticket barcode
App.TicketTokenDelegate {
Layout.columnSpan: 2
ticket: reservation.reservedTicket
}
// departure data
QQC2.Label {
Layout.columnSpan: 2
Layout.fillWidth: true
text: qsTr("Departure")
horizontalAlignment: Qt.AlignHCenter
}
QQC2.Label {
text: qsTr("Departure time:")
}
QQC2.Label {
text: Localizer.formatDateTime(reservation.reservationFor, "departureTime")
}
QQC2.Label {
text: reservation.reservationFor.departureStation.name
Layout.columnSpan: 2
}
App.PlaceDelegate {
Layout.columnSpan: 2
Layout.fillWidth: true
place: reservation.reservationFor.departureStation
}
Kirigami.Separator {
Layout.columnSpan: 2
Layout.fillWidth: true
}
// arrival data
QQC2.Label {
Layout.columnSpan: 2
Layout.fillWidth: true
text: qsTr("Arrival")
horizontalAlignment: Qt.AlignHCenter
}
QQC2.Label {
text: qsTr("Arrival time:")
}
QQC2.Label {
text: Localizer.formatDateTime(reservation.reservationFor, "arrivalTime")
}
QQC2.Label {
text: reservation.reservationFor.arrivalStation.name
Layout.columnSpan: 2
}
App.PlaceDelegate {
Layout.columnSpan: 2
Layout.fillWidth: true
place: reservation.reservationFor.arrivalStation
}
Kirigami.Separator {
Layout.columnSpan: 2
Layout.fillWidth: true
}
// seat reservation
QQC2.Label {
Layout.columnSpan: 2
Layout.fillWidth: true
text: qsTr("Seat")
horizontalAlignment: Qt.AlignHCenter
}
QQC2.Label {
text: qsTr("Seat:")
}
QQC2.Label {
text: reservation.reservedTicket.ticketedSeat.seatNumber
}
// booking details
Kirigami.Separator {
Layout.columnSpan: 2
Layout.fillWidth: true
}
QQC2.Label {
Layout.columnSpan: 2
Layout.fillWidth: true
text: qsTr("Booking")
horizontalAlignment: Qt.AlignHCenter
}
QQC2.Label {
text: qsTr("Booking reference:")
}
QQC2.Label {
text: reservation.reservationNumber
}
QQC2.Label {
text: qsTr("Under name:")
}
QQC2.Label {
text: reservation.underName.name
}
}
}
......@@ -56,6 +56,7 @@ qml_lint(
main.qml
BoardingPass.qml
BusDelegate.qml
BusPage.qml
DetailsPage.qml
FlightDelegate.qml
FlightPage.qml
......@@ -64,7 +65,6 @@ qml_lint(
PkPassPage.qml
PlaceDelegate.qml
RestaurantDelegate.qml
TicketPage.qml
TicketTokenDelegate.qml
TimelineDelegate.qml
TimelinePage.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.kitinerary 1.0
import org.kde.itinerary 1.0
import "." as App
Kirigami.Page {
id: root
title: qsTr("Ticket")
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:
{
console.log(reservation.reservedTicket.ticketTokenType, Ticket.AztecCode);
if (reservation == undefined || reservation.reservedTicket == undefined)
return Prison.Barcode.Null;
switch (reservation.reservedTicket.ticketTokenType) {
case Ticket.QRCode: return Prison.Barcode.QRCode;
case Ticket.AztecCode: return Prison.Barcode.Aztec;
}
return Prison.Barcode.Null;
}
content:
{
if (barcodeType == Prison.Barcode.Null || reservation == undefined || reservation.reservedTicket == undefined)
return "";
return reservation.reservedTicket.ticketTokenData;
}
}
}
}
}
onBackRequested: pageStack.pop()
}
......@@ -38,11 +38,6 @@ Kirigami.AbstractCard {
applicationWindow().pageStack.push(pkpassComponent);
}
function showTicket()
{
applicationWindow().pageStack.push(ticketPageComponent);
}
Component {
id: pkpassComponent
App.PkPassPage {
......@@ -50,11 +45,4 @@ Kirigami.AbstractCard {
pass: root.pass
}
}
Component {
id: ticketPageComponent
App.TicketPage {
reservation: root.reservation
}
}
}
......@@ -108,4 +108,3 @@ App.TimelineDelegate {
onClicked: applicationWindow().pageStack.push(detailsComponent);
}
......@@ -160,4 +160,3 @@ App.DetailsPage {
}
}
}
......@@ -3,6 +3,7 @@
<file>main.qml</file>
<file>BoardingPass.qml</file>
<file>BusDelegate.qml</file>
<file>BusPage.qml</file>
<file>DetailsPage.qml</file>
<file>FlightDelegate.qml</file>
<file>FlightPage.qml</file>
......@@ -11,7 +12,6 @@
<file>PkPassPage.qml</file>
<file>PlaceDelegate.qml</file>
<file>RestaurantDelegate.qml</file>
<file>TicketPage.qml</file>
<file>TicketTokenDelegate.qml</file>
<file>TimelineDelegate.qml</file>
<file>TimelinePage.qml</file>
......
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