Commit 353d1108 authored by Volker Krause's avatar Volker Krause

Change the UI to show reservations in the timeline rather than passes

Boarding passes are available on a second page now, as far as we have one
for a given reservation.
parent 4d3d32c5
......@@ -49,14 +49,14 @@ Item {
Image {
Layout.rowSpan: 2
source: "image://org.kde.pkpass/" + passId + "/logo"
source: passId !== "" ? "image://org.kde.pkpass/" + passId + "/logo" : null
sourceSize.height: 1 // ??? seems necessary to trigger high dpi scaling...
}
QQC2.Label {
Layout.rowSpan: 2
Layout.fillWidth: true
text: pass.logoText
Layout.fillWidth: pass ? true : false
text: pass ? pass.logoText : ""
color: pass.foregroundColor
}
......
/*
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 "." as App
App.TimelineDelegate {
id: root
implicitHeight: topLayout.implicitHeight
ColumnLayout {
id: topLayout
anchors.left: parent.left
anchors.right: parent.right
Rectangle {
id: headerBackground
Layout.fillWidth: true
color: Kirigami.Theme.complementaryBackgroundColor
implicitHeight: headerLayout.implicitHeight
RowLayout {
id: headerLayout
anchors.left: parent.left
anchors.right: parent.right
QQC2.Label {
text: qsTr("✈ %1 %2 %3 -> %4")
.arg(reservation.reservationFor.airline.iataCode)
.arg(reservation.reservationFor.flightNumber)
.arg(reservation.reservationFor.departureAirport.iataCode)
.arg(reservation.reservationFor.arrivalAirport.iataCode)
color: Kirigami.Theme.complementaryTextColor
font.pointSize: Kirigami.Theme.defaultFont.pointSize * 1.6
Layout.fillWidth: true
}
QQC2.Label {
text: reservation.reservationFor.boardingTimeLocalized
color: Kirigami.Theme.complementaryTextColor
font.pointSize: Kirigami.Theme.defaultFont.pointSize * 1.6
}
}
}
QQC2.Label {
text: qsTr("Terminal: %1 Gate: %2 Seat: %3")
.arg(reservation.reservationFor.departureTerminal)
.arg(reservation.reservationFor.departureGate)
.arg(reservation.airplaneSeat)
color: Kirigami.Theme.textColor
}
QQC2.Label {
text: qsTr("Departure from %1: %2")
.arg(reservation.reservationFor.departureAirport.name)
.arg(reservation.reservationFor.departureTimeLocalized)
color: Kirigami.Theme.textColor
}
QQC2.Label {
text: qsTr("Arrival at %1: %2")
.arg(reservation.reservationFor.arrivalAirport.name)
.arg(reservation.reservationFor.arrivalTimeLocalized)
color: Kirigami.Theme.textColor
}
QQC2.Button {
Layout.alignment: Qt.AlignHCenter
text: qsTr("Boarding Pass")
onClicked: showBoardingPass(root.pass, root.passId)
visible: root.passId !== ""
icon.source: root.passId !== "" ? "image://org.kde.pkpass/" + passId + "/icon" : null
}
}
}
/*
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 "." as App
App.TimelineDelegate {
implicitHeight: topLayout.implicitHeight
ColumnLayout {
id: topLayout
anchors.left: parent.left
anchors.right: parent.right
Rectangle {
id: headerBackground
Layout.fillWidth: true
color: Kirigami.Theme.complementaryBackgroundColor
implicitHeight: headerLayout.implicitHeight
RowLayout {
id: headerLayout
anchors.left: parent.left
anchors.right: parent.right
QQC2.Label {
text: qsTr("⌂ %1")
.arg(reservation.reservationFor.name)
color: Kirigami.Theme.complementaryTextColor
font.pointSize: Kirigami.Theme.defaultFont.pointSize * 1.6
Layout.fillWidth: true
}
}
}
QQC2.Label {
text: qsTr("Address:\n%1\n%2 %3\n%4 ")
.arg(reservation.reservationFor.address.streetAddress)
.arg(reservation.reservationFor.address.postalCode)
.arg(reservation.reservationFor.address.addressLocality)
.arg(reservation.reservationFor.address.addressCountry)
color: Kirigami.Theme.textColor
}
QQC2.Label {
text: qsTr("Check-in time: %1")
.arg(reservation.checkinDate)
color: Kirigami.Theme.textColor
}
QQC2.Label {
text: qsTr("Check-out time: %1")
.arg(reservation.checkoutDate)
color: Kirigami.Theme.textColor
}
}
}
/*
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.0
Item {
property var reservation
property var pass
property string passId
anchors.left: parent.left
anchors.right: parent.right
signal showBoardingPass(var pass, string passId)
}
......@@ -19,10 +19,14 @@ 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.itinerary 1.0
import "." as App
Kirigami.ScrollablePage {
title: qsTr("Boarding Passes")
id: root
signal showBoardingPass(var pass, string passId)
title: qsTr("My Itinerary")
// context drawer content
actions {
contextualActions: [
......@@ -35,19 +39,43 @@ Kirigami.ScrollablePage {
}
// page content
Component {
id: flightDelegate
App.FlightDelegate {}
}
Component {
id: hotelDelegate
App.HotelDelegate {}
}
ListView {
model: _timelineModel
spacing: 5
delegate: Item {
height: passElement.implicitHeight
width: passElement.implicitWidth
App.BoardingPass {
x: (parent.ListView.view.width - implicitWidth) / 2
id: passElement
pass: model.pass
passId: model.passId
delegate: Loader {
property var modelData: model
height: item.implicitHeight
width: ListView.view.width
sourceComponent: {
switch (modelData.type) {
case TimelineModel.Flight: return flightDelegate;
case TimelineModel.Hotel: return hotelDelegate;
// TODO complete this
}
}
onLoaded: {
item.reservation = Qt.binding(function() { return modelData.reservation; });
item.passId = Qt.binding(function() { return modelData.passId; });
item.pass = Qt.binding(function() { return modelData.pass; });
item.showBoardingPass.connect(onShowBoardingPass);
}
function onShowBoardingPass(pass, passId) {
root.showBoardingPass(pass, passId)
}
}
section.property: "sectionHeader"
section.delegate: Rectangle {
color: Kirigami.Theme.backgroundColor
......
......@@ -78,6 +78,25 @@ Kirigami.ApplicationWindow {
pageStack.initialPage: mainPageComponent
Component {
id: mainPageComponent
App.TimelinePage {}
App.TimelinePage {
onShowBoardingPass: {
pageStack.push(pkpassComponent);
pageStack.currentItem.passId = passId
pageStack.currentItem.pass = pass
}
}
}
Component {
id: pkpassComponent
Kirigami.Page {
property alias passId: pkpass.passId
property alias pass: pkpass.pass
App.BoardingPass {
x: (parent.width - implicitWidth) / 2
id: pkpass
}
onBackRequested: pageStack.pop()
}
}
}
......@@ -2,6 +2,9 @@
<qresource prefix="/">
<file>main.qml</file>
<file>BoardingPass.qml</file>
<file>FlightDelegate.qml</file>
<file>HotelDelegate.qml</file>
<file>TimelineDelegate.qml</file>
<file>TimelinePage.qml</file>
</qresource>
</RCC>
[
{
"@context": "http://schema.org",
"@type": "FlightReservation",
"airplaneSeat": "15F",
"reservationFor": {
"@type": "Flight",
"airline": {
"@type": "Airline",
"iataCode": "LX"
},
"arrivalAirport": {
"@type": "Airport",
"iataCode": "ZRH",
"name": "Zürich"
},
"arrivalTime": "2017-09-10T08:15:00",
"boardingTime": "2017-09-10T06:15:00",
"departureAirport": {
"@type": "Airport",
"iataCode": "TXL",
"name": "Berlin Tegel"
},
"departureGate": "A10",
"departureDay": "2017-09-10",
"departureTime": "2017-09-10T06:45:00",
"flightNumber": "963"
},
"reservationNumber": "XXX007"
},
{
"@context": "http://schema.org",
"@type": "LodgingReservation",
"checkinDate": "2017-09-10T15:00:00+02:00",
"checkoutDate": "2017-09-15T10:00:00+02:00",
"reservationFor": {
"@type": "LodgingBusiness",
"address": {
"@type": "PostalAddress",
"addressCountry": "Switzerland",
"addressLocality": "Randa",
"addressRegion": "Wallis",
"postalCode": "3928",
"streetAddress": "Haus Maria am Weg"
},
"name": "Haus Randa",
"url": "https://randa-meetings.ch/"
}
},
{
"@context": "http://schema.org",
"@type": "FlightReservation",
"airplaneSeat": "10E",
"reservationFor": {
"@type": "Flight",
"airline": {
"@type": "Airline",
"iataCode": "LX"
},
"arrivalAirport": {
"@type": "Airport",
"iataCode": "TXL",
"name": "Berlin Tegel"
},
"arrivalTime": "2017-09-15T22:15:00",
"boardingTime": "2017-09-15T20:25:00",
"departureAirport": {
"@type": "Airport",
"iataCode": "ZRH",
"name": "Zürich"
},
"departureGate": "52",
"departureTerminal": "AB",
"departureDay": "2017-09-15",
"departureTime": "2017-09-15T20:50:00",
"flightNumber": "962"
},
"reservationNumber": "XXX007"
}
]
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