Warning, /utilities/ktrip/src/qml/BackendPage.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2019 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 import QtQuick 2.5
0008 import QtQuick.Layouts 1.1
0009 import QtQuick.Controls 2.1 as QQC2
0010 import org.kde.i18n.localeData 1.0
0011 import org.kde.kirigami 2.10 as Kirigami
0012 import org.kde.kpublictransport 1.0 as KPublicTransport
0013 import org.kde.ktrip 1.0
0014 
0015 Kirigami.ScrollablePage {
0016     id: root
0017     title: i18n("Providers")
0018 
0019         header: Kirigami.InlineMessage {
0020         text: i18n("Select the providers relevant for your area")
0021         visible: true
0022     }
0023 
0024     actions.main: Kirigami.Action {
0025         text: i18n("Save")
0026         iconName: "emblem-ok-symbolic"
0027         onTriggered: pageStack.pop()
0028     }
0029 
0030     KPublicTransport.BackendModel {
0031         id: backendModel
0032         manager: Manager
0033     }
0034 
0035     Component {
0036         id: backendDelegate
0037         Kirigami.AbstractListItem {
0038             highlighted: false
0039             enabled: model.itemEnabled
0040 
0041             Item {
0042                 anchors.margins: Kirigami.Units.largeSpacing
0043                 implicitHeight: childrenRect.height
0044 
0045                 QQC2.Label {
0046                     id: nameLabel
0047                     text: model.name
0048                     anchors.left: parent.left
0049                     anchors.top: parent.top
0050                     anchors.right: securityIcon.left
0051                     anchors.rightMargin: Kirigami.Units.largeSpacing
0052                     // try to retain trailing abbreviations when we have to elide
0053                     elide: text.endsWith(")") ? Text.ElideMiddle : Text.ElideRight
0054                 }
0055                 Kirigami.Icon {
0056                     id: securityIcon
0057                     source: model.isSecure ? "channel-secure-symbolic" : "channel-insecure-symbolic"
0058                     color: model.isSecure ? Kirigami.Theme.positiveTextColor : Kirigami.Theme.negativeTextColor
0059                     width: height
0060                     height: Kirigami.Units.gridUnit
0061                     anchors.top: parent.top
0062                     anchors.right: toggle.left
0063                 }
0064                 QQC2.Switch {
0065                     id: toggle
0066                     checked: model.backendEnabled
0067                     onToggled: model.backendEnabled = checked;
0068                     anchors.top: parent.top
0069                     anchors.right: parent.right
0070                 }
0071                 QQC2.Label {
0072                     anchors.top: nameLabel.bottom
0073                     anchors.left: parent.left
0074                     anchors.right: toggle.left
0075                     anchors.topMargin: Kirigami.Units.smallSpacing
0076                     text: model.description
0077                     font.italic: true
0078                     wrapMode: Text.WordWrap
0079                 }
0080             }
0081 
0082             onClicked: {
0083                 toggle.toggle(); // does not trigger the signal handler for toggled...
0084                 model.backendEnabled = toggle.checked;
0085             }
0086         }
0087     }
0088 
0089     ListView {
0090         model: backendModel
0091         delegate: backendDelegate
0092 
0093         section.property: "countryCode"
0094         section.delegate: Kirigami.ListSectionHeader {
0095             text: {
0096                 switch (section) {
0097                     case "":
0098                     case "UN":
0099                         return i18n("Global")
0100                     case "EU":
0101                         return i18n("🇪🇺 European Union");
0102                     default:
0103                         const c = Country.fromAlpha2(section);
0104                         return i18nc("emoji flag, country name", "%1 %2", c.emojiFlag, c.name);
0105                 }
0106             }
0107         }
0108         section.criteria: ViewSection.FullString
0109         section.labelPositioning: ViewSection.CurrentLabelAtStart | ViewSection.InlineLabels
0110     }
0111 }