fort/src/ui/qml/pages/MainPage.qml

144 lines
3.9 KiB
QML
Raw Normal View History

2017-09-03 05:57:35 +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-09-03 05:57:35 +00:00
import com.fortfirewall 1.0
Page {
2017-09-03 06:49:58 +00:00
id: mainPage
2017-09-04 11:39:15 +00:00
signal opened()
signal closed()
signal aboutToSave()
2017-09-03 06:49:58 +00:00
signal saved()
2017-09-03 05:57:35 +00:00
2017-09-07 05:34:18 +00:00
property bool confFlagsEdited
property bool confEdited
2017-09-21 13:46:34 +00:00
property bool scheduleEdited
2017-09-07 05:34:18 +00:00
function setConfFlagsEdited() {
confFlagsEdited = true;
}
function setConfEdited() {
confEdited = true;
}
2017-09-21 13:46:34 +00:00
function setScheduleEdited() {
scheduleEdited = true;
}
function resetEdited() {
2017-09-07 05:34:18 +00:00
confFlagsEdited = false;
confEdited = false;
2017-09-21 13:46:34 +00:00
scheduleEdited = false;
2017-09-07 05:34:18 +00:00
}
2017-09-04 11:39:15 +00:00
onOpened: {
2017-09-21 13:46:34 +00:00
resetEdited();
2017-09-07 05:34:18 +00:00
2017-09-03 05:57:35 +00:00
tabBar.currentItem.forceActiveFocus();
}
header: TabBar {
id: tabBar
currentIndex: swipeView.currentIndex
TabButton {
2017-09-06 10:24:03 +00:00
icon.source: "qrc:/images/cog.png"
2017-09-07 10:44:15 +00:00
text: translationManager.dummyBool
&& qsTranslate("qml", "Options")
2017-09-03 05:57:35 +00:00
}
TabButton {
2017-09-06 10:24:03 +00:00
icon.source: "qrc:/images/link.png"
2017-09-07 10:44:15 +00:00
text: translationManager.dummyBool
&& qsTranslate("qml", "IPv4 Addresses")
2017-09-03 05:57:35 +00:00
}
TabButton {
2017-10-28 05:14:24 +00:00
icon.source: "qrc:/images/application_double.png"
2017-09-07 10:44:15 +00:00
text: translationManager.dummyBool
&& qsTranslate("qml", "Applications")
2017-09-03 05:57:35 +00:00
}
TabButton {
2017-11-20 15:28:52 +00:00
icon.source: "qrc:/images/application_error.png"
2017-09-07 10:44:15 +00:00
text: translationManager.dummyBool
&& qsTranslate("qml", "Blocked")
2017-09-03 05:57:35 +00:00
}
2017-11-20 07:50:16 +00:00
TabButton {
icon.source: "qrc:/images/chart_line.png"
text: translationManager.dummyBool
&& qsTranslate("qml", "Statistics")
}
2017-12-21 11:35:34 +00:00
TabButton {
icon.source: "qrc:/images/clock.png"
text: translationManager.dummyBool
&& qsTranslate("qml", "Schedule")
}
2017-09-03 05:57:35 +00:00
}
SwipeView {
id: swipeView
anchors.fill: parent
currentIndex: tabBar.currentIndex
OptionsPage {}
AddressesPage {}
ApplicationsPage {}
BlockedPage {}
2017-11-20 07:50:16 +00:00
StatisticsPage {}
2017-12-21 11:35:34 +00:00
SchedulePage {}
2017-09-03 05:57:35 +00:00
}
footer: Pane {
RowLayout {
anchors.right: parent.right
Button {
2017-09-21 13:46:34 +00:00
enabled: confFlagsEdited || confEdited || scheduleEdited
2017-11-20 15:28:52 +00:00
icon.source: "qrc:/images/tick.png"
2017-09-07 10:44:15 +00:00
text: translationManager.dummyBool
&& qsTranslate("qml", "OK")
2017-09-03 05:57:35 +00:00
onClicked: {
mainPage.aboutToSave();
2017-09-21 13:46:34 +00:00
if (confFlagsEdited || confEdited) {
if (!fortManager.saveConf(confFlagsEdited))
return;
2017-09-03 06:49:58 +00:00
}
2017-09-21 13:46:34 +00:00
mainPage.saved();
closeWindow();
2017-09-03 05:57:35 +00:00
}
}
Button {
2017-09-21 13:46:34 +00:00
enabled: confFlagsEdited || confEdited || scheduleEdited
2017-11-20 15:28:52 +00:00
icon.source: "qrc:/images/accept.png"
2017-09-07 10:44:15 +00:00
text: translationManager.dummyBool
&& qsTranslate("qml", "Apply")
2017-09-07 05:34:18 +00:00
onClicked: {
mainPage.aboutToSave();
2017-09-21 13:46:34 +00:00
if (confFlagsEdited || confEdited) {
if (!fortManager.applyConf(confFlagsEdited))
return;
2017-09-07 05:34:18 +00:00
}
2017-09-21 13:46:34 +00:00
mainPage.saved();
resetEdited();
2017-09-07 05:34:18 +00:00
}
2017-09-03 05:57:35 +00:00
}
Button {
2017-11-20 15:28:52 +00:00
icon.source: "qrc:/images/cancel.png"
2017-09-07 10:44:15 +00:00
text: translationManager.dummyBool
&& qsTranslate("qml", "Cancel")
2017-09-03 05:57:35 +00:00
onClicked: closeWindow()
}
Button {
2017-11-20 15:28:52 +00:00
icon.source: "qrc:/images/cross.png"
2017-09-07 10:44:15 +00:00
text: translationManager.dummyBool
&& qsTranslate("qml", "Quit")
2017-09-06 08:39:20 +00:00
onClicked: fortManager.exit()
2017-09-03 05:57:35 +00:00
}
}
}
}