added config export in native format openvpn and wireguard

This commit is contained in:
vladimir.kuznetsov 2023-07-05 10:15:38 +09:00
parent 43261f8469
commit a97417fd38
5 changed files with 137 additions and 39 deletions

View file

@ -55,7 +55,7 @@ Button {
fillColor: "transparent"
strokeColor: {
if (ConnectionController.isConnectionInProgress) {
return Qt.rgba(251/255, 178/255, 106/255, 1)
return "#261E1A"
} else if (ConnectionController.isConnected) {
return connectedButtonColor
} else {

View file

@ -137,7 +137,7 @@ DrawerType {
Layout.topMargin: 16
}
TextField {
TextArea {
Layout.fillWidth: true
Layout.topMargin: 16
Layout.bottomMargin: 16
@ -147,16 +147,17 @@ DrawerType {
height: 24
color: "#D7D8DB"
selectionColor: "#412102"
selectedTextColor: "#D7D8DB"
font.pixelSize: 16
font.weight: Font.Medium
font.family: "PT Root UI VF"
text: ExportController.amneziaCode
text: ExportController.formattedConfig
wrapMode: Text.Wrap
readOnly: true
background: Rectangle {
color: "transparent"
}
@ -186,11 +187,13 @@ DrawerType {
running: ExportController.qrCodesCount > 0
repeat: true
onTriggered: {
index++
if (index >= ExportController.qrCodesCount) {
index = 0
if (ExportController.qrCodesCount > 0) {
index++
if (index >= ExportController.qrCodesCount) {
index = 0
}
parent.source = ExportController.qrCodes[index]
}
parent.source = ExportController.qrCodes[index]
}
}
@ -205,6 +208,8 @@ DrawerType {
Layout.topMargin: 24
Layout.bottomMargin: 32
visible: ExportController.qrCodesCount > 0
horizontalAlignment: Text.AlignHCenter
text: qsTr("To read the QR code in the Amnezia app, select \"Add Server\" → \"I have connection details\"")
}

View file

@ -16,18 +16,30 @@ import "../Components"
PageType {
id: root
enum ConfigType {
AmneziaConnection,
AmenziaFullAccess,
OpenVpn,
WireGuard
}
Connections {
target: ExportController
function onGenerateConfig(isFullAccess) {
function onGenerateConfig(type) {
shareConnectionDrawer.open()
shareConnectionDrawer.contentVisible = false
PageController.showBusyIndicator(true)
if (isFullAccess) {
ExportController.generateFullAccessConfig()
} else {
ExportController.generateConnectionConfig()
console.log(type)
switch (type) {
case PageShare.ConfigType.AmneziaConnection: ExportController.generateConnectionConfig(); break;
case PageShare.ConfigType.AmenziaFullAccess: ExportController.generateFullAccessConfig(); break;
case PageShare.ConfigType.OpenVpn: ExportController.generateOpenVpnConfig(); break;
case PageShare.ConfigType.WireGuard: ExportController.generateWireGuardConfig(); break;
}
PageController.showBusyIndicator(false)
shareConnectionDrawer.contentVisible = true
}
@ -46,23 +58,17 @@ PageType {
QtObject {
id: amneziaConnectionFormat
property string name: qsTr("For the AmnesiaVPN app")
property var func: function() {
ExportController.generateConfig(false)
}
property var type: PageShare.ConfigType.AmneziaConnection
}
QtObject {
id: openVpnConnectionFormat
property string name: qsTr("OpenVpn native format")
property var func: function() {
console.log("Item 3 clicked")
}
property var type: PageShare.ConfigType.OpenVpn
}
QtObject {
id: wireGuardConnectionFormat
property string name: qsTr("WireGuard native format")
property var func: function() {
console.log("Item 3 clicked")
}
property var type: PageShare.ConfigType.WireGuard
}
FlickableType {
@ -334,9 +340,9 @@ PageType {
onClicked: {
if (accessTypeSelector.currentIndex === 0) {
root.connectionTypesModel[accessTypeSelector.currentIndex].func()
ExportController.generateConfig(root.connectionTypesModel[exportTypeSelector.currentIndex].type)
} else {
ExportController.generateConfig(true)
ExportController.generateConfig(PageShare.ConfigType.AmneziaFullAccess)
}
}
}