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

276 lines
8.8 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
2024-04-18 17:54:55 +04:00
defaultActiveFocusItem: focusItem
Item {
id: focusItem
KeyNavigation.tab: backButton
}
BackButtonType {
id: backButton
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
2024-04-18 17:54:55 +04:00
KeyNavigation.tab: switcher
}
FlickableType {
id: fl
anchors.top: backButton.bottom
anchors.bottom: parent.bottom
contentHeight: content.height
ColumnLayout {
id: content
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
2024-09-09 20:53:44 +04:00
spacing: 0
HeaderType {
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
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-09-09 20:53:44 +04:00
//KeyNavigation.tab: openFolderButton
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 {
// id: labelWithButton2
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
// KeyNavigation.tab: labelWithButton3
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"))
if (!GC.isMobile()) {
focusItem.forceActiveFocus()
}
}
var noButtonFunction = function() {
if (!GC.isMobile()) {
focusItem.forceActiveFocus()
}
}
2024-09-09 20:53:44 +04:00
showQuestionDrawer(headerText, "", yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
}
}
2024-09-09 20:53:44 +04:00
ListItemTitleType {
Layout.fillWidth: true
Layout.topMargin: 8
Layout.leftMargin: 16
Layout.rightMargin: 16
2024-09-09 20:53:44 +04:00
text: qsTr("Client logs")
}
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
text: qsTr("AmneziaVPN logs")
}
2024-09-09 20:53:44 +04:00
LabelWithButtonType {
// id: labelWithButton2
Layout.fillWidth: true
Layout.topMargin: -8
Layout.bottomMargin: -8
2024-09-09 20:53:44 +04:00
text: qsTr("Open logs folder")
leftImageSource: "qrc:/images/controls/folder-open.svg"
isSmallLeftImage: true
// KeyNavigation.tab: labelWithButton3
clickedFunction: function() {
SettingsController.openLogsFolder()
}
2024-09-09 20:53:44 +04:00
}
2024-09-09 20:53:44 +04:00
DividerType {}
LabelWithButtonType {
// id: labelWithButton2
Layout.fillWidth: true
Layout.topMargin: -8
Layout.bottomMargin: -8
text: qsTr("Export logs")
leftImageSource: "qrc:/images/controls/save.svg"
isSmallLeftImage: true
// KeyNavigation.tab: labelWithButton3
clickedFunction: 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")
}
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-09-09 20:53:44 +04:00
DividerType {}
2024-09-09 20:53:44 +04:00
ListItemTitleType {
visible: !GC.isMobile()
Layout.fillWidth: true
Layout.topMargin: 32
Layout.leftMargin: 16
Layout.rightMargin: 16
text: qsTr("Service logs")
}
ParagraphTextType {
visible: !GC.isMobile()
Layout.fillWidth: true
Layout.topMargin: 8
Layout.leftMargin: 16
Layout.rightMargin: 16
color: AmneziaStyle.color.mutedGray
text: qsTr("AmneziaVPN-service logs")
}
LabelWithButtonType {
// id: labelWithButton2
visible: !GC.isMobile()
Layout.fillWidth: true
Layout.topMargin: -8
Layout.bottomMargin: -8
text: qsTr("Open logs folder")
leftImageSource: "qrc:/images/controls/folder-open.svg"
isSmallLeftImage: true
// KeyNavigation.tab: labelWithButton3
clickedFunction: function() {
SettingsController.openServiceLogsFolder()
}
2024-09-09 20:53:44 +04:00
}
2024-09-09 20:53:44 +04:00
DividerType {
visible: !GC.isMobile()
}
LabelWithButtonType {
// id: labelWithButton2
2024-09-09 20:53:44 +04:00
visible: !GC.isMobile()
2024-09-09 20:53:44 +04:00
Layout.fillWidth: true
Layout.topMargin: -8
Layout.bottomMargin: -8
text: qsTr("Export logs")
leftImageSource: "qrc:/images/controls/save.svg"
isSmallLeftImage: true
// KeyNavigation.tab: labelWithButton3
clickedFunction: 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")
}
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
DividerType {
visible: !GC.isMobile()
}
}
}
}