2017-09-01 13:13:12 +00:00
|
|
|
import QtQuick 2.9
|
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
import QtQuick.Controls 2.2
|
2017-09-02 12:52:39 +00:00
|
|
|
import "apps"
|
2017-09-02 10:17:51 +00:00
|
|
|
import com.fortfirewall 1.0
|
2017-09-01 13:13:12 +00:00
|
|
|
|
2017-09-01 15:13:17 +00:00
|
|
|
BasePage {
|
|
|
|
|
2017-09-02 12:52:39 +00:00
|
|
|
readonly property var appGroups: firewallConf.appGroups
|
2017-09-05 14:12:31 +00:00
|
|
|
readonly property int appGroupsCount: appGroups.length
|
2017-09-02 12:52:39 +00:00
|
|
|
|
|
|
|
function resetGroupName() {
|
|
|
|
editGroupName.text = "";
|
|
|
|
editGroupName.forceActiveFocus();
|
|
|
|
}
|
|
|
|
|
2017-09-05 14:32:11 +00:00
|
|
|
function addAppGroup() {
|
|
|
|
const lastIndex = appGroups.length;
|
|
|
|
firewallConf.addAppGroupByName(editGroupName.text);
|
|
|
|
barGroups.currentIndex = lastIndex;
|
|
|
|
resetGroupName();
|
|
|
|
}
|
|
|
|
|
|
|
|
function removeAppGroup(index) {
|
|
|
|
firewallConf.removeAppGroup(index, index);
|
|
|
|
var lastIndex = appGroupsCount - 1;
|
|
|
|
barGroups.currentIndex = (index < appGroupsCount)
|
|
|
|
? index : appGroupsCount - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
function renameAppGroup() {
|
|
|
|
const appGroup = appsColumn.appGroup;
|
|
|
|
appGroup.name = editGroupName.text;
|
|
|
|
resetGroupName();
|
|
|
|
}
|
|
|
|
|
2017-09-05 14:12:31 +00:00
|
|
|
function moveAppGroup(index, step) {
|
|
|
|
var toIndex = index + step;
|
|
|
|
if (toIndex < 0)
|
|
|
|
toIndex = appGroupsCount - 1;
|
|
|
|
else if (toIndex >= appGroupsCount)
|
|
|
|
toIndex = 0;
|
|
|
|
|
|
|
|
firewallConf.moveAppGroup(index, toIndex);
|
|
|
|
barGroups.currentIndex = toIndex;
|
|
|
|
}
|
|
|
|
|
2017-09-02 10:17:51 +00:00
|
|
|
ColumnLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
RowLayout {
|
2017-09-02 12:52:39 +00:00
|
|
|
TextField {
|
2017-09-05 14:12:31 +00:00
|
|
|
enabled: appGroupsCount < 16
|
2017-09-02 12:52:39 +00:00
|
|
|
id: editGroupName
|
|
|
|
placeholderText: QT_TRANSLATE_NOOP("qml", "Group Name")
|
|
|
|
}
|
2017-09-02 10:17:51 +00:00
|
|
|
Button {
|
2017-09-02 12:52:39 +00:00
|
|
|
enabled: editGroupName.text
|
2017-09-02 10:17:51 +00:00
|
|
|
text: QT_TRANSLATE_NOOP("qml", "Add Group")
|
2017-09-05 14:32:11 +00:00
|
|
|
onClicked: addAppGroup()
|
2017-09-02 10:17:51 +00:00
|
|
|
}
|
|
|
|
Button {
|
2017-09-02 13:14:12 +00:00
|
|
|
enabled: editGroupName.text && appsColumn.enabled
|
2017-09-02 12:52:39 +00:00
|
|
|
text: QT_TRANSLATE_NOOP("qml", "Rename Group")
|
2017-09-05 14:32:11 +00:00
|
|
|
onClicked: removeAppGroup()
|
2017-09-02 10:17:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
|
|
|
CheckBox {
|
|
|
|
text: QT_TRANSLATE_NOOP("qml", "Block All")
|
2017-09-02 12:52:39 +00:00
|
|
|
checked: firewallConf.appBlockAll
|
|
|
|
onToggled: {
|
|
|
|
firewallConf.appBlockAll = checked;
|
|
|
|
}
|
2017-09-02 10:17:51 +00:00
|
|
|
}
|
|
|
|
CheckBox {
|
|
|
|
text: QT_TRANSLATE_NOOP("qml", "Allow All")
|
2017-09-02 12:52:39 +00:00
|
|
|
checked: firewallConf.appAllowAll
|
|
|
|
onToggled: {
|
|
|
|
firewallConf.appAllowAll = checked;
|
|
|
|
}
|
2017-09-02 10:17:51 +00:00
|
|
|
}
|
|
|
|
}
|
2017-09-01 15:13:17 +00:00
|
|
|
|
2017-09-02 10:17:51 +00:00
|
|
|
TabBar {
|
|
|
|
id: barGroups
|
|
|
|
Layout.fillWidth: true
|
2017-09-02 12:52:39 +00:00
|
|
|
clip: true
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
id: rptAppGroups
|
|
|
|
model: appGroups
|
2017-09-02 10:17:51 +00:00
|
|
|
|
2017-09-02 12:52:39 +00:00
|
|
|
TabButton {
|
2017-09-06 10:24:03 +00:00
|
|
|
width: Math.max(100, implicitWidth)
|
2017-09-03 07:10:36 +00:00
|
|
|
font.bold: checked
|
2017-09-02 12:52:39 +00:00
|
|
|
text: appGroup.name
|
2017-09-06 10:24:03 +00:00
|
|
|
icon.source: "qrc:/images/application_double.png"
|
2017-09-02 12:52:39 +00:00
|
|
|
|
|
|
|
readonly property AppGroup appGroup: modelData
|
|
|
|
}
|
2017-09-02 10:17:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-02 14:25:47 +00:00
|
|
|
Frame {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: 1
|
|
|
|
}
|
|
|
|
|
2017-09-02 12:52:39 +00:00
|
|
|
AppsColumn {
|
|
|
|
id: appsColumn
|
2017-09-02 10:17:51 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2017-09-02 12:52:39 +00:00
|
|
|
|
|
|
|
enabled: index >= 0
|
|
|
|
opacity: enabled ? 1.0 : 0
|
|
|
|
|
|
|
|
Behavior on opacity { NumberAnimation { duration: 150 } }
|
|
|
|
|
|
|
|
index: barGroups.currentIndex
|
|
|
|
appGroup: enabled ? barGroups.currentItem.appGroup
|
|
|
|
: nullAppGroup
|
|
|
|
|
|
|
|
readonly property AppGroup nullAppGroup: AppGroup {}
|
2017-09-02 10:17:51 +00:00
|
|
|
}
|
|
|
|
}
|
2017-09-01 13:13:12 +00:00
|
|
|
}
|