From 1fd48a1cf827236ec2fcc7b98db6b44469b33042 Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Wed, 7 Jun 2023 18:28:32 +0800 Subject: [PATCH] added protocol settings page and openvpn settings page --- client/resources.qrc | 3 + client/ui/controllers/pageController.h | 28 +++++-- .../qml/Components/HomeContainersListView.qml | 1 + .../Components/Protocols/OpenVpnSettings.qml | 81 +++++++++++++++++++ .../Components/SettingsContainersListView.qml | 4 +- .../qml/Components/TransportProtoSelector.qml | 59 ++++++++++++++ .../qml/Controls2/HorizontalRadioButton.qml | 10 +-- client/ui/qml/Pages2/PageHome.qml | 5 +- .../qml/Pages2/PageSettingsServerProtocol.qml | 24 ++++++ .../ui/qml/Pages2/PageSettingsServersList.qml | 1 + .../PageSetupWizardProtocolSettings.qml | 59 +++----------- client/ui/qml/Pages2/PageStart.qml | 1 + 12 files changed, 209 insertions(+), 67 deletions(-) create mode 100644 client/ui/qml/Components/Protocols/OpenVpnSettings.qml create mode 100644 client/ui/qml/Components/TransportProtoSelector.qml create mode 100644 client/ui/qml/Pages2/PageSettingsServerProtocol.qml diff --git a/client/resources.qrc b/client/resources.qrc index 185c4469..e2f16853 100644 --- a/client/resources.qrc +++ b/client/resources.qrc @@ -254,5 +254,8 @@ ui/qml/Components/QuestionDrawer.qml ui/qml/Pages2/PageDeinstalling.qml ui/qml/Controls2/BackButtonType.qml + ui/qml/Pages2/PageSettingsServerProtocol.qml + ui/qml/Components/Protocols/OpenVpnSettings.qml + ui/qml/Components/TransportProtoSelector.qml diff --git a/client/ui/controllers/pageController.h b/client/ui/controllers/pageController.h index 22ee0bb3..946c1ce5 100644 --- a/client/ui/controllers/pageController.h +++ b/client/ui/controllers/pageController.h @@ -9,14 +9,30 @@ namespace PageLoader { Q_NAMESPACE - enum class PageEnum { PageStart = 0, PageHome, PageShare, PageDeinstalling, + enum class PageEnum { + PageStart = 0, + PageHome, + PageShare, + PageDeinstalling, - PageSettingsServersList, PageSettings, PageSettingsServerData, PageSettingsServerInfo, - PageSettingsServerProtocols, PageSettingsServerServices, + PageSettingsServersList, + PageSettings, + PageSettingsServerData, + PageSettingsServerInfo, + PageSettingsServerProtocols, + PageSettingsServerServices, + PageSettingsServerProtocol, - PageSetupWizardStart, PageTest, PageSetupWizardCredentials, PageSetupWizardProtocols, PageSetupWizardEasy, - PageSetupWizardProtocolSettings, PageSetupWizardInstalling, PageSetupWizardConfigSource, - PageSetupWizardTextKey, PageSetupWizardViewConfig + PageSetupWizardStart, + PageTest, + PageSetupWizardCredentials, + PageSetupWizardProtocols, + PageSetupWizardEasy, + PageSetupWizardProtocolSettings, + PageSetupWizardInstalling, + PageSetupWizardConfigSource, + PageSetupWizardTextKey, + PageSetupWizardViewConfig }; Q_ENUM_NS(PageEnum) diff --git a/client/ui/qml/Components/HomeContainersListView.qml b/client/ui/qml/Components/HomeContainersListView.qml index 0d42b8e9..926302c4 100644 --- a/client/ui/qml/Components/HomeContainersListView.qml +++ b/client/ui/qml/Components/HomeContainersListView.qml @@ -20,6 +20,7 @@ ListView { height: menuContent.contentItem.height clip: true + interactive: false ButtonGroup { id: containersRadioButtonGroup diff --git a/client/ui/qml/Components/Protocols/OpenVpnSettings.qml b/client/ui/qml/Components/Protocols/OpenVpnSettings.qml new file mode 100644 index 00000000..8c036fc0 --- /dev/null +++ b/client/ui/qml/Components/Protocols/OpenVpnSettings.qml @@ -0,0 +1,81 @@ +import QtQuick 2.15 +import QtQuick.Controls +import QtQuick.Layouts + +import "../../Controls2" +import "../../Controls2/TextTypes" +import "../../Components" + +Item { + id: root + + ColumnLayout { + anchors.fill: parent + + anchors.leftMargin: 16 + anchors.rightMargin: 16 + + spacing: 16 + + Header2TextType { + Layout.fillWidth: true + + text: "OpenVpn" + } + + TextFieldWithHeaderType { + Layout.fillWidth: true + + headerText: qsTr("VPN Addresses Subnet") + } + + ParagraphTextType { + Layout.fillWidth: true + + text: qsTr("Network protocol") + } + + TransportProtoSelector { + Layout.fillWidth: true + } + + TextFieldWithHeaderType { + Layout.fillWidth: true + + headerText: qsTr("Port") + } + + SwitcherType { + Layout.fillWidth: true + text: qsTr("Auto-negotiate encryption") + } + + DropDownType { + Layout.fillWidth: true + + } + + DropDownType { + Layout.fillWidth: true + + } + + CheckBoxType { + Layout.fillWidth: true + + text: qsTr("TLS auth") + } + + CheckBoxType { + Layout.fillWidth: true + + text: qsTr("Block DNS requests outside of VPN") + } + + SwitcherType { + Layout.fillWidth: true + + text: qsTr("Additional configuration commands") + } + } +} diff --git a/client/ui/qml/Components/SettingsContainersListView.qml b/client/ui/qml/Components/SettingsContainersListView.qml index 5175fd49..334696b0 100644 --- a/client/ui/qml/Components/SettingsContainersListView.qml +++ b/client/ui/qml/Components/SettingsContainersListView.qml @@ -18,6 +18,7 @@ ListView { height: root.contentItem.height clip: true + interactive: false ButtonGroup { id: containersRadioButtonGroup @@ -89,8 +90,7 @@ ListView { onClicked: { if (isInstalled) { -// isDefault = true -// root.currentIndex = index + goToPage(PageEnum.PageSettingsServerProtocol) } else { ContainersModel.setCurrentlyInstalledContainerIndex(root.model.mapToSource(index)) InstallController.setShouldCreateServer(false) diff --git a/client/ui/qml/Components/TransportProtoSelector.qml b/client/ui/qml/Components/TransportProtoSelector.qml new file mode 100644 index 00000000..6f5aa44b --- /dev/null +++ b/client/ui/qml/Components/TransportProtoSelector.qml @@ -0,0 +1,59 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts + +import "../Controls2" +import "../Controls2/TextTypes" + +Rectangle { + id: root + + property var rootWidth: root.width + property int currentIndex + + property alias mouseArea: transportProtoButtonMouseArea + + implicitWidth: transportProtoButtonGroup.implicitWidth + implicitHeight: transportProtoButtonGroup.implicitHeight + + color: "#1C1D21" + radius: 16 + + RowLayout { + id: transportProtoButtonGroup + + spacing: 0 + + HorizontalRadioButton { + checked: root.currentIndex === 0 + + implicitWidth: (rootWidth - 32) / 2 + text: "UDP" + + hoverEnabled: !transportProtoButtonMouseArea.enabled + + onClicked: { + root.currentIndex = 0 + } + } + + HorizontalRadioButton { + checked: root.currentIndex === 1 + + implicitWidth: (rootWidth - 32) / 2 + text: "TCP" + + hoverEnabled: !transportProtoButtonMouseArea.enabled + + onClicked: { + root.currentIndex = 1 + } + } + } + + MouseArea { + id: transportProtoButtonMouseArea + + anchors.fill: parent + } +} diff --git a/client/ui/qml/Controls2/HorizontalRadioButton.qml b/client/ui/qml/Controls2/HorizontalRadioButton.qml index 6f00d210..86218b3f 100644 --- a/client/ui/qml/Controls2/HorizontalRadioButton.qml +++ b/client/ui/qml/Controls2/HorizontalRadioButton.qml @@ -2,6 +2,8 @@ import QtQuick import QtQuick.Controls import QtQuick.Layouts +import "TextTypes" + RadioButton { id: root @@ -74,15 +76,9 @@ RadioButton { anchors.fill: parent spacing: 16 - Text { + ButtonTextType { text: root.text - wrapMode: Text.WordWrap - color: "#D7D8DB" - font.pixelSize: 16 - font.weight: 400 - font.family: "PT Root UI VF" - height: 24 Layout.fillWidth: true Layout.rightMargin: 16 Layout.leftMargin: 16 diff --git a/client/ui/qml/Pages2/PageHome.qml b/client/ui/qml/Pages2/PageHome.qml index e5521787..276764a3 100644 --- a/client/ui/qml/Pages2/PageHome.qml +++ b/client/ui/qml/Pages2/PageHome.qml @@ -164,7 +164,7 @@ PageType { text: root.currentContainerName textColor: "#0E0E11" - headerText: "Протокол подключения" + headerText: qsTr("Протокол подключения") headerBackButtonImage: "qrc:/images/controls/arrow-left.svg" onRootButtonClicked: function() { @@ -198,7 +198,7 @@ PageType { actionButtonImage: "qrc:/images/controls/plus.svg" - headerText: "Серверы" + headerText: qsTr("Servers") actionButtonFunction: function() { menu.visible = false @@ -237,6 +237,7 @@ PageType { currentIndex: ServersModel.getDefaultServerIndex() clip: true + interactive: false delegate: Item { id: menuContentDelegate diff --git a/client/ui/qml/Pages2/PageSettingsServerProtocol.qml b/client/ui/qml/Pages2/PageSettingsServerProtocol.qml new file mode 100644 index 00000000..800041f0 --- /dev/null +++ b/client/ui/qml/Pages2/PageSettingsServerProtocol.qml @@ -0,0 +1,24 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts + +import SortFilterProxyModel 0.2 + +import PageEnum 1.0 +import ProtocolEnum 1.0 +import ContainerProps 1.0 + +import "./" +import "../Controls2" +import "../Controls2/TextTypes" +import "../Config" +import "../Components" +import "../Components/Protocols" + +PageType { + id: root + + OpenVpnSettings { + anchors.fill: parent + } +} diff --git a/client/ui/qml/Pages2/PageSettingsServersList.qml b/client/ui/qml/Pages2/PageSettingsServersList.qml index 9c5ddc74..fa4ce86c 100644 --- a/client/ui/qml/Pages2/PageSettingsServersList.qml +++ b/client/ui/qml/Pages2/PageSettingsServersList.qml @@ -67,6 +67,7 @@ PageType { model: ServersModel clip: true + interactive: false delegate: Item { implicitWidth: servers.width diff --git a/client/ui/qml/Pages2/PageSetupWizardProtocolSettings.qml b/client/ui/qml/Pages2/PageSetupWizardProtocolSettings.qml index 19f81d09..57fa497d 100644 --- a/client/ui/qml/Pages2/PageSetupWizardProtocolSettings.qml +++ b/client/ui/qml/Pages2/PageSetupWizardProtocolSettings.qml @@ -12,6 +12,7 @@ import "./" import "../Controls2" import "../Controls2/TextTypes" import "../Config" +import "../Components" PageType { id: root @@ -83,53 +84,11 @@ PageType { text: "Network protocol" } - Rectangle { - id: transportProtoBackground + TransportProtoSelector { + id: transportProtoSelector - implicitWidth: transportProtoButtonGroup.implicitWidth - implicitHeight: transportProtoButtonGroup.implicitHeight - - color: "#1C1D21" - radius: 16 - - RowLayout { - id: transportProtoButtonGroup - - property int currentIndex - spacing: 0 - - HorizontalRadioButton { - checked: transportProtoButtonGroup.currentIndex === 0 - - implicitWidth: (root.width - 32) / 2 - text: "UDP" - - hoverEnabled: !transportProtoButtonMouseArea.enabled - - onClicked: { - transportProtoButtonGroup.currentIndex = 0 - } - } - - HorizontalRadioButton { - checked: transportProtoButtonGroup.currentIndex === 1 - - implicitWidth: (root.width - 32) / 2 - text: "TCP" - - hoverEnabled: !transportProtoButtonMouseArea.enabled - - onClicked: { - transportProtoButtonGroup.currentIndex = 1 - } - } - } - - MouseArea { - id: transportProtoButtonMouseArea - - anchors.fill: parent - } + Layout.fillWidth: true + rootWidth: root.width } TextFieldWithHeaderType { @@ -143,7 +102,7 @@ PageType { Rectangle { // todo make it dynamic implicitHeight: root.height - port.implicitHeight - - transportProtoBackground.implicitHeight - transportProtoHeader.implicitHeight - + transportProtoSelector.implicitHeight - transportProtoHeader.implicitHeight - header.implicitHeight - backButton.implicitHeight - installButton.implicitHeight - 116 color: "transparent" @@ -159,7 +118,7 @@ PageType { onClicked: function() { goToPage(PageEnum.PageSetupWizardInstalling); - InstallController.install(dockerContainer, port.textFieldText, transportProtoButtonGroup.currentIndex) + InstallController.install(dockerContainer, port.textFieldText, transportProtoSelector.currentIndex) } } @@ -172,10 +131,10 @@ PageType { } else { port.textFieldText = ProtocolProps.defaultPort(defaultContainerProto) } - transportProtoButtonGroup.currentIndex = ProtocolProps.defaultTransportProto(defaultContainerProto) + transportProtoSelector.currentIndex = ProtocolProps.defaultTransportProto(defaultContainerProto) port.enabled = ProtocolProps.defaultPortChangeable(defaultContainerProto) - transportProtoButtonMouseArea.enabled = !ProtocolProps.defaultTransportProtoChangeable(defaultContainerProto) + transportProtoSelector.mouseArea.enabled = !ProtocolProps.defaultTransportProtoChangeable(defaultContainerProto) } } } diff --git a/client/ui/qml/Pages2/PageStart.qml b/client/ui/qml/Pages2/PageStart.qml index 436194b2..a801bb66 100644 --- a/client/ui/qml/Pages2/PageStart.qml +++ b/client/ui/qml/Pages2/PageStart.qml @@ -78,6 +78,7 @@ PageType { TabImageButtonType { isSelected: tabBar.currentIndex === 1 image: "qrc:/images/controls/share-2.svg" + onClicked: {} } TabImageButtonType { isSelected: tabBar.currentIndex === 2