Warning, /plasma/plasma-firewall/kcm/ui/SimpleRuleEdit.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0002 // SPDX-FileCopyrightText: 2018 Alexis Lopes Zubeta <contact@azubieta.net>
0003 // SPDX-FileCopyrightText: 2020 Tomaz Canabrava <tcanabrava@kde.org>
0004 
0005 import QtQuick 2.12
0006 import QtQuick.Controls 2.0
0007 import QtQuick.Layouts 1.1
0008 
0009 import QtQuick.Controls 2.12 as QQC2
0010 import org.kde.kirigami 2.4 as Kirigami
0011 
0012 import org.kcm.firewall 1.0 as Firewall
0013 
0014 Kirigami.FormLayout {
0015     property alias service : application.model
0016     property alias index: application.currentIndex
0017     property alias policy: policy
0018     property alias incoming: incoming
0019 
0020     QQC2.ComboBox {
0021         id: application
0022         Kirigami.FormData.label: kcm.client.name == "firewalld" ?
0023 i18n("Allow connections for:") : i18n("Application:")
0024         model: kcm.client.knownApplications()
0025     }
0026 
0027     QQC2.ComboBox {
0028         id: policy
0029         Kirigami.FormData.label: i18n("Policy:")
0030         model: policyChoices
0031         textRole: "text"
0032         currentIndex: rule.policy == "" ? 0 : policyChoices.findIndex((policy) => policy.data == rule.policy)
0033         visible: kcm.client.name != "firewalld"
0034         onActivated: index => {
0035             rule.policy = policyChoices[index].data;
0036         }
0037     }
0038 
0039     RowLayout {
0040         Kirigami.FormData.label: i18n("Direction:")
0041         visible: kcm.client.name != "firewalld"
0042         QQC2.RadioButton {
0043             id: incoming
0044             text: i18n("Incoming")
0045             icon.name: "arrow-down"
0046             checked: rule.incoming
0047             onClicked: rule.incoming = true
0048         }
0049         QQC2.RadioButton {
0050             text: i18n("Outgoing")
0051             icon.name: "arrow-up"
0052             checked: !rule.incoming
0053             onClicked: rule.incoming = false
0054         }
0055     }
0056 
0057     onVisibleChanged: {
0058         console.log("services available: ", kcm.client.knownApplications());
0059         application.model = kcm.client.knownApplications();
0060         application.currentIndex = -1;
0061     }
0062 }