From b5e1c78461a9cf52e8743a17e7e675a35a3831f7 Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Sun, 20 Aug 2023 13:36:54 +0500 Subject: [PATCH] minor ui fixes --- client/containers/containers_defs.cpp | 29 ++++- client/containers/containers_defs.h | 105 +++++++++--------- client/ui/controllers/installController.cpp | 15 +++ client/ui/controllers/installController.h | 2 + client/ui/models/containers_model.cpp | 8 +- client/ui/models/containers_model.h | 3 +- .../Pages2/PageServiceTorWebsiteSettings.qml | 2 +- client/ui/qml/Pages2/PageSettingsAbout.qml | 2 +- .../qml/Pages2/PageSettingsSplitTunneling.qml | 2 +- client/ui/qml/Pages2/PageSetupWizardEasy.qml | 26 ++++- .../PageSetupWizardProtocolSettings.qml | 4 +- 11 files changed, 132 insertions(+), 66 deletions(-) diff --git a/client/containers/containers_defs.cpp b/client/containers/containers_defs.cpp index 27f6f1dd..fc4570f4 100644 --- a/client/containers/containers_defs.cpp +++ b/client/containers/containers_defs.cpp @@ -81,7 +81,7 @@ QMap ContainerProps::containerHumanNames() { return { { DockerContainer::None, "Not installed" }, { DockerContainer::OpenVpn, "OpenVPN" }, - { DockerContainer::ShadowSocks, "OpenVPN over ShadowSocks" }, + { DockerContainer::ShadowSocks, "ShadowSocks" }, { DockerContainer::Cloak, "OpenVPN over Cloak" }, { DockerContainer::WireGuard, "WireGuard" }, { DockerContainer::Ipsec, QObject::tr("IPsec") }, @@ -93,6 +93,33 @@ QMap ContainerProps::containerHumanNames() } QMap ContainerProps::containerDescriptions() +{ + return { { DockerContainer::OpenVpn, + QObject::tr("OpenVPN is the most popular VPN protocol, with flexible configuration options. It uses its " + "own security protocol with SSL/TLS for key exchange.") }, + { DockerContainer::ShadowSocks, + QObject::tr("ShadowSocks - masks VPN traffic, making it similar to normal web traffic, but is " + "recognised by analysis systems in some highly censored regions.") }, + { DockerContainer::Cloak, + QObject::tr("OpenVPN over Cloak - OpenVPN with VPN masquerading as web traffic and protection against " + "active-probbing detection. Ideal for bypassing blocking in regions with the highest levels " + "of censorship.") }, + { DockerContainer::WireGuard, + QObject::tr("WireGuard - New popular VPN protocol with high performance, high speed and low power " + "consumption. Recommended for regions with low levels of censorship.") }, + { DockerContainer::Ipsec, + QObject::tr("IKEv2 - Modern stable protocol, a bit faster than others, restores connection after " + "signal loss. It has native support on the latest versions of Android and iOS.") }, + + { DockerContainer::TorWebSite, QObject::tr("Deploy a WordPress site on the Tor network in two clicks.") }, + { DockerContainer::Dns, + QObject::tr("Replace the current DNS server with your own. This will increase your privacy level.") }, + //{DockerContainer::FileShare, QObject::tr("SMB file sharing service - is Window file sharing protocol")}, + { DockerContainer::Sftp, + QObject::tr("Creates a file vault on your server to securely store and transfer files.") } }; +} + +QMap ContainerProps::containerDetailedDescriptions() { return { { DockerContainer::OpenVpn, QObject::tr("OpenVPN container") }, { DockerContainer::ShadowSocks, QObject::tr("Container with OpenVpn and ShadowSocks") }, diff --git a/client/containers/containers_defs.h b/client/containers/containers_defs.h index d4a35d26..a84d997c 100644 --- a/client/containers/containers_defs.h +++ b/client/containers/containers_defs.h @@ -8,72 +8,69 @@ using namespace amnezia; -namespace amnezia { - -namespace ContainerEnumNS { -Q_NAMESPACE -enum DockerContainer { - None = 0, - OpenVpn, - ShadowSocks, - Cloak, - WireGuard, - Ipsec, - - //non-vpn - TorWebSite, - Dns, - //FileShare, - Sftp -}; -Q_ENUM_NS(DockerContainer) -} // namespace ContainerEnumNS - -using namespace ContainerEnumNS; -using namespace ProtocolEnumNS; - -class ContainerProps : public QObject +namespace amnezia { - Q_OBJECT -public: - Q_INVOKABLE static amnezia::DockerContainer containerFromString(const QString &container); - Q_INVOKABLE static QString containerToString(amnezia::DockerContainer container); - Q_INVOKABLE static QString containerTypeToString(amnezia::DockerContainer c); + namespace ContainerEnumNS + { + Q_NAMESPACE + enum DockerContainer { + None = 0, + OpenVpn, + ShadowSocks, + Cloak, + WireGuard, + Ipsec, - Q_INVOKABLE static QList allContainers(); + // non-vpn + TorWebSite, + Dns, + // FileShare, + Sftp + }; + Q_ENUM_NS(DockerContainer) + } // namespace ContainerEnumNS - Q_INVOKABLE static QMap containerHumanNames(); - Q_INVOKABLE static QMap containerDescriptions(); + using namespace ContainerEnumNS; + using namespace ProtocolEnumNS; - // these protocols will be displayed in container settings - Q_INVOKABLE static QVector protocolsForContainer(amnezia::DockerContainer container); + class ContainerProps : public QObject + { + Q_OBJECT - Q_INVOKABLE static amnezia::ServiceType containerService(amnezia::DockerContainer c); + public: + Q_INVOKABLE static amnezia::DockerContainer containerFromString(const QString &container); + Q_INVOKABLE static QString containerToString(amnezia::DockerContainer container); + Q_INVOKABLE static QString containerTypeToString(amnezia::DockerContainer c); - // binding between Docker container and main protocol of given container - // it may be changed fot future containers :) - Q_INVOKABLE static amnezia::Proto defaultProtocol(amnezia::DockerContainer c); + Q_INVOKABLE static QList allContainers(); - Q_INVOKABLE static bool isSupportedByCurrentPlatform(amnezia::DockerContainer c); - Q_INVOKABLE static QStringList fixedPortsForContainer(amnezia::DockerContainer c); + Q_INVOKABLE static QMap containerHumanNames(); + Q_INVOKABLE static QMap containerDescriptions(); + Q_INVOKABLE static QMap containerDetailedDescriptions(); - static bool isEasySetupContainer(amnezia::DockerContainer container); - static QString easySetupHeader(amnezia::DockerContainer container); - static QString easySetupDescription(amnezia::DockerContainer container); -}; + // these protocols will be displayed in container settings + Q_INVOKABLE static QVector protocolsForContainer(amnezia::DockerContainer container); + Q_INVOKABLE static amnezia::ServiceType containerService(amnezia::DockerContainer c); + // binding between Docker container and main protocol of given container + // it may be changed fot future containers :) + Q_INVOKABLE static amnezia::Proto defaultProtocol(amnezia::DockerContainer c); -static void declareQmlContainerEnum() { - qmlRegisterUncreatableMetaObject( - ContainerEnumNS::staticMetaObject, - "ContainerEnum", - 1, 0, - "ContainerEnum", - "Error: only enums" - ); -} + Q_INVOKABLE static bool isSupportedByCurrentPlatform(amnezia::DockerContainer c); + Q_INVOKABLE static QStringList fixedPortsForContainer(amnezia::DockerContainer c); + + static bool isEasySetupContainer(amnezia::DockerContainer container); + static QString easySetupHeader(amnezia::DockerContainer container); + static QString easySetupDescription(amnezia::DockerContainer container); + }; + + static void declareQmlContainerEnum() + { + qmlRegisterUncreatableMetaObject(ContainerEnumNS::staticMetaObject, "ContainerEnum", 1, 0, "ContainerEnum", + "Error: only enums"); + } } // namespace amnezia diff --git a/client/ui/controllers/installController.cpp b/client/ui/controllers/installController.cpp index 06a5c554..18588aef 100644 --- a/client/ui/controllers/installController.cpp +++ b/client/ui/controllers/installController.cpp @@ -446,3 +446,18 @@ void InstallController::setEncryptedPassphrase(QString passphrase) m_privateKeyPassphrase = passphrase; emit passphraseRequestFinished(); } + +void InstallController::addEmptyServer() +{ + QJsonObject server; + server.insert(config_key::hostName, m_currentlyInstalledServerCredentials.hostName); + server.insert(config_key::userName, m_currentlyInstalledServerCredentials.userName); + server.insert(config_key::password, m_currentlyInstalledServerCredentials.secretData); + server.insert(config_key::port, m_currentlyInstalledServerCredentials.port); + server.insert(config_key::description, m_settings->nextAvailableServerName()); + + m_serversModel->addServer(server); + m_serversModel->setDefaultServerIndex(m_serversModel->getServersCount() - 1); + + emit installServerFinished(tr("Server added successfully")); +} diff --git a/client/ui/controllers/installController.h b/client/ui/controllers/installController.h index 63d4c714..4060c97c 100644 --- a/client/ui/controllers/installController.h +++ b/client/ui/controllers/installController.h @@ -41,6 +41,8 @@ public slots: void setEncryptedPassphrase(QString passphrase); + void addEmptyServer(); + signals: void installContainerFinished(const QString &finishMessage, bool isServiceInstall); void installServerFinished(const QString &finishMessage); diff --git a/client/ui/models/containers_model.cpp b/client/ui/models/containers_model.cpp index dd1d8d4e..0a07895c 100644 --- a/client/ui/models/containers_model.cpp +++ b/client/ui/models/containers_model.cpp @@ -24,7 +24,7 @@ bool ContainersModel::setData(const QModelIndex &index, const QVariant &value, i switch (role) { case NameRole: // return ContainerProps::containerHumanNames().value(container); - case DescRole: + case DescriptionRole: // return ContainerProps::containerDescriptions().value(container); case ConfigRole: { m_settings->setContainerConfig(m_currentlyProcessedServerIndex, container, value.toJsonObject()); @@ -62,7 +62,8 @@ QVariant ContainersModel::data(const QModelIndex &index, int role) const switch (role) { case NameRole: return ContainerProps::containerHumanNames().value(container); - case DescRole: return ContainerProps::containerDescriptions().value(container); + case DescriptionRole: return ContainerProps::containerDescriptions().value(container); + case DetailedDescriptionRole: return ContainerProps::containerDetailedDescriptions().value(container); case ConfigRole: { if (container == DockerContainer::None) { return QJsonObject(); @@ -220,7 +221,8 @@ QHash ContainersModel::roleNames() const { QHash roles; roles[NameRole] = "name"; - roles[DescRole] = "description"; + roles[DescriptionRole] = "description"; + roles[DetailedDescriptionRole] = "detailedDescription"; roles[ServiceTypeRole] = "serviceType"; roles[DockerContainerRole] = "dockerContainer"; roles[ConfigRole] = "config"; diff --git a/client/ui/models/containers_model.h b/client/ui/models/containers_model.h index 8978315c..cde77526 100644 --- a/client/ui/models/containers_model.h +++ b/client/ui/models/containers_model.h @@ -17,7 +17,8 @@ public: enum Roles { NameRole = Qt::UserRole + 1, - DescRole, + DescriptionRole, + DetailedDescriptionRole, ServiceTypeRole, ConfigRole, DockerContainerRole, diff --git a/client/ui/qml/Pages2/PageServiceTorWebsiteSettings.qml b/client/ui/qml/Pages2/PageServiceTorWebsiteSettings.qml index 080f5ee6..38490375 100644 --- a/client/ui/qml/Pages2/PageServiceTorWebsiteSettings.qml +++ b/client/ui/qml/Pages2/PageServiceTorWebsiteSettings.qml @@ -138,7 +138,7 @@ PageType { text: qsTr("Remove website") onClicked: { - questionDrawer.headerText = qsTr("Some description") + questionDrawer.headerText = qsTr("The site with all data will be removed from the tor network.") questionDrawer.yesButtonText = qsTr("Continue") questionDrawer.noButtonText = qsTr("Cancel") diff --git a/client/ui/qml/Pages2/PageSettingsAbout.qml b/client/ui/qml/Pages2/PageSettingsAbout.qml index 9fc23c15..67dada43 100644 --- a/client/ui/qml/Pages2/PageSettingsAbout.qml +++ b/client/ui/qml/Pages2/PageSettingsAbout.qml @@ -81,7 +81,7 @@ And if you don't like the app, all the more support it - the donation will be us text: qsTr("Card on Patreon") - clickedFunction: function() { + onClicked: function() { Qt.openUrlExternally(qsTr("https://www.patreon.com/amneziavpn")) } } diff --git a/client/ui/qml/Pages2/PageSettingsSplitTunneling.qml b/client/ui/qml/Pages2/PageSettingsSplitTunneling.qml index 5cd0d095..71f2ba29 100644 --- a/client/ui/qml/Pages2/PageSettingsSplitTunneling.qml +++ b/client/ui/qml/Pages2/PageSettingsSplitTunneling.qml @@ -43,7 +43,7 @@ PageType { QtObject { id: onlyForwardSites - property string name: qsTr("Addresses from the list should always open via VPN") + property string name: qsTr("Only the addresses in the list must be opened via VPN") property int type: routeMode.onlyForwardSites } QtObject { diff --git a/client/ui/qml/Pages2/PageSetupWizardEasy.qml b/client/ui/qml/Pages2/PageSetupWizardEasy.qml index ac1c3a44..f2600f65 100644 --- a/client/ui/qml/Pages2/PageSetupWizardEasy.qml +++ b/client/ui/qml/Pages2/PageSetupWizardEasy.qml @@ -126,6 +126,8 @@ PageType { } } + DividerType {} + CardType { implicitWidth: parent.width @@ -143,14 +145,14 @@ PageType { id: continueButton implicitWidth: parent.width - anchors.bottomMargin: 24 + anchors.topMargin: 24 text: qsTr("Continue") onClicked: function() { if (root.isEasySetup) { ContainersModel.setCurrentlyProcessedContainerIndex(containers.dockerContainer) - goToPage(PageEnum.PageSetupWizardInstalling); + goToPage(PageEnum.PageSetupWizardInstalling) InstallController.install(containers.dockerContainer, containers.containerDefaultPort, containers.containerDefaultTransportProto) @@ -159,6 +161,26 @@ PageType { } } } + + BasicButtonType { + implicitWidth: parent.width + anchors.topMargin: 8 + anchors.bottomMargin: 24 + + defaultColor: "transparent" + hoveredColor: Qt.rgba(1, 1, 1, 0.08) + pressedColor: Qt.rgba(1, 1, 1, 0.12) + disabledColor: "#878B91" + textColor: "#D7D8DB" + borderWidth: 1 + + text: qsTr("Set up later") + + onClicked: function() { + goToPage(PageEnum.PageSetupWizardInstalling) + InstallController.addEmptyServer() + } + } } } } diff --git a/client/ui/qml/Pages2/PageSetupWizardProtocolSettings.qml b/client/ui/qml/Pages2/PageSetupWizardProtocolSettings.qml index f5f07609..2f5ed569 100644 --- a/client/ui/qml/Pages2/PageSetupWizardProtocolSettings.qml +++ b/client/ui/qml/Pages2/PageSetupWizardProtocolSettings.qml @@ -73,7 +73,7 @@ PageType { Layout.fillWidth: true headerText: qsTr("Installing ") + name - descriptionText: qsTr("protocol description") + descriptionText: description } BasicButtonType { @@ -159,7 +159,7 @@ PageType { font.weight: Font.Medium font.family: "PT Root UI VF" - text: qsTr("detailed protocol description") + text: detailedDescription wrapMode: Text.WordWrap