mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-23 02:00:20 +07:00
refactor OpenVpnConfigModel to use QObject instead of QAbstractListModel
This commit is contained in:
@@ -2,72 +2,128 @@
|
|||||||
|
|
||||||
#include "protocols/protocols_defs.h"
|
#include "protocols/protocols_defs.h"
|
||||||
|
|
||||||
OpenVpnConfigModel::OpenVpnConfigModel(QObject *parent) : QAbstractListModel(parent)
|
OpenVpnConfigModel::OpenVpnConfigModel(QObject *parent)
|
||||||
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int OpenVpnConfigModel::rowCount(const QModelIndex &parent) const
|
QString OpenVpnConfigModel::subnetAddress() const
|
||||||
{
|
{
|
||||||
Q_UNUSED(parent);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OpenVpnConfigModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
|
||||||
{
|
|
||||||
if (!index.isValid() || index.row() < 0 || index.row() >= ContainerProps::allContainers().size()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (role) {
|
|
||||||
case Roles::SubnetAddressRole: m_protocolConfig.insert(amnezia::config_key::subnet_address, value.toString()); break;
|
|
||||||
case Roles::TransportProtoRole: m_protocolConfig.insert(config_key::transport_proto, value.toString()); break;
|
|
||||||
case Roles::PortRole: m_protocolConfig.insert(config_key::port, value.toString()); break;
|
|
||||||
case Roles::AutoNegotiateEncryprionRole: m_protocolConfig.insert(config_key::ncp_disable, !value.toBool()); break;
|
|
||||||
case Roles::HashRole: m_protocolConfig.insert(config_key::hash, value.toString()); break;
|
|
||||||
case Roles::CipherRole: m_protocolConfig.insert(config_key::cipher, value.toString()); break;
|
|
||||||
case Roles::TlsAuthRole: m_protocolConfig.insert(config_key::tls_auth, value.toBool()); break;
|
|
||||||
case Roles::BlockDnsRole: m_protocolConfig.insert(config_key::block_outside_dns, value.toBool()); break;
|
|
||||||
case Roles::AdditionalClientCommandsRole: m_protocolConfig.insert(config_key::additional_client_config, value.toString()); break;
|
|
||||||
case Roles::AdditionalServerCommandsRole: m_protocolConfig.insert(config_key::additional_server_config, value.toString()); break;
|
|
||||||
}
|
|
||||||
|
|
||||||
emit dataChanged(index, index, QList { role });
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant OpenVpnConfigModel::data(const QModelIndex &index, int role) const
|
|
||||||
{
|
|
||||||
if (!index.isValid() || index.row() < 0 || index.row() >= rowCount()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (role) {
|
|
||||||
case Roles::SubnetAddressRole:
|
|
||||||
return m_protocolConfig.value(amnezia::config_key::subnet_address).toString(amnezia::protocols::openvpn::defaultSubnetAddress);
|
return m_protocolConfig.value(amnezia::config_key::subnet_address).toString(amnezia::protocols::openvpn::defaultSubnetAddress);
|
||||||
case Roles::TransportProtoRole:
|
}
|
||||||
|
|
||||||
|
void OpenVpnConfigModel::setSubnetAddress(const QString &subnetAddress)
|
||||||
|
{
|
||||||
|
m_protocolConfig.insert(amnezia::config_key::subnet_address, subnetAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString OpenVpnConfigModel::transportProto() const
|
||||||
|
{
|
||||||
return m_protocolConfig.value(config_key::transport_proto).toString(protocols::openvpn::defaultTransportProto);
|
return m_protocolConfig.value(config_key::transport_proto).toString(protocols::openvpn::defaultTransportProto);
|
||||||
case Roles::PortRole: return m_protocolConfig.value(config_key::port).toString(protocols::openvpn::defaultPort);
|
}
|
||||||
case Roles::AutoNegotiateEncryprionRole:
|
|
||||||
|
void OpenVpnConfigModel::setTransportProto(const QString &transportProto)
|
||||||
|
{
|
||||||
|
m_protocolConfig.insert(config_key::transport_proto, transportProto);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString OpenVpnConfigModel::port() const
|
||||||
|
{
|
||||||
|
return m_protocolConfig.value(config_key::port).toString(protocols::openvpn::defaultPort);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenVpnConfigModel::setPort(const QString &port)
|
||||||
|
{
|
||||||
|
m_protocolConfig.insert(config_key::port, port);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OpenVpnConfigModel::autoNegotiateEncryption() const
|
||||||
|
{
|
||||||
return !m_protocolConfig.value(config_key::ncp_disable).toBool(protocols::openvpn::defaultNcpDisable);
|
return !m_protocolConfig.value(config_key::ncp_disable).toBool(protocols::openvpn::defaultNcpDisable);
|
||||||
case Roles::HashRole: return m_protocolConfig.value(config_key::hash).toString(protocols::openvpn::defaultHash);
|
}
|
||||||
case Roles::CipherRole: return m_protocolConfig.value(config_key::cipher).toString(protocols::openvpn::defaultCipher);
|
|
||||||
case Roles::TlsAuthRole: return m_protocolConfig.value(config_key::tls_auth).toBool(protocols::openvpn::defaultTlsAuth);
|
void OpenVpnConfigModel::setAutoNegotiateEncryption(bool enabled)
|
||||||
case Roles::BlockDnsRole:
|
{
|
||||||
|
m_protocolConfig.insert(config_key::ncp_disable, !enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString OpenVpnConfigModel::hash() const
|
||||||
|
{
|
||||||
|
return m_protocolConfig.value(config_key::hash).toString(protocols::openvpn::defaultHash);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenVpnConfigModel::setHash(const QString &hash)
|
||||||
|
{
|
||||||
|
m_protocolConfig.insert(config_key::hash, hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString OpenVpnConfigModel::cipher() const
|
||||||
|
{
|
||||||
|
return m_protocolConfig.value(config_key::cipher).toString(protocols::openvpn::defaultCipher);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenVpnConfigModel::setCipher(const QString &cipher)
|
||||||
|
{
|
||||||
|
m_protocolConfig.insert(config_key::cipher, cipher);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OpenVpnConfigModel::tlsAuth() const
|
||||||
|
{
|
||||||
|
return m_protocolConfig.value(config_key::tls_auth).toBool(protocols::openvpn::defaultTlsAuth);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenVpnConfigModel::setTlsAuth(bool enabled)
|
||||||
|
{
|
||||||
|
m_protocolConfig.insert(config_key::tls_auth, enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OpenVpnConfigModel::blockDns() const
|
||||||
|
{
|
||||||
return m_protocolConfig.value(config_key::block_outside_dns).toBool(protocols::openvpn::defaultBlockOutsideDns);
|
return m_protocolConfig.value(config_key::block_outside_dns).toBool(protocols::openvpn::defaultBlockOutsideDns);
|
||||||
case Roles::AdditionalClientCommandsRole:
|
}
|
||||||
|
|
||||||
|
void OpenVpnConfigModel::setBlockDns(bool enabled)
|
||||||
|
{
|
||||||
|
m_protocolConfig.insert(config_key::block_outside_dns, enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString OpenVpnConfigModel::additionalClientCommands() const
|
||||||
|
{
|
||||||
return m_protocolConfig.value(config_key::additional_client_config).toString(protocols::openvpn::defaultAdditionalClientConfig);
|
return m_protocolConfig.value(config_key::additional_client_config).toString(protocols::openvpn::defaultAdditionalClientConfig);
|
||||||
case Roles::AdditionalServerCommandsRole:
|
}
|
||||||
|
|
||||||
|
void OpenVpnConfigModel::setAdditionalClientCommands(const QString &commands)
|
||||||
|
{
|
||||||
|
m_protocolConfig.insert(config_key::additional_client_config, commands);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString OpenVpnConfigModel::additionalServerCommands() const
|
||||||
|
{
|
||||||
return m_protocolConfig.value(config_key::additional_server_config).toString(protocols::openvpn::defaultAdditionalServerConfig);
|
return m_protocolConfig.value(config_key::additional_server_config).toString(protocols::openvpn::defaultAdditionalServerConfig);
|
||||||
case Roles::IsPortEditable: return m_container == DockerContainer::OpenVpn ? true : false;
|
}
|
||||||
case Roles::IsTransportProtoEditable: return m_container == DockerContainer::OpenVpn ? true : false;
|
|
||||||
case Roles::HasRemoveButton: return m_container == DockerContainer::OpenVpn ? true : false;
|
void OpenVpnConfigModel::setAdditionalServerCommands(const QString &commands)
|
||||||
}
|
{
|
||||||
return QVariant();
|
m_protocolConfig.insert(config_key::additional_server_config, commands);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OpenVpnConfigModel::isPortEditable() const
|
||||||
|
{
|
||||||
|
return m_container == DockerContainer::OpenVpn;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OpenVpnConfigModel::isTransportProtoEditable() const
|
||||||
|
{
|
||||||
|
return m_container == DockerContainer::OpenVpn;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OpenVpnConfigModel::hasRemoveButton() const
|
||||||
|
{
|
||||||
|
return m_container == DockerContainer::OpenVpn;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenVpnConfigModel::updateModel(const QJsonObject &config)
|
void OpenVpnConfigModel::updateModel(const QJsonObject &config)
|
||||||
{
|
{
|
||||||
beginResetModel();
|
|
||||||
m_container = ContainerProps::containerFromString(config.value(config_key::container).toString());
|
m_container = ContainerProps::containerFromString(config.value(config_key::container).toString());
|
||||||
|
|
||||||
m_fullConfig = config;
|
m_fullConfig = config;
|
||||||
@@ -100,8 +156,6 @@ void OpenVpnConfigModel::updateModel(const QJsonObject &config)
|
|||||||
m_protocolConfig.insert(
|
m_protocolConfig.insert(
|
||||||
config_key::additional_server_config,
|
config_key::additional_server_config,
|
||||||
protocolConfig.value(config_key::additional_server_config).toString(protocols::openvpn::defaultAdditionalServerConfig));
|
protocolConfig.value(config_key::additional_server_config).toString(protocols::openvpn::defaultAdditionalServerConfig));
|
||||||
|
|
||||||
endResetModel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject OpenVpnConfigModel::getConfig()
|
QJsonObject OpenVpnConfigModel::getConfig()
|
||||||
@@ -109,26 +163,3 @@ QJsonObject OpenVpnConfigModel::getConfig()
|
|||||||
m_fullConfig.insert(config_key::openvpn, m_protocolConfig);
|
m_fullConfig.insert(config_key::openvpn, m_protocolConfig);
|
||||||
return m_fullConfig;
|
return m_fullConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<int, QByteArray> OpenVpnConfigModel::roleNames() const
|
|
||||||
{
|
|
||||||
QHash<int, QByteArray> roles;
|
|
||||||
|
|
||||||
roles[SubnetAddressRole] = "subnetAddress";
|
|
||||||
roles[TransportProtoRole] = "transportProto";
|
|
||||||
roles[PortRole] = "port";
|
|
||||||
roles[AutoNegotiateEncryprionRole] = "autoNegotiateEncryprion";
|
|
||||||
roles[HashRole] = "hash";
|
|
||||||
roles[CipherRole] = "cipher";
|
|
||||||
roles[TlsAuthRole] = "tlsAuth";
|
|
||||||
roles[BlockDnsRole] = "blockDns";
|
|
||||||
roles[AdditionalClientCommandsRole] = "additionalClientCommands";
|
|
||||||
roles[AdditionalServerCommandsRole] = "additionalServerCommands";
|
|
||||||
|
|
||||||
roles[IsPortEditable] = "isPortEditable";
|
|
||||||
roles[IsTransportProtoEditable] = "isTransportProtoEditable";
|
|
||||||
|
|
||||||
roles[HasRemoveButton] = "hasRemoveButton";
|
|
||||||
|
|
||||||
return roles;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,47 +1,90 @@
|
|||||||
#ifndef OPENVPNCONFIGMODEL_H
|
#ifndef OPENVPNCONFIGMODEL_H
|
||||||
#define OPENVPNCONFIGMODEL_H
|
#define OPENVPNCONFIGMODEL_H
|
||||||
|
|
||||||
#include <QAbstractListModel>
|
#include <QObject>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
|
||||||
#include "containers/containers_defs.h"
|
#include "containers/containers_defs.h"
|
||||||
|
|
||||||
class OpenVpnConfigModel : public QAbstractListModel
|
class OpenVpnConfigModel : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString subnetAddress READ subnetAddress WRITE setSubnetAddress NOTIFY subnetAddressChanged)
|
||||||
|
Q_PROPERTY(QString transportProto READ transportProto WRITE setTransportProto NOTIFY transportProtoChanged)
|
||||||
|
Q_PROPERTY(QString port READ port WRITE setPort NOTIFY portChanged)
|
||||||
|
Q_PROPERTY(bool autoNegotiateEncryption READ autoNegotiateEncryption WRITE setAutoNegotiateEncryption NOTIFY autoNegotiateEncryptionChanged)
|
||||||
|
Q_PROPERTY(QString hash READ hash WRITE setHash NOTIFY hashChanged)
|
||||||
|
Q_PROPERTY(QString cipher READ cipher WRITE setCipher NOTIFY cipherChanged)
|
||||||
|
Q_PROPERTY(bool tlsAuth READ tlsAuth WRITE setTlsAuth NOTIFY tlsAuthChanged)
|
||||||
|
Q_PROPERTY(bool blockDns READ blockDns WRITE setBlockDns NOTIFY blockDnsChanged)
|
||||||
|
Q_PROPERTY(QString additionalClientCommands READ additionalClientCommands WRITE setAdditionalClientCommands NOTIFY additionalClientCommandsChanged)
|
||||||
|
Q_PROPERTY(QString additionalServerCommands READ additionalServerCommands WRITE setAdditionalServerCommands NOTIFY additionalServerCommandsChanged)
|
||||||
|
Q_PROPERTY(bool isPortEditable READ isPortEditable NOTIFY isPortEditableChanged)
|
||||||
|
Q_PROPERTY(bool isTransportProtoEditable READ isTransportProtoEditable NOTIFY isTransportProtoEditableChanged)
|
||||||
|
Q_PROPERTY(bool hasRemoveButton READ hasRemoveButton NOTIFY hasRemoveButtonChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Roles {
|
|
||||||
SubnetAddressRole = Qt::UserRole + 1,
|
|
||||||
TransportProtoRole,
|
|
||||||
PortRole,
|
|
||||||
AutoNegotiateEncryprionRole,
|
|
||||||
HashRole,
|
|
||||||
CipherRole,
|
|
||||||
TlsAuthRole,
|
|
||||||
BlockDnsRole,
|
|
||||||
AdditionalClientCommandsRole,
|
|
||||||
AdditionalServerCommandsRole,
|
|
||||||
|
|
||||||
IsPortEditable,
|
|
||||||
IsTransportProtoEditable,
|
|
||||||
|
|
||||||
HasRemoveButton
|
|
||||||
};
|
|
||||||
|
|
||||||
explicit OpenVpnConfigModel(QObject *parent = nullptr);
|
explicit OpenVpnConfigModel(QObject *parent = nullptr);
|
||||||
|
~OpenVpnConfigModel() override = default;
|
||||||
|
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
OpenVpnConfigModel(const OpenVpnConfigModel &) = delete;
|
||||||
|
OpenVpnConfigModel &operator=(const OpenVpnConfigModel &) = delete;
|
||||||
|
OpenVpnConfigModel(OpenVpnConfigModel &&) = delete;
|
||||||
|
OpenVpnConfigModel &operator=(OpenVpnConfigModel &&) = delete;
|
||||||
|
|
||||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
QString subnetAddress() const;
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
void setSubnetAddress(const QString &subnetAddress);
|
||||||
|
|
||||||
|
QString transportProto() const;
|
||||||
|
void setTransportProto(const QString &transportProto);
|
||||||
|
|
||||||
|
QString port() const;
|
||||||
|
void setPort(const QString &port);
|
||||||
|
|
||||||
|
bool autoNegotiateEncryption() const;
|
||||||
|
void setAutoNegotiateEncryption(bool enabled);
|
||||||
|
|
||||||
|
QString hash() const;
|
||||||
|
void setHash(const QString &hash);
|
||||||
|
|
||||||
|
QString cipher() const;
|
||||||
|
void setCipher(const QString &cipher);
|
||||||
|
|
||||||
|
bool tlsAuth() const;
|
||||||
|
void setTlsAuth(bool enabled);
|
||||||
|
|
||||||
|
bool blockDns() const;
|
||||||
|
void setBlockDns(bool enabled);
|
||||||
|
|
||||||
|
QString additionalClientCommands() const;
|
||||||
|
void setAdditionalClientCommands(const QString &commands);
|
||||||
|
|
||||||
|
QString additionalServerCommands() const;
|
||||||
|
void setAdditionalServerCommands(const QString &commands);
|
||||||
|
|
||||||
|
bool isPortEditable() const;
|
||||||
|
bool isTransportProtoEditable() const;
|
||||||
|
bool hasRemoveButton() const;
|
||||||
|
|
||||||
|
Q_INVOKABLE QJsonObject getConfig();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void subnetAddressChanged(const QString &);
|
||||||
|
void transportProtoChanged(const QString &);
|
||||||
|
void portChanged(const QString &);
|
||||||
|
void autoNegotiateEncryptionChanged(bool);
|
||||||
|
void hashChanged(const QString &);
|
||||||
|
void cipherChanged(const QString &);
|
||||||
|
void tlsAuthChanged(bool);
|
||||||
|
void blockDnsChanged(bool);
|
||||||
|
void additionalClientCommandsChanged(const QString &);
|
||||||
|
void additionalServerCommandsChanged(const QString &);
|
||||||
|
void isPortEditableChanged(bool);
|
||||||
|
void isTransportProtoEditableChanged(bool);
|
||||||
|
void hasRemoveButtonChanged(bool);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateModel(const QJsonObject &config);
|
void updateModel(const QJsonObject &config);
|
||||||
QJsonObject getConfig();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
QHash<int, QByteArray> roleNames() const override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DockerContainer m_container;
|
DockerContainer m_container;
|
||||||
|
|||||||
@@ -17,69 +17,45 @@ import "../Components"
|
|||||||
PageType {
|
PageType {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
ColumnLayout {
|
|
||||||
id: backButtonLayout
|
|
||||||
|
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
|
|
||||||
anchors.topMargin: 20
|
|
||||||
|
|
||||||
BackButtonType {
|
BackButtonType {
|
||||||
id: backButton
|
id: backButton
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FlickableType {
|
|
||||||
id: fl
|
|
||||||
anchors.top: backButtonLayout.bottom
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
contentHeight: content.implicitHeight
|
|
||||||
|
|
||||||
Column {
|
|
||||||
id: content
|
|
||||||
|
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
anchors.topMargin: 20
|
||||||
|
|
||||||
|
onFocusChanged: {
|
||||||
|
if (this.activeFocus) {
|
||||||
|
listView.positionViewAtBeginning()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ListViewType {
|
||||||
|
id: listView
|
||||||
|
|
||||||
|
anchors.top: backButton.bottom
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.left: parent.left
|
||||||
|
|
||||||
enabled: ServersModel.isProcessedServerHasWriteAccess()
|
enabled: ServersModel.isProcessedServerHasWriteAccess()
|
||||||
|
|
||||||
ListView {
|
|
||||||
id: listview
|
|
||||||
|
|
||||||
width: parent.width
|
|
||||||
height: listview.contentItem.height
|
|
||||||
|
|
||||||
clip: true
|
|
||||||
interactive: false
|
|
||||||
|
|
||||||
model: OpenVpnConfigModel
|
model: OpenVpnConfigModel
|
||||||
|
|
||||||
delegate: Item {
|
delegate: ColumnLayout {
|
||||||
id: delegateItem
|
width: listView.width
|
||||||
|
|
||||||
property alias vpnAddressSubnetTextField: vpnAddressSubnetTextField
|
property alias vpnAddressSubnetTextField: vpnAddressSubnetTextField
|
||||||
property bool isEnabled: ServersModel.isProcessedServerHasWriteAccess()
|
|
||||||
|
|
||||||
implicitWidth: listview.width
|
|
||||||
implicitHeight: col.implicitHeight
|
|
||||||
|
|
||||||
ColumnLayout {
|
|
||||||
id: col
|
|
||||||
|
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
|
|
||||||
anchors.leftMargin: 16
|
|
||||||
anchors.rightMargin: 16
|
|
||||||
|
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
BaseHeaderType {
|
BaseHeaderType {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
Layout.leftMargin: 16
|
||||||
|
Layout.rightMargin: 16
|
||||||
|
|
||||||
headerText: qsTr("OpenVPN settings")
|
headerText: qsTr("OpenVPN settings")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,26 +64,24 @@ PageType {
|
|||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 32
|
Layout.topMargin: 32
|
||||||
|
Layout.leftMargin: 16
|
||||||
enabled: delegateItem.isEnabled
|
Layout.rightMargin: 16
|
||||||
|
|
||||||
headerText: qsTr("VPN address subnet")
|
headerText: qsTr("VPN address subnet")
|
||||||
textField.text: subnetAddress
|
textField.text: subnetAddress
|
||||||
|
|
||||||
parentFlickable: fl
|
|
||||||
|
|
||||||
textField.onEditingFinished: {
|
textField.onEditingFinished: {
|
||||||
if (textField.text !== subnetAddress) {
|
if (textField.text !== subnetAddress) {
|
||||||
subnetAddress = textField.text
|
subnetAddress = textField.text
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
checkEmptyText: true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ParagraphTextType {
|
ParagraphTextType {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 32
|
Layout.topMargin: 32
|
||||||
|
Layout.leftMargin: 16
|
||||||
|
Layout.rightMargin: 16
|
||||||
|
|
||||||
text: qsTr("Network protocol")
|
text: qsTr("Network protocol")
|
||||||
}
|
}
|
||||||
@@ -116,6 +90,8 @@ PageType {
|
|||||||
id: transportProtoSelector
|
id: transportProtoSelector
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 16
|
Layout.topMargin: 16
|
||||||
|
Layout.leftMargin: 16
|
||||||
|
Layout.rightMargin: 16
|
||||||
rootWidth: root.width
|
rootWidth: root.width
|
||||||
|
|
||||||
enabled: isTransportProtoEditable
|
enabled: isTransportProtoEditable
|
||||||
@@ -138,9 +114,10 @@ PageType {
|
|||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 40
|
Layout.topMargin: 40
|
||||||
parentFlickable: fl
|
Layout.leftMargin: 16
|
||||||
|
Layout.rightMargin: 16
|
||||||
|
|
||||||
enabled: delegateItem.isEnabled
|
enabled: listView.enabled
|
||||||
|
|
||||||
headerText: qsTr("Port")
|
headerText: qsTr("Port")
|
||||||
textField.text: port
|
textField.text: port
|
||||||
@@ -152,8 +129,6 @@ PageType {
|
|||||||
port = textField.text
|
port = textField.text
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
checkEmptyText: true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SwitcherType {
|
SwitcherType {
|
||||||
@@ -161,7 +136,8 @@ PageType {
|
|||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 24
|
Layout.topMargin: 24
|
||||||
parentFlickable: fl
|
Layout.leftMargin: 16
|
||||||
|
Layout.rightMargin: 16
|
||||||
|
|
||||||
text: qsTr("Auto-negotiate encryption")
|
text: qsTr("Auto-negotiate encryption")
|
||||||
checked: autoNegotiateEncryprion
|
checked: autoNegotiateEncryprion
|
||||||
@@ -177,6 +153,8 @@ PageType {
|
|||||||
id: hashDropDown
|
id: hashDropDown
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
|
Layout.leftMargin: 16
|
||||||
|
Layout.rightMargin: 16
|
||||||
|
|
||||||
enabled: !autoNegotiateEncryprionSwitcher.checked
|
enabled: !autoNegotiateEncryprionSwitcher.checked
|
||||||
|
|
||||||
@@ -216,6 +194,9 @@ PageType {
|
|||||||
if (hashListView.model.get(i).name === hashDropDown.text) {
|
if (hashListView.model.get(i).name === hashDropDown.text) {
|
||||||
currentIndex = i
|
currentIndex = i
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Keys.onEnterPressed: saveButton.clicked()
|
||||||
|
Keys.onReturnPressed: saveButton.clicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -225,6 +206,8 @@ PageType {
|
|||||||
id: cipherDropDown
|
id: cipherDropDown
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 16
|
Layout.topMargin: 16
|
||||||
|
Layout.leftMargin: 16
|
||||||
|
Layout.rightMargin: 16
|
||||||
|
|
||||||
enabled: !autoNegotiateEncryprionSwitcher.checked
|
enabled: !autoNegotiateEncryprionSwitcher.checked
|
||||||
|
|
||||||
@@ -273,6 +256,8 @@ PageType {
|
|||||||
id: contentRect
|
id: contentRect
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 32
|
Layout.topMargin: 32
|
||||||
|
Layout.leftMargin: 16
|
||||||
|
Layout.rightMargin: 16
|
||||||
Layout.preferredHeight: checkboxLayout.implicitHeight
|
Layout.preferredHeight: checkboxLayout.implicitHeight
|
||||||
color: AmneziaStyle.color.onyxBlack
|
color: AmneziaStyle.color.onyxBlack
|
||||||
radius: 16
|
radius: 16
|
||||||
@@ -329,7 +314,8 @@ PageType {
|
|||||||
id: additionalClientCommandsSwitcher
|
id: additionalClientCommandsSwitcher
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 32
|
Layout.topMargin: 32
|
||||||
parentFlickable: fl
|
Layout.leftMargin: 16
|
||||||
|
Layout.rightMargin: 16
|
||||||
|
|
||||||
checked: additionalClientCommands !== ""
|
checked: additionalClientCommands !== ""
|
||||||
|
|
||||||
@@ -346,11 +332,11 @@ PageType {
|
|||||||
id: additionalClientCommandsTextArea
|
id: additionalClientCommandsTextArea
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 16
|
Layout.topMargin: 16
|
||||||
|
Layout.leftMargin: 16
|
||||||
|
Layout.rightMargin: 16
|
||||||
|
|
||||||
visible: additionalClientCommandsSwitcher.checked
|
visible: additionalClientCommandsSwitcher.checked
|
||||||
|
|
||||||
parentFlickable: fl
|
|
||||||
|
|
||||||
textAreaText: additionalClientCommands
|
textAreaText: additionalClientCommands
|
||||||
placeholderText: qsTr("Commands:")
|
placeholderText: qsTr("Commands:")
|
||||||
|
|
||||||
@@ -365,7 +351,8 @@ PageType {
|
|||||||
id: additionalServerCommandsSwitcher
|
id: additionalServerCommandsSwitcher
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 16
|
Layout.topMargin: 16
|
||||||
parentFlickable: fl
|
Layout.leftMargin: 16
|
||||||
|
Layout.rightMargin: 16
|
||||||
|
|
||||||
checked: additionalServerCommands !== ""
|
checked: additionalServerCommands !== ""
|
||||||
|
|
||||||
@@ -382,12 +369,14 @@ PageType {
|
|||||||
id: additionalServerCommandsTextArea
|
id: additionalServerCommandsTextArea
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 16
|
Layout.topMargin: 16
|
||||||
|
Layout.leftMargin: 16
|
||||||
|
Layout.rightMargin: 16
|
||||||
|
|
||||||
visible: additionalServerCommandsSwitcher.checked
|
visible: additionalServerCommandsSwitcher.checked
|
||||||
|
|
||||||
textAreaText: additionalServerCommands
|
textAreaText: additionalServerCommands
|
||||||
placeholderText: qsTr("Commands:")
|
placeholderText: qsTr("Commands:")
|
||||||
parentFlickable: fl
|
|
||||||
textArea.onEditingFinished: {
|
textArea.onEditingFinished: {
|
||||||
if (additionalServerCommands !== textAreaText) {
|
if (additionalServerCommands !== textAreaText) {
|
||||||
additionalServerCommands = textAreaText
|
additionalServerCommands = textAreaText
|
||||||
@@ -396,17 +385,18 @@ PageType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BasicButtonType {
|
BasicButtonType {
|
||||||
id: saveButton
|
id: saveRestartButton
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 24
|
Layout.topMargin: 24
|
||||||
Layout.bottomMargin: 24
|
Layout.bottomMargin: 24
|
||||||
|
Layout.leftMargin: 16
|
||||||
|
Layout.rightMargin: 16
|
||||||
|
|
||||||
enabled: vpnAddressSubnetTextField.errorText === "" &&
|
enabled: vpnAddressSubnetTextField.errorText === "" &&
|
||||||
portTextField.errorText === ""
|
portTextField.errorText === ""
|
||||||
|
|
||||||
text: qsTr("Save")
|
text: qsTr("Save")
|
||||||
parentFlickable: fl
|
|
||||||
|
|
||||||
onClicked: function() {
|
onClicked: function() {
|
||||||
forceActiveFocus()
|
forceActiveFocus()
|
||||||
@@ -438,7 +428,4 @@ PageType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user