UI: Improve app groups handling.

This commit is contained in:
Nodir Temirkhodjaev 2017-09-05 19:32:11 +05:00
parent b8c58cce82
commit 9e32f39fb1
3 changed files with 24 additions and 15 deletions

View File

@ -155,7 +155,7 @@ BasePage {
Switch { Switch {
id: cbShowBlockedApps id: cbShowBlockedApps
text: QT_TRANSLATE_NOOP("qml", "Show Blocked Applications and Addresses") text: QT_TRANSLATE_NOOP("qml", "Log Blocked Applications")
onToggled: switchLogReading(checked) onToggled: switchLogReading(checked)
} }
} }

View File

@ -14,6 +14,26 @@ BasePage {
editGroupName.forceActiveFocus(); editGroupName.forceActiveFocus();
} }
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();
}
function moveAppGroup(index, step) { function moveAppGroup(index, step) {
var toIndex = index + step; var toIndex = index + step;
if (toIndex < 0) if (toIndex < 0)
@ -37,21 +57,12 @@ BasePage {
Button { Button {
enabled: editGroupName.text enabled: editGroupName.text
text: QT_TRANSLATE_NOOP("qml", "Add Group") text: QT_TRANSLATE_NOOP("qml", "Add Group")
onClicked: { onClicked: addAppGroup()
const lastIndex = appGroups.length;
firewallConf.addAppGroupByName(editGroupName.text);
barGroups.currentIndex = lastIndex;
resetGroupName();
}
} }
Button { Button {
enabled: editGroupName.text && appsColumn.enabled enabled: editGroupName.text && appsColumn.enabled
text: QT_TRANSLATE_NOOP("qml", "Rename Group") text: QT_TRANSLATE_NOOP("qml", "Rename Group")
onClicked: { onClicked: removeAppGroup()
const appGroup = appsColumn.appGroup;
appGroup.name = editGroupName.text;
resetGroupName();
}
} }
Item { Item {

View File

@ -11,9 +11,7 @@ ColumnLayout {
RowLayout { RowLayout {
Button { Button {
text: QT_TRANSLATE_NOOP("qml", "Remove Group") text: QT_TRANSLATE_NOOP("qml", "Remove Group")
onClicked: { onClicked: removeAppGroup(index)
firewallConf.removeAppGroup(index, index);
}
} }
Button { Button {
text: QT_TRANSLATE_NOOP("qml", "Move left") text: QT_TRANSLATE_NOOP("qml", "Move left")