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

201 lines
6.2 KiB
QML
Raw Normal View History

2017-11-20 07:50:16 +00:00
import QtQuick 2.9
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.2
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)
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.4,
trafsContainer.width * 0.2,
trafsContainer.width * 0.2,
trafsContainer.width * 0.2
]
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 {
2017-12-11 06:05:49 +00:00
spacing: 15
Button {
enabled: appListView.currentIndex >= 0
text: translationManager.dummyBool
&& qsTranslate("qml", "Refresh")
onClicked: trafListModel.refresh()
}
2017-12-11 06:05:49 +00:00
Row {
spacing: 5
Label {
anchors.verticalCenter: parent.verticalCenter
text: translationManager.dummyBool
&& qsTranslate("qml", "Units:")
}
ComboBox {
id: comboTrafUnit
currentIndex: firewallConf.trafUnit
model: trafUnitNames
onActivated: {
firewallConf.trafUnit = index;
fortManager.applyConfImmediateValues();
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;
2017-12-11 06:05:49 +00:00
fortManager.applyConfImmediateValues();
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: 4
clip: true
model: trafListModel
delegate: TrafRow {}
}
}
2017-12-05 05:06:15 +00:00
}
}
TextFieldFrame {
Layout.fillWidth: true
text: currentAppPath || ""
2017-11-20 07:50:16 +00:00
}
}
}