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

251 lines
7.5 KiB
QML
Raw Normal View History

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import PageEnum 1.0
2024-07-07 13:42:38 +03:00
import Style 1.0
import "./"
import "../Controls2"
import "../Config"
import "../Controls2/TextTypes"
import "../Components"
PageType {
id: root
BackButtonType {
id: backButton
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
onActiveFocusChanged: {
if(backButton.enabled && backButton.activeFocus) {
listView.positionViewAtBeginning()
}
}
}
ListViewType {
id: listView
anchors.top: backButton.bottom
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
header: ColumnLayout {
width: listView.width
2025-05-02 23:54:36 -07:00
BaseHeaderType {
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
headerText: qsTr("Application")
}
}
model: 1 // fake model to force the ListView to be created without a model
delegate: ColumnLayout { // TODO(CyAn84): add DelegateChooser when have migrated to 6.9
width: listView.width
SwitcherType {
id: switcherAllowScreenshots
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)
}
}
}
DividerType {
visible: GC.isMobile()
}
2024-05-12 18:04:14 +03:00
LabelWithButtonType {
id: labelWithButtonNotification
2024-05-12 18:04:14 +03:00
visible: Qt.platform.os === "android" && !SettingsController.isNotificationPermissionGranted
2024-05-12 18:04:14 +03:00
Layout.fillWidth: true
text: qsTr("Enable notifications")
descriptionText: qsTr("Enable notifications to show the VPN state in the status bar")
rightImageSource: "qrc:/images/controls/chevron-right.svg"
clickedFunction: function() {
SettingsController.requestNotificationPermission()
}
}
DividerType {
visible: Qt.platform.os === "android" && !SettingsController.isNotificationPermissionGranted
}
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
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")
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 (works with autostart option turned on)")
enabled: switcherAutoStart.checked
opacity: enabled ? 1.0 : 0.5
2023-08-24 14:53:52 +05:00
checked: SettingsController.isStartMinimizedEnabled()
onCheckedChanged: {
if (checked !== SettingsController.isStartMinimizedEnabled()) {
SettingsController.toggleStartMinimized(checked)
}
}
}
DividerType {
visible: !GC.isMobile()
}
}
footer: ColumnLayout {
width: listView.width
2023-08-24 14:53:52 +05:00
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"
clickedFunction: function() {
2024-12-31 04:16:52 +01:00
selectLanguageDrawer.openTriggered()
}
}
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"
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"
textColor: AmneziaStyle.color.vibrantRed
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.goToPageHome()
}
}
2024-02-16 15:24:06 +05:00
var noButtonFunction = function() {
}
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
}
}