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

147 lines
4.4 KiB
QML
Raw Normal View History

2024-03-18 12:41:53 +02:00
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import SortFilterProxyModel 0.2
import PageEnum 1.0
import Style 1.0
2024-03-18 12:41:53 +02:00
import "./"
import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
import "../Components"
PageType {
id: root
BackButtonType {
id: backButton
2024-03-18 12:41:53 +02:00
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
2025-11-04 11:43:36 +08:00
anchors.topMargin: 20 + SettingsController.safeAreaTopMargin
2024-03-18 12:41:53 +02:00
onFocusChanged: {
if (this.activeFocus) {
listView.positionViewAtBeginning()
}
2024-03-18 12:41:53 +02:00
}
}
ListViewType {
id: listView
2024-03-18 12:41:53 +02:00
anchors.top: backButton.bottom
anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.left: parent.left
2024-03-18 12:41:53 +02:00
enabled: ServersModel.isProcessedServerHasWriteAccess()
2024-03-18 12:41:53 +02:00
model: WireGuardConfigModel
2024-03-18 12:41:53 +02:00
delegate: ColumnLayout {
width: listView.width
2024-03-18 12:41:53 +02:00
property bool isEnabled: ServersModel.isProcessedServerHasWriteAccess()
2024-03-18 12:41:53 +02:00
spacing: 0
2024-03-18 12:41:53 +02:00
BaseHeaderType {
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
2024-03-18 12:41:53 +02:00
headerText: qsTr("WG settings")
}
2024-09-13 12:38:48 +04:00
TextFieldWithHeaderType {
id: vpnAddressSubnetTextField
2024-04-18 17:54:55 +04:00
Layout.fillWidth: true
Layout.topMargin: 40
Layout.leftMargin: 16
Layout.rightMargin: 16
2024-03-18 12:41:53 +02:00
headerText: qsTr("VPN address subnet")
textField.text: subnetAddress
2024-03-18 12:41:53 +02:00
textField.onEditingFinished: {
if (textField.text !== subnetAddress) {
subnetAddress = textField.text
}
}
2024-03-18 12:41:53 +02:00
checkEmptyText: true
}
2024-03-18 12:41:53 +02:00
TextFieldWithHeaderType {
id: portTextField
Layout.fillWidth: true
Layout.topMargin: 16
Layout.leftMargin: 16
Layout.rightMargin: 16
2024-03-18 12:41:53 +02:00
headerText: qsTr("Port")
textField.text: port
textField.maximumLength: 5
textField.validator: IntValidator { bottom: 1; top: 65535 }
2024-09-13 12:38:48 +04:00
textField.onEditingFinished: {
if (textField.text !== port) {
port = textField.text
}
}
checkEmptyText: true
}
BasicButtonType {
id: saveButton
Layout.fillWidth: true
Layout.topMargin: 24
Layout.bottomMargin: 24
Layout.leftMargin: 16
Layout.rightMargin: 16
enabled: portTextField.errorText === "" &&
vpnAddressSubnetTextField.errorText === ""
text: qsTr("Save")
onClicked: function() {
forceActiveFocus()
2024-03-18 12:41:53 +02:00
var headerText = qsTr("Save settings?")
var descriptionText = qsTr("All users with whom you shared a connection with will no longer be able to connect to it.")
var yesButtonText = qsTr("Continue")
var noButtonText = qsTr("Cancel")
2024-03-18 12:41:53 +02:00
var yesButtonFunction = function() {
if (ConnectionController.isConnected && ServersModel.getDefaultServerData("defaultContainer") === ContainersModel.getProcessedContainerIndex()) {
PageController.showNotificationMessage(qsTr("Unable change settings while there is an active connection"))
return
2024-03-18 12:41:53 +02:00
}
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
InstallController.updateContainer(WireGuardConfigModel.getConfig())
}
var noButtonFunction = function() {
if (!GC.isMobile()) {
saveButton.forceActiveFocus()
2024-03-18 12:41:53 +02:00
}
}
showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
2024-03-18 12:41:53 +02:00
}
Keys.onEnterPressed: saveButton.clicked()
Keys.onReturnPressed: saveButton.clicked()
2024-03-18 12:41:53 +02:00
}
}
}
}