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

163 lines
4.9 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
2024-04-18 17:54:55 +04:00
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: root.defaultActiveFocusItem
}
FlickableType {
id: fl
anchors.top: backButton.bottom
anchors.bottom: parent.bottom
contentHeight: content.height
2024-02-19 19:54:15 +05:00
property var isServerFromApi: ServersModel.getDefaultServerData("isServerFromApi")
enabled: !isServerFromApi
Component.onCompleted: {
2024-02-19 19:54:15 +05:00
if (isServerFromApi) {
2024-06-19 02:14:22 +03:00
PageController.showNotificationMessage(qsTr("Default server does not support custom DNS"))
}
}
ColumnLayout {
id: content
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 16
anchors.rightMargin: 16
spacing: 16
HeaderType {
Layout.fillWidth: true
headerText: qsTr("DNS servers")
}
ParagraphTextType {
2023-10-16 13:32:56 +05:00
Layout.fillWidth: true
text: qsTr("If AmneziaDNS is not used or installed")
}
TextFieldWithHeaderType {
id: primaryDns
Layout.fillWidth: true
2023-10-05 00:54:49 +08:00
headerText: qsTr("Primary DNS")
textFieldText: SettingsController.primaryDns
textField.validator: RegularExpressionValidator {
regularExpression: InstallController.ipAddressRegExp()
}
KeyNavigation.tab: secondaryDns.textField
}
TextFieldWithHeaderType {
id: secondaryDns
Layout.fillWidth: true
2023-10-05 00:54:49 +08:00
headerText: qsTr("Secondary DNS")
textFieldText: SettingsController.secondaryDns
textField.validator: RegularExpressionValidator {
regularExpression: InstallController.ipAddressRegExp()
}
2024-04-18 17:54:55 +04:00
KeyNavigation.tab: restoreDefaultButton
}
BasicButtonType {
2024-04-18 17:54:55 +04:00
id: restoreDefaultButton
Layout.fillWidth: true
2024-07-07 13:42:38 +03:00
defaultColor: AmneziaStyle.color.transparent
hoveredColor: AmneziaStyle.color.blackHovered
pressedColor: AmneziaStyle.color.blackPressed
disabledColor: AmneziaStyle.color.grey
textColor: AmneziaStyle.color.white
borderWidth: 1
text: qsTr("Restore default")
clickedFunc: function() {
2024-02-16 15:24:06 +05:00
var headerText = qsTr("Restore default DNS settings?")
var yesButtonText = qsTr("Continue")
var noButtonText = qsTr("Cancel")
2024-02-16 15:24:06 +05:00
var yesButtonFunction = function() {
SettingsController.primaryDns = "1.1.1.1"
primaryDns.textFieldText = SettingsController.primaryDns
SettingsController.secondaryDns = "1.0.0.1"
secondaryDns.textFieldText = SettingsController.secondaryDns
PageController.showNotificationMessage(qsTr("Settings have been reset"))
2024-04-18 17:54:55 +04:00
if (!GC.isMobile()) {
// defaultActiveFocusItem.forceActiveFocus()
2024-04-18 17:54:55 +04:00
}
}
2024-02-16 15:24:06 +05:00
var noButtonFunction = function() {
2024-04-18 17:54:55 +04:00
if (!GC.isMobile()) {
// defaultActiveFocusItem.forceActiveFocus()
2024-04-18 17:54:55 +04:00
}
}
2024-02-16 15:24:06 +05:00
showQuestionDrawer(headerText, "", yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
}
2024-04-18 17:54:55 +04:00
KeyNavigation.tab: saveButton
}
BasicButtonType {
id: saveButton
Layout.fillWidth: true
text: qsTr("Save")
clickedFunc: function() {
if (primaryDns.textFieldText !== SettingsController.primaryDns) {
SettingsController.primaryDns = primaryDns.textFieldText
}
if (secondaryDns.textFieldText !== SettingsController.secondaryDns) {
SettingsController.secondaryDns = secondaryDns.textFieldText
}
PageController.showNotificationMessage(qsTr("Settings saved"))
}
2024-04-18 17:54:55 +04:00
Keys.onTabPressed: lastItemTabClicked(focusItem)
}
}
}
}