fix: fix page share connection headers and config description

This commit is contained in:
vkamn
2025-08-27 16:41:11 +08:00
parent 4551659c2a
commit 1ea716a163
7 changed files with 61 additions and 33 deletions

View File

@@ -40,7 +40,7 @@ namespace PageLoader
PageSettingsApiDevices,
PageSettingsApiSubscriptionKey,
PageSettingsKillSwitchExceptions,
PageServiceSftpSettings,
PageServiceTorWebsiteSettings,
PageServiceDnsSettings,
@@ -125,6 +125,8 @@ signals:
void goToPageViewConfig();
void goToPageSettingsServerServices();
void goToPageSettingsBackup();
void goToShareConnectionPage(QString headerText, QString configContentHeaderText, QString configCaption, QString configExtension,
QString configFileName);
void closePage();

View File

@@ -218,9 +218,6 @@ PageType {
ApiConfigsController.prepareVpnKeyExport()
PageController.showBusyIndicator(false)
// Navigate to PageShareConnection page
//PageController.goToPage(PageEnum.PageShareConnection)
}
}

View File

@@ -53,14 +53,6 @@ PageType {
Layout.leftMargin: 16
Layout.rightMargin: 16
defaultColor: AmneziaStyle.color.paleGray
hoveredColor: AmneziaStyle.color.sheerWhite
pressedColor: AmneziaStyle.color.translucentWhite
disabledColor: AmneziaStyle.color.mutedGray
textColor: AmneziaStyle.color.black
leftImageColor: "black"
borderWidth: 1
text: qsTr("Copy key")
leftImageSource: "qrc:/images/controls/copy.svg"
@@ -194,7 +186,7 @@ PageType {
font.pixelSize: 16
font.weight: Font.Medium
font.family: "PT Root UI VF"
text: ApiConfigsController.vpnKey //|| ""
text: ApiConfigsController.vpnKey
wrapMode: Text.Wrap
background: Rectangle { color: AmneziaStyle.color.transparent }
}

View File

@@ -45,40 +45,67 @@ PageType {
function onGenerateConfig(type) {
PageController.showBusyIndicator(true)
var configCaption
var configExtension
var configFileName
switch (type) {
case PageShare.ConfigType.AmneziaConnection: {
ExportController.generateConnectionConfig(clientNameTextField.textField.text);
configCaption = qsTr("Save AmneziaVPN config")
configExtension = ".vpn"
configFileName = "amnezia_config"
break;
}
case PageShare.ConfigType.OpenVpn: {
ExportController.generateOpenVpnConfig(clientNameTextField.textField.text)
configCaption = qsTr("Save OpenVPN config")
configExtension = ".ovpn"
configFileName = "amnezia_for_openvpn"
break
}
case PageShare.ConfigType.WireGuard: {
ExportController.generateWireGuardConfig(clientNameTextField.textField.text)
configCaption = qsTr("Save WireGuard config")
configExtension = ".conf"
configFileName = "amnezia_for_wireguard"
break
}
case PageShare.ConfigType.Awg: {
ExportController.generateAwgConfig(clientNameTextField.textField.text)
configCaption = qsTr("Save AmneziaWG config")
configExtension = ".conf"
configFileName = "amnezia_for_awg"
break
}
case PageShare.ConfigType.ShadowSocks: {
ExportController.generateShadowSocksConfig()
configCaption = qsTr("Save Shadowsocks config")
configExtension = ".json"
configFileName = "amnezia_for_shadowsocks"
break
}
case PageShare.ConfigType.Cloak: {
ExportController.generateCloakConfig()
configCaption = qsTr("Save Cloak config")
configExtension = ".json"
configFileName = "amnezia_for_cloak"
break
}
case PageShare.ConfigType.Xray: {
ExportController.generateXrayConfig(clientNameTextField.textField.text)
configCaption = qsTr("Save XRay config")
configExtension = ".json"
configFileName = "amnezia_for_xray"
break
}
}
PageController.showBusyIndicator(false)
PageController.goToPage(PageEnum.PageShareConnection)
var headerText = qsTr("Connection to ") + serverSelector.text
var configContentHeaderText = qsTr("File with connection settings to ") + serverSelector.text
PageController.goToShareConnectionPage(headerText, configContentHeaderText, configCaption, configExtension, configFileName)
}
function onExportErrorOccurred(error) {

View File

@@ -21,12 +21,6 @@ PageType {
id: pageShareConnection
property string headerText
Component.onCompleted: {
var serverName = ServersModel.getProcessedServerData("name") || ServersModel.getProcessedServerData("hostName") || "Server"
headerText = qsTr("Connection to ") + serverName
configContentHeaderText = qsTr("File with connection settings to ") + serverName
}
property string configContentHeaderText
property string shareButtonText: qsTr("Share")
property string copyButtonText: qsTr("Copy")
@@ -36,17 +30,17 @@ PageType {
property string configCaption: qsTr("Save AmneziaVPN config")
property string configFileName: "amnezia_config"
onVisibleChanged: {
configExtension = ".vpn"
configCaption = qsTr("Save AmneziaVPN config")
configFileName = "amnezia_config"
// onVisibleChanged: {
// configExtension = ".vpn"
// configCaption = qsTr("Save AmneziaVPN config")
// configFileName = "amnezia_config"
if (visible) {
var serverName = ServersModel.getProcessedServerData("name") || ServersModel.getProcessedServerData("hostName") || "Server"
headerText = qsTr("Connection to ") + serverName
configContentHeaderText = qsTr("File with connection settings to ") + serverName
}
}
// if (visible) {
// var serverName = ServersModel.getProcessedServerData("name") || ServersModel.getProcessedServerData("hostName") || "Server"
// headerText = qsTr("Connection to ") + serverName
// configContentHeaderText = qsTr("File with connection settings to ") + serverName
// }
// }
BackButtonType {
id: backButton

View File

@@ -37,6 +37,9 @@ PageType {
ListViewType {
id: listView
property string headerText: ""
property string configContentHeaderText: ""
anchors.top: backButton.bottom
anchors.bottom: parent.bottom
anchors.right: parent.right
@@ -108,8 +111,8 @@ PageType {
serverSelector.currentIndex = serverSelectorListView.currentIndex
}
shareConnectionPage.headerText = qsTr("Accessing ") + serverSelector.text
shareConnectionPage.configContentHeaderText = qsTr("File with accessing settings to ") + serverSelector.text
listView.headerText = qsTr("Accessing ") + serverSelector.text
listView.configContentHeaderText = qsTr("File with accessing settings to ") + serverSelector.text
serverSelector.closeTriggered()
}
@@ -156,7 +159,7 @@ PageType {
PageController.showBusyIndicator(false)
PageController.goToPage(PageEnum.PageShareConnection)
PageController.goToShareConnectionPage(listView.headerText, listView.configContentHeaderText, "", "", "")
}
}
}

View File

@@ -44,6 +44,19 @@ PageType {
tabBarStackView.push(pagePath, { "objectName" : pagePath }, StackView.PushTransition)
}
function onGoToShareConnectionPage(headerText, configContentHeaderText, configCaption, configExtension, configFileName) {
var pagePath = PageController.getPagePath(PageEnum.PageShareConnection)
tabBarStackView.push(pagePath,
{ "objectName" : pagePath,
"headerText" : headerText,
"configContentHeaderText" : configContentHeaderText,
"configCaption" : configCaption,
"configExtension" : configExtension,
"configFileName" : configFileName
},
StackView.PushTransition)
}
function onDisableControls(disabled) {
isControlsDisabled = disabled
}