Files
amnezia-client/client/ui/qml/Pages2/PageSettingsLogging.qml
T

230 lines
7.0 KiB
QML
Raw Normal View History

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
2023-08-30 15:10:44 +05:00
import QtQuick.Dialogs
import QtCore
import PageEnum 1.0
2024-07-07 13:42:38 +03:00
import Style 1.0
import "../Controls2"
import "../Config"
import "../Components"
import "../Controls2/TextTypes"
PageType {
id: root
BackButtonType {
id: backButton
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
}
2024-12-31 04:16:52 +01:00
ListView {
id: listView
anchors.top: backButton.bottom
anchors.bottom: parent.bottom
2024-12-31 04:16:52 +01:00
anchors.right: parent.right
anchors.left: parent.left
property bool isFocusable: true
2024-12-31 04:16:52 +01:00
ScrollBar.vertical: ScrollBarType {}
2024-12-31 04:16:52 +01:00
header: ColumnLayout {
width: listView.width
2025-05-02 23:54:36 -07:00
BaseHeaderType {
Layout.fillWidth: true
2024-09-09 20:53:44 +04:00
Layout.leftMargin: 16
Layout.rightMargin: 16
headerText: qsTr("Logging")
2024-06-19 02:14:22 +03:00
descriptionText: qsTr("Enabling this function will save application's logs automatically. " +
2024-03-26 20:05:04 +02:00
"By default, logging functionality is disabled. Enable log saving in case of application malfunction.")
}
SwitcherType {
2024-04-18 17:54:55 +04:00
id: switcher
2024-12-31 04:16:52 +01:00
Layout.fillWidth: true
Layout.topMargin: 16
2024-09-09 20:53:44 +04:00
Layout.leftMargin: 16
Layout.rightMargin: 16
2024-09-09 20:53:44 +04:00
text: qsTr("Enable logs")
2023-08-08 19:10:14 +05:00
checked: SettingsController.isLoggingEnabled
2024-12-31 04:16:52 +01:00
onCheckedChanged: {
2023-08-08 19:10:14 +05:00
if (checked !== SettingsController.isLoggingEnabled) {
SettingsController.isLoggingEnabled = checked
}
}
}
2024-09-09 20:53:44 +04:00
DividerType {}
LabelWithButtonType {
Layout.fillWidth: true
2024-09-09 20:53:44 +04:00
Layout.topMargin: -8
text: qsTr("Clear logs")
leftImageSource: "qrc:/images/controls/trash.svg"
isSmallLeftImage: true
clickedFunction: function() {
var headerText = qsTr("Clear logs?")
var yesButtonText = qsTr("Continue")
var noButtonText = qsTr("Cancel")
var yesButtonFunction = function() {
PageController.showBusyIndicator(true)
SettingsController.clearLogs()
PageController.showBusyIndicator(false)
PageController.showNotificationMessage(qsTr("Logs have been cleaned up"))
}
2024-12-31 04:16:52 +01:00
2024-09-09 20:53:44 +04:00
var noButtonFunction = function() {
2024-12-31 04:16:52 +01:00
2024-09-09 20:53:44 +04:00
}
2024-09-09 20:53:44 +04:00
showQuestionDrawer(headerText, "", yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
}
}
2024-12-31 04:16:52 +01:00
}
model: logTypes
clip: true
reuseItems: true
snapMode: ListView.SnapOneItem
delegate: ColumnLayout {
id: delegateContent
width: listView.width
enabled: isVisible
2024-09-09 20:53:44 +04:00
ListItemTitleType {
Layout.fillWidth: true
Layout.topMargin: 8
Layout.leftMargin: 16
Layout.rightMargin: 16
2024-12-31 04:16:52 +01:00
text: title
2024-09-09 20:53:44 +04:00
}
2024-09-09 20:53:44 +04:00
ParagraphTextType {
Layout.fillWidth: true
Layout.topMargin: 8
Layout.leftMargin: 16
Layout.rightMargin: 16
2024-09-09 20:53:44 +04:00
color: AmneziaStyle.color.mutedGray
2024-12-31 04:16:52 +01:00
text: description
2024-09-09 20:53:44 +04:00
}
2024-09-09 20:53:44 +04:00
LabelWithButtonType {
Layout.fillWidth: true
Layout.topMargin: -8
Layout.bottomMargin: -8
visible: !GC.isMobile()
2024-09-09 20:53:44 +04:00
text: qsTr("Open logs folder")
leftImageSource: "qrc:/images/controls/folder-open.svg"
isSmallLeftImage: true
2024-12-31 04:16:52 +01:00
clickedFunction: openLogsHandler
2024-09-09 20:53:44 +04:00
}
2024-09-09 20:53:44 +04:00
DividerType {}
LabelWithButtonType {
Layout.fillWidth: true
Layout.topMargin: -8
Layout.bottomMargin: -8
text: qsTr("Export logs")
leftImageSource: "qrc:/images/controls/save.svg"
isSmallLeftImage: true
2024-12-31 04:16:52 +01:00
clickedFunction: exportLogsHandler
2024-09-09 20:53:44 +04:00
}
2024-09-09 20:53:44 +04:00
DividerType {}
2024-12-31 04:16:52 +01:00
}
}
2024-12-31 04:16:52 +01:00
property list<QtObject> logTypes: [
clientLogs,
serviceLogs
]
2024-09-09 20:53:44 +04:00
2024-12-31 04:16:52 +01:00
QtObject {
id: clientLogs
2024-09-09 20:53:44 +04:00
2024-12-31 04:16:52 +01:00
readonly property string title: qsTr("Client logs")
readonly property string description: qsTr("AmneziaVPN logs")
readonly property bool isVisible: true
readonly property var openLogsHandler: function() {
SettingsController.openLogsFolder()
}
readonly property var exportLogsHandler: function() {
var fileName = ""
if (GC.isMobile()) {
fileName = "AmneziaVPN.log"
} else {
fileName = SystemController.getFileName(qsTr("Save"),
qsTr("Logs files (*.log)"),
StandardPaths.standardLocations(StandardPaths.DocumentsLocation) + "/AmneziaVPN",
true,
".log")
2024-09-09 20:53:44 +04:00
}
2024-12-31 04:16:52 +01:00
if (fileName !== "") {
PageController.showBusyIndicator(true)
SettingsController.exportLogsFile(fileName)
PageController.showBusyIndicator(false)
PageController.showNotificationMessage(qsTr("Logs file saved"))
2024-09-09 20:53:44 +04:00
}
2024-12-31 04:16:52 +01:00
}
}
2024-09-09 20:53:44 +04:00
2024-12-31 04:16:52 +01:00
QtObject {
id: serviceLogs
2024-09-09 20:53:44 +04:00
2024-12-31 04:16:52 +01:00
readonly property string title: qsTr("Service logs")
readonly property string description: qsTr("AmneziaVPN-service logs")
readonly property bool isVisible: !GC.isMobile()
readonly property var openLogsHandler: function() {
SettingsController.openServiceLogsFolder()
}
readonly property var exportLogsHandler: function() {
var fileName = ""
if (GC.isMobile()) {
fileName = "AmneziaVPN-service.log"
} else {
fileName = SystemController.getFileName(qsTr("Save"),
qsTr("Logs files (*.log)"),
StandardPaths.standardLocations(StandardPaths.DocumentsLocation) + "/AmneziaVPN-service",
true,
".log")
}
2024-12-31 04:16:52 +01:00
if (fileName !== "") {
PageController.showBusyIndicator(true)
SettingsController.exportServiceLogsFile(fileName)
PageController.showBusyIndicator(false)
PageController.showNotificationMessage(qsTr("Logs file saved"))
2024-09-09 20:53:44 +04:00
}
}
}
}