JourneyDelegateHeader.qml 1.63 KB
Newer Older
1
/*
2
    SPDX-FileCopyrightText: 2019 Volker Krause <vkrause@kde.org>
3

4
    SPDX-License-Identifier: LGPL-2.0-or-later
5
6
7
8
9
*/

import QtQuick 2.5
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.1 as QQC2
10
import org.kde.kirigami 2.17 as Kirigami
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import org.kde.kpublictransport 1.0
import org.kde.itinerary 1.0
import "." as App

Rectangle {
    property var journey

    Kirigami.Theme.colorSet: Kirigami.Theme.Complementary
    Kirigami.Theme.inherit: false
    color: journey.disruptionEffect == Disruption.NormalService ? Kirigami.Theme.backgroundColor : Kirigami.Theme.negativeTextColor
    implicitHeight: headerLayout.implicitHeight + Kirigami.Units.largeSpacing * 2
    anchors.leftMargin: -root.leftPadding
    anchors.topMargin: -root.topPadding
    anchors.rightMargin: -root.rightPadding
25
    radius: Kirigami.Units.smallSpacing
26
27
28
29
30
31
32
33
34

    RowLayout {
        id: headerLayout
        anchors.fill: parent
        anchors.margins: Kirigami.Units.largeSpacing

        QQC2.Label {
            text: Localizer.formatTime(journey, "scheduledDepartureTime")
            color: Kirigami.Theme.textColor
35
36
37
38
        }
        QQC2.Label {
            text: (journey.departureDelay >= 0 ? "+" : "") + journey.departureDelay;
            color: journey.departureDelay > 1 ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.positiveTextColor;
39
            visible: journey.hasExpectedDepartureTime && journey.disruption != Disruption.NoService
40
41
42
43
44
        }

        QQC2.Label {
            text: Localizer.formatDuration(journey.duration)
            color: Kirigami.Theme.textColor
45
46
            Layout.fillWidth: true
            horizontalAlignment: Text.AlignRight
47
48
49
        }
    }
}