NewServerSettings qml rework
This commit is contained in:
parent
3175bc1e48
commit
40fa2d6779
34 changed files with 644 additions and 255 deletions
|
@ -18,6 +18,7 @@ HEADERS += \
|
|||
configurators/ssh_configurator.h \
|
||||
configurators/vpn_configurator.h \
|
||||
configurators/wireguard_configurator.h \
|
||||
containers/containers_defs.h \
|
||||
core/defs.h \
|
||||
core/errorstrings.h \
|
||||
core/ipcclient.h \
|
||||
|
@ -33,6 +34,7 @@ HEADERS += \
|
|||
protocols/shadowsocksvpnprotocol.h \
|
||||
protocols/wireguardprotocol.h \
|
||||
settings.h \
|
||||
ui/models/all_containers_model.h \
|
||||
ui/pages.h \
|
||||
ui/pages_logic/AppSettingsLogic.h \
|
||||
ui/pages_logic/GeneralSettingsLogic.h \
|
||||
|
@ -52,10 +54,10 @@ HEADERS += \
|
|||
ui/pages_logic/protocols/OpenVpnLogic.h \
|
||||
ui/pages_logic/protocols/ShadowSocksLogic.h \
|
||||
ui/property_helper.h \
|
||||
ui/serversmodel.h \
|
||||
ui/models/servers_model.h \
|
||||
ui/uilogic.h \
|
||||
ui/qautostart.h \
|
||||
ui/sites_model.h \
|
||||
ui/models/sites_model.h \
|
||||
utils.h \
|
||||
vpnconnection.h \
|
||||
protocols/vpnprotocol.h \
|
||||
|
@ -67,6 +69,7 @@ SOURCES += \
|
|||
configurators/ssh_configurator.cpp \
|
||||
configurators/vpn_configurator.cpp \
|
||||
configurators/wireguard_configurator.cpp \
|
||||
containers/containers_defs.cpp \
|
||||
core/errorstrings.cpp \
|
||||
core/ipcclient.cpp \
|
||||
configurators/openvpn_configurator.cpp \
|
||||
|
@ -81,6 +84,7 @@ SOURCES += \
|
|||
protocols/shadowsocksvpnprotocol.cpp \
|
||||
protocols/wireguardprotocol.cpp \
|
||||
settings.cpp \
|
||||
ui/models/all_containers_model.cpp \
|
||||
ui/pages_logic/AppSettingsLogic.cpp \
|
||||
ui/pages_logic/GeneralSettingsLogic.cpp \
|
||||
ui/pages_logic/NetworkSettingsLogic.cpp \
|
||||
|
@ -98,10 +102,10 @@ SOURCES += \
|
|||
ui/pages_logic/protocols/CloakLogic.cpp \
|
||||
ui/pages_logic/protocols/OpenVpnLogic.cpp \
|
||||
ui/pages_logic/protocols/ShadowSocksLogic.cpp \
|
||||
ui/serversmodel.cpp \
|
||||
ui/models/servers_model.cpp \
|
||||
ui/uilogic.cpp \
|
||||
ui/qautostart.cpp \
|
||||
ui/sites_model.cpp \
|
||||
ui/models/sites_model.cpp \
|
||||
utils.cpp \
|
||||
vpnconnection.cpp \
|
||||
protocols/vpnprotocol.cpp \
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
|
||||
#include "protocols/protocols_defs.h"
|
||||
#include "containers/containers_defs.h"
|
||||
|
||||
QString CloakConfigurator::genCloakConfig(const ServerCredentials &credentials,
|
||||
DockerContainer container, const QJsonObject &containerConfig, ErrorCode *errorCode)
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <QTemporaryFile>
|
||||
|
||||
#include "core/server_defs.h"
|
||||
#include "protocols/protocols_defs.h"
|
||||
#include "containers/containers_defs.h"
|
||||
#include "core/scripts_registry.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
|
||||
#include "protocols/protocols_defs.h"
|
||||
#include "containers/containers_defs.h"
|
||||
|
||||
QString ShadowSocksConfigurator::genShadowSocksConfig(const ServerCredentials &credentials,
|
||||
DockerContainer container, const QJsonObject &containerConfig, ErrorCode *errorCode)
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
|
||||
#include "protocols/protocols_defs.h"
|
||||
#include "containers/containers_defs.h"
|
||||
|
||||
|
||||
QString VpnConfigurator::genVpnProtocolConfig(const ServerCredentials &credentials,
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "sftpdefs.h"
|
||||
|
||||
#include "core/server_defs.h"
|
||||
#include "protocols/protocols_defs.h"
|
||||
#include "containers/containers_defs.h"
|
||||
#include "core/scripts_registry.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
|
87
client/containers/containers_defs.cpp
Normal file
87
client/containers/containers_defs.cpp
Normal file
|
@ -0,0 +1,87 @@
|
|||
#include "containers_defs.h"
|
||||
|
||||
QDebug operator<<(QDebug debug, const amnezia::DockerContainer &c)
|
||||
{
|
||||
QDebugStateSaver saver(debug);
|
||||
debug.nospace() << containerToString(c);
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
||||
amnezia::DockerContainer amnezia::containerFromString(const QString &container){
|
||||
if (container == config_key::amnezia_openvpn) return DockerContainer::OpenVpn;
|
||||
if (container == config_key::amnezia_openvpn_cloak) return DockerContainer::OpenVpnOverCloak;
|
||||
if (container == config_key::amnezia_shadowsocks) return DockerContainer::OpenVpnOverShadowSocks;
|
||||
if (container == config_key::amnezia_wireguard) return DockerContainer::WireGuard;
|
||||
return DockerContainer::None;
|
||||
}
|
||||
|
||||
QString amnezia::containerToString(amnezia::DockerContainer container){
|
||||
switch (container) {
|
||||
case(DockerContainer::OpenVpn): return config_key::amnezia_openvpn;
|
||||
case(DockerContainer::OpenVpnOverCloak): return config_key::amnezia_openvpn_cloak;
|
||||
case(DockerContainer::OpenVpnOverShadowSocks): return config_key::amnezia_shadowsocks;
|
||||
case(DockerContainer::WireGuard): return config_key::amnezia_wireguard;
|
||||
default: return "none";
|
||||
}
|
||||
}
|
||||
|
||||
QVector<amnezia::Protocol> amnezia::protocolsForContainer(amnezia::DockerContainer container)
|
||||
{
|
||||
switch (container) {
|
||||
case DockerContainer::OpenVpn:
|
||||
return { Protocol::OpenVpn };
|
||||
|
||||
case DockerContainer::OpenVpnOverShadowSocks:
|
||||
return { Protocol::OpenVpn, Protocol::ShadowSocks };
|
||||
|
||||
case DockerContainer::OpenVpnOverCloak:
|
||||
return { Protocol::OpenVpn, Protocol::ShadowSocks, Protocol::Cloak };
|
||||
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
QVector<amnezia::DockerContainer> amnezia::allContainers()
|
||||
{
|
||||
return QVector<amnezia::DockerContainer> {
|
||||
DockerContainer::OpenVpn,
|
||||
DockerContainer::OpenVpnOverShadowSocks,
|
||||
DockerContainer::OpenVpnOverCloak,
|
||||
DockerContainer::WireGuard
|
||||
};
|
||||
}
|
||||
|
||||
QMap<DockerContainer, QString> amnezia::containerHumanNames()
|
||||
{
|
||||
return {
|
||||
{DockerContainer::OpenVpn, "OpenVPN"},
|
||||
{DockerContainer::OpenVpnOverShadowSocks, "OpenVpn over ShadowSocks"},
|
||||
{DockerContainer::OpenVpnOverCloak, "OpenVpn over Cloak"},
|
||||
{DockerContainer::WireGuard, "WireGuard"}
|
||||
};
|
||||
}
|
||||
|
||||
QMap<DockerContainer, QString> amnezia::containerDescriptions()
|
||||
{
|
||||
return {
|
||||
{DockerContainer::OpenVpn, QObject::tr("OpenVPN container")},
|
||||
{DockerContainer::OpenVpnOverShadowSocks, QObject::tr("Container with OpenVpn and ShadowSocks")},
|
||||
{DockerContainer::OpenVpnOverCloak, QObject::tr("Container with OpenVpn and ShadowSocks protocols "
|
||||
"configured with traffic masking by Cloak plugin")},
|
||||
{DockerContainer::WireGuard, QObject::tr("WireGuard container")}
|
||||
};
|
||||
}
|
||||
|
||||
bool amnezia::isContainerVpnType(DockerContainer c)
|
||||
{
|
||||
switch (c) {
|
||||
case DockerContainer::None : return false;
|
||||
case DockerContainer::OpenVpn : return true;
|
||||
case DockerContainer::OpenVpnOverCloak : return true;
|
||||
case DockerContainer::OpenVpnOverShadowSocks : return true;
|
||||
case DockerContainer::WireGuard : return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
35
client/containers/containers_defs.h
Normal file
35
client/containers/containers_defs.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
#ifndef CONTAIERNS_DEFS_H
|
||||
#define CONTAIERNS_DEFS_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "../protocols/protocols_defs.h"
|
||||
|
||||
using namespace amnezia;
|
||||
|
||||
namespace amnezia {
|
||||
|
||||
enum class DockerContainer {
|
||||
None,
|
||||
OpenVpn,
|
||||
OpenVpnOverShadowSocks,
|
||||
OpenVpnOverCloak,
|
||||
WireGuard
|
||||
};
|
||||
|
||||
DockerContainer containerFromString(const QString &container);
|
||||
QString containerToString(DockerContainer container);
|
||||
|
||||
QVector<DockerContainer> allContainers();
|
||||
|
||||
QMap<DockerContainer, QString> containerHumanNames();
|
||||
QMap<DockerContainer, QString> containerDescriptions();
|
||||
bool isContainerVpnType(DockerContainer c);
|
||||
|
||||
QVector<Protocol> protocolsForContainer(DockerContainer container);
|
||||
|
||||
} // namespace amnezia
|
||||
|
||||
QDebug operator<<(QDebug debug, const amnezia::DockerContainer &c);
|
||||
|
||||
#endif // CONTAIERNS_DEFS_H
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <QLatin1String>
|
||||
#include "core/defs.h"
|
||||
#include "protocols/protocols_defs.h"
|
||||
#include "containers/containers_defs.h"
|
||||
|
||||
namespace amnezia {
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define SERVER_DEFS_H
|
||||
|
||||
#include <QObject>
|
||||
#include "protocols/protocols_defs.h"
|
||||
#include "containers/containers_defs.h"
|
||||
|
||||
namespace amnezia {
|
||||
namespace server {
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "sftpchannel.h"
|
||||
#include "sshconnectionmanager.h"
|
||||
|
||||
#include "protocols/protocols_defs.h"
|
||||
#include "containers/containers_defs.h"
|
||||
#include "server_defs.h"
|
||||
#include "scripts_registry.h"
|
||||
#include "utils.h"
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "sshconnection.h"
|
||||
#include "sshremoteprocess.h"
|
||||
#include "defs.h"
|
||||
#include "protocols/protocols_defs.h"
|
||||
#include "containers/containers_defs.h"
|
||||
|
||||
#include "sftpdefs.h"
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "core/servercontroller.h"
|
||||
|
||||
#include "utils.h"
|
||||
#include "protocols/protocols_defs.h"
|
||||
#include "containers/containers_defs.h"
|
||||
|
||||
#include <QCryptographicHash>
|
||||
#include <QDebug>
|
||||
|
|
|
@ -8,14 +8,6 @@ QDebug operator<<(QDebug debug, const amnezia::Protocol &p)
|
|||
return debug;
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug debug, const amnezia::DockerContainer &c)
|
||||
{
|
||||
QDebugStateSaver saver(debug);
|
||||
debug.nospace() << containerToString(c);
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
||||
amnezia::Protocol amnezia::protoFromString(QString proto){
|
||||
if (proto == config_key::openvpn) return Protocol::OpenVpn;
|
||||
if (proto == config_key::cloak) return Protocol::Cloak;
|
||||
|
@ -34,24 +26,6 @@ QString amnezia::protoToString(amnezia::Protocol proto){
|
|||
}
|
||||
}
|
||||
|
||||
amnezia::DockerContainer amnezia::containerFromString(const QString &container){
|
||||
if (container == config_key::amnezia_openvpn) return DockerContainer::OpenVpn;
|
||||
if (container == config_key::amnezia_openvpn_cloak) return DockerContainer::OpenVpnOverCloak;
|
||||
if (container == config_key::amnezia_shadowsocks) return DockerContainer::OpenVpnOverShadowSocks;
|
||||
if (container == config_key::amnezia_wireguard) return DockerContainer::WireGuard;
|
||||
return DockerContainer::None;
|
||||
}
|
||||
|
||||
QString amnezia::containerToString(amnezia::DockerContainer container){
|
||||
switch (container) {
|
||||
case(DockerContainer::OpenVpn): return config_key::amnezia_openvpn;
|
||||
case(DockerContainer::OpenVpnOverCloak): return config_key::amnezia_openvpn_cloak;
|
||||
case(DockerContainer::OpenVpnOverShadowSocks): return config_key::amnezia_shadowsocks;
|
||||
case(DockerContainer::WireGuard): return config_key::amnezia_wireguard;
|
||||
default: return "none";
|
||||
}
|
||||
}
|
||||
|
||||
QVector<amnezia::Protocol> amnezia::allProtocols()
|
||||
{
|
||||
return QVector<amnezia::Protocol> {
|
||||
|
@ -62,19 +36,3 @@ QVector<amnezia::Protocol> amnezia::allProtocols()
|
|||
};
|
||||
}
|
||||
|
||||
QVector<amnezia::Protocol> amnezia::protocolsForContainer(amnezia::DockerContainer container)
|
||||
{
|
||||
switch (container) {
|
||||
case DockerContainer::OpenVpn:
|
||||
return { Protocol::OpenVpn };
|
||||
|
||||
case DockerContainer::OpenVpnOverShadowSocks:
|
||||
return { Protocol::OpenVpn, Protocol::ShadowSocks };
|
||||
|
||||
case DockerContainer::OpenVpnOverCloak:
|
||||
return { Protocol::OpenVpn, Protocol::ShadowSocks, Protocol::Cloak };
|
||||
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,22 +126,8 @@ Protocol protoFromString(QString proto);
|
|||
QString protoToString(Protocol proto);
|
||||
|
||||
|
||||
enum class DockerContainer {
|
||||
None,
|
||||
OpenVpn,
|
||||
OpenVpnOverShadowSocks,
|
||||
OpenVpnOverCloak,
|
||||
WireGuard
|
||||
};
|
||||
|
||||
DockerContainer containerFromString(const QString &container);
|
||||
QString containerToString(DockerContainer container);
|
||||
|
||||
QVector<Protocol> protocolsForContainer(DockerContainer container);
|
||||
|
||||
} // namespace amnezia
|
||||
|
||||
QDebug operator<<(QDebug debug, const amnezia::Protocol &p);
|
||||
QDebug operator<<(QDebug debug, const amnezia::DockerContainer &c);
|
||||
|
||||
#endif // PROTOCOLS_DEFS_H
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "debug.h"
|
||||
#include "utils.h"
|
||||
#include "protocols/protocols_defs.h"
|
||||
#include "containers/containers_defs.h"
|
||||
|
||||
#include <QCryptographicHash>
|
||||
#include <QJsonDocument>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "openvpnprotocol.h"
|
||||
#include "QProcess"
|
||||
#include "protocols/protocols_defs.h"
|
||||
#include "containers/containers_defs.h"
|
||||
|
||||
class ShadowSocksVpnProtocol : public OpenVpnProtocol
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "vpnprotocol.h"
|
||||
#include "core/errorstrings.h"
|
||||
#include "protocols/protocols_defs.h"
|
||||
#include "containers/containers_defs.h"
|
||||
|
||||
VpnProtocol::VpnProtocol(const QJsonObject &configuration, QObject* parent)
|
||||
: QObject(parent),
|
||||
|
|
|
@ -107,5 +107,6 @@
|
|||
<file>ui/qml/Pages/InstallSettings/InstallSettingsBase.qml</file>
|
||||
<file>ui/qml/Controls/Caption.qml</file>
|
||||
<file>ui/qml/Controls/Logo.qml</file>
|
||||
<file>ui/qml/Pages/InstallSettings/SelectContainer.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "utils.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include "protocols/protocols_defs.h"
|
||||
#include "containers/containers_defs.h"
|
||||
|
||||
const char Settings::cloudFlareNs1[] = "1.1.1.1";
|
||||
const char Settings::cloudFlareNs2[] = "1.0.0.1";
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <QJsonObject>
|
||||
|
||||
#include "core/defs.h"
|
||||
#include "protocols/protocols_defs.h"
|
||||
#include "containers/containers_defs.h"
|
||||
|
||||
using namespace amnezia;
|
||||
|
||||
|
|
51
client/ui/models/all_containers_model.cpp
Normal file
51
client/ui/models/all_containers_model.cpp
Normal file
|
@ -0,0 +1,51 @@
|
|||
#include "all_containers_model.h"
|
||||
|
||||
AllContainersModel::AllContainersModel(QObject *parent) :
|
||||
QAbstractListModel(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int AllContainersModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
return amnezia::allContainers().size();
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> AllContainersModel::roleNames() const {
|
||||
QHash<int, QByteArray> roles;
|
||||
roles[NameRole] = "name";
|
||||
roles[DescRole] = "desc";
|
||||
roles[TypeRole] = "is_vpn";
|
||||
roles[InstalledRole] = "installed";
|
||||
return roles;
|
||||
}
|
||||
|
||||
QVariant AllContainersModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid() || index.row() < 0
|
||||
|| index.row() >= amnezia::allContainers().size()) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
DockerContainer c = amnezia::allContainers().at(index.row());
|
||||
if (role == NameRole) {
|
||||
return containerHumanNames().value(c);
|
||||
}
|
||||
if (role == DescRole) {
|
||||
return containerDescriptions().value(c);
|
||||
}
|
||||
if (role == TypeRole) {
|
||||
return isContainerVpnType(c);
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void AllContainersModel::setServerData(const QJsonObject &server)
|
||||
{
|
||||
beginResetModel();
|
||||
m_serverData = server;
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
|
36
client/ui/models/all_containers_model.h
Normal file
36
client/ui/models/all_containers_model.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
#ifndef ALL_CONTAINERS_MODEL_H
|
||||
#define ALL_CONTAINERS_MODEL_H
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <QJsonObject>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
|
||||
#include "containers/containers_defs.h"
|
||||
|
||||
class AllContainersModel : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AllContainersModel(QObject *parent = nullptr);
|
||||
public:
|
||||
enum SiteRoles {
|
||||
NameRole = Qt::UserRole + 1,
|
||||
DescRole,
|
||||
TypeRole,
|
||||
InstalledRole
|
||||
};
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
void setServerData(const QJsonObject &server);
|
||||
|
||||
protected:
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
private:
|
||||
QJsonObject m_serverData;
|
||||
};
|
||||
|
||||
#endif // ALL_CONTAINERS_MODEL_H
|
|
@ -1,4 +1,4 @@
|
|||
#include "serversmodel.h"
|
||||
#include "servers_model.h"
|
||||
|
||||
ServersModel::ServersModel(QObject *parent) :
|
||||
QAbstractListModel(parent)
|
|
@ -1,7 +1,7 @@
|
|||
#include "ServerListLogic.h"
|
||||
|
||||
#include "vpnconnection.h"
|
||||
#include "../serversmodel.h"
|
||||
#include "../models/servers_model.h"
|
||||
#include "../uilogic.h"
|
||||
|
||||
ServerListLogic::ServerListLogic(UiLogic *logic, QObject *parent):
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <functional>
|
||||
|
||||
#include "../uilogic.h"
|
||||
#include "../sites_model.h"
|
||||
#include "../models/sites_model.h"
|
||||
|
||||
SitesLogic::SitesLogic(UiLogic *logic, QObject *parent):
|
||||
PageLogicBase(logic, parent),
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
//#include "core/server_defs.h"
|
||||
//#include "core/errorstrings.h"
|
||||
|
||||
//#include "protocols/protocols_defs.h"
|
||||
//#include "containers/containers_defs.h"
|
||||
//#include "protocols/shadowsocksvpnprotocol.h"
|
||||
|
||||
|
||||
|
|
168
client/ui/qml/Pages/InstallSettings/SelectContainer.qml
Normal file
168
client/ui/qml/Pages/InstallSettings/SelectContainer.qml
Normal file
|
@ -0,0 +1,168 @@
|
|||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12
|
||||
import "./"
|
||||
import "../../Controls"
|
||||
import "../../Config"
|
||||
|
||||
Drawer {
|
||||
id: root
|
||||
signal containerSelected(int id)
|
||||
property alias selectedIndex: tb.currentIndex
|
||||
|
||||
z: -3
|
||||
|
||||
y: 0
|
||||
x: 0
|
||||
edge: Qt.RightEdge
|
||||
width: parent.width * 0.85
|
||||
height: parent.height
|
||||
|
||||
modal: true
|
||||
interactive: true
|
||||
|
||||
onClosed: {
|
||||
tb.currentIndex = -1
|
||||
}
|
||||
|
||||
Flickable {
|
||||
clip: true
|
||||
anchors.fill: parent
|
||||
contentHeight: col.height
|
||||
|
||||
Column {
|
||||
id: col
|
||||
anchors {
|
||||
left: parent.left;
|
||||
right: parent.right;
|
||||
}
|
||||
topPadding: 20
|
||||
spacing: 10
|
||||
|
||||
Caption {
|
||||
id: cap1
|
||||
text: qsTr("VPN containers")
|
||||
font.pixelSize: 20
|
||||
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: tb
|
||||
x: 10
|
||||
width: parent.width - 40
|
||||
height: contentItem.height
|
||||
|
||||
spacing: 1
|
||||
clip: true
|
||||
interactive: false
|
||||
model: UiLogic.allContainersModel
|
||||
|
||||
delegate: Item {
|
||||
implicitWidth: 170 * 2
|
||||
implicitHeight: 30
|
||||
Item {
|
||||
width: parent.width
|
||||
height: 30
|
||||
anchors.left: parent.left
|
||||
id: c1
|
||||
Rectangle {
|
||||
anchors.top: parent.top
|
||||
width: parent.width
|
||||
height: 1
|
||||
color: "lightgray"
|
||||
visible: index !== tb.currentIndex
|
||||
}
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "#63B4FB"
|
||||
visible: index === tb.currentIndex
|
||||
|
||||
}
|
||||
Text {
|
||||
id: text_name
|
||||
text: name
|
||||
font.pointSize: 12
|
||||
anchors.fill: parent
|
||||
leftPadding: 10
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
wrapMode: Text.WordWrap
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
tb.currentIndex = index
|
||||
containerSelected(index)
|
||||
root.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Caption {
|
||||
// id: cap2
|
||||
// text: qsTr("Other containers")
|
||||
// }
|
||||
|
||||
// ListView {
|
||||
// id: tb_other
|
||||
// x: 10
|
||||
// //y: 20
|
||||
// width: parent.width - 40
|
||||
// height: contentItem.height
|
||||
|
||||
// spacing: 1
|
||||
// clip: true
|
||||
// interactive: false
|
||||
// property int currentRow: -1
|
||||
// model: UiLogic.allContainersModel
|
||||
|
||||
// delegate: Item {
|
||||
// implicitWidth: 170 * 2
|
||||
// implicitHeight: 30
|
||||
// Item {
|
||||
// width: parent.width
|
||||
// height: 30
|
||||
// anchors.left: parent.left
|
||||
// id: c1_other
|
||||
// Rectangle {
|
||||
// anchors.top: parent.top
|
||||
// width: parent.width
|
||||
// height: 1
|
||||
// color: "lightgray"
|
||||
// visible: index !== tb_other.currentRow
|
||||
// }
|
||||
// Rectangle {
|
||||
// anchors.fill: parent
|
||||
// color: "#63B4FB"
|
||||
// visible: index === tb_other.currentRow
|
||||
|
||||
// }
|
||||
// Text {
|
||||
// id: text_name_other
|
||||
// text: name
|
||||
// font.pointSize: 12
|
||||
// anchors.fill: parent
|
||||
// leftPadding: 10
|
||||
// verticalAlignment: Text.AlignVCenter
|
||||
// wrapMode: Text.WordWrap
|
||||
// }
|
||||
// }
|
||||
|
||||
// MouseArea {
|
||||
// anchors.fill: parent
|
||||
// onClicked: {
|
||||
// tb_other.currentRow = index
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -27,138 +27,47 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
// RoundButton {
|
||||
// id: pb_add_container
|
||||
// anchors.horizontalCenter: parent.horizontalCenter
|
||||
// anchors.top: labelCaption.bottom
|
||||
// anchors.topMargin: 10
|
||||
|
||||
// width: parent.width - 40
|
||||
// height: 40
|
||||
// text: qsTr("Add protocol")
|
||||
// onClicked: drawer_menu.visible ? drawer_menu.close() : drawer_menu.open()
|
||||
|
||||
// }
|
||||
|
||||
// Drawer {
|
||||
// id: drawer_menu
|
||||
// z: -3
|
||||
|
||||
// y: 0
|
||||
// x: 0
|
||||
// edge: Qt.RightEdge
|
||||
// width: parent.width * 0.75
|
||||
// height: parent.height
|
||||
|
||||
// modal: true
|
||||
// interactive: true
|
||||
|
||||
// Label {
|
||||
// text: "Content goes here!"
|
||||
// anchors.centerIn: parent
|
||||
// }
|
||||
// }
|
||||
|
||||
ScrollView {
|
||||
id: scrollView
|
||||
width: parent.width - 40
|
||||
RoundButton {
|
||||
id: pb_add_container
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
anchors.top: caption.bottom
|
||||
anchors.topMargin: 10
|
||||
|
||||
anchors.bottom: pushButtonConfigure.top
|
||||
anchors.bottomMargin: 10
|
||||
width: parent.width - 40
|
||||
height: 40
|
||||
text: qsTr("Add protocol")
|
||||
font.pointSize: 12
|
||||
onClicked: drawer_menu.visible ? drawer_menu.close() : drawer_menu.open()
|
||||
|
||||
clip: true
|
||||
Column {
|
||||
width: scrollView.width
|
||||
}
|
||||
|
||||
SelectContainer {
|
||||
id: drawer_menu
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: frame_settings
|
||||
width: parent.width
|
||||
anchors.top: pb_add_container.bottom
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.topMargin: 10
|
||||
|
||||
border.width: 1
|
||||
border.color: "lightgray"
|
||||
anchors.bottomMargin: 5
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
visible: false
|
||||
radius: 2
|
||||
Grid {
|
||||
id: container
|
||||
anchors.fill: parent
|
||||
columns: 2
|
||||
horizontalItemAlignment: Grid.AlignHCenter
|
||||
verticalItemAlignment: Grid.AlignVCenter
|
||||
topPadding: 5
|
||||
leftPadding: 10
|
||||
spacing: 5
|
||||
InstallSettingsBase {
|
||||
containerDescription: qsTr("OpenVPN and ShadowSocks\n with masking using Cloak plugin")
|
||||
onContainerChecked: NewServerProtocolsLogic.checkBoxCloakChecked = checked
|
||||
|
||||
LabelType {
|
||||
width: 130
|
||||
height: (parent.height - parent.spacing - parent.topPadding * 2) / 2
|
||||
text: qsTr("Port (TCP)")
|
||||
}
|
||||
TextFieldType {
|
||||
width: parent.width - 130 - parent.spacing - parent.leftPadding * 2
|
||||
height: (parent.height - parent.spacing - parent.topPadding * 2) / 2
|
||||
text: NewServerProtocolsLogic.lineEditCloakPortText
|
||||
onEditingFinished: {
|
||||
NewServerProtocolsLogic.lineEditCloakPortText = text
|
||||
}
|
||||
}
|
||||
LabelType {
|
||||
width: 130
|
||||
height: (parent.height - parent.spacing - parent.topPadding * 2) / 2
|
||||
text: qsTr("Fake Web Site")
|
||||
}
|
||||
TextFieldType {
|
||||
width: parent.width - 130 - parent.spacing - parent.leftPadding * 2
|
||||
height: (parent.height - parent.spacing - parent.topPadding * 2) / 2
|
||||
text: NewServerProtocolsLogic.lineEditCloakSiteText
|
||||
onEditingFinished: {
|
||||
NewServerProtocolsLogic.lineEditCloakSiteText = text
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
InstallSettingsBase {
|
||||
containerDescription: qsTr("ShadowSocks")
|
||||
onContainerChecked: NewServerProtocolsLogic.checkBoxSsChecked = checked
|
||||
|
||||
LabelType {
|
||||
width: 130
|
||||
height: (parent.height - parent.spacing - parent.topPadding * 2) / 2
|
||||
text: qsTr("Port (TCP)")
|
||||
}
|
||||
TextFieldType {
|
||||
width: parent.width - 130 - parent.spacing - parent.leftPadding * 2
|
||||
height: (parent.height - parent.spacing - parent.topPadding * 2) / 2
|
||||
text: NewServerProtocolsLogic.lineEditSsPortText
|
||||
onEditingFinished: {
|
||||
NewServerProtocolsLogic.lineEditSsPortText = text
|
||||
}
|
||||
}
|
||||
LabelType {
|
||||
width: 130
|
||||
height: (parent.height - parent.spacing - parent.topPadding * 2) / 2
|
||||
text: qsTr("Encryption")
|
||||
}
|
||||
ComboBoxType {
|
||||
width: parent.width - 130 - parent.spacing - parent.leftPadding * 2
|
||||
height: (parent.height - parent.spacing - parent.topPadding * 2) / 2
|
||||
model: [
|
||||
qsTr("chacha20-ietf-poly1305"),
|
||||
qsTr("xchacha20-ietf-poly1305"),
|
||||
qsTr("aes-256-gcm"),
|
||||
qsTr("aes-192-gcm"),
|
||||
qsTr("aes-128-gcm")
|
||||
]
|
||||
currentIndex: {
|
||||
for (let i = 0; i < model.length; ++i) {
|
||||
if (NewServerProtocolsLogic.comboBoxSsCipherText === model[i]) {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
onCurrentTextChanged: {
|
||||
NewServerProtocolsLogic.comboBoxSsCipherText = currentText
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
InstallSettingsBase {
|
||||
containerDescription: qsTr("OpenVPN")
|
||||
onContainerChecked: NewServerProtocolsLogic.checkBoxOpenVpnChecked = checked
|
||||
|
||||
LabelType {
|
||||
width: 130
|
||||
|
@ -197,25 +106,174 @@ Item {
|
|||
NewServerProtocolsLogic.comboBoxOpenvpnProtoText = currentText
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
InstallSettingsBase {
|
||||
visible: false
|
||||
containerDescription: qsTr("WireGuard")
|
||||
onContainerChecked: NewServerProtocolsLogic.checkBoxWireGuardChecked = checked
|
||||
|
||||
LabelType {
|
||||
width: 130
|
||||
height: (parent.height - parent.spacing - parent.topPadding * 2)
|
||||
text: qsTr("Port (UDP)")
|
||||
}
|
||||
TextFieldType {
|
||||
width: parent.width - 130 - parent.spacing - parent.leftPadding * 2
|
||||
height: (parent.height - parent.spacing - parent.topPadding * 2)
|
||||
text: "32767"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ScrollView {
|
||||
// id: scrollView
|
||||
// width: parent.width - 40
|
||||
// anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
// anchors.top: pb_add_container.bottom
|
||||
// anchors.topMargin: 10
|
||||
|
||||
// anchors.bottom: pushButtonConfigure.top
|
||||
// anchors.bottomMargin: 10
|
||||
|
||||
// clip: true
|
||||
// Column {
|
||||
// width: scrollView.width
|
||||
// anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
// spacing: 5
|
||||
// InstallSettingsBase {
|
||||
// containerDescription: qsTr("OpenVPN and ShadowSocks\n with masking using Cloak plugin")
|
||||
// onContainerChecked: NewServerProtocolsLogic.checkBoxCloakChecked = checked
|
||||
|
||||
// LabelType {
|
||||
// width: 130
|
||||
// height: (parent.height - parent.spacing - parent.topPadding * 2) / 2
|
||||
// text: qsTr("Port (TCP)")
|
||||
// }
|
||||
// TextFieldType {
|
||||
// width: parent.width - 130 - parent.spacing - parent.leftPadding * 2
|
||||
// height: (parent.height - parent.spacing - parent.topPadding * 2) / 2
|
||||
// text: NewServerProtocolsLogic.lineEditCloakPortText
|
||||
// onEditingFinished: {
|
||||
// NewServerProtocolsLogic.lineEditCloakPortText = text
|
||||
// }
|
||||
// }
|
||||
// LabelType {
|
||||
// width: 130
|
||||
// height: (parent.height - parent.spacing - parent.topPadding * 2) / 2
|
||||
// text: qsTr("Fake Web Site")
|
||||
// }
|
||||
// TextFieldType {
|
||||
// width: parent.width - 130 - parent.spacing - parent.leftPadding * 2
|
||||
// height: (parent.height - parent.spacing - parent.topPadding * 2) / 2
|
||||
// text: NewServerProtocolsLogic.lineEditCloakSiteText
|
||||
// onEditingFinished: {
|
||||
// NewServerProtocolsLogic.lineEditCloakSiteText = text
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// InstallSettingsBase {
|
||||
// containerDescription: qsTr("ShadowSocks")
|
||||
// onContainerChecked: NewServerProtocolsLogic.checkBoxSsChecked = checked
|
||||
|
||||
// LabelType {
|
||||
// width: 130
|
||||
// height: (parent.height - parent.spacing - parent.topPadding * 2) / 2
|
||||
// text: qsTr("Port (TCP)")
|
||||
// }
|
||||
// TextFieldType {
|
||||
// width: parent.width - 130 - parent.spacing - parent.leftPadding * 2
|
||||
// height: (parent.height - parent.spacing - parent.topPadding * 2) / 2
|
||||
// text: NewServerProtocolsLogic.lineEditSsPortText
|
||||
// onEditingFinished: {
|
||||
// NewServerProtocolsLogic.lineEditSsPortText = text
|
||||
// }
|
||||
// }
|
||||
// LabelType {
|
||||
// width: 130
|
||||
// height: (parent.height - parent.spacing - parent.topPadding * 2) / 2
|
||||
// text: qsTr("Encryption")
|
||||
// }
|
||||
// ComboBoxType {
|
||||
// width: parent.width - 130 - parent.spacing - parent.leftPadding * 2
|
||||
// height: (parent.height - parent.spacing - parent.topPadding * 2) / 2
|
||||
// model: [
|
||||
// qsTr("chacha20-ietf-poly1305"),
|
||||
// qsTr("xchacha20-ietf-poly1305"),
|
||||
// qsTr("aes-256-gcm"),
|
||||
// qsTr("aes-192-gcm"),
|
||||
// qsTr("aes-128-gcm")
|
||||
// ]
|
||||
// currentIndex: {
|
||||
// for (let i = 0; i < model.length; ++i) {
|
||||
// if (NewServerProtocolsLogic.comboBoxSsCipherText === model[i]) {
|
||||
// return i
|
||||
// }
|
||||
// }
|
||||
// return -1
|
||||
// }
|
||||
// onCurrentTextChanged: {
|
||||
// NewServerProtocolsLogic.comboBoxSsCipherText = currentText
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// InstallSettingsBase {
|
||||
// containerDescription: qsTr("OpenVPN")
|
||||
// onContainerChecked: NewServerProtocolsLogic.checkBoxOpenVpnChecked = checked
|
||||
|
||||
// LabelType {
|
||||
// width: 130
|
||||
// height: (parent.height - parent.spacing - parent.topPadding * 2) / 2
|
||||
// text: qsTr("Port (TCP/UDP)")
|
||||
// }
|
||||
// TextFieldType {
|
||||
// width: parent.width - 130 - parent.spacing - parent.leftPadding * 2
|
||||
// height: (parent.height - parent.spacing - parent.topPadding * 2) / 2
|
||||
// text: NewServerProtocolsLogic.lineEditOpenvpnPortText
|
||||
// onEditingFinished: {
|
||||
// NewServerProtocolsLogic.lineEditOpenvpnPortText = text
|
||||
// }
|
||||
// }
|
||||
// LabelType {
|
||||
// width: 130
|
||||
// height: (parent.height - parent.spacing - parent.topPadding * 2) / 2
|
||||
// text: qsTr("Protocol")
|
||||
// }
|
||||
// ComboBoxType {
|
||||
// width: parent.width - 130 - parent.spacing - parent.leftPadding * 2
|
||||
// height: (parent.height - parent.spacing - parent.topPadding * 2) / 2
|
||||
// model: [
|
||||
// qsTr("udp"),
|
||||
// qsTr("tcp"),
|
||||
// ]
|
||||
// currentIndex: {
|
||||
// for (let i = 0; i < model.length; ++i) {
|
||||
// if (NewServerProtocolsLogic.comboBoxOpenvpnProtoText === model[i]) {
|
||||
// return i
|
||||
// }
|
||||
// }
|
||||
// return -1
|
||||
// }
|
||||
// onCurrentTextChanged: {
|
||||
// NewServerProtocolsLogic.comboBoxOpenvpnProtoText = currentText
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// InstallSettingsBase {
|
||||
// visible: false
|
||||
// containerDescription: qsTr("WireGuard")
|
||||
// onContainerChecked: NewServerProtocolsLogic.checkBoxWireGuardChecked = checked
|
||||
|
||||
// LabelType {
|
||||
// width: 130
|
||||
// height: (parent.height - parent.spacing - parent.topPadding * 2)
|
||||
// text: qsTr("Port (UDP)")
|
||||
// }
|
||||
// TextFieldType {
|
||||
// width: parent.width - 130 - parent.spacing - parent.leftPadding * 2
|
||||
// height: (parent.height - parent.spacing - parent.topPadding * 2)
|
||||
// text: "32767"
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "core/server_defs.h"
|
||||
#include "core/errorstrings.h"
|
||||
|
||||
#include "protocols/protocols_defs.h"
|
||||
#include "containers/containers_defs.h"
|
||||
#include "protocols/shadowsocksvpnprotocol.h"
|
||||
|
||||
#include "ui/qautostart.h"
|
||||
|
@ -72,9 +72,9 @@ UiLogic::UiLogic(QObject *parent) :
|
|||
m_trayIconUrl{},
|
||||
m_trayActionDisconnectEnabled{true},
|
||||
m_trayActionConnectEnabled{true},
|
||||
m_dialogConnectErrorText{},
|
||||
m_vpnConnection(nullptr)
|
||||
m_dialogConnectErrorText{}
|
||||
{
|
||||
m_allContainersModel = new AllContainersModel(this);
|
||||
m_vpnConnection = new VpnConnection(this);
|
||||
|
||||
m_appSettingsLogic = new AppSettingsLogic(this);
|
||||
|
|
|
@ -5,8 +5,11 @@
|
|||
#include <QQmlEngine>
|
||||
#include <functional>
|
||||
|
||||
#include "property_helper.h"
|
||||
#include "pages.h"
|
||||
#include "protocols/vpnprotocol.h"
|
||||
#include "containers/containers_defs.h"
|
||||
#include "models/all_containers_model.h"
|
||||
|
||||
#include "settings.h"
|
||||
|
||||
|
@ -35,6 +38,8 @@ class UiLogic : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
READONLY_PROPERTY(QObject *, allContainersModel)
|
||||
|
||||
Q_PROPERTY(int currentPageValue READ getCurrentPageValue WRITE setCurrentPageValue NOTIFY currentPageValueChanged)
|
||||
Q_PROPERTY(QString trayIconUrl READ getTrayIconUrl WRITE setTrayIconUrl NOTIFY trayIconUrlChanged)
|
||||
Q_PROPERTY(bool trayActionDisconnectEnabled READ getTrayActionDisconnectEnabled WRITE setTrayActionDisconnectEnabled NOTIFY trayActionDisconnectEnabledChanged)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue