minor ui fixes

This commit is contained in:
vladimir.kuznetsov 2023-08-20 13:36:54 +05:00
parent 0060f57b63
commit b5e1c78461
11 changed files with 132 additions and 66 deletions

View file

@ -81,7 +81,7 @@ QMap<DockerContainer, QString> 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<DockerContainer, QString> ContainerProps::containerHumanNames()
}
QMap<DockerContainer, QString> 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<DockerContainer, QString> ContainerProps::containerDetailedDescriptions()
{
return { { DockerContainer::OpenVpn, QObject::tr("OpenVPN container") },
{ DockerContainer::ShadowSocks, QObject::tr("Container with OpenVpn and ShadowSocks") },

View file

@ -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<amnezia::DockerContainer> allContainers();
// non-vpn
TorWebSite,
Dns,
// FileShare,
Sftp
};
Q_ENUM_NS(DockerContainer)
} // namespace ContainerEnumNS
Q_INVOKABLE static QMap<amnezia::DockerContainer, QString> containerHumanNames();
Q_INVOKABLE static QMap<amnezia::DockerContainer, QString> containerDescriptions();
using namespace ContainerEnumNS;
using namespace ProtocolEnumNS;
// these protocols will be displayed in container settings
Q_INVOKABLE static QVector<amnezia::Proto> 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<amnezia::DockerContainer> allContainers();
Q_INVOKABLE static bool isSupportedByCurrentPlatform(amnezia::DockerContainer c);
Q_INVOKABLE static QStringList fixedPortsForContainer(amnezia::DockerContainer c);
Q_INVOKABLE static QMap<amnezia::DockerContainer, QString> containerHumanNames();
Q_INVOKABLE static QMap<amnezia::DockerContainer, QString> containerDescriptions();
Q_INVOKABLE static QMap<amnezia::DockerContainer, QString> 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<amnezia::Proto> 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

View file

@ -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"));
}

View file

@ -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);

View file

@ -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<int, QByteArray> ContainersModel::roleNames() const
{
QHash<int, QByteArray> roles;
roles[NameRole] = "name";
roles[DescRole] = "description";
roles[DescriptionRole] = "description";
roles[DetailedDescriptionRole] = "detailedDescription";
roles[ServiceTypeRole] = "serviceType";
roles[DockerContainerRole] = "dockerContainer";
roles[ConfigRole] = "config";

View file

@ -17,7 +17,8 @@ public:
enum Roles {
NameRole = Qt::UserRole + 1,
DescRole,
DescriptionRole,
DetailedDescriptionRole,
ServiceTypeRole,
ConfigRole,
DockerContainerRole,

View file

@ -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")

View file

@ -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"))
}
}

View file

@ -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 {

View file

@ -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()
}
}
}
}
}

View file

@ -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