SettingsPage.qml 3.85 KB
Newer Older
Volker Krause's avatar
Volker Krause committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*
    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
15
    along with this program.  If not, see <https://www.gnu.org/licenses/>.
Volker Krause's avatar
Volker Krause committed
16 17 18 19 20 21 22 23 24 25 26
*/

import QtQuick 2.5
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.1 as QQC2
import org.kde.kirigami 2.4 as Kirigami
import org.kde.itinerary 1.0
import "." as App

Kirigami.ScrollablePage {
    id: root
Volker Krause's avatar
Volker Krause committed
27
    title: i18n("Settings")
Volker Krause's avatar
Volker Krause committed
28

29 30 31 32
    CountryModel {
        id: countryModel
    }

33
    Kirigami.FormLayout {
Volker Krause's avatar
Volker Krause committed
34 35
        width: root.width

36 37 38 39 40
        Kirigami.Separator {
            Kirigami.FormData.isSection: true
            Kirigami.FormData.label: i18n("Home")
        }

Volker Krause's avatar
Volker Krause committed
41
        QQC2.ComboBox {
42
            Kirigami.FormData.label: i18n("Home Country")
43 44
            model: countryModel
            textRole: "display"
45 46
            currentIndex: countryModel.isoCodeToIndex(_settings.homeCountryIsoCode)
            onActivated: _settings.homeCountryIsoCode = countryModel.isoCodeFromIndex(currentIndex)
Volker Krause's avatar
Volker Krause committed
47 48
        }

49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
        Kirigami.Separator {
            Kirigami.FormData.isSection: true
            Kirigami.FormData.label: i18n("Online Services")
        }

        QQC2.Switch {
            Kirigami.FormData.label: i18n("Query Traffic Data")
            checked: _settings.queryLiveData
            onToggled: _settings.queryLiveData = checked
        }
        QQC2.Label {
            Kirigami.FormData.isSection: true
            Layout.fillWidth: true
            wrapMode: Text.WordWrap
            text: i18n("When enabled, this will query transport provider online services for changes such as delays or gate and platform changes.")
        }
        QQC2.Switch {
            Kirigami.FormData.label: i18n("Use insecure services")
            checked: _settings.allowInsecureServices
            onToggled: _settings.allowInsecureServices = checked
        }
        QQC2.Label {
            Kirigami.FormData.isSection: true
            Layout.fillWidth: true
            wrapMode: Text.WordWrap
            text: i18n("Enabling this will also use online services that do not offer transport encryption. This is not recommended, but might be unavoidable when relying on live data from certain providers.")
            color: Kirigami.Theme.negativeTextColor
        }

Volker Krause's avatar
Volker Krause committed
78 79
        QQC2.Switch {
            id: weatherSwitch
80
            Kirigami.FormData.label: i18n("Weather Forecast")
81 82
            checked: _settings.weatherForecastEnabled
            onToggled: _settings.weatherForecastEnabled = checked
Volker Krause's avatar
Volker Krause committed
83 84
        }
        QQC2.Label {
85
            Kirigami.FormData.isSection: true
Volker Krause's avatar
Volker Krause committed
86
            Layout.fillWidth: true
Nicolas Fella's avatar
Nicolas Fella committed
87
            wrapMode: Text.WordWrap
Volker Krause's avatar
Volker Krause committed
88
            text: i18n("Showing weather forecasts will query online services.")
Volker Krause's avatar
Volker Krause committed
89 90 91 92
            visible: !weatherSwitch.checked
        }
        // ATTENTION do not remove this note, see https://api.met.no/license_data.html
        QQC2.Label {
93
            Kirigami.FormData.isSection:true
Volker Krause's avatar
Volker Krause committed
94
            Layout.fillWidth: true
Volker Krause's avatar
Volker Krause committed
95
            text: i18n("Using data from <a href=\"https://www.met.no/\">The Norwegian Meteorological Institute</a> under <a href=\"https://creativecommons.org/licenses/by/4.0\">Creative Commons 4.0 BY International</a> license.")
Volker Krause's avatar
Volker Krause committed
96 97 98 99 100 101 102 103
            visible: weatherSwitch.checked
            wrapMode: Text.WordWrap
            onLinkActivated: Qt.openUrlExternally(link)
        }
    }

    onBackRequested: pageStack.pop()
}