fort/src/ui/qml/pages/StatisticsPage.qml

242 lines
7.8 KiB
QML
Raw Normal View History

2017-11-20 07:50:16 +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-11-20 07:50:16 +00:00
import "../controls"
2017-12-05 05:06:15 +00:00
import "log"
2017-11-20 07:50:16 +00:00
import com.fortfirewall 1.0
BasePage {
id: statisticsPage
2017-11-20 07:50:16 +00:00
readonly property LogManager logManager: fortManager.logManager
2017-12-05 05:06:15 +00:00
readonly property AppStatModel appStatModel: logManager.appStatModel
readonly property TrafListModel trafListModel:
appStatModel.trafListModel(tabBar.currentIndex,
appListView.currentIndex,
currentAppPath)
2017-12-05 05:06:15 +00:00
readonly property string currentAppPath:
(appListView.currentIndex >= 0 && appListView.currentItem)
? appListView.currentItem.appPath : ""
2017-11-20 07:50:16 +00:00
readonly property var trafCellWidths: [
trafsContainer.width * 0.34,
trafsContainer.width * 0.22,
trafsContainer.width * 0.22,
trafsContainer.width * 0.22
]
2017-12-11 06:05:49 +00:00
readonly property var trafUnitNames:
translationManager.dummyBool
&& [
qsTranslate("qml", "Adaptive"),
qsTranslate("qml", "Bytes"),
qsTranslate("qml", "KiB"),
qsTranslate("qml", "MiB"),
qsTranslate("qml", "GiB"),
qsTranslate("qml", "TiB")
]
2017-11-20 07:50:16 +00:00
ColumnLayout {
anchors.fill: parent
spacing: 10
RowLayout {
Button {
enabled: appListView.count
icon.source: "qrc:/images/arrow_refresh.png"
text: translationManager.dummyBool
&& qsTranslate("qml", "Refresh")
onClicked: trafListModel.refresh()
}
2017-12-14 10:40:39 +00:00
ButtonMenu {
enabled: appListView.count
icon.source: "qrc:/images/bin_empty.png"
text: translationManager.dummyBool
2017-12-19 11:20:14 +00:00
&& qsTranslate("qml", "Clear…")
2017-12-14 10:40:39 +00:00
MenuItem {
enabled: appListView.currentIndex > 0
text: translationManager.dummyBool
&& qsTranslate("qml", "Remove Application")
onTriggered: appStatModel.remove(
appListView.currentIndex)
}
MenuItem {
text: translationManager.dummyBool
&& qsTranslate("qml", "Reset Total")
onTriggered: trafListModel.resetAppTotals()
}
MenuItem {
text: translationManager.dummyBool
&& qsTranslate("qml", "Clear All")
onTriggered: {
appListView.currentIndex = 0;
appStatModel.clear();
}
}
}
TrafKeepButton {}
2017-12-11 06:05:49 +00:00
Row {
spacing: 5
Item {
width: 1
height: 1
}
2017-12-11 06:05:49 +00:00
Label {
anchors.verticalCenter: parent.verticalCenter
text: translationManager.dummyBool
&& qsTranslate("qml", "Units:")
}
ComboBox {
id: comboTrafUnit
currentIndex: firewallConf.trafUnit
model: trafUnitNames
onModelChanged: {
currentIndex = firewallConf.trafUnit;
}
2017-12-11 06:05:49 +00:00
onActivated: {
firewallConf.trafUnit = index;
fortManager.applyConfImmediateFlags();
2017-12-11 06:05:49 +00:00
trafListModel.refresh();
}
}
}
2017-11-20 07:50:16 +00:00
Item {
Layout.fillWidth: true
}
Switch {
id: cbShowBlockedApps
font.weight: Font.DemiBold
text: translationManager.dummyBool
2017-11-20 14:39:57 +00:00
&& qsTranslate("qml", "Collect Traffic Statistics")
checked: firewallConf.logStat
onToggled: {
if (firewallConf.logStat === checked)
return;
firewallConf.logStat = checked;
fortManager.applyConfImmediateFlags();
2017-11-20 14:39:57 +00:00
}
2017-11-20 07:50:16 +00:00
}
}
Frame {
Layout.fillWidth: true
Layout.fillHeight: true
clip: true
2017-12-05 05:06:15 +00:00
RowLayout {
anchors.fill: parent
spacing: 20
AppListView {
id: appListView
Layout.fillWidth: true
2017-12-05 12:50:10 +00:00
Layout.preferredWidth: 100
2017-12-05 05:06:15 +00:00
Layout.fillHeight: true
model: appStatModel
2017-12-05 12:50:10 +00:00
emptyText: translationManager.dummyBool
&& qsTranslate("qml", "All")
emptyIcon: "qrc:/images/application_double.png"
2017-12-05 05:06:15 +00:00
}
ColumnLayout {
id: trafsContainer
Layout.fillWidth: true
Layout.preferredWidth: 200
Layout.fillHeight: true
spacing: 10
TabBar {
id: tabBar
Layout.fillWidth: true
TabButton {
text: translationManager.dummyBool
2017-12-06 02:07:30 +00:00
&& qsTranslate("qml", "Hourly", "Stat")
}
TabButton {
text: translationManager.dummyBool
2017-12-06 02:07:30 +00:00
&& qsTranslate("qml", "Daily", "Stat")
}
TabButton {
text: translationManager.dummyBool
2017-12-06 02:07:30 +00:00
&& qsTranslate("qml", "Monthly", "Stat")
}
TabButton {
text: translationManager.dummyBool
2017-12-06 02:07:30 +00:00
&& qsTranslate("qml", "Total", "Stat")
}
}
Row {
Layout.fillWidth: true
spacing: 0
Label {
width: trafCellWidths[0]
text: translationManager.dummyBool
&& qsTranslate("qml", "Date")
}
Label {
width: trafCellWidths[1]
text: translationManager.dummyBool
&& qsTranslate("qml", "Download")
}
Label {
width: trafCellWidths[2]
text: translationManager.dummyBool
&& qsTranslate("qml", "Upload")
}
Label {
width: trafCellWidths[3]
text: translationManager.dummyBool
&& qsTranslate("qml", "Sum")
}
}
Frame {
Layout.fillWidth: true
Layout.preferredHeight: 1
}
ListView {
id: trafListView
Layout.fillWidth: true
Layout.fillHeight: true
spacing: 5
clip: true
model: trafListModel
delegate: TrafRow {}
ScrollBar.vertical: ScrollBarControl {}
}
}
2017-12-05 05:06:15 +00:00
}
}
TextFieldFrame {
Layout.fillWidth: true
text: currentAppPath || ""
2017-11-20 07:50:16 +00:00
}
}
}