Warning, /multimedia/kasts/src/qml/ConnectionCheckAction.qml is written in an unsupported language. File is not indexed.
0001 /**
0002 * SPDX-FileCopyrightText: 2021 Bart De Vries <bart@mogwai.be>
0003 *
0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005 */
0006
0007 import QtQuick
0008 import QtQuick.Controls as Controls
0009 import QtQuick.Layouts
0010
0011 import org.kde.kirigami as Kirigami
0012 import org.kde.kirigamiaddons.delegates as Delegates
0013
0014 import org.kde.kasts
0015 import org.kde.kasts.settings
0016
0017 Kirigami.Dialog {
0018 id: overlay
0019 parent: applicationWindow().overlay
0020 closePolicy: Kirigami.Dialog.CloseOnEscape | Kirigami.Dialog.CloseOnPressOutside
0021
0022 property string headingText: i18nc("@info:status", "Podcast updates are currently not allowed on metered connections")
0023 property bool condition: NetworkConnectionManager.feedUpdatesAllowed
0024
0025 // Function to be overloaded where this is instantiated with another purpose
0026 // than refreshing all feeds
0027 function action() {
0028 Fetcher.fetchAll();
0029 }
0030
0031 // This function will be executed when "Don't allow" is chosen; can be overloaded
0032 function abortAction() { }
0033
0034 // This function will be executed when the "Allow once" action is chosen; can be overloaded
0035 function allowOnceAction() {
0036 action()
0037 }
0038
0039 // This function will be executed when the "Always allow" action is chosed; can be overloaded
0040 function alwaysAllowAction() {
0041 SettingsManager.allowMeteredFeedUpdates = true;
0042 SettingsManager.save();
0043 action()
0044 }
0045
0046 // this is the function that should be called if the action should be
0047 // triggered conditionally (on the basis that the condition is passed)
0048 function run() {
0049 if (condition) {
0050 action();
0051 } else {
0052 overlay.open();
0053 }
0054 }
0055
0056 title: NetworkConnectionManager.networkReachable ? i18nc("@title:window", "Select Option") : i18nc("@title:window", "Network not reachable")
0057
0058 ColumnLayout {
0059 spacing: 0
0060
0061 Controls.Label {
0062 Layout.topMargin: Kirigami.Units.largeSpacing
0063 Layout.bottomMargin: Kirigami.Units.largeSpacing
0064 Layout.leftMargin: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
0065 Layout.rightMargin: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
0066 Layout.fillWidth: true
0067 text: NetworkConnectionManager.networkReachable ? headingText : i18nc("@info:status", "It seems the network cannot be reached. If this is incorrect, this check can be disabled through: Settings > Network.")
0068 wrapMode: Text.Wrap
0069 color: NetworkConnectionManager.networkReachable ?Kirigami.Theme.disabledTextColor : Kirigami.Theme.textColor
0070 }
0071
0072 Kirigami.Separator {
0073 visible: NetworkConnectionManager.networkReachable
0074 Layout.fillWidth: true
0075 opacity: 0.5
0076 }
0077
0078 Delegates.RoundedItemDelegate {
0079 visible: NetworkConnectionManager.networkReachable
0080 Layout.fillWidth: true
0081 Layout.preferredHeight: Kirigami.Units.gridUnit * 2
0082 leftPadding: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
0083 rightPadding: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
0084
0085 text: i18n("Don't Allow")
0086 onClicked: {
0087 abortAction();
0088 close();
0089 }
0090 }
0091
0092 Delegates.RoundedItemDelegate {
0093 visible: NetworkConnectionManager.networkReachable
0094 Layout.fillWidth: true
0095 Layout.preferredHeight: Kirigami.Units.gridUnit * 2
0096 leftPadding: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
0097 rightPadding: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
0098
0099 text: i18n("Allow Once")
0100 onClicked: {
0101 allowOnceAction();
0102 close();
0103 }
0104 }
0105
0106 Delegates.RoundedItemDelegate {
0107 visible: NetworkConnectionManager.networkReachable
0108 Layout.fillWidth: true
0109 Layout.preferredHeight: Kirigami.Units.gridUnit * 2
0110 leftPadding: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
0111 rightPadding: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
0112
0113 text: i18n("Always Allow")
0114 onClicked: {
0115 alwaysAllowAction();
0116 close();
0117 }
0118 }
0119 }
0120 }