Commit 9e4618a6 authored by Nicolas Fella's avatar Nicolas Fella

Revamp ConnectionsPage

parent 53d15431
/**
* Copyright 2020 Nicolas Fella <nicolas.fella@gmx.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* 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 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 <https://www.gnu.org/licenses/>.
*/
import QtQuick 2.2
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.4
import org.kde.kirigami 2.4 as Kirigami
import org.kde.kpublictransport 1.0 as KPT
import org.kde.ktrip 1.0
Row {
property var journey
spacing: Kirigami.Units.smallSpacing
Kirigami.Heading {
id: durationHeading
level: 2
text: _formatter.formatDuration(journey.duration)
font.strikeout: journey.disruptionEffect == KPT.Disruption.NoService
}
Repeater {
model: journey.sections
delegate: Loader {
sourceComponent: model.modelData.route.line.hasLogo ? secIcon : secLabel
Component {
id: secIcon
Kirigami.Icon {
width: height
height: durationHeading.height
source: modelData.route.line.logo
}
}
Component {
id: secLabel
Label {
height: durationHeading.height
text: modelData.route.line.name
}
}
}
}
}
......@@ -57,32 +57,54 @@ Kirigami.ScrollablePage
highlighted: false
onClicked: pageStack.push(Qt.resolvedUrl("ConnectionDetailsPage.qml"), {journey: journey})
readonly property bool cancelled: journey.disruptionEffect == KPT.Disruption.NoService
readonly property var firstSection: journey.sections[0]
readonly property var lastSection: journey.sections[journey.sections.length - 1]
RowLayout {
Label {
text: i18n("%1 - %2", journey.sections[0].scheduledDepartureTime.toLocaleTimeString(Locale.ShortFormat), journey.sections[journey.sections.length - 1].scheduledArrivalTime.toLocaleTimeString(Locale.ShortFormat))
font.strikeout: cancelled
}
Column {
Label {
text: i18n("(%1)", _formatter.formatDuration(journey.duration))
Layout.fillWidth: !delayLabel.visible
font.strikeout: cancelled
ConnectionHeading {
journey: model.journey
}
Label {
id: delayLabel
Layout.fillWidth: true
visible: journey.sections[journey.sections.length - 1].hasExpectedArrivalTime
text: i18n("+%1", journey.sections[journey.sections.length - 1].arrivalDelay)
color: journey.sections[journey.sections.length - 1].arrivalDelay > 0 ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.positiveTextColor
font.strikeout: cancelled
RowLayout {
width: parent.width
Label {
text: i18n("%1 %2", firstSection.scheduledDepartureTime.toLocaleTimeString(Locale.ShortFormat), firstSection.from.name)
font.strikeout: cancelled
}
Label {
visible: firstSection.hasExpectedDepartureTime
text: i18n("+%1", firstSection.departureDelay)
color: firstSection.departureDelay > 0 ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.positiveTextColor
font.strikeout: cancelled
}
Item {
Layout.fillWidth: true
}
Label {
text: i18np("%1 change", "%1 changes", journey.numberOfChanges)
visible: journey.numberOfChanges > 0
font.strikeout: cancelled
Layout.alignment: Qt.AlignRight
}
}
Label {
text: i18np("%1 change", "%1 changes", journey.numberOfChanges)
visible: journey.numberOfChanges > 0
font.strikeout: cancelled
RowLayout {
width: parent.width
Label {
text: i18n("%1 %2", lastSection.scheduledArrivalTime.toLocaleTimeString(Locale.ShortFormat), lastSection.to.name)
font.strikeout: cancelled
}
Label {
Layout.fillWidth: true
visible: lastSection.hasExpectedArrivalTime
text: i18n("+%1", lastSection.arrivalDelay)
color: lastSection.arrivalDelay > 0 ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.positiveTextColor
font.strikeout: cancelled
}
}
}
}
......
......@@ -9,6 +9,7 @@
<file>qml/DatePickerButton.qml</file>
<file>qml/TimePickerButton.qml</file>
<file>qml/DeparturesPage.qml</file>
<file>qml/ConnectionHeading.qml</file>
<file>qtquickcontrols2.conf</file>
<file>ktrip.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