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

254 lines
7.5 KiB
QML
Raw Normal View History

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import PageEnum 1.0
import "./"
import "../Controls2"
import "../Config"
import "../Controls2/TextTypes"
import "../Components"
PageType {
id: root
2024-04-18 17:54:55 +04:00
defaultActiveFocusItem: focusItem
Item {
id: focusItem
2024-04-30 14:32:30 +05:00
KeyNavigation.tab: backButton
2024-04-18 17:54:55 +04:00
onFocusChanged: {
if (focusItem.activeFocus) {
fl.contentY = 0
}
}
}
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
2024-04-30 14:32:30 +05:00
KeyNavigation.tab: GC.isMobile() ? switcher : switcherAutoStart
}
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
HeaderType {
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
headerText: qsTr("Application")
}
SwitcherType {
2024-04-18 17:54:55 +04:00
id: switcher
visible: GC.isMobile()
Layout.fillWidth: true
Layout.margins: 16
text: qsTr("Allow application screenshots")
checked: SettingsController.isScreenshotsEnabled()
onCheckedChanged: {
if (checked !== SettingsController.isScreenshotsEnabled()) {
SettingsController.toggleScreenshotsEnabled(checked)
}
}
2024-04-18 17:54:55 +04:00
2024-04-30 14:32:30 +05:00
KeyNavigation.tab: labelWithButtonLanguage.rightButton
2024-04-18 17:54:55 +04:00
parentFlickable: fl
}
DividerType {
visible: GC.isMobile()
}
2023-08-24 14:53:52 +05:00
SwitcherType {
2024-04-18 17:54:55 +04:00
id: switcherAutoStart
2023-08-24 14:53:52 +05:00
visible: !GC.isMobile()
Layout.fillWidth: true
Layout.margins: 16
text: qsTr("Auto start")
2023-10-16 14:34:03 +05:00
descriptionText: qsTr("Launch the application every time the device is starts")
2023-08-24 14:53:52 +05:00
2024-04-30 14:32:30 +05:00
KeyNavigation.tab: switcherAutoConnect
2024-04-18 17:54:55 +04:00
parentFlickable: fl
2023-08-24 14:53:52 +05:00
checked: SettingsController.isAutoStartEnabled()
onCheckedChanged: {
if (checked !== SettingsController.isAutoStartEnabled()) {
SettingsController.toggleAutoStart(checked)
}
}
}
DividerType {
visible: !GC.isMobile()
}
SwitcherType {
2024-04-18 17:54:55 +04:00
id: switcherAutoConnect
visible: !GC.isMobile()
Layout.fillWidth: true
Layout.margins: 16
text: qsTr("Auto connect")
descriptionText: qsTr("Connect to VPN on app start")
2024-04-30 14:32:30 +05:00
KeyNavigation.tab: switcherStartMinimized
2024-04-18 17:54:55 +04:00
parentFlickable: fl
checked: SettingsController.isAutoConnectEnabled()
onCheckedChanged: {
if (checked !== SettingsController.isAutoConnectEnabled()) {
SettingsController.toggleAutoConnect(checked)
}
}
}
DividerType {
visible: !GC.isMobile()
}
2023-08-24 14:53:52 +05:00
SwitcherType {
2024-04-18 17:54:55 +04:00
id: switcherStartMinimized
2023-08-24 14:53:52 +05:00
visible: !GC.isMobile()
Layout.fillWidth: true
Layout.margins: 16
text: qsTr("Start minimized")
descriptionText: qsTr("Launch application minimized")
2024-04-30 14:32:30 +05:00
KeyNavigation.tab: labelWithButtonLanguage.rightButton
2024-04-18 17:54:55 +04:00
parentFlickable: fl
2023-08-24 14:53:52 +05:00
checked: SettingsController.isStartMinimizedEnabled()
onCheckedChanged: {
if (checked !== SettingsController.isStartMinimizedEnabled()) {
SettingsController.toggleStartMinimized(checked)
}
}
}
DividerType {
visible: !GC.isMobile()
}
LabelWithButtonType {
2024-04-18 17:54:55 +04:00
id: labelWithButtonLanguage
Layout.fillWidth: true
text: qsTr("Language")
descriptionText: LanguageModel.currentLanguageName
rightImageSource: "qrc:/images/controls/chevron-right.svg"
2024-04-30 14:32:30 +05:00
KeyNavigation.tab: labelWithButtonLogging.rightButton
2024-04-18 17:54:55 +04:00
parentFlickable: fl
clickedFunction: function() {
selectLanguageDrawer.open()
}
}
DividerType {}
LabelWithButtonType {
2024-04-18 17:54:55 +04:00
id: labelWithButtonLogging
Layout.fillWidth: true
text: qsTr("Logging")
2023-08-08 19:10:14 +05:00
descriptionText: SettingsController.isLoggingEnabled ? qsTr("Enabled") : qsTr("Disabled")
rightImageSource: "qrc:/images/controls/chevron-right.svg"
2024-04-30 14:32:30 +05:00
KeyNavigation.tab: labelWithButtonReset.rightButton
2024-04-18 17:54:55 +04:00
parentFlickable: fl
clickedFunction: function() {
2023-09-06 13:37:37 +05:00
PageController.goToPage(PageEnum.PageSettingsLogging)
}
}
DividerType {}
LabelWithButtonType {
2024-04-18 17:54:55 +04:00
id: labelWithButtonReset
Layout.fillWidth: true
text: qsTr("Reset settings and remove all data from the application")
rightImageSource: "qrc:/images/controls/chevron-right.svg"
2024-02-17 21:48:41 +02:00
textColor: "#EB5757"
2024-04-18 17:54:55 +04:00
Keys.onTabPressed: lastItemTabClicked()
parentFlickable: fl
clickedFunction: function() {
2024-02-16 15:24:06 +05:00
var headerText = qsTr("Reset settings and remove all data from the application?")
var descriptionText = qsTr("All settings will be reset to default. All installed AmneziaVPN services will still remain on the server.")
var yesButtonText = qsTr("Continue")
var noButtonText = qsTr("Cancel")
2024-02-16 15:24:06 +05:00
var yesButtonFunction = function() {
if (ServersModel.isDefaultServerCurrentlyProcessed() && ConnectionController.isConnected) {
PageController.showNotificationMessage(qsTr("Cannot reset settings during active connection"))
} else
{
SettingsController.clearSettings()
PageController.replaceStartPage()
}
2024-04-18 17:54:55 +04:00
if (!GC.isMobile()) {
root.defaultActiveFocusItem.forceActiveFocus()
}
}
2024-02-16 15:24:06 +05:00
var noButtonFunction = function() {
2024-04-18 17:54:55 +04:00
if (!GC.isMobile()) {
root.defaultActiveFocusItem.forceActiveFocus()
}
}
2024-02-16 15:24:06 +05:00
showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
}
}
DividerType {}
}
}
2024-02-16 15:24:06 +05:00
SelectLanguageDrawer {
id: selectLanguageDrawer
width: root.width
height: root.height
2024-04-18 17:54:55 +04:00
onClosed: {
if (!GC.isMobile()) {
focusItem.forceActiveFocus()
}
}
2024-02-16 15:24:06 +05:00
}
}