mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-23 02:00:20 +07:00
replace FlickableType with ListViewType in PageSettingsDns
This commit is contained in:
@@ -1,140 +1,167 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
|
||||||
import PageEnum 1.0
|
import PageEnum 1.0
|
||||||
import Style 1.0
|
import Style 1.0
|
||||||
|
|
||||||
import "./"
|
import "./"
|
||||||
import "../Controls2"
|
import "../Controls2"
|
||||||
import "../Config"
|
import "../Config"
|
||||||
import "../Controls2/TextTypes"
|
import "../Controls2/TextTypes"
|
||||||
import "../Components"
|
import "../Components"
|
||||||
|
|
||||||
PageType {
|
PageType {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
BackButtonType {
|
BackButtonType {
|
||||||
id: backButton
|
id: backButton
|
||||||
|
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.topMargin: 20
|
anchors.topMargin: 20
|
||||||
}
|
|
||||||
|
onFocusChanged: {
|
||||||
FlickableType {
|
if (this.activeFocus) {
|
||||||
id: fl
|
listView.positionViewAtBeginning()
|
||||||
anchors.top: backButton.bottom
|
}
|
||||||
anchors.bottom: parent.bottom
|
}
|
||||||
contentHeight: content.height
|
}
|
||||||
|
|
||||||
property var isServerFromApi: ServersModel.isServerFromApi(ServersModel.defaultIndex)
|
ListViewType {
|
||||||
|
id: listView
|
||||||
enabled: !isServerFromApi
|
|
||||||
|
anchors.top: backButton.bottom
|
||||||
Component.onCompleted: {
|
anchors.bottom: parent.bottom
|
||||||
if (isServerFromApi) {
|
anchors.right: parent.right
|
||||||
PageController.showNotificationMessage(qsTr("Default server does not support custom DNS"))
|
anchors.left: parent.left
|
||||||
}
|
|
||||||
}
|
property var isServerFromApi: ServersModel.isServerFromApi(ServersModel.defaultIndex)
|
||||||
|
|
||||||
ColumnLayout {
|
enabled: !isServerFromApi
|
||||||
id: content
|
|
||||||
|
Component.onCompleted: {
|
||||||
anchors.top: parent.top
|
if (isServerFromApi) {
|
||||||
anchors.left: parent.left
|
PageController.showNotificationMessage(qsTr("Default server does not support custom DNS"))
|
||||||
anchors.right: parent.right
|
}
|
||||||
anchors.leftMargin: 16
|
}
|
||||||
anchors.rightMargin: 16
|
|
||||||
|
header: ColumnLayout {
|
||||||
spacing: 16
|
width: listView.width
|
||||||
|
spacing: 16
|
||||||
BaseHeaderType {
|
|
||||||
Layout.fillWidth: true
|
BaseHeaderType {
|
||||||
|
Layout.fillWidth: true
|
||||||
headerText: qsTr("DNS servers")
|
Layout.leftMargin: 16
|
||||||
}
|
Layout.rightMargin: 16
|
||||||
|
|
||||||
ParagraphTextType {
|
headerText: qsTr("DNS servers")
|
||||||
Layout.fillWidth: true
|
}
|
||||||
text: qsTr("If AmneziaDNS is not used or installed")
|
|
||||||
}
|
ParagraphTextType {
|
||||||
|
Layout.fillWidth: true
|
||||||
TextFieldWithHeaderType {
|
Layout.leftMargin: 16
|
||||||
id: primaryDns
|
Layout.rightMargin: 16
|
||||||
|
|
||||||
Layout.fillWidth: true
|
text: qsTr("If AmneziaDNS is not used or installed")
|
||||||
headerText: qsTr("Primary DNS")
|
}
|
||||||
|
|
||||||
textField.text: SettingsController.primaryDns
|
TextFieldWithHeaderType {
|
||||||
textField.validator: RegularExpressionValidator {
|
id: primaryDns
|
||||||
regularExpression: InstallController.ipAddressRegExp()
|
|
||||||
}
|
Layout.fillWidth: true
|
||||||
}
|
Layout.leftMargin: 16
|
||||||
|
Layout.rightMargin: 16
|
||||||
TextFieldWithHeaderType {
|
|
||||||
id: secondaryDns
|
headerText: qsTr("Primary DNS")
|
||||||
|
|
||||||
Layout.fillWidth: true
|
textField.text: SettingsController.primaryDns
|
||||||
headerText: qsTr("Secondary DNS")
|
textField.validator: RegularExpressionValidator {
|
||||||
|
regularExpression: InstallController.ipAddressRegExp()
|
||||||
textField.text: SettingsController.secondaryDns
|
}
|
||||||
textField.validator: RegularExpressionValidator {
|
}
|
||||||
regularExpression: InstallController.ipAddressRegExp()
|
|
||||||
}
|
TextFieldWithHeaderType {
|
||||||
}
|
id: secondaryDns
|
||||||
|
|
||||||
BasicButtonType {
|
Layout.fillWidth: true
|
||||||
id: restoreDefaultButton
|
Layout.leftMargin: 16
|
||||||
Layout.fillWidth: true
|
Layout.rightMargin: 16
|
||||||
|
|
||||||
defaultColor: AmneziaStyle.color.transparent
|
headerText: qsTr("Secondary DNS")
|
||||||
hoveredColor: AmneziaStyle.color.translucentWhite
|
|
||||||
pressedColor: AmneziaStyle.color.sheerWhite
|
textField.text: SettingsController.secondaryDns
|
||||||
disabledColor: AmneziaStyle.color.mutedGray
|
textField.validator: RegularExpressionValidator {
|
||||||
textColor: AmneziaStyle.color.paleGray
|
regularExpression: InstallController.ipAddressRegExp()
|
||||||
borderWidth: 1
|
}
|
||||||
|
}
|
||||||
text: qsTr("Restore default")
|
}
|
||||||
|
|
||||||
clickedFunc: function() {
|
model: 1 // fake model to force the ListView to be created without a model
|
||||||
var headerText = qsTr("Restore default DNS settings?")
|
spacing: 16
|
||||||
var yesButtonText = qsTr("Continue")
|
|
||||||
var noButtonText = qsTr("Cancel")
|
delegate: ColumnLayout {
|
||||||
|
width: listView.width
|
||||||
var yesButtonFunction = function() {
|
|
||||||
SettingsController.primaryDns = "1.1.1.1"
|
BasicButtonType {
|
||||||
primaryDns.textField.text = SettingsController.primaryDns
|
id: restoreDefaultButton
|
||||||
SettingsController.secondaryDns = "1.0.0.1"
|
|
||||||
secondaryDns.textField.text = SettingsController.secondaryDns
|
Layout.fillWidth: true
|
||||||
PageController.showNotificationMessage(qsTr("Settings have been reset"))
|
Layout.topMargin: 16
|
||||||
}
|
Layout.leftMargin: 16
|
||||||
var noButtonFunction = function() {
|
Layout.rightMargin: 16
|
||||||
}
|
|
||||||
|
defaultColor: AmneziaStyle.color.transparent
|
||||||
showQuestionDrawer(headerText, "", yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
|
hoveredColor: AmneziaStyle.color.translucentWhite
|
||||||
}
|
pressedColor: AmneziaStyle.color.sheerWhite
|
||||||
}
|
disabledColor: AmneziaStyle.color.mutedGray
|
||||||
|
textColor: AmneziaStyle.color.paleGray
|
||||||
BasicButtonType {
|
borderWidth: 1
|
||||||
id: saveButton
|
|
||||||
|
text: qsTr("Restore default")
|
||||||
Layout.fillWidth: true
|
|
||||||
|
clickedFunc: function() {
|
||||||
text: qsTr("Save")
|
var headerText = qsTr("Restore default DNS settings?")
|
||||||
|
var yesButtonText = qsTr("Continue")
|
||||||
clickedFunc: function() {
|
var noButtonText = qsTr("Cancel")
|
||||||
if (primaryDns.textField.text !== SettingsController.primaryDns) {
|
|
||||||
SettingsController.primaryDns = primaryDns.textField.text
|
var yesButtonFunction = function() {
|
||||||
}
|
SettingsController.primaryDns = "1.1.1.1"
|
||||||
if (secondaryDns.textField.text !== SettingsController.secondaryDns) {
|
primaryDns.textField.text = SettingsController.primaryDns
|
||||||
SettingsController.secondaryDns = secondaryDns.textField.text
|
SettingsController.secondaryDns = "1.0.0.1"
|
||||||
}
|
secondaryDns.textField.text = SettingsController.secondaryDns
|
||||||
PageController.showNotificationMessage(qsTr("Settings saved"))
|
PageController.showNotificationMessage(qsTr("Settings have been reset"))
|
||||||
}
|
}
|
||||||
}
|
var noButtonFunction = function() {
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
showQuestionDrawer(headerText, "", yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
footer: ColumnLayout {
|
||||||
|
width: listView.width
|
||||||
|
|
||||||
|
BasicButtonType {
|
||||||
|
id: saveButton
|
||||||
|
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.margins: 16
|
||||||
|
|
||||||
|
text: qsTr("Save")
|
||||||
|
|
||||||
|
clickedFunc: function() {
|
||||||
|
if (primaryDns.textField.text !== SettingsController.primaryDns) {
|
||||||
|
SettingsController.primaryDns = primaryDns.textField.text
|
||||||
|
}
|
||||||
|
if (secondaryDns.textField.text !== SettingsController.secondaryDns) {
|
||||||
|
SettingsController.secondaryDns = secondaryDns.textField.text
|
||||||
|
}
|
||||||
|
PageController.showNotificationMessage(qsTr("Settings saved"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user