From b2c62a7f8ebc8af614b86c57458c94ad91757a25 Mon Sep 17 00:00:00 2001 From: Mitternacht822 Date: Thu, 24 Jul 2025 16:11:37 +0400 Subject: [PATCH] added button for importing config from file --- client/resources.qrc | 1 + .../Components/BlackButtonWithBorder.qml | 37 +++++++++++++++++++ .../Pages/PageSetupWizardConfigSource.qml | 28 ++++++++++++-- 3 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 client/ui/qml/DefaultVpn/Components/BlackButtonWithBorder.qml diff --git a/client/resources.qrc b/client/resources.qrc index 5ed29238..20a028c3 100644 --- a/client/resources.qrc +++ b/client/resources.qrc @@ -273,6 +273,7 @@ ui/qml/Components/ApiPremV1SubListDrawer.qml ui/qml/Components/OtpCodeDrawer.qml ui/qml/Components/AwgTextField.qml + ui/qml/DefaultVpn/Components/BlackButtonWithBorder.qml images/flagKit/ZW.svg diff --git a/client/ui/qml/DefaultVpn/Components/BlackButtonWithBorder.qml b/client/ui/qml/DefaultVpn/Components/BlackButtonWithBorder.qml new file mode 100644 index 00000000..b1fc79c8 --- /dev/null +++ b/client/ui/qml/DefaultVpn/Components/BlackButtonWithBorder.qml @@ -0,0 +1,37 @@ +pragma ComponentBehavior: Bound + +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import Qt5Compat.GraphicalEffects + +import Config 1.0 + +import "../Controls/TextTypes" +import "../Controls" + +ButtonType { + defaultBackgroundColor: Style.color.black + defaultBorderColor: Style.color.gray7 + defaultTextColor: Style.color.white + defaultImageColor: Style.color.white + + hoveredBackgroundColor: Style.color.black + hoveredBorderColor: Style.color.gray5 + hoveredTextColor: Style.color.white + hoveredImageColor: Style.color.white + + pressedBackgroundColor: Style.color.gray9 + pressedBorderColor: Style.color.gray5 + pressedTextColor: Style.color.white + pressedImageColor: Style.color.white + + disabledBackgroundColor: Style.color.gray8 + disabledBorderColor: Style.color.gray9 + disabledTextColor: Style.color.gray2 + disabledImageColor: Style.color.gray2 + + defaultBorderWidth: 1 + disabledBorderWidth: 1 + hoveredBorderWidth: 1 +} diff --git a/client/ui/qml/DefaultVpn/Pages/PageSetupWizardConfigSource.qml b/client/ui/qml/DefaultVpn/Pages/PageSetupWizardConfigSource.qml index 32a74130..80755169 100644 --- a/client/ui/qml/DefaultVpn/Pages/PageSetupWizardConfigSource.qml +++ b/client/ui/qml/DefaultVpn/Pages/PageSetupWizardConfigSource.qml @@ -83,13 +83,13 @@ Page { Layout.leftMargin: 16 Layout.rightMargin: 16 Layout.fillWidth: true - Layout.preferredHeight: 308 + Layout.preferredHeight: 240 placeholderText: qsTr("VPN://") } WhiteButtonWithBorder { - Layout.topMargin: 24 + Layout.topMargin: 12 Layout.leftMargin: 16 Layout.rightMargin: 16 Layout.fillWidth: true @@ -103,7 +103,7 @@ Page { } BlueButtonNoBorder { - Layout.topMargin: 24 + Layout.topMargin: 12 Layout.leftMargin: 16 Layout.rightMargin: 16 Layout.fillWidth: true @@ -119,6 +119,28 @@ Page { } } + BlackButtonWithBorder { + id: importConfigButton + + Layout.topMargin: 12 + Layout.leftMargin: 16 + Layout.rightMargin: 16 + Layout.fillWidth: true + + text: qsTr("Import config from file") + + onClicked: function() { + var nameFilter = !ServersModel.getServersCount() ? "Config or backup files (*.vpn *.ovpn *.conf *.json *.backup)" : + "Config files (*.vpn *.ovpn *.conf *.json)" + var fileName = SystemController.getFileName(qsTr("Open config file"), nameFilter) + if (fileName !== "") { + if (ImportController.extractConfigFromFile(fileName)) { + ImportController.importConfig() + } + } + } + } + Item { Layout.fillHeight: true }