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.kirigamiaddons.components 1.0 as Components
0013 import org.kde.kirigamiaddons.delegates 1.0 as Delegates
0014 import org.kde.kpublictransport 1.0 as KPublicTransport
0015 import org.kde.ktrip 1.0
0016 
0017 Kirigami.ScrollablePage {
0018     id: root
0019 
0020     title: i18n("Providers")
0021 
0022     header: Components.Banner {
0023         text: i18n("Select the providers relevant for your area")
0024         visible: true
0025     }
0026 
0027     actions: [
0028         Kirigami.Action {
0029             text: i18n("Save")
0030             icon.name: "emblem-ok-symbolic"
0031             onTriggered: pageStack.pop()
0032         }
0033     ]
0034 
0035     KPublicTransport.BackendModel {
0036         id: backendModel
0037         manager: Manager
0038     }
0039 
0040     Component {
0041         id: backendDelegate
0042 
0043         Delegates.RoundedItemDelegate {
0044             enabled: model.itemEnabled
0045 
0046             contentItem: Item {
0047                 anchors.margins: Kirigami.Units.largeSpacing
0048                 implicitHeight: childrenRect.height
0049 
0050                 QQC2.Label {
0051                     id: nameLabel
0052                     text: model.name
0053                     anchors.left: parent.left
0054                     anchors.top: parent.top
0055                     anchors.right: securityIcon.left
0056                     anchors.rightMargin: Kirigami.Units.largeSpacing
0057                     // try to retain trailing abbreviations when we have to elide
0058                     elide: text.endsWith(")") ? Text.ElideMiddle : Text.ElideRight
0059                 }
0060                 Kirigami.Icon {
0061                     id: securityIcon
0062                     source: model.isSecure ? "channel-secure-symbolic" : "channel-insecure-symbolic"
0063                     color: model.isSecure ? Kirigami.Theme.positiveTextColor : Kirigami.Theme.negativeTextColor
0064                     width: height
0065                     height: Kirigami.Units.gridUnit
0066                     anchors.top: parent.top
0067                     anchors.right: toggle.left
0068                 }
0069                 QQC2.Switch {
0070                     id: toggle
0071                     checked: model.backendEnabled
0072                     onToggled: model.backendEnabled = checked
0073                     anchors.top: parent.top
0074                     anchors.right: parent.right
0075                 }
0076                 QQC2.Label {
0077                     anchors.top: nameLabel.bottom
0078                     anchors.left: parent.left
0079                     anchors.right: toggle.left
0080                     anchors.topMargin: Kirigami.Units.smallSpacing
0081                     text: model.description
0082                     font.italic: true
0083                     wrapMode: Text.WordWrap
0084                 }
0085             }
0086 
0087             onClicked: {
0088                 toggle.toggle(); // does not trigger the signal handler for toggled...
0089                 model.backendEnabled = toggle.checked;
0090             }
0091         }
0092     }
0093 
0094     ListView {
0095         model: backendModel
0096         delegate: backendDelegate
0097 
0098         section {
0099             property: "countryCode"
0100             delegate: Kirigami.ListSectionHeader {
0101                 text: {
0102                     switch (section) {
0103                     case "":
0104                     case "UN":
0105                         return i18n("Global");
0106                     case "EU":
0107                         return i18n("🇪🇺 European Union");
0108                     default:
0109                         const c = Country.fromAlpha2(section);
0110                         return i18nc("emoji flag, country name", "%1 %2", c.emojiFlag, c.name);
0111                     }
0112                 }
0113             }
0114             criteria: ViewSection.FullString
0115         }
0116     }
0117 }