fort/src/ui/qml/pages/ApplicationsPage.qml

155 lines
4.3 KiB
QML
Raw Normal View History

2017-09-01 13:13:12 +00:00
import QtQuick 2.9
import QtQuick.Controls 2.2
2017-12-14 08:44:10 +00:00
import QtQuick.Layouts 1.3
2017-10-26 03:52:49 +00:00
import "../controls"
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();
2017-09-07 05:34:18 +00:00
setConfEdited();
2017-09-05 14:32:11 +00:00
}
function removeAppGroup(index) {
firewallConf.removeAppGroup(index, index);
var lastIndex = appGroupsCount - 1;
barGroups.currentIndex = (index < appGroupsCount)
? index : appGroupsCount - 1;
2017-09-07 05:34:18 +00:00
setConfEdited();
2017-09-05 14:32:11 +00:00
}
function renameAppGroup() {
const appGroup = appsColumn.appGroup;
appGroup.name = editGroupName.text;
resetGroupName();
2017-09-07 05:34:18 +00:00
setConfEdited();
2017-09-05 14:32:11 +00:00
}
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-07 05:34:18 +00:00
setConfEdited();
2017-09-05 14:12:31 +00:00
}
2017-09-02 10:17:51 +00:00
ColumnLayout {
anchors.fill: parent
RowLayout {
2017-10-26 03:52:49 +00:00
TextFieldFrame {
2017-09-02 12:52:39 +00:00
id: editGroupName
2017-10-26 03:52:49 +00:00
enabled: appGroupsCount < 16
2017-09-07 10:44:15 +00:00
placeholderText: translationManager.dummyBool
&& qsTranslate("qml", "Group Name")
2017-09-02 12:52:39 +00:00
}
2017-09-02 10:17:51 +00:00
Button {
2017-09-02 12:52:39 +00:00
enabled: editGroupName.text
2017-10-28 05:14:24 +00:00
icon.source: "qrc:/images/application_add.png"
2017-09-07 10:44:15 +00:00
text: translationManager.dummyBool
&& qsTranslate("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-10-28 05:14:24 +00:00
icon.source: "qrc:/images/application_edit.png"
2017-09-07 10:44:15 +00:00
text: translationManager.dummyBool
&& qsTranslate("qml", "Rename Group")
2017-09-07 05:46:50 +00:00
onClicked: renameAppGroup()
2017-09-02 10:17:51 +00:00
}
Item {
Layout.fillWidth: true
}
CheckBox {
id: cbBlockAll
enabled: !cbAllowAll.checked || checked
2017-09-07 10:44:15 +00:00
text: translationManager.dummyBool
&& qsTranslate("qml", "Block All")
2017-09-02 12:52:39 +00:00
checked: firewallConf.appBlockAll
onToggled: {
firewallConf.appBlockAll = checked;
2017-09-07 05:34:18 +00:00
setConfFlagsEdited();
2017-09-02 12:52:39 +00:00
}
2017-09-02 10:17:51 +00:00
}
CheckBox {
id: cbAllowAll
enabled: !cbBlockAll.checked || checked
2017-09-07 10:44:15 +00:00
text: translationManager.dummyBool
&& qsTranslate("qml", "Allow All")
2017-09-02 12:52:39 +00:00
checked: firewallConf.appAllowAll
onToggled: {
firewallConf.appAllowAll = checked;
2017-09-07 05:34:18 +00:00
setConfFlagsEdited();
2017-09-02 12:52:39 +00:00
}
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-10-28 05:14:24 +00:00
icon.source: "qrc:/images/application.png"
2017-09-06 12:06:14 +00:00
text: appGroup.name
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
}