QML gui refact started
This commit is contained in:
parent
febf9cfafb
commit
135b96a280
35 changed files with 1700 additions and 523 deletions
|
@ -33,6 +33,19 @@ HEADERS += \
|
||||||
protocols/shadowsocksvpnprotocol.h \
|
protocols/shadowsocksvpnprotocol.h \
|
||||||
protocols/wireguardprotocol.h \
|
protocols/wireguardprotocol.h \
|
||||||
settings.h \
|
settings.h \
|
||||||
|
ui/pages.h \
|
||||||
|
ui/pages_logic/AppSettingsLogic.h \
|
||||||
|
ui/pages_logic/GeneralSettingsLogic.h \
|
||||||
|
ui/pages_logic/NetworkSettingsLogic.h \
|
||||||
|
ui/pages_logic/NewServerLogic.h \
|
||||||
|
ui/pages_logic/ProtocolSettingsLogic.h \
|
||||||
|
ui/pages_logic/ServerListLogic.h \
|
||||||
|
ui/pages_logic/ServerSettingsLogic.h \
|
||||||
|
ui/pages_logic/ServerVpnProtocolsLogic.h \
|
||||||
|
ui/pages_logic/ShareConnectionLogic.h \
|
||||||
|
ui/pages_logic/SitesLogic.h \
|
||||||
|
ui/pages_logic/VpnLogic.h \
|
||||||
|
ui/pages_logic/WizardLogic.h \
|
||||||
ui/serversmodel.h \
|
ui/serversmodel.h \
|
||||||
ui/uilogic.h \
|
ui/uilogic.h \
|
||||||
ui/qautostart.h \
|
ui/qautostart.h \
|
||||||
|
@ -62,6 +75,18 @@ SOURCES += \
|
||||||
protocols/shadowsocksvpnprotocol.cpp \
|
protocols/shadowsocksvpnprotocol.cpp \
|
||||||
protocols/wireguardprotocol.cpp \
|
protocols/wireguardprotocol.cpp \
|
||||||
settings.cpp \
|
settings.cpp \
|
||||||
|
ui/pages_logic/AppSettingsLogic.cpp \
|
||||||
|
ui/pages_logic/GeneralSettingsLogic.cpp \
|
||||||
|
ui/pages_logic/NetworkSettingsLogic.cpp \
|
||||||
|
ui/pages_logic/NewServerLogic.cpp \
|
||||||
|
ui/pages_logic/ProtocolSettingsLogic.cpp \
|
||||||
|
ui/pages_logic/ServerListLogic.cpp \
|
||||||
|
ui/pages_logic/ServerSettingsLogic.cpp \
|
||||||
|
ui/pages_logic/ServerVpnProtocolsLogic.cpp \
|
||||||
|
ui/pages_logic/ShareConnectionLogic.cpp \
|
||||||
|
ui/pages_logic/SitesLogic.cpp \
|
||||||
|
ui/pages_logic/VpnLogic.cpp \
|
||||||
|
ui/pages_logic/WizardLogic.cpp \
|
||||||
ui/serversmodel.cpp \
|
ui/serversmodel.cpp \
|
||||||
ui/uilogic.cpp \
|
ui/uilogic.cpp \
|
||||||
ui/qautostart.cpp \
|
ui/qautostart.cpp \
|
||||||
|
|
|
@ -11,6 +11,22 @@
|
||||||
#include "ui/uilogic.h"
|
#include "ui/uilogic.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include "ui/pages.h"
|
||||||
|
|
||||||
|
#include "ui/pages_logic/AppSettingsLogic.h"
|
||||||
|
#include "ui/pages_logic/GeneralSettingsLogic.h"
|
||||||
|
#include "ui/pages_logic/NetworkSettingsLogic.h"
|
||||||
|
#include "ui/pages_logic/NewServerLogic.h"
|
||||||
|
#include "ui/pages_logic/ProtocolSettingsLogic.h"
|
||||||
|
#include "ui/pages_logic/ServerListLogic.h"
|
||||||
|
#include "ui/pages_logic/ServerSettingsLogic.h"
|
||||||
|
#include "ui/pages_logic/ServerVpnProtocolsLogic.h"
|
||||||
|
#include "ui/pages_logic/ShareConnectionLogic.h"
|
||||||
|
#include "ui/pages_logic/SitesLogic.h"
|
||||||
|
#include "ui/pages_logic/VpnLogic.h"
|
||||||
|
#include "ui/pages_logic/WizardLogic.h"
|
||||||
|
|
||||||
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
|
|
||||||
|
@ -93,16 +109,46 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
app.setQuitOnLastWindowClosed(false);
|
app.setQuitOnLastWindowClosed(false);
|
||||||
|
|
||||||
UiLogic uiLogic;
|
UiLogic *uiLogic = new UiLogic;
|
||||||
|
|
||||||
|
AppSettingsLogic *appSettingsLogic = new AppSettingsLogic(uiLogic);
|
||||||
|
GeneralSettingsLogic *generalSettingsLogic = new GeneralSettingsLogic(uiLogic);
|
||||||
|
NetworkSettingsLogic *networkSettingsLogic = new NetworkSettingsLogic(uiLogic);
|
||||||
|
NewServerLogic *newServerLogic = new NewServerLogic(uiLogic);
|
||||||
|
ProtocolSettingsLogic *protocolSettingsLogic = new ProtocolSettingsLogic(uiLogic);
|
||||||
|
ServerListLogic *serverListLogic = new ServerListLogic(uiLogic);
|
||||||
|
ServerSettingsLogic *serverSettingsLogic = new ServerSettingsLogic(uiLogic);
|
||||||
|
ServerVpnProtocolsLogic *serverVpnProtocolsLogic = new ServerVpnProtocolsLogic(uiLogic);
|
||||||
|
ShareConnectionLogic *shareConnectionLogic = new ShareConnectionLogic(uiLogic);
|
||||||
|
SitesLogic *sitesLogic = new SitesLogic(uiLogic);
|
||||||
|
VpnLogic *vpnLogic = new VpnLogic(uiLogic);
|
||||||
|
WizardLogic *wizardLogic = new WizardLogic(uiLogic);
|
||||||
|
|
||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
UiLogic::declareQML();
|
PageEnumNS::declareQML();
|
||||||
const QUrl url(QStringLiteral("qrc:/ui/qml/main.qml"));
|
const QUrl url(QStringLiteral("qrc:/ui/qml/main.qml"));
|
||||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
|
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
|
||||||
&app, [url](QObject *obj, const QUrl &objUrl) {
|
&app, [url](QObject *obj, const QUrl &objUrl) {
|
||||||
if (!obj && url == objUrl)
|
if (!obj && url == objUrl)
|
||||||
QCoreApplication::exit(-1);
|
QCoreApplication::exit(-1);
|
||||||
}, Qt::QueuedConnection);
|
}, Qt::QueuedConnection);
|
||||||
engine.rootContext()->setContextProperty("UiLogic", &uiLogic);
|
|
||||||
|
engine.rootContext()->setContextProperty("UiLogic", uiLogic);
|
||||||
|
|
||||||
|
engine.rootContext()->setContextProperty("AppSettingsLogic", appSettingsLogic);
|
||||||
|
engine.rootContext()->setContextProperty("GeneralSettingsLogic", generalSettingsLogic);
|
||||||
|
engine.rootContext()->setContextProperty("NetworkSettingsLogic", networkSettingsLogic);
|
||||||
|
engine.rootContext()->setContextProperty("NewServerLogic", newServerLogic);
|
||||||
|
engine.rootContext()->setContextProperty("ProtocolSettingsLogic", protocolSettingsLogic);
|
||||||
|
engine.rootContext()->setContextProperty("ServerListLogic", serverListLogic);
|
||||||
|
engine.rootContext()->setContextProperty("ServerSettingsLogic", serverSettingsLogic);
|
||||||
|
engine.rootContext()->setContextProperty("ServerVpnProtocolsLogic", serverVpnProtocolsLogic);
|
||||||
|
engine.rootContext()->setContextProperty("ShareConnectionLogic", shareConnectionLogic);
|
||||||
|
engine.rootContext()->setContextProperty("SitesLogic", sitesLogic);
|
||||||
|
engine.rootContext()->setContextProperty("VpnLogic", vpnLogic);
|
||||||
|
engine.rootContext()->setContextProperty("WizardLogic", wizardLogic);
|
||||||
|
|
||||||
|
|
||||||
engine.load(url);
|
engine.load(url);
|
||||||
|
|
||||||
// TODO - fix
|
// TODO - fix
|
||||||
|
|
29
client/ui/pages.h
Normal file
29
client/ui/pages.h
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#ifndef PAGES_H
|
||||||
|
#define PAGES_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QQmlEngine>
|
||||||
|
|
||||||
|
namespace PageEnumNS
|
||||||
|
{
|
||||||
|
Q_NAMESPACE
|
||||||
|
enum Page {Start = 0, NewServer, NewServerProtocols, Vpn,
|
||||||
|
Wizard, WizardLow, WizardMedium, WizardHigh, WizardVpnMode, ServerConfiguring,
|
||||||
|
GeneralSettings, AppSettings, NetworkSettings, ServerSettings,
|
||||||
|
ServerVpnProtocols, ServersList, ShareConnection, Sites,
|
||||||
|
OpenVpnSettings, ShadowSocksSettings, CloakSettings};
|
||||||
|
Q_ENUM_NS(Page)
|
||||||
|
|
||||||
|
static void declareQML() {
|
||||||
|
qmlRegisterUncreatableMetaObject(
|
||||||
|
PageEnumNS::staticMetaObject,
|
||||||
|
"PageEnum",
|
||||||
|
1, 0,
|
||||||
|
"PageEnum",
|
||||||
|
"Error: only enums"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // PAGES_H
|
||||||
|
|
||||||
|
#endif
|
147
client/ui/pages_logic/AppSettingsLogic.cpp
Normal file
147
client/ui/pages_logic/AppSettingsLogic.cpp
Normal file
|
@ -0,0 +1,147 @@
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QClipboard>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QHostInfo>
|
||||||
|
#include <QItemSelectionModel>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QMetaEnum>
|
||||||
|
#include <QSysInfo>
|
||||||
|
#include <QThread>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
#include <QSaveFile>
|
||||||
|
|
||||||
|
//#include "configurators/cloak_configurator.h"
|
||||||
|
//#include "configurators/vpn_configurator.h"
|
||||||
|
//#include "configurators/openvpn_configurator.h"
|
||||||
|
//#include "configurators/shadowsocks_configurator.h"
|
||||||
|
//#include "configurators/ssh_configurator.h"
|
||||||
|
|
||||||
|
//#include "core/servercontroller.h"
|
||||||
|
//#include "core/server_defs.h"
|
||||||
|
//#include "core/errorstrings.h"
|
||||||
|
|
||||||
|
//#include "protocols/protocols_defs.h"
|
||||||
|
//#include "protocols/shadowsocksvpnprotocol.h"
|
||||||
|
|
||||||
|
#include "ui/qautostart.h"
|
||||||
|
|
||||||
|
#include "debug.h"
|
||||||
|
#include "defines.h"
|
||||||
|
#include "AppSettingsLogic.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "vpnconnection.h"
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
#if defined Q_OS_MAC || defined Q_OS_LINUX
|
||||||
|
#include "ui/macos_util.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using namespace amnezia;
|
||||||
|
using namespace PageEnumNS;
|
||||||
|
|
||||||
|
|
||||||
|
AppSettingsLogic::AppSettingsLogic(UiLogic *uiLogic, QObject *parent):
|
||||||
|
QObject(parent),
|
||||||
|
m_uiLogic(uiLogic),
|
||||||
|
m_checkBoxAppSettingsAutostartChecked{false},
|
||||||
|
m_checkBoxAppSettingsAutoconnectChecked{false},
|
||||||
|
m_checkBoxAppSettingsStartMinimizedChecked{false}
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSettingsLogic::updateAppSettingsPage()
|
||||||
|
{
|
||||||
|
setCheckBoxAppSettingsAutostartChecked(Autostart::isAutostart());
|
||||||
|
setCheckBoxAppSettingsAutoconnectChecked(m_settings.isAutoConnect());
|
||||||
|
setCheckBoxAppSettingsStartMinimizedChecked(m_settings.isStartMinimized());
|
||||||
|
|
||||||
|
QString ver = QString("%1: %2 (%3)")
|
||||||
|
.arg(tr("Software version"))
|
||||||
|
.arg(QString(APP_MAJOR_VERSION))
|
||||||
|
.arg(__DATE__);
|
||||||
|
setLabelAppSettingsVersionText(ver);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AppSettingsLogic::getCheckBoxAppSettingsAutostartChecked() const
|
||||||
|
{
|
||||||
|
return m_checkBoxAppSettingsAutostartChecked;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSettingsLogic::setCheckBoxAppSettingsAutostartChecked(bool checkBoxAppSettingsAutostartChecked)
|
||||||
|
{
|
||||||
|
if (m_checkBoxAppSettingsAutostartChecked != checkBoxAppSettingsAutostartChecked) {
|
||||||
|
m_checkBoxAppSettingsAutostartChecked = checkBoxAppSettingsAutostartChecked;
|
||||||
|
emit checkBoxAppSettingsAutostartCheckedChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AppSettingsLogic::getCheckBoxAppSettingsAutoconnectChecked() const
|
||||||
|
{
|
||||||
|
return m_checkBoxAppSettingsAutoconnectChecked;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSettingsLogic::setCheckBoxAppSettingsAutoconnectChecked(bool checkBoxAppSettingsAutoconnectChecked)
|
||||||
|
{
|
||||||
|
if (m_checkBoxAppSettingsAutoconnectChecked != checkBoxAppSettingsAutoconnectChecked) {
|
||||||
|
m_checkBoxAppSettingsAutoconnectChecked = checkBoxAppSettingsAutoconnectChecked;
|
||||||
|
emit checkBoxAppSettingsAutoconnectCheckedChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AppSettingsLogic::getCheckBoxAppSettingsStartMinimizedChecked() const
|
||||||
|
{
|
||||||
|
return m_checkBoxAppSettingsStartMinimizedChecked;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSettingsLogic::setCheckBoxAppSettingsStartMinimizedChecked(bool checkBoxAppSettingsStartMinimizedChecked)
|
||||||
|
{
|
||||||
|
if (m_checkBoxAppSettingsStartMinimizedChecked != checkBoxAppSettingsStartMinimizedChecked) {
|
||||||
|
m_checkBoxAppSettingsStartMinimizedChecked = checkBoxAppSettingsStartMinimizedChecked;
|
||||||
|
emit checkBoxAppSettingsStartMinimizedCheckedChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSettingsLogic::onCheckBoxAppSettingsAutostartToggled(bool checked)
|
||||||
|
{
|
||||||
|
if (!checked) {
|
||||||
|
setCheckBoxAppSettingsAutoconnectChecked(false);
|
||||||
|
}
|
||||||
|
Autostart::setAutostart(checked);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSettingsLogic::onCheckBoxAppSettingsAutoconnectToggled(bool checked)
|
||||||
|
{
|
||||||
|
m_settings.setAutoConnect(checked);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSettingsLogic::onCheckBoxAppSettingsStartMinimizedToggled(bool checked)
|
||||||
|
{
|
||||||
|
m_settings.setStartMinimized(checked);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSettingsLogic::setLabelAppSettingsVersionText(const QString &labelAppSettingsVersionText)
|
||||||
|
{
|
||||||
|
if (m_labelAppSettingsVersionText != labelAppSettingsVersionText) {
|
||||||
|
m_labelAppSettingsVersionText = labelAppSettingsVersionText;
|
||||||
|
emit labelAppSettingsVersionTextChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AppSettingsLogic::getLabelAppSettingsVersionText() const
|
||||||
|
{
|
||||||
|
return m_labelAppSettingsVersionText;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSettingsLogic::onPushButtonAppSettingsOpenLogsChecked()
|
||||||
|
{
|
||||||
|
Debug::openLogsFolder();
|
||||||
|
}
|
68
client/ui/pages_logic/AppSettingsLogic.h
Normal file
68
client/ui/pages_logic/AppSettingsLogic.h
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
#ifndef APP_SETTINGS_LOGIC_H
|
||||||
|
#define APP_SETTINGS_LOGIC_H
|
||||||
|
|
||||||
|
#include "../pages.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
|
class UiLogic;
|
||||||
|
|
||||||
|
class AppSettingsLogic : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
Q_INVOKABLE void updateAppSettingsPage();
|
||||||
|
|
||||||
|
Q_PROPERTY(bool checkBoxAppSettingsAutostartChecked READ getCheckBoxAppSettingsAutostartChecked WRITE setCheckBoxAppSettingsAutostartChecked NOTIFY checkBoxAppSettingsAutostartCheckedChanged)
|
||||||
|
Q_PROPERTY(bool checkBoxAppSettingsAutoconnectChecked READ getCheckBoxAppSettingsAutoconnectChecked WRITE setCheckBoxAppSettingsAutoconnectChecked NOTIFY checkBoxAppSettingsAutoconnectCheckedChanged)
|
||||||
|
Q_PROPERTY(bool checkBoxAppSettingsStartMinimizedChecked READ getCheckBoxAppSettingsStartMinimizedChecked WRITE setCheckBoxAppSettingsStartMinimizedChecked NOTIFY checkBoxAppSettingsStartMinimizedCheckedChanged)
|
||||||
|
|
||||||
|
Q_PROPERTY(QString labelAppSettingsVersionText READ getLabelAppSettingsVersionText WRITE setLabelAppSettingsVersionText NOTIFY labelAppSettingsVersionTextChanged)
|
||||||
|
|
||||||
|
Q_INVOKABLE void onCheckBoxAppSettingsAutostartToggled(bool checked);
|
||||||
|
Q_INVOKABLE void onCheckBoxAppSettingsAutoconnectToggled(bool checked);
|
||||||
|
Q_INVOKABLE void onCheckBoxAppSettingsStartMinimizedToggled(bool checked);
|
||||||
|
|
||||||
|
Q_INVOKABLE void onPushButtonAppSettingsOpenLogsChecked();
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit AppSettingsLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||||
|
~AppSettingsLogic() = default;
|
||||||
|
|
||||||
|
|
||||||
|
bool getCheckBoxAppSettingsAutostartChecked() const;
|
||||||
|
void setCheckBoxAppSettingsAutostartChecked(bool checkBoxAppSettingsAutostartChecked);
|
||||||
|
bool getCheckBoxAppSettingsAutoconnectChecked() const;
|
||||||
|
void setCheckBoxAppSettingsAutoconnectChecked(bool checkBoxAppSettingsAutoconnectChecked);
|
||||||
|
bool getCheckBoxAppSettingsStartMinimizedChecked() const;
|
||||||
|
void setCheckBoxAppSettingsStartMinimizedChecked(bool checkBoxAppSettingsStartMinimizedChecked);
|
||||||
|
|
||||||
|
QString getLabelAppSettingsVersionText() const;
|
||||||
|
void setLabelAppSettingsVersionText(const QString &labelAppSettingsVersionText);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void checkBoxAppSettingsAutostartCheckedChanged();
|
||||||
|
void checkBoxAppSettingsAutoconnectCheckedChanged();
|
||||||
|
void checkBoxAppSettingsStartMinimizedCheckedChanged();
|
||||||
|
|
||||||
|
void labelAppSettingsVersionTextChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
Settings m_settings;
|
||||||
|
UiLogic *m_uiLogic;
|
||||||
|
|
||||||
|
bool m_checkBoxAppSettingsAutostartChecked;
|
||||||
|
bool m_checkBoxAppSettingsAutoconnectChecked;
|
||||||
|
bool m_checkBoxAppSettingsStartMinimizedChecked;
|
||||||
|
|
||||||
|
QString m_labelAppSettingsVersionText;
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif // APP_SETTINGS_LOGIC_H
|
66
client/ui/pages_logic/GeneralSettingsLogic.cpp
Normal file
66
client/ui/pages_logic/GeneralSettingsLogic.cpp
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
//#include <QApplication>
|
||||||
|
//#include <QClipboard>
|
||||||
|
//#include <QDebug>
|
||||||
|
//#include <QDesktopServices>
|
||||||
|
//#include <QFileDialog>
|
||||||
|
//#include <QHBoxLayout>
|
||||||
|
//#include <QHostInfo>
|
||||||
|
//#include <QItemSelectionModel>
|
||||||
|
//#include <QJsonDocument>
|
||||||
|
//#include <QJsonObject>
|
||||||
|
//#include <QKeyEvent>
|
||||||
|
//#include <QMenu>
|
||||||
|
//#include <QMessageBox>
|
||||||
|
//#include <QMetaEnum>
|
||||||
|
//#include <QSysInfo>
|
||||||
|
//#include <QThread>
|
||||||
|
//#include <QTimer>
|
||||||
|
//#include <QRegularExpression>
|
||||||
|
//#include <QSaveFile>
|
||||||
|
|
||||||
|
#include "GeneralSettingsLogic.h"
|
||||||
|
#include "../uilogic.h"
|
||||||
|
|
||||||
|
using namespace amnezia;
|
||||||
|
using namespace PageEnumNS;
|
||||||
|
|
||||||
|
|
||||||
|
GeneralSettingsLogic::GeneralSettingsLogic(UiLogic *uiLogic, QObject *parent):
|
||||||
|
QObject(parent),
|
||||||
|
m_uiLogic(uiLogic)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void GeneralSettingsLogic::updateGeneralSettingPage()
|
||||||
|
{
|
||||||
|
setPushButtonGeneralSettingsShareConnectionEnable(m_settings.haveAuthData(m_settings.defaultServerIndex()));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GeneralSettingsLogic::getPushButtonGeneralSettingsShareConnectionEnable() const
|
||||||
|
{
|
||||||
|
return m_pushButtonGeneralSettingsShareConnectionEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GeneralSettingsLogic::setPushButtonGeneralSettingsShareConnectionEnable(bool pushButtonGeneralSettingsShareConnectionEnable)
|
||||||
|
{
|
||||||
|
if (m_pushButtonGeneralSettingsShareConnectionEnable != pushButtonGeneralSettingsShareConnectionEnable) {
|
||||||
|
m_pushButtonGeneralSettingsShareConnectionEnable = pushButtonGeneralSettingsShareConnectionEnable;
|
||||||
|
emit pushButtonGeneralSettingsShareConnectionEnableChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GeneralSettingsLogic::onPushButtonGeneralSettingsServerSettingsClicked()
|
||||||
|
{
|
||||||
|
m_uiLogic->selectedServerIndex = m_settings.defaultServerIndex();
|
||||||
|
m_uiLogic->goToPage(Page::ServerSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GeneralSettingsLogic::onPushButtonGeneralSettingsShareConnectionClicked()
|
||||||
|
{
|
||||||
|
m_uiLogic->selectedServerIndex = m_settings.defaultServerIndex();
|
||||||
|
m_uiLogic->selectedDockerContainer = m_settings.defaultContainer(m_uiLogic->selectedServerIndex);
|
||||||
|
|
||||||
|
m_uiLogic->updateSharingPage(m_uiLogic->selectedServerIndex, m_settings.serverCredentials(m_uiLogic->selectedServerIndex), m_uiLogic->selectedDockerContainer);
|
||||||
|
m_uiLogic->goToPage(Page::ShareConnection);
|
||||||
|
}
|
48
client/ui/pages_logic/GeneralSettingsLogic.h
Normal file
48
client/ui/pages_logic/GeneralSettingsLogic.h
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
#ifndef GENERAL_SETTINGS_LOGIC_H
|
||||||
|
#define GENERAL_SETTINGS_LOGIC_H
|
||||||
|
|
||||||
|
#include "../pages.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
|
class UiLogic;
|
||||||
|
|
||||||
|
class GeneralSettingsLogic : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
Q_INVOKABLE void updateGeneralSettingPage();
|
||||||
|
|
||||||
|
Q_PROPERTY(bool pushButtonGeneralSettingsShareConnectionEnable READ getPushButtonGeneralSettingsShareConnectionEnable WRITE setPushButtonGeneralSettingsShareConnectionEnable NOTIFY pushButtonGeneralSettingsShareConnectionEnableChanged)
|
||||||
|
|
||||||
|
Q_INVOKABLE void onPushButtonGeneralSettingsServerSettingsClicked();
|
||||||
|
Q_INVOKABLE void onPushButtonGeneralSettingsShareConnectionClicked();
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit GeneralSettingsLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||||
|
~GeneralSettingsLogic() = default;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool getPushButtonGeneralSettingsShareConnectionEnable() const;
|
||||||
|
void setPushButtonGeneralSettingsShareConnectionEnable(bool pushButtonGeneralSettingsShareConnectionEnable);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void pushButtonGeneralSettingsShareConnectionEnableChanged();
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
Settings m_settings;
|
||||||
|
UiLogic *m_uiLogic;
|
||||||
|
|
||||||
|
bool m_pushButtonGeneralSettingsShareConnectionEnable;
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif // GENERAL_SETTINGS_LOGIC_H
|
101
client/ui/pages_logic/NetworkSettingsLogic.cpp
Normal file
101
client/ui/pages_logic/NetworkSettingsLogic.cpp
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
//#include <QApplication>
|
||||||
|
//#include <QClipboard>
|
||||||
|
//#include <QDebug>
|
||||||
|
//#include <QDesktopServices>
|
||||||
|
//#include <QFileDialog>
|
||||||
|
//#include <QHBoxLayout>
|
||||||
|
//#include <QHostInfo>
|
||||||
|
//#include <QItemSelectionModel>
|
||||||
|
//#include <QJsonDocument>
|
||||||
|
//#include <QJsonObject>
|
||||||
|
//#include <QKeyEvent>
|
||||||
|
//#include <QMenu>
|
||||||
|
//#include <QMessageBox>
|
||||||
|
//#include <QMetaEnum>
|
||||||
|
//#include <QSysInfo>
|
||||||
|
//#include <QThread>
|
||||||
|
//#include <QTimer>
|
||||||
|
//#include <QRegularExpression>
|
||||||
|
//#include <QSaveFile>
|
||||||
|
|
||||||
|
#include "defines.h"
|
||||||
|
#include "NetworkSettingsLogic.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
|
||||||
|
using namespace amnezia;
|
||||||
|
using namespace PageEnumNS;
|
||||||
|
|
||||||
|
|
||||||
|
NetworkSettingsLogic::NetworkSettingsLogic(UiLogic *uiLogic, QObject *parent):
|
||||||
|
QObject(parent),
|
||||||
|
m_uiLogic(uiLogic),
|
||||||
|
m_ipAddressValidatorRegex{Utils::ipAddressRegExp().pattern()}
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkSettingsLogic::updateNetworkSettingsPage()
|
||||||
|
{
|
||||||
|
setLineEditNetworkSettingsDns1Text(m_settings.primaryDns());
|
||||||
|
setLineEditNetworkSettingsDns2Text(m_settings.secondaryDns());
|
||||||
|
}
|
||||||
|
|
||||||
|
QString NetworkSettingsLogic::getLineEditNetworkSettingsDns1Text() const
|
||||||
|
{
|
||||||
|
return m_lineEditNetworkSettingsDns1Text;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkSettingsLogic::setLineEditNetworkSettingsDns1Text(const QString &lineEditNetworkSettingsDns1Text)
|
||||||
|
{
|
||||||
|
if (m_lineEditNetworkSettingsDns1Text != lineEditNetworkSettingsDns1Text) {
|
||||||
|
m_lineEditNetworkSettingsDns1Text = lineEditNetworkSettingsDns1Text;
|
||||||
|
emit lineEditNetworkSettingsDns1TextChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString NetworkSettingsLogic::getLineEditNetworkSettingsDns2Text() const
|
||||||
|
{
|
||||||
|
return m_lineEditNetworkSettingsDns2Text;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkSettingsLogic::setLineEditNetworkSettingsDns2Text(const QString &lineEditNetworkSettingsDns2Text)
|
||||||
|
{
|
||||||
|
if (m_lineEditNetworkSettingsDns2Text != lineEditNetworkSettingsDns2Text) {
|
||||||
|
m_lineEditNetworkSettingsDns2Text = lineEditNetworkSettingsDns2Text;
|
||||||
|
emit lineEditNetworkSettingsDns2TextChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkSettingsLogic::onLineEditNetworkSettingsDns1EditFinished(const QString &text)
|
||||||
|
{
|
||||||
|
QRegExp reg{getIpAddressValidatorRegex()};
|
||||||
|
if (reg.exactMatch(text)) {
|
||||||
|
m_settings.setPrimaryDns(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkSettingsLogic::onLineEditNetworkSettingsDns2EditFinished(const QString &text)
|
||||||
|
{
|
||||||
|
QRegExp reg{getIpAddressValidatorRegex()};
|
||||||
|
if (reg.exactMatch(text)) {
|
||||||
|
m_settings.setSecondaryDns(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkSettingsLogic::onPushButtonNetworkSettingsResetdns1Clicked()
|
||||||
|
{
|
||||||
|
m_settings.setPrimaryDns(m_settings.cloudFlareNs1);
|
||||||
|
updateNetworkSettingsPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkSettingsLogic::onPushButtonNetworkSettingsResetdns2Clicked()
|
||||||
|
{
|
||||||
|
m_settings.setSecondaryDns(m_settings.cloudFlareNs2);
|
||||||
|
updateNetworkSettingsPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString NetworkSettingsLogic::getIpAddressValidatorRegex() const
|
||||||
|
{
|
||||||
|
return m_ipAddressValidatorRegex;
|
||||||
|
}
|
61
client/ui/pages_logic/NetworkSettingsLogic.h
Normal file
61
client/ui/pages_logic/NetworkSettingsLogic.h
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
#ifndef NETWORK_SETTINGS_LOGIC_H
|
||||||
|
#define NETWORK_SETTINGS_LOGIC_H
|
||||||
|
|
||||||
|
#include "../pages.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
|
class UiLogic;
|
||||||
|
|
||||||
|
class NetworkSettingsLogic : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
Q_INVOKABLE void updateNetworkSettingsPage();
|
||||||
|
|
||||||
|
Q_PROPERTY(QString lineEditNetworkSettingsDns1Text READ getLineEditNetworkSettingsDns1Text WRITE setLineEditNetworkSettingsDns1Text NOTIFY lineEditNetworkSettingsDns1TextChanged)
|
||||||
|
Q_PROPERTY(QString lineEditNetworkSettingsDns2Text READ getLineEditNetworkSettingsDns2Text WRITE setLineEditNetworkSettingsDns2Text NOTIFY lineEditNetworkSettingsDns2TextChanged)
|
||||||
|
|
||||||
|
Q_PROPERTY(QString ipAddressValidatorRegex READ getIpAddressValidatorRegex CONSTANT)
|
||||||
|
|
||||||
|
Q_INVOKABLE void onLineEditNetworkSettingsDns1EditFinished(const QString& text);
|
||||||
|
Q_INVOKABLE void onLineEditNetworkSettingsDns2EditFinished(const QString& text);
|
||||||
|
Q_INVOKABLE void onPushButtonNetworkSettingsResetdns1Clicked();
|
||||||
|
Q_INVOKABLE void onPushButtonNetworkSettingsResetdns2Clicked();
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit NetworkSettingsLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||||
|
~NetworkSettingsLogic() = default;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
QString getLineEditNetworkSettingsDns1Text() const;
|
||||||
|
void setLineEditNetworkSettingsDns1Text(const QString &lineEditNetworkSettingsDns1Text);
|
||||||
|
QString getLineEditNetworkSettingsDns2Text() const;
|
||||||
|
void setLineEditNetworkSettingsDns2Text(const QString &lineEditNetworkSettingsDns2Text);
|
||||||
|
|
||||||
|
QString getIpAddressValidatorRegex() const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void lineEditNetworkSettingsDns1TextChanged();
|
||||||
|
void lineEditNetworkSettingsDns2TextChanged();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
Settings m_settings;
|
||||||
|
UiLogic *m_uiLogic;
|
||||||
|
|
||||||
|
QString m_lineEditNetworkSettingsDns1Text;
|
||||||
|
QString m_lineEditNetworkSettingsDns2Text;
|
||||||
|
|
||||||
|
QString m_ipAddressValidatorRegex;
|
||||||
|
};
|
||||||
|
#endif // NETWORK_SETTINGS_LOGIC_H
|
54
client/ui/pages_logic/NewServerLogic.cpp
Normal file
54
client/ui/pages_logic/NewServerLogic.cpp
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QClipboard>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QHostInfo>
|
||||||
|
#include <QItemSelectionModel>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QMetaEnum>
|
||||||
|
#include <QSysInfo>
|
||||||
|
#include <QThread>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
#include <QSaveFile>
|
||||||
|
|
||||||
|
//#include "configurators/cloak_configurator.h"
|
||||||
|
//#include "configurators/vpn_configurator.h"
|
||||||
|
//#include "configurators/openvpn_configurator.h"
|
||||||
|
//#include "configurators/shadowsocks_configurator.h"
|
||||||
|
//#include "configurators/ssh_configurator.h"
|
||||||
|
|
||||||
|
//#include "core/servercontroller.h"
|
||||||
|
//#include "core/server_defs.h"
|
||||||
|
//#include "core/errorstrings.h"
|
||||||
|
|
||||||
|
//#include "protocols/protocols_defs.h"
|
||||||
|
//#include "protocols/shadowsocksvpnprotocol.h"
|
||||||
|
|
||||||
|
#include "debug.h"
|
||||||
|
#include "defines.h"
|
||||||
|
#include "NewServerLogic.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "vpnconnection.h"
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
#if defined Q_OS_MAC || defined Q_OS_LINUX
|
||||||
|
#include "ui/macos_util.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using namespace amnezia;
|
||||||
|
using namespace PageEnumNS;
|
||||||
|
|
||||||
|
|
||||||
|
NewServerLogic::NewServerLogic(UiLogic *uiLogic, QObject *parent):
|
||||||
|
QObject(parent),
|
||||||
|
m_uiLogic(uiLogic)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
35
client/ui/pages_logic/NewServerLogic.h
Normal file
35
client/ui/pages_logic/NewServerLogic.h
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#ifndef NEW_SERVER_LOGIC_H
|
||||||
|
#define NEW_SERVER_LOGIC_H
|
||||||
|
|
||||||
|
#include "../pages.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
|
class UiLogic;
|
||||||
|
|
||||||
|
class NewServerLogic : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit NewServerLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||||
|
~NewServerLogic() = default;
|
||||||
|
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
Settings m_settings;
|
||||||
|
UiLogic *m_uiLogic;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif // NEW_SERVER_LOGIC_H
|
54
client/ui/pages_logic/ProtocolSettingsLogic.cpp
Normal file
54
client/ui/pages_logic/ProtocolSettingsLogic.cpp
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QClipboard>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QHostInfo>
|
||||||
|
#include <QItemSelectionModel>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QMetaEnum>
|
||||||
|
#include <QSysInfo>
|
||||||
|
#include <QThread>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
#include <QSaveFile>
|
||||||
|
|
||||||
|
//#include "configurators/cloak_configurator.h"
|
||||||
|
//#include "configurators/vpn_configurator.h"
|
||||||
|
//#include "configurators/openvpn_configurator.h"
|
||||||
|
//#include "configurators/shadowsocks_configurator.h"
|
||||||
|
//#include "configurators/ssh_configurator.h"
|
||||||
|
|
||||||
|
//#include "core/servercontroller.h"
|
||||||
|
//#include "core/server_defs.h"
|
||||||
|
//#include "core/errorstrings.h"
|
||||||
|
|
||||||
|
//#include "protocols/protocols_defs.h"
|
||||||
|
//#include "protocols/shadowsocksvpnprotocol.h"
|
||||||
|
|
||||||
|
#include "debug.h"
|
||||||
|
#include "defines.h"
|
||||||
|
#include "ProtocolSettingsLogic.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "vpnconnection.h"
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
#if defined Q_OS_MAC || defined Q_OS_LINUX
|
||||||
|
#include "ui/macos_util.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using namespace amnezia;
|
||||||
|
using namespace PageEnumNS;
|
||||||
|
|
||||||
|
|
||||||
|
ProtocolSettingsLogic::ProtocolSettingsLogic(UiLogic *uiLogic, QObject *parent):
|
||||||
|
QObject(parent),
|
||||||
|
m_uiLogic(uiLogic)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
35
client/ui/pages_logic/ProtocolSettingsLogic.h
Normal file
35
client/ui/pages_logic/ProtocolSettingsLogic.h
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#ifndef PROTOCOL_SETTINGS_LOGIC_H
|
||||||
|
#define PROTOCOL_SETTINGS_LOGIC_H
|
||||||
|
|
||||||
|
#include "../pages.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
|
class UiLogic;
|
||||||
|
|
||||||
|
class ProtocolSettingsLogic : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ProtocolSettingsLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||||
|
~ProtocolSettingsLogic() = default;
|
||||||
|
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
Settings m_settings;
|
||||||
|
UiLogic *m_uiLogic;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif // PROTOCOL_SETTINGS_LOGIC_H
|
54
client/ui/pages_logic/ServerListLogic.cpp
Normal file
54
client/ui/pages_logic/ServerListLogic.cpp
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QClipboard>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QHostInfo>
|
||||||
|
#include <QItemSelectionModel>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QMetaEnum>
|
||||||
|
#include <QSysInfo>
|
||||||
|
#include <QThread>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
#include <QSaveFile>
|
||||||
|
|
||||||
|
//#include "configurators/cloak_configurator.h"
|
||||||
|
//#include "configurators/vpn_configurator.h"
|
||||||
|
//#include "configurators/openvpn_configurator.h"
|
||||||
|
//#include "configurators/shadowsocks_configurator.h"
|
||||||
|
//#include "configurators/ssh_configurator.h"
|
||||||
|
|
||||||
|
//#include "core/servercontroller.h"
|
||||||
|
//#include "core/server_defs.h"
|
||||||
|
//#include "core/errorstrings.h"
|
||||||
|
|
||||||
|
//#include "protocols/protocols_defs.h"
|
||||||
|
//#include "protocols/shadowsocksvpnprotocol.h"
|
||||||
|
|
||||||
|
#include "debug.h"
|
||||||
|
#include "defines.h"
|
||||||
|
#include "ServerListLogic.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "vpnconnection.h"
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
#if defined Q_OS_MAC || defined Q_OS_LINUX
|
||||||
|
#include "ui/macos_util.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using namespace amnezia;
|
||||||
|
using namespace PageEnumNS;
|
||||||
|
|
||||||
|
|
||||||
|
ServerListLogic::ServerListLogic(UiLogic *uiLogic, QObject *parent):
|
||||||
|
QObject(parent),
|
||||||
|
m_uiLogic(uiLogic)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
34
client/ui/pages_logic/ServerListLogic.h
Normal file
34
client/ui/pages_logic/ServerListLogic.h
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#ifndef SERVER_LIST_LOGIC_H
|
||||||
|
#define SERVER_LIST_LOGIC_H
|
||||||
|
|
||||||
|
#include "../pages.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
|
class UiLogic;
|
||||||
|
|
||||||
|
class ServerListLogic : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ServerListLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||||
|
~ServerListLogic() = default;
|
||||||
|
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
Settings m_settings;
|
||||||
|
UiLogic *m_uiLogic;
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif // SERVER_LIST_LOGIC_H
|
54
client/ui/pages_logic/ServerSettingsLogic.cpp
Normal file
54
client/ui/pages_logic/ServerSettingsLogic.cpp
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QClipboard>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QHostInfo>
|
||||||
|
#include <QItemSelectionModel>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QMetaEnum>
|
||||||
|
#include <QSysInfo>
|
||||||
|
#include <QThread>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
#include <QSaveFile>
|
||||||
|
|
||||||
|
//#include "configurators/cloak_configurator.h"
|
||||||
|
//#include "configurators/vpn_configurator.h"
|
||||||
|
//#include "configurators/openvpn_configurator.h"
|
||||||
|
//#include "configurators/shadowsocks_configurator.h"
|
||||||
|
//#include "configurators/ssh_configurator.h"
|
||||||
|
|
||||||
|
//#include "core/servercontroller.h"
|
||||||
|
//#include "core/server_defs.h"
|
||||||
|
//#include "core/errorstrings.h"
|
||||||
|
|
||||||
|
//#include "protocols/protocols_defs.h"
|
||||||
|
//#include "protocols/shadowsocksvpnprotocol.h"
|
||||||
|
|
||||||
|
#include "debug.h"
|
||||||
|
#include "defines.h"
|
||||||
|
#include "ServerSettingsLogic.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "vpnconnection.h"
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
#if defined Q_OS_MAC || defined Q_OS_LINUX
|
||||||
|
#include "ui/macos_util.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using namespace amnezia;
|
||||||
|
using namespace PageEnumNS;
|
||||||
|
|
||||||
|
|
||||||
|
ServerSettingsLogic::ServerSettingsLogic(UiLogic *uiLogic, QObject *parent):
|
||||||
|
QObject(parent),
|
||||||
|
m_uiLogic(uiLogic)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
35
client/ui/pages_logic/ServerSettingsLogic.h
Normal file
35
client/ui/pages_logic/ServerSettingsLogic.h
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#ifndef SERVER_SETTINGS_LOGIC_H
|
||||||
|
#define SERVER_SETTINGS_LOGIC_H
|
||||||
|
|
||||||
|
#include "../pages.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
|
class UiLogic;
|
||||||
|
|
||||||
|
class ServerSettingsLogic : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ServerSettingsLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||||
|
~ServerSettingsLogic() = default;
|
||||||
|
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
Settings m_settings;
|
||||||
|
UiLogic *m_uiLogic;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif // SERVER_SETTINGS_LOGIC_H
|
54
client/ui/pages_logic/ServerVpnProtocolsLogic.cpp
Normal file
54
client/ui/pages_logic/ServerVpnProtocolsLogic.cpp
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QClipboard>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QHostInfo>
|
||||||
|
#include <QItemSelectionModel>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QMetaEnum>
|
||||||
|
#include <QSysInfo>
|
||||||
|
#include <QThread>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
#include <QSaveFile>
|
||||||
|
|
||||||
|
//#include "configurators/cloak_configurator.h"
|
||||||
|
//#include "configurators/vpn_configurator.h"
|
||||||
|
//#include "configurators/openvpn_configurator.h"
|
||||||
|
//#include "configurators/shadowsocks_configurator.h"
|
||||||
|
//#include "configurators/ssh_configurator.h"
|
||||||
|
|
||||||
|
//#include "core/servercontroller.h"
|
||||||
|
//#include "core/server_defs.h"
|
||||||
|
//#include "core/errorstrings.h"
|
||||||
|
|
||||||
|
//#include "protocols/protocols_defs.h"
|
||||||
|
//#include "protocols/shadowsocksvpnprotocol.h"
|
||||||
|
|
||||||
|
#include "debug.h"
|
||||||
|
#include "defines.h"
|
||||||
|
#include "ServerVpnProtocolsLogic.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "vpnconnection.h"
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
#if defined Q_OS_MAC || defined Q_OS_LINUX
|
||||||
|
#include "ui/macos_util.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using namespace amnezia;
|
||||||
|
using namespace PageEnumNS;
|
||||||
|
|
||||||
|
|
||||||
|
ServerVpnProtocolsLogic::ServerVpnProtocolsLogic(UiLogic *uiLogic, QObject *parent):
|
||||||
|
QObject(parent),
|
||||||
|
m_uiLogic(uiLogic)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
35
client/ui/pages_logic/ServerVpnProtocolsLogic.h
Normal file
35
client/ui/pages_logic/ServerVpnProtocolsLogic.h
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#ifndef SERVER_VPN_PROTOCOLS_LOGIC_H
|
||||||
|
#define SERVER_VPN_PROTOCOLS_LOGIC_H
|
||||||
|
|
||||||
|
#include "../pages.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
|
class UiLogic;
|
||||||
|
|
||||||
|
class ServerVpnProtocolsLogic : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ServerVpnProtocolsLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||||
|
~ServerVpnProtocolsLogic() = default;
|
||||||
|
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
Settings m_settings;
|
||||||
|
UiLogic *m_uiLogic;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif // SERVER_VPN_PROTOCOLS_LOGIC_H
|
54
client/ui/pages_logic/ShareConnectionLogic.cpp
Normal file
54
client/ui/pages_logic/ShareConnectionLogic.cpp
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QClipboard>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QHostInfo>
|
||||||
|
#include <QItemSelectionModel>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QMetaEnum>
|
||||||
|
#include <QSysInfo>
|
||||||
|
#include <QThread>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
#include <QSaveFile>
|
||||||
|
|
||||||
|
//#include "configurators/cloak_configurator.h"
|
||||||
|
//#include "configurators/vpn_configurator.h"
|
||||||
|
//#include "configurators/openvpn_configurator.h"
|
||||||
|
//#include "configurators/shadowsocks_configurator.h"
|
||||||
|
//#include "configurators/ssh_configurator.h"
|
||||||
|
|
||||||
|
//#include "core/servercontroller.h"
|
||||||
|
//#include "core/server_defs.h"
|
||||||
|
//#include "core/errorstrings.h"
|
||||||
|
|
||||||
|
//#include "protocols/protocols_defs.h"
|
||||||
|
//#include "protocols/shadowsocksvpnprotocol.h"
|
||||||
|
|
||||||
|
#include "debug.h"
|
||||||
|
#include "defines.h"
|
||||||
|
#include "ShareConnectionLogic.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "vpnconnection.h"
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
#if defined Q_OS_MAC || defined Q_OS_LINUX
|
||||||
|
#include "ui/macos_util.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using namespace amnezia;
|
||||||
|
using namespace PageEnumNS;
|
||||||
|
|
||||||
|
|
||||||
|
ShareConnectionLogic::ShareConnectionLogic(UiLogic *uiLogic, QObject *parent):
|
||||||
|
QObject(parent),
|
||||||
|
m_uiLogic(uiLogic)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
35
client/ui/pages_logic/ShareConnectionLogic.h
Normal file
35
client/ui/pages_logic/ShareConnectionLogic.h
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#ifndef SHARE_CONNECTION_LOGIC_H
|
||||||
|
#define SHARE_CONNECTION_LOGIC_H
|
||||||
|
|
||||||
|
#include "../pages.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
|
class UiLogic;
|
||||||
|
|
||||||
|
class ShareConnectionLogic: public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ShareConnectionLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||||
|
~ShareConnectionLogic() = default;
|
||||||
|
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
Settings m_settings;
|
||||||
|
UiLogic *m_uiLogic;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif // SHARE_CONNECTION_LOGIC_H
|
202
client/ui/pages_logic/SitesLogic.cpp
Normal file
202
client/ui/pages_logic/SitesLogic.cpp
Normal file
|
@ -0,0 +1,202 @@
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <QHostInfo>
|
||||||
|
|
||||||
|
|
||||||
|
#include "SitesLogic.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "vpnconnection.h"
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
#include "../uilogic.h"
|
||||||
|
#include "../sites_model.h"
|
||||||
|
|
||||||
|
|
||||||
|
using namespace amnezia;
|
||||||
|
using namespace PageEnumNS;
|
||||||
|
|
||||||
|
|
||||||
|
SitesLogic::SitesLogic(UiLogic *uiLogic, QObject *parent):
|
||||||
|
QObject(parent),
|
||||||
|
m_uiLogic(uiLogic),
|
||||||
|
m_labelSitesAddCustomText{},
|
||||||
|
m_tableViewSitesModel{nullptr},
|
||||||
|
m_lineEditSitesAddCustomText{}
|
||||||
|
{
|
||||||
|
sitesModels.insert(Settings::VpnOnlyForwardSites, new SitesModel(Settings::VpnOnlyForwardSites));
|
||||||
|
sitesModels.insert(Settings::VpnAllExceptSites, new SitesModel(Settings::VpnAllExceptSites));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SitesLogic::updateSitesPage()
|
||||||
|
{
|
||||||
|
Settings::RouteMode m = m_settings.routeMode();
|
||||||
|
if (m == Settings::VpnAllSites) return;
|
||||||
|
|
||||||
|
if (m == Settings::VpnOnlyForwardSites) {
|
||||||
|
setLabelSitesAddCustomText(tr("These sites will be opened using VPN"));
|
||||||
|
}
|
||||||
|
if (m == Settings::VpnAllExceptSites) {
|
||||||
|
setLabelSitesAddCustomText(tr("These sites will be excepted from VPN"));
|
||||||
|
}
|
||||||
|
|
||||||
|
setTableViewSitesModel(sitesModels.value(m));
|
||||||
|
sitesModels.value(m)->resetCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString SitesLogic::getLabelSitesAddCustomText() const
|
||||||
|
{
|
||||||
|
return m_labelSitesAddCustomText;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SitesLogic::setLabelSitesAddCustomText(const QString &labelSitesAddCustomText)
|
||||||
|
{
|
||||||
|
if (m_labelSitesAddCustomText != labelSitesAddCustomText) {
|
||||||
|
m_labelSitesAddCustomText = labelSitesAddCustomText;
|
||||||
|
emit labelSitesAddCustomTextChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QObject* SitesLogic::getTableViewSitesModel() const
|
||||||
|
{
|
||||||
|
return m_tableViewSitesModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SitesLogic::setTableViewSitesModel(QObject* tableViewSitesModel)
|
||||||
|
{
|
||||||
|
if (m_tableViewSitesModel != tableViewSitesModel) {
|
||||||
|
m_tableViewSitesModel = tableViewSitesModel;
|
||||||
|
emit tableViewSitesModelChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString SitesLogic::getLineEditSitesAddCustomText() const
|
||||||
|
{
|
||||||
|
return m_lineEditSitesAddCustomText;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SitesLogic::setLineEditSitesAddCustomText(const QString &lineEditSitesAddCustomText)
|
||||||
|
{
|
||||||
|
if (m_lineEditSitesAddCustomText != lineEditSitesAddCustomText) {
|
||||||
|
m_lineEditSitesAddCustomText = lineEditSitesAddCustomText;
|
||||||
|
emit lineEditSitesAddCustomTextChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SitesLogic::onPushButtonAddCustomSitesClicked()
|
||||||
|
{
|
||||||
|
if (m_uiLogic->getRadioButtonVpnModeAllSitesChecked()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Settings::RouteMode mode = m_settings.routeMode();
|
||||||
|
|
||||||
|
QString newSite = getLineEditSitesAddCustomText();
|
||||||
|
|
||||||
|
if (newSite.isEmpty()) return;
|
||||||
|
if (!newSite.contains(".")) return;
|
||||||
|
|
||||||
|
if (!Utils::ipAddressWithSubnetRegExp().exactMatch(newSite)) {
|
||||||
|
// get domain name if it present
|
||||||
|
newSite.replace("https://", "");
|
||||||
|
newSite.replace("http://", "");
|
||||||
|
newSite.replace("ftp://", "");
|
||||||
|
|
||||||
|
newSite = newSite.split("/", QString::SkipEmptyParts).first();
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto &cbProcess = [this, mode](const QString &newSite, const QString &ip) {
|
||||||
|
m_settings.addVpnSite(mode, newSite, ip);
|
||||||
|
|
||||||
|
if (!ip.isEmpty()) {
|
||||||
|
m_uiLogic->m_vpnConnection->addRoutes(QStringList() << ip);
|
||||||
|
m_uiLogic->m_vpnConnection->flushDns();
|
||||||
|
}
|
||||||
|
else if (Utils::ipAddressWithSubnetRegExp().exactMatch(newSite)) {
|
||||||
|
m_uiLogic->m_vpnConnection->addRoutes(QStringList() << newSite);
|
||||||
|
m_uiLogic->m_vpnConnection->flushDns();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateSitesPage();
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto &cbResolv = [this, cbProcess](const QHostInfo &hostInfo){
|
||||||
|
const QList<QHostAddress> &addresses = hostInfo.addresses();
|
||||||
|
QString ipv4Addr;
|
||||||
|
for (const QHostAddress &addr: hostInfo.addresses()) {
|
||||||
|
if (addr.protocol() == QAbstractSocket::NetworkLayerProtocol::IPv4Protocol) {
|
||||||
|
cbProcess(hostInfo.hostName(), addr.toString());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
setLineEditSitesAddCustomText("");
|
||||||
|
|
||||||
|
if (Utils::ipAddressWithSubnetRegExp().exactMatch(newSite)) {
|
||||||
|
cbProcess(newSite, "");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cbProcess(newSite, "");
|
||||||
|
updateSitesPage();
|
||||||
|
QHostInfo::lookupHost(newSite, this, cbResolv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SitesLogic::onPushButtonSitesDeleteClicked(int row)
|
||||||
|
{
|
||||||
|
Settings::RouteMode mode = m_settings.routeMode();
|
||||||
|
|
||||||
|
auto siteModel = qobject_cast<SitesModel*> (getTableViewSitesModel());
|
||||||
|
if (!siteModel) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (row < 0 || row >= siteModel->rowCount()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
QStringList sites;
|
||||||
|
sites.append(siteModel->data(row, 0).toString());
|
||||||
|
m_settings.removeVpnSites(mode, sites);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_uiLogic->m_vpnConnection->connectionState() == VpnProtocol::Connected) {
|
||||||
|
QStringList ips;
|
||||||
|
ips.append(siteModel->data(row, 1).toString());
|
||||||
|
m_uiLogic->m_vpnConnection->deleteRoutes(ips);
|
||||||
|
m_uiLogic->m_vpnConnection->flushDns();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateSitesPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SitesLogic::onPushButtonSitesImportClicked(const QString& fileName)
|
||||||
|
{
|
||||||
|
QFile file(QUrl{fileName}.toLocalFile());
|
||||||
|
if (!file.open(QIODevice::ReadOnly)) {
|
||||||
|
qDebug() << "Can't open file " << QUrl{fileName}.toLocalFile();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Settings::RouteMode mode = m_settings.routeMode();
|
||||||
|
|
||||||
|
QStringList ips;
|
||||||
|
while (!file.atEnd()) {
|
||||||
|
QString line = file.readLine();
|
||||||
|
|
||||||
|
int pos = 0;
|
||||||
|
QRegExp rx = Utils::ipAddressWithSubnetRegExp();
|
||||||
|
while ((pos = rx.indexIn(line, pos)) != -1) {
|
||||||
|
ips << rx.cap(0);
|
||||||
|
pos += rx.matchedLength();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_settings.addVpnIps(mode, ips);
|
||||||
|
|
||||||
|
m_uiLogic->m_vpnConnection->addRoutes(QStringList() << ips);
|
||||||
|
m_uiLogic->m_vpnConnection->flushDns();
|
||||||
|
|
||||||
|
updateSitesPage();
|
||||||
|
}
|
||||||
|
|
60
client/ui/pages_logic/SitesLogic.h
Normal file
60
client/ui/pages_logic/SitesLogic.h
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
#ifndef SITES_LOGIC_H
|
||||||
|
#define SITES_LOGIC_H
|
||||||
|
|
||||||
|
#include "../pages.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
|
class UiLogic;
|
||||||
|
class SitesModel;
|
||||||
|
|
||||||
|
class SitesLogic : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
Q_INVOKABLE void updateSitesPage();
|
||||||
|
|
||||||
|
Q_PROPERTY(QString labelSitesAddCustomText READ getLabelSitesAddCustomText WRITE setLabelSitesAddCustomText NOTIFY labelSitesAddCustomTextChanged)
|
||||||
|
Q_PROPERTY(QObject* tableViewSitesModel READ getTableViewSitesModel NOTIFY tableViewSitesModelChanged)
|
||||||
|
Q_PROPERTY(QString lineEditSitesAddCustomText READ getLineEditSitesAddCustomText WRITE setLineEditSitesAddCustomText NOTIFY lineEditSitesAddCustomTextChanged)
|
||||||
|
|
||||||
|
Q_INVOKABLE void onPushButtonAddCustomSitesClicked();
|
||||||
|
Q_INVOKABLE void onPushButtonSitesDeleteClicked(int row);
|
||||||
|
Q_INVOKABLE void onPushButtonSitesImportClicked(const QString &fileName);
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit SitesLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||||
|
~SitesLogic() = default;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
QString getLabelSitesAddCustomText() const;
|
||||||
|
void setLabelSitesAddCustomText(const QString &labelSitesAddCustomText);
|
||||||
|
QObject* getTableViewSitesModel() const;
|
||||||
|
void setTableViewSitesModel(QObject *tableViewSitesModel);
|
||||||
|
QString getLineEditSitesAddCustomText() const;
|
||||||
|
void setLineEditSitesAddCustomText(const QString &lineEditSitesAddCustomText);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void labelSitesAddCustomTextChanged();
|
||||||
|
void tableViewSitesModelChanged();
|
||||||
|
void lineEditSitesAddCustomTextChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
Settings m_settings;
|
||||||
|
UiLogic *m_uiLogic;
|
||||||
|
|
||||||
|
QString m_labelSitesAddCustomText;
|
||||||
|
QObject* m_tableViewSitesModel;
|
||||||
|
QString m_lineEditSitesAddCustomText;
|
||||||
|
|
||||||
|
QMap<Settings::RouteMode, SitesModel *> sitesModels;
|
||||||
|
};
|
||||||
|
#endif // SITES_LOGIC_H
|
54
client/ui/pages_logic/VpnLogic.cpp
Normal file
54
client/ui/pages_logic/VpnLogic.cpp
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QClipboard>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QHostInfo>
|
||||||
|
#include <QItemSelectionModel>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QMetaEnum>
|
||||||
|
#include <QSysInfo>
|
||||||
|
#include <QThread>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
#include <QSaveFile>
|
||||||
|
|
||||||
|
//#include "configurators/cloak_configurator.h"
|
||||||
|
//#include "configurators/vpn_configurator.h"
|
||||||
|
//#include "configurators/openvpn_configurator.h"
|
||||||
|
//#include "configurators/shadowsocks_configurator.h"
|
||||||
|
//#include "configurators/ssh_configurator.h"
|
||||||
|
|
||||||
|
//#include "core/servercontroller.h"
|
||||||
|
//#include "core/server_defs.h"
|
||||||
|
//#include "core/errorstrings.h"
|
||||||
|
|
||||||
|
//#include "protocols/protocols_defs.h"
|
||||||
|
//#include "protocols/shadowsocksvpnprotocol.h"
|
||||||
|
|
||||||
|
#include "debug.h"
|
||||||
|
#include "defines.h"
|
||||||
|
#include "VpnLogic.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "vpnconnection.h"
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
#if defined Q_OS_MAC || defined Q_OS_LINUX
|
||||||
|
#include "ui/macos_util.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using namespace amnezia;
|
||||||
|
using namespace PageEnumNS;
|
||||||
|
|
||||||
|
|
||||||
|
VpnLogic::VpnLogic(UiLogic *uiLogic, QObject *parent):
|
||||||
|
QObject(parent),
|
||||||
|
m_uiLogic(uiLogic)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
34
client/ui/pages_logic/VpnLogic.h
Normal file
34
client/ui/pages_logic/VpnLogic.h
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#ifndef VPN_LOGIC_H
|
||||||
|
#define VPN_LOGIC_H
|
||||||
|
|
||||||
|
#include "../pages.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
|
class UiLogic;
|
||||||
|
|
||||||
|
class VpnLogic : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit VpnLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||||
|
~VpnLogic() = default;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
Settings m_settings;
|
||||||
|
UiLogic *m_uiLogic;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif // VPN_LOGIC_H
|
54
client/ui/pages_logic/WizardLogic.cpp
Normal file
54
client/ui/pages_logic/WizardLogic.cpp
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QClipboard>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QHostInfo>
|
||||||
|
#include <QItemSelectionModel>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QMetaEnum>
|
||||||
|
#include <QSysInfo>
|
||||||
|
#include <QThread>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
#include <QSaveFile>
|
||||||
|
|
||||||
|
//#include "configurators/cloak_configurator.h"
|
||||||
|
//#include "configurators/vpn_configurator.h"
|
||||||
|
//#include "configurators/openvpn_configurator.h"
|
||||||
|
//#include "configurators/shadowsocks_configurator.h"
|
||||||
|
//#include "configurators/ssh_configurator.h"
|
||||||
|
|
||||||
|
//#include "core/servercontroller.h"
|
||||||
|
//#include "core/server_defs.h"
|
||||||
|
//#include "core/errorstrings.h"
|
||||||
|
|
||||||
|
//#include "protocols/protocols_defs.h"
|
||||||
|
//#include "protocols/shadowsocksvpnprotocol.h"
|
||||||
|
|
||||||
|
#include "debug.h"
|
||||||
|
#include "defines.h"
|
||||||
|
#include "WizardLogic.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "vpnconnection.h"
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
#if defined Q_OS_MAC || defined Q_OS_LINUX
|
||||||
|
#include "ui/macos_util.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using namespace amnezia;
|
||||||
|
using namespace PageEnumNS;
|
||||||
|
|
||||||
|
|
||||||
|
WizardLogic::WizardLogic(UiLogic *uiLogic, QObject *parent):
|
||||||
|
QObject(parent),
|
||||||
|
m_uiLogic(uiLogic)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
35
client/ui/pages_logic/WizardLogic.h
Normal file
35
client/ui/pages_logic/WizardLogic.h
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#ifndef WIZARD_LOGIC_H
|
||||||
|
#define WIZARD_LOGIC_H
|
||||||
|
|
||||||
|
#include "../pages.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
|
class UiLogic;
|
||||||
|
|
||||||
|
class WizardLogic : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit WizardLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||||
|
~WizardLogic() = default;
|
||||||
|
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
Settings m_settings;
|
||||||
|
UiLogic *m_uiLogic;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif // WIZARD_LOGIC_H
|
|
@ -36,10 +36,10 @@ PageBase {
|
||||||
width: 211
|
width: 211
|
||||||
height: 31
|
height: 31
|
||||||
text: qsTr("Auto connect")
|
text: qsTr("Auto connect")
|
||||||
checked: UiLogic.checkBoxAppSettingsAutoconnectChecked
|
checked: AppSettingsLogic.checkBoxAppSettingsAutoconnectChecked
|
||||||
onCheckedChanged: {
|
onCheckedChanged: {
|
||||||
UiLogic.checkBoxAppSettingsAutoconnectChecked = checked
|
AppSettingsLogic.checkBoxAppSettingsAutoconnectChecked = checked
|
||||||
UiLogic.onCheckBoxAppSettingsAutoconnectToggled(checked)
|
AppSettingsLogic.onCheckBoxAppSettingsAutoconnectToggled(checked)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CheckBoxType {
|
CheckBoxType {
|
||||||
|
@ -48,10 +48,10 @@ PageBase {
|
||||||
width: 211
|
width: 211
|
||||||
height: 31
|
height: 31
|
||||||
text: qsTr("Auto start")
|
text: qsTr("Auto start")
|
||||||
checked: UiLogic.checkBoxAppSettingsAutostartChecked
|
checked: AppSettingsLogic.checkBoxAppSettingsAutostartChecked
|
||||||
onCheckedChanged: {
|
onCheckedChanged: {
|
||||||
UiLogic.checkBoxAppSettingsAutostartChecked = checked
|
AppSettingsLogic.checkBoxAppSettingsAutostartChecked = checked
|
||||||
UiLogic.onCheckBoxAppSettingsAutostartToggled(checked)
|
AppSettingsLogic.onCheckBoxAppSettingsAutostartToggled(checked)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CheckBoxType {
|
CheckBoxType {
|
||||||
|
@ -60,10 +60,10 @@ PageBase {
|
||||||
width: 211
|
width: 211
|
||||||
height: 31
|
height: 31
|
||||||
text: qsTr("Start minimized")
|
text: qsTr("Start minimized")
|
||||||
checked: UiLogic.checkBoxAppSettingsStartMinimizedChecked
|
checked: AppSettingsLogic.checkBoxAppSettingsStartMinimizedChecked
|
||||||
onCheckedChanged: {
|
onCheckedChanged: {
|
||||||
UiLogic.checkBoxAppSettingsStartMinimizedChecked = checked
|
AppSettingsLogic.checkBoxAppSettingsStartMinimizedChecked = checked
|
||||||
UiLogic.onCheckBoxAppSettingsStartMinimizedToggled(checked)
|
AppSettingsLogic.onCheckBoxAppSettingsStartMinimizedToggled(checked)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Image {
|
Image {
|
||||||
|
@ -78,7 +78,7 @@ PageBase {
|
||||||
y: 240
|
y: 240
|
||||||
width: 281
|
width: 281
|
||||||
height: 21
|
height: 21
|
||||||
text: UiLogic.labelAppSettingsVersionText
|
text: AppSettingsLogic.labelAppSettingsVersionText
|
||||||
}
|
}
|
||||||
BlueButtonType {
|
BlueButtonType {
|
||||||
x: 30
|
x: 30
|
||||||
|
@ -97,7 +97,7 @@ PageBase {
|
||||||
height: 41
|
height: 41
|
||||||
text: qsTr("Open logs folder")
|
text: qsTr("Open logs folder")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
UiLogic.onPushButtonAppSettingsOpenLogsChecked()
|
AppSettingsLogic.onPushButtonAppSettingsOpenLogsChecked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ Item {
|
||||||
icon.source: "qrc:/images/server_settings.png"
|
icon.source: "qrc:/images/server_settings.png"
|
||||||
text: qsTr("Server management")
|
text: qsTr("Server management")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
UiLogic.onPushButtonGeneralSettingsServerSettingsClicked()
|
GeneralSettingsLogic.onPushButtonGeneralSettingsServerSettingsClicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SettingButtonType {
|
SettingButtonType {
|
||||||
|
@ -130,9 +130,9 @@ Item {
|
||||||
height: 30
|
height: 30
|
||||||
icon.source: "qrc:/images/share.png"
|
icon.source: "qrc:/images/share.png"
|
||||||
text: qsTr("Share connection")
|
text: qsTr("Share connection")
|
||||||
enabled: UiLogic.pushButtonGeneralSettingsShareConnectionEnable
|
enabled: GeneralSettingsLogic.pushButtonGeneralSettingsShareConnectionEnable
|
||||||
onClicked: {
|
onClicked: {
|
||||||
UiLogic.onPushButtonGeneralSettingsShareConnectionClicked()
|
GeneralSettingsLogic.onPushButtonGeneralSettingsShareConnectionClicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SettingButtonType {
|
SettingButtonType {
|
||||||
|
|
|
@ -57,13 +57,13 @@ Item {
|
||||||
y: 120
|
y: 120
|
||||||
width: 271
|
width: 271
|
||||||
height: 40
|
height: 40
|
||||||
text: UiLogic.lineEditNetworkSettingsDns1Text
|
text: NetworkSettingsLogic.lineEditNetworkSettingsDns1Text
|
||||||
onEditingFinished: {
|
onEditingFinished: {
|
||||||
UiLogic.lineEditNetworkSettingsDns1Text = text
|
NetworkSettingsLogic.lineEditNetworkSettingsDns1Text = text
|
||||||
UiLogic.onLineEditNetworkSettingsDns1EditFinished(text)
|
NetworkSettingsLogic.onLineEditNetworkSettingsDns1EditFinished(text)
|
||||||
}
|
}
|
||||||
validator: RegExpValidator {
|
validator: RegExpValidator {
|
||||||
regExp: UiLogic.ipAddressValidatorRegex
|
regExp: NetworkSettingsLogic.ipAddressValidatorRegex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TextFieldType {
|
TextFieldType {
|
||||||
|
@ -72,13 +72,13 @@ Item {
|
||||||
y: 200
|
y: 200
|
||||||
width: 271
|
width: 271
|
||||||
height: 40
|
height: 40
|
||||||
text: UiLogic.lineEditNetworkSettingsDns2Text
|
text: NetworkSettingsLogic.lineEditNetworkSettingsDns2Text
|
||||||
onEditingFinished: {
|
onEditingFinished: {
|
||||||
UiLogic.lineEditNetworkSettingsDns2Text = text
|
NetworkSettingsLogic.lineEditNetworkSettingsDns2Text = text
|
||||||
UiLogic.onLineEditNetworkSettingsDns2EditFinished(text)
|
NetworkSettingsLogic.onLineEditNetworkSettingsDns2EditFinished(text)
|
||||||
}
|
}
|
||||||
validator: RegExpValidator {
|
validator: RegExpValidator {
|
||||||
regExp: UiLogic.ipAddressValidatorRegex
|
regExp: NetworkSettingsLogic.ipAddressValidatorRegex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImageButtonType {
|
ImageButtonType {
|
||||||
|
@ -89,7 +89,7 @@ Item {
|
||||||
height: 24
|
height: 24
|
||||||
icon.source: "qrc:/images/reload.png"
|
icon.source: "qrc:/images/reload.png"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
UiLogic.onPushButtonNetworkSettingsResetdns1Clicked()
|
NetworkSettingsLogic.onPushButtonNetworkSettingsResetdns1Clicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImageButtonType {
|
ImageButtonType {
|
||||||
|
@ -100,7 +100,7 @@ Item {
|
||||||
height: 24
|
height: 24
|
||||||
icon.source: "qrc:/images/reload.png"
|
icon.source: "qrc:/images/reload.png"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
UiLogic.onPushButtonNetworkSettingsResetdns2Clicked()
|
NetworkSettingsLogic.onPushButtonNetworkSettingsResetdns2Clicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -388,7 +388,7 @@ Item {
|
||||||
border.width: 1
|
border.width: 1
|
||||||
border.color: "lightgray"
|
border.color: "lightgray"
|
||||||
radius: 2
|
radius: 2
|
||||||
visible: UiLogic.frameFireguardVisible
|
visible: UiLogic.frameWireguardVisible
|
||||||
Item {
|
Item {
|
||||||
x: 5
|
x: 5
|
||||||
y: 5
|
y: 5
|
||||||
|
|
|
@ -28,7 +28,7 @@ Item {
|
||||||
color: "#100A44"
|
color: "#100A44"
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
verticalAlignment: Text.AlignTop
|
verticalAlignment: Text.AlignTop
|
||||||
text: UiLogic.labelSitesAddCustomText
|
text: SitesLogic.labelSitesAddCustomText
|
||||||
x: 20
|
x: 20
|
||||||
y: 40
|
y: 40
|
||||||
width: 340
|
width: 340
|
||||||
|
@ -40,12 +40,12 @@ Item {
|
||||||
width: 231
|
width: 231
|
||||||
height: 31
|
height: 31
|
||||||
placeholderText: qsTr("yousite.com or IP address")
|
placeholderText: qsTr("yousite.com or IP address")
|
||||||
text: UiLogic.lineEditSitesAddCustomText
|
text: SitesLogic.lineEditSitesAddCustomText
|
||||||
onEditingFinished: {
|
onEditingFinished: {
|
||||||
UiLogic.lineEditSitesAddCustomText = text
|
SitesLogic.lineEditSitesAddCustomText = text
|
||||||
}
|
}
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
UiLogic.onPushButtonAddCustomSitesClicked()
|
SitesLogic.onPushButtonAddCustomSitesClicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImageButtonType {
|
ImageButtonType {
|
||||||
|
@ -68,7 +68,7 @@ Item {
|
||||||
font.pixelSize: 24
|
font.pixelSize: 24
|
||||||
text: "+"
|
text: "+"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
UiLogic.onPushButtonAddCustomSitesClicked()
|
SitesLogic.onPushButtonAddCustomSitesClicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BlueButtonType {
|
BlueButtonType {
|
||||||
|
@ -80,7 +80,7 @@ Item {
|
||||||
font.pixelSize: 16
|
font.pixelSize: 16
|
||||||
text: qsTr("Delete selected")
|
text: qsTr("Delete selected")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
UiLogic.onPushButtonSitesDeleteClicked(tb.currentRow)
|
SitesLogic.onPushButtonSitesDeleteClicked(tb.currentRow)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ Item {
|
||||||
visible: false
|
visible: false
|
||||||
folder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation)
|
folder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation)
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
UiLogic.onPushButtonSitesImportClicked(fileUrl)
|
SitesLogic.onPushButtonSitesImportClicked(fileUrl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ListView {
|
ListView {
|
||||||
|
@ -129,7 +129,7 @@ Item {
|
||||||
spacing: 1
|
spacing: 1
|
||||||
clip: true
|
clip: true
|
||||||
property int currentRow: -1
|
property int currentRow: -1
|
||||||
model: UiLogic.tableViewSitesModel
|
model: SitesLogic.tableViewSitesModel
|
||||||
|
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
implicitWidth: 170 * 2
|
implicitWidth: 170 * 2
|
||||||
|
|
|
@ -156,7 +156,7 @@ Window {
|
||||||
UiLogic.progressBarNewServerConfiguringValue = 0;
|
UiLogic.progressBarNewServerConfiguringValue = 0;
|
||||||
}
|
}
|
||||||
if (page === PageEnum.GeneralSettings) {
|
if (page === PageEnum.GeneralSettings) {
|
||||||
UiLogic.updateGeneralSettingPage();
|
GeneralSettingsLogic.updateGeneralSettingPage();
|
||||||
}
|
}
|
||||||
if (page === PageEnum.ServersList) {
|
if (page === PageEnum.ServersList) {
|
||||||
UiLogic.updateServersListPage();
|
UiLogic.updateServersListPage();
|
||||||
|
@ -172,13 +172,13 @@ Window {
|
||||||
UiLogic.updateProtocolsPage()
|
UiLogic.updateProtocolsPage()
|
||||||
}
|
}
|
||||||
if (page === PageEnum.AppSettings) {
|
if (page === PageEnum.AppSettings) {
|
||||||
UiLogic.updateAppSettingsPage()
|
AppSettingsLogic.updateAppSettingsPage()
|
||||||
}
|
}
|
||||||
if (page === PageEnum.NetworkSettings) {
|
if (page === PageEnum.NetworkSettings) {
|
||||||
UiLogic.updateAppSettingsPage()
|
NetworkSettingsLogic.updateNetworkSettingsPage()
|
||||||
}
|
}
|
||||||
if (page === PageEnum.Sites) {
|
if (page === PageEnum.Sites) {
|
||||||
UiLogic.updateSitesPage()
|
SitesLogic.updateSitesPage()
|
||||||
}
|
}
|
||||||
if (page === PageEnum.Vpn) {
|
if (page === PageEnum.Vpn) {
|
||||||
UiLogic.updateVpnPage()
|
UiLogic.updateVpnPage()
|
||||||
|
|
|
@ -50,7 +50,7 @@ using namespace PageEnumNS;
|
||||||
UiLogic::UiLogic(QObject *parent) :
|
UiLogic::UiLogic(QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_frameWireguardSettingsVisible{false},
|
m_frameWireguardSettingsVisible{false},
|
||||||
m_frameFireguardVisible{false},
|
m_frameWireguardVisible{false},
|
||||||
m_frameNewServerSettingsParentWireguardVisible{false},
|
m_frameNewServerSettingsParentWireguardVisible{false},
|
||||||
m_radioButtonSetupWizardMediumChecked{true},
|
m_radioButtonSetupWizardMediumChecked{true},
|
||||||
m_lineEditSetupWizardHighWebsiteMaskingText{},
|
m_lineEditSetupWizardHighWebsiteMaskingText{},
|
||||||
|
@ -80,13 +80,7 @@ UiLogic::UiLogic(QObject *parent) :
|
||||||
m_radioButtonVpnModeForwardSitesChecked{false},
|
m_radioButtonVpnModeForwardSitesChecked{false},
|
||||||
m_radioButtonVpnModeExceptSitesChecked{false},
|
m_radioButtonVpnModeExceptSitesChecked{false},
|
||||||
m_pushButtonVpnAddSiteEnabled{true},
|
m_pushButtonVpnAddSiteEnabled{true},
|
||||||
m_checkBoxAppSettingsAutostartChecked{false},
|
|
||||||
m_checkBoxAppSettingsAutoconnectChecked{false},
|
|
||||||
m_checkBoxAppSettingsStartMinimizedChecked{false},
|
|
||||||
m_lineEditNetworkSettingsDns1Text{},
|
|
||||||
m_lineEditNetworkSettingsDns2Text{},
|
|
||||||
m_labelAppSettingsVersionText{},
|
|
||||||
m_pushButtonGeneralSettingsShareConnectionEnable{},
|
|
||||||
m_labelServerSettingsWaitInfoVisible{true},
|
m_labelServerSettingsWaitInfoVisible{true},
|
||||||
m_labelServerSettingsWaitInfoText{},
|
m_labelServerSettingsWaitInfoText{},
|
||||||
m_pushButtonServerSettingsClearVisible{true},
|
m_pushButtonServerSettingsClearVisible{true},
|
||||||
|
@ -118,11 +112,8 @@ UiLogic::UiLogic(QObject *parent) :
|
||||||
m_radioButtonSetupWizardHighChecked{false},
|
m_radioButtonSetupWizardHighChecked{false},
|
||||||
m_radioButtonSetupWizardLowChecked{false},
|
m_radioButtonSetupWizardLowChecked{false},
|
||||||
m_checkBoxSetupWizardVpnModeChecked{false},
|
m_checkBoxSetupWizardVpnModeChecked{false},
|
||||||
m_ipAddressValidatorRegex{Utils::ipAddressRegExp().pattern()},
|
|
||||||
m_pushButtonConnectChecked{false},
|
m_pushButtonConnectChecked{false},
|
||||||
m_labelSitesAddCustomText{},
|
|
||||||
m_tableViewSitesModel{nullptr},
|
|
||||||
m_lineEditSitesAddCustomText{},
|
|
||||||
m_widgetProtoCloakEnabled{false},
|
m_widgetProtoCloakEnabled{false},
|
||||||
m_pushButtonProtoCloakSaveVisible{false},
|
m_pushButtonProtoCloakSaveVisible{false},
|
||||||
m_progressBarProtoCloakResetVisible{false},
|
m_progressBarProtoCloakResetVisible{false},
|
||||||
|
@ -243,7 +234,7 @@ UiLogic::UiLogic(QObject *parent) :
|
||||||
void UiLogic::initalizeUiLogic()
|
void UiLogic::initalizeUiLogic()
|
||||||
{
|
{
|
||||||
setFrameWireguardSettingsVisible(false);
|
setFrameWireguardSettingsVisible(false);
|
||||||
setFrameFireguardVisible(false);
|
setFrameWireguardVisible(false);
|
||||||
setFrameNewServerSettingsParentWireguardVisible(false);
|
setFrameNewServerSettingsParentWireguardVisible(false);
|
||||||
|
|
||||||
setupTray();
|
setupTray();
|
||||||
|
@ -310,8 +301,7 @@ void UiLogic::initalizeUiLogic()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sitesModels.insert(Settings::VpnOnlyForwardSites, new SitesModel(Settings::VpnOnlyForwardSites));
|
|
||||||
sitesModels.insert(Settings::VpnAllExceptSites, new SitesModel(Settings::VpnAllExceptSites));
|
|
||||||
m_serverListModel = new ServersModel(this);
|
m_serverListModel = new ServersModel(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,16 +318,16 @@ void UiLogic::setFrameWireguardSettingsVisible(bool frameWireguardSettingsVisibl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UiLogic::getFrameFireguardVisible() const
|
bool UiLogic::getFrameWireguardVisible() const
|
||||||
{
|
{
|
||||||
return m_frameFireguardVisible;
|
return m_frameWireguardVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UiLogic::setFrameFireguardVisible(bool frameFireguardVisible)
|
void UiLogic::setFrameWireguardVisible(bool frameWireguardVisible)
|
||||||
{
|
{
|
||||||
if (m_frameFireguardVisible != frameFireguardVisible) {
|
if (m_frameWireguardVisible != frameWireguardVisible) {
|
||||||
m_frameFireguardVisible = frameFireguardVisible;
|
m_frameWireguardVisible = frameWireguardVisible;
|
||||||
emit frameFireguardVisibleChanged();
|
emit frameWireguardVisibleChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -689,6 +679,16 @@ bool UiLogic::getRadioButtonVpnModeAllSitesChecked() const
|
||||||
return m_radioButtonVpnModeAllSitesChecked;
|
return m_radioButtonVpnModeAllSitesChecked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UiLogic::getRadioButtonVpnModeForwardSitesChecked() const
|
||||||
|
{
|
||||||
|
return m_radioButtonVpnModeForwardSitesChecked;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UiLogic::getRadioButtonVpnModeExceptSitesChecked() const
|
||||||
|
{
|
||||||
|
return m_radioButtonVpnModeExceptSitesChecked;
|
||||||
|
}
|
||||||
|
|
||||||
void UiLogic::setRadioButtonVpnModeAllSitesChecked(bool radioButtonVpnModeAllSitesChecked)
|
void UiLogic::setRadioButtonVpnModeAllSitesChecked(bool radioButtonVpnModeAllSitesChecked)
|
||||||
{
|
{
|
||||||
if (m_radioButtonVpnModeAllSitesChecked != radioButtonVpnModeAllSitesChecked) {
|
if (m_radioButtonVpnModeAllSitesChecked != radioButtonVpnModeAllSitesChecked) {
|
||||||
|
@ -697,11 +697,6 @@ void UiLogic::setRadioButtonVpnModeAllSitesChecked(bool radioButtonVpnModeAllSit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UiLogic::getRadioButtonVpnModeForwardSitesChecked() const
|
|
||||||
{
|
|
||||||
return m_radioButtonVpnModeForwardSitesChecked;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::setRadioButtonVpnModeForwardSitesChecked(bool radioButtonVpnModeForwardSitesChecked)
|
void UiLogic::setRadioButtonVpnModeForwardSitesChecked(bool radioButtonVpnModeForwardSitesChecked)
|
||||||
{
|
{
|
||||||
if (m_radioButtonVpnModeForwardSitesChecked != radioButtonVpnModeForwardSitesChecked) {
|
if (m_radioButtonVpnModeForwardSitesChecked != radioButtonVpnModeForwardSitesChecked) {
|
||||||
|
@ -710,11 +705,6 @@ void UiLogic::setRadioButtonVpnModeForwardSitesChecked(bool radioButtonVpnModeFo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UiLogic::getRadioButtonVpnModeExceptSitesChecked() const
|
|
||||||
{
|
|
||||||
return m_radioButtonVpnModeExceptSitesChecked;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::setRadioButtonVpnModeExceptSitesChecked(bool radioButtonVpnModeExceptSitesChecked)
|
void UiLogic::setRadioButtonVpnModeExceptSitesChecked(bool radioButtonVpnModeExceptSitesChecked)
|
||||||
{
|
{
|
||||||
if (m_radioButtonVpnModeExceptSitesChecked != radioButtonVpnModeExceptSitesChecked) {
|
if (m_radioButtonVpnModeExceptSitesChecked != radioButtonVpnModeExceptSitesChecked) {
|
||||||
|
@ -723,109 +713,11 @@ void UiLogic::setRadioButtonVpnModeExceptSitesChecked(bool radioButtonVpnModeExc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UiLogic::getPushButtonVpnAddSiteEnabled() const
|
|
||||||
{
|
|
||||||
return m_pushButtonVpnAddSiteEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::setPushButtonVpnAddSiteEnabled(bool pushButtonVpnAddSiteEnabled)
|
|
||||||
{
|
|
||||||
if (m_pushButtonVpnAddSiteEnabled != pushButtonVpnAddSiteEnabled) {
|
|
||||||
m_pushButtonVpnAddSiteEnabled = pushButtonVpnAddSiteEnabled;
|
|
||||||
emit pushButtonVpnAddSiteEnabledChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UiLogic::getCheckBoxAppSettingsAutostartChecked() const
|
|
||||||
{
|
|
||||||
return m_checkBoxAppSettingsAutostartChecked;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::setCheckBoxAppSettingsAutostartChecked(bool checkBoxAppSettingsAutostartChecked)
|
|
||||||
{
|
|
||||||
if (m_checkBoxAppSettingsAutostartChecked != checkBoxAppSettingsAutostartChecked) {
|
|
||||||
m_checkBoxAppSettingsAutostartChecked = checkBoxAppSettingsAutostartChecked;
|
|
||||||
emit checkBoxAppSettingsAutostartCheckedChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UiLogic::getCheckBoxAppSettingsAutoconnectChecked() const
|
|
||||||
{
|
|
||||||
return m_checkBoxAppSettingsAutoconnectChecked;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::setCheckBoxAppSettingsAutoconnectChecked(bool checkBoxAppSettingsAutoconnectChecked)
|
|
||||||
{
|
|
||||||
if (m_checkBoxAppSettingsAutoconnectChecked != checkBoxAppSettingsAutoconnectChecked) {
|
|
||||||
m_checkBoxAppSettingsAutoconnectChecked = checkBoxAppSettingsAutoconnectChecked;
|
|
||||||
emit checkBoxAppSettingsAutoconnectCheckedChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UiLogic::getCheckBoxAppSettingsStartMinimizedChecked() const
|
|
||||||
{
|
|
||||||
return m_checkBoxAppSettingsStartMinimizedChecked;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::setCheckBoxAppSettingsStartMinimizedChecked(bool checkBoxAppSettingsStartMinimizedChecked)
|
|
||||||
{
|
|
||||||
if (m_checkBoxAppSettingsStartMinimizedChecked != checkBoxAppSettingsStartMinimizedChecked) {
|
|
||||||
m_checkBoxAppSettingsStartMinimizedChecked = checkBoxAppSettingsStartMinimizedChecked;
|
|
||||||
emit checkBoxAppSettingsStartMinimizedCheckedChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString UiLogic::getLineEditNetworkSettingsDns1Text() const
|
|
||||||
{
|
|
||||||
return m_lineEditNetworkSettingsDns1Text;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::setLineEditNetworkSettingsDns1Text(const QString &lineEditNetworkSettingsDns1Text)
|
|
||||||
{
|
|
||||||
if (m_lineEditNetworkSettingsDns1Text != lineEditNetworkSettingsDns1Text) {
|
|
||||||
m_lineEditNetworkSettingsDns1Text = lineEditNetworkSettingsDns1Text;
|
|
||||||
emit lineEditNetworkSettingsDns1TextChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString UiLogic::getLineEditNetworkSettingsDns2Text() const
|
|
||||||
{
|
|
||||||
return m_lineEditNetworkSettingsDns2Text;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::setLineEditNetworkSettingsDns2Text(const QString &lineEditNetworkSettingsDns2Text)
|
|
||||||
{
|
|
||||||
if (m_lineEditNetworkSettingsDns2Text != lineEditNetworkSettingsDns2Text) {
|
|
||||||
m_lineEditNetworkSettingsDns2Text = lineEditNetworkSettingsDns2Text;
|
|
||||||
emit lineEditNetworkSettingsDns2TextChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString UiLogic::getLabelAppSettingsVersionText() const
|
|
||||||
{
|
|
||||||
return m_labelAppSettingsVersionText;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::setLabelAppSettingsVersionText(const QString &labelAppSettingsVersionText)
|
|
||||||
{
|
|
||||||
if (m_labelAppSettingsVersionText != labelAppSettingsVersionText) {
|
|
||||||
m_labelAppSettingsVersionText = labelAppSettingsVersionText;
|
|
||||||
emit labelAppSettingsVersionTextChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UiLogic::getPushButtonGeneralSettingsShareConnectionEnable() const
|
|
||||||
{
|
|
||||||
return m_pushButtonGeneralSettingsShareConnectionEnable;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::setPushButtonGeneralSettingsShareConnectionEnable(bool pushButtonGeneralSettingsShareConnectionEnable)
|
|
||||||
{
|
|
||||||
if (m_pushButtonGeneralSettingsShareConnectionEnable != pushButtonGeneralSettingsShareConnectionEnable) {
|
|
||||||
m_pushButtonGeneralSettingsShareConnectionEnable = pushButtonGeneralSettingsShareConnectionEnable;
|
|
||||||
emit pushButtonGeneralSettingsShareConnectionEnableChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UiLogic::getLabelServerSettingsWaitInfoVisible() const
|
bool UiLogic::getLabelServerSettingsWaitInfoVisible() const
|
||||||
{
|
{
|
||||||
|
@ -1229,10 +1121,7 @@ void UiLogic::setCheckBoxSetupWizardVpnModeChecked(bool checkBoxSetupWizardVpnMo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString UiLogic::getIpAddressValidatorRegex() const
|
|
||||||
{
|
|
||||||
return m_ipAddressValidatorRegex;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UiLogic::getPushButtonConnectChecked() const
|
bool UiLogic::getPushButtonConnectChecked() const
|
||||||
{
|
{
|
||||||
|
@ -1247,42 +1136,16 @@ void UiLogic::setPushButtonConnectChecked(bool pushButtonConnectChecked)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString UiLogic::getLabelSitesAddCustomText() const
|
bool UiLogic::getPushButtonVpnAddSiteEnabled() const
|
||||||
{
|
{
|
||||||
return m_labelSitesAddCustomText;
|
return m_pushButtonVpnAddSiteEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UiLogic::setLabelSitesAddCustomText(const QString &labelSitesAddCustomText)
|
void UiLogic::setPushButtonVpnAddSiteEnabled(bool pushButtonVpnAddSiteEnabled)
|
||||||
{
|
{
|
||||||
if (m_labelSitesAddCustomText != labelSitesAddCustomText) {
|
if (m_pushButtonVpnAddSiteEnabled != pushButtonVpnAddSiteEnabled) {
|
||||||
m_labelSitesAddCustomText = labelSitesAddCustomText;
|
m_pushButtonVpnAddSiteEnabled = pushButtonVpnAddSiteEnabled;
|
||||||
emit labelSitesAddCustomTextChanged();
|
emit pushButtonVpnAddSiteEnabledChanged();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QObject* UiLogic::getTableViewSitesModel() const
|
|
||||||
{
|
|
||||||
return m_tableViewSitesModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::setTableViewSitesModel(QObject* tableViewSitesModel)
|
|
||||||
{
|
|
||||||
if (m_tableViewSitesModel != tableViewSitesModel) {
|
|
||||||
m_tableViewSitesModel = tableViewSitesModel;
|
|
||||||
emit tableViewSitesModelChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString UiLogic::getLineEditSitesAddCustomText() const
|
|
||||||
{
|
|
||||||
return m_lineEditSitesAddCustomText;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::setLineEditSitesAddCustomText(const QString &lineEditSitesAddCustomText)
|
|
||||||
{
|
|
||||||
if (m_lineEditSitesAddCustomText != lineEditSitesAddCustomText) {
|
|
||||||
m_lineEditSitesAddCustomText = lineEditSitesAddCustomText;
|
|
||||||
emit lineEditSitesAddCustomTextChanged();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3679,123 +3542,7 @@ void UiLogic::onDisconnect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void UiLogic::onPushButtonAddCustomSitesClicked()
|
|
||||||
{
|
|
||||||
if (getRadioButtonVpnModeAllSitesChecked()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Settings::RouteMode mode = m_settings.routeMode();
|
|
||||||
|
|
||||||
QString newSite = getLineEditSitesAddCustomText();
|
|
||||||
|
|
||||||
if (newSite.isEmpty()) return;
|
|
||||||
if (!newSite.contains(".")) return;
|
|
||||||
|
|
||||||
if (!Utils::ipAddressWithSubnetRegExp().exactMatch(newSite)) {
|
|
||||||
// get domain name if it present
|
|
||||||
newSite.replace("https://", "");
|
|
||||||
newSite.replace("http://", "");
|
|
||||||
newSite.replace("ftp://", "");
|
|
||||||
|
|
||||||
newSite = newSite.split("/", QString::SkipEmptyParts).first();
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto &cbProcess = [this, mode](const QString &newSite, const QString &ip) {
|
|
||||||
m_settings.addVpnSite(mode, newSite, ip);
|
|
||||||
|
|
||||||
if (!ip.isEmpty()) {
|
|
||||||
m_vpnConnection->addRoutes(QStringList() << ip);
|
|
||||||
m_vpnConnection->flushDns();
|
|
||||||
}
|
|
||||||
else if (Utils::ipAddressWithSubnetRegExp().exactMatch(newSite)) {
|
|
||||||
m_vpnConnection->addRoutes(QStringList() << newSite);
|
|
||||||
m_vpnConnection->flushDns();
|
|
||||||
}
|
|
||||||
|
|
||||||
updateSitesPage();
|
|
||||||
};
|
|
||||||
|
|
||||||
const auto &cbResolv = [this, cbProcess](const QHostInfo &hostInfo){
|
|
||||||
const QList<QHostAddress> &addresses = hostInfo.addresses();
|
|
||||||
QString ipv4Addr;
|
|
||||||
for (const QHostAddress &addr: hostInfo.addresses()) {
|
|
||||||
if (addr.protocol() == QAbstractSocket::NetworkLayerProtocol::IPv4Protocol) {
|
|
||||||
cbProcess(hostInfo.hostName(), addr.toString());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
setLineEditSitesAddCustomText("");
|
|
||||||
|
|
||||||
if (Utils::ipAddressWithSubnetRegExp().exactMatch(newSite)) {
|
|
||||||
cbProcess(newSite, "");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
cbProcess(newSite, "");
|
|
||||||
updateSitesPage();
|
|
||||||
QHostInfo::lookupHost(newSite, this, cbResolv);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::onPushButtonSitesDeleteClicked(int row)
|
|
||||||
{
|
|
||||||
Settings::RouteMode mode = m_settings.routeMode();
|
|
||||||
|
|
||||||
auto siteModel = qobject_cast<SitesModel*> (getTableViewSitesModel());
|
|
||||||
if (!siteModel) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (row < 0 || row >= siteModel->rowCount()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
QStringList sites;
|
|
||||||
sites.append(siteModel->data(row, 0).toString());
|
|
||||||
m_settings.removeVpnSites(mode, sites);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_vpnConnection->connectionState() == VpnProtocol::Connected) {
|
|
||||||
QStringList ips;
|
|
||||||
ips.append(siteModel->data(row, 1).toString());
|
|
||||||
m_vpnConnection->deleteRoutes(ips);
|
|
||||||
m_vpnConnection->flushDns();
|
|
||||||
}
|
|
||||||
|
|
||||||
updateSitesPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::onPushButtonSitesImportClicked(const QString& fileName)
|
|
||||||
{
|
|
||||||
QFile file(QUrl{fileName}.toLocalFile());
|
|
||||||
if (!file.open(QIODevice::ReadOnly)) {
|
|
||||||
qDebug() << "Can't open file " << QUrl{fileName}.toLocalFile();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Settings::RouteMode mode = m_settings.routeMode();
|
|
||||||
|
|
||||||
QStringList ips;
|
|
||||||
while (!file.atEnd()) {
|
|
||||||
QString line = file.readLine();
|
|
||||||
|
|
||||||
int pos = 0;
|
|
||||||
QRegExp rx = Utils::ipAddressWithSubnetRegExp();
|
|
||||||
while ((pos = rx.indexIn(line, pos)) != -1) {
|
|
||||||
ips << rx.cap(0);
|
|
||||||
pos += rx.matchedLength();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_settings.addVpnIps(mode, ips);
|
|
||||||
|
|
||||||
m_vpnConnection->addRoutes(QStringList() << ips);
|
|
||||||
m_vpnConnection->flushDns();
|
|
||||||
|
|
||||||
updateSitesPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::onPushButtonShareFullCopyClicked()
|
void UiLogic::onPushButtonShareFullCopyClicked()
|
||||||
{
|
{
|
||||||
|
@ -3953,20 +3700,7 @@ void UiLogic::onPushButtonShareOpenvpnSaveClicked()
|
||||||
save.commit();
|
save.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UiLogic::onPushButtonGeneralSettingsServerSettingsClicked()
|
|
||||||
{
|
|
||||||
selectedServerIndex = m_settings.defaultServerIndex();
|
|
||||||
goToPage(Page::ServerSettings);
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::onPushButtonGeneralSettingsShareConnectionClicked()
|
|
||||||
{
|
|
||||||
selectedServerIndex = m_settings.defaultServerIndex();
|
|
||||||
selectedDockerContainer = m_settings.defaultContainer(selectedServerIndex);
|
|
||||||
|
|
||||||
updateSharingPage(selectedServerIndex, m_settings.serverCredentials(selectedServerIndex), selectedDockerContainer);
|
|
||||||
goToPage(Page::ShareConnection);
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::onPushButtonProtoOpenvpnContOpenvpnConfigClicked()
|
void UiLogic::onPushButtonProtoOpenvpnContOpenvpnConfigClicked()
|
||||||
{
|
{
|
||||||
|
@ -4191,21 +3925,7 @@ void UiLogic::updateStartPage()
|
||||||
setPushButtonNewServerConnectVisible(true);
|
setPushButtonNewServerConnectVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UiLogic::updateSitesPage()
|
|
||||||
{
|
|
||||||
Settings::RouteMode m = m_settings.routeMode();
|
|
||||||
if (m == Settings::VpnAllSites) return;
|
|
||||||
|
|
||||||
if (m == Settings::VpnOnlyForwardSites) {
|
|
||||||
setLabelSitesAddCustomText(tr("These sites will be opened using VPN"));
|
|
||||||
}
|
|
||||||
if (m == Settings::VpnAllExceptSites) {
|
|
||||||
setLabelSitesAddCustomText(tr("These sites will be excepted from VPN"));
|
|
||||||
}
|
|
||||||
|
|
||||||
setTableViewSitesModel(sitesModels.value(m));
|
|
||||||
sitesModels.value(m)->resetCache();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::updateVpnPage()
|
void UiLogic::updateVpnPage()
|
||||||
{
|
{
|
||||||
|
@ -4216,26 +3936,8 @@ void UiLogic::updateVpnPage()
|
||||||
setPushButtonVpnAddSiteEnabled(mode != Settings::VpnAllSites);
|
setPushButtonVpnAddSiteEnabled(mode != Settings::VpnAllSites);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UiLogic::updateAppSettingsPage()
|
|
||||||
{
|
|
||||||
setCheckBoxAppSettingsAutostartChecked(Autostart::isAutostart());
|
|
||||||
setCheckBoxAppSettingsAutoconnectChecked(m_settings.isAutoConnect());
|
|
||||||
setCheckBoxAppSettingsStartMinimizedChecked(m_settings.isStartMinimized());
|
|
||||||
|
|
||||||
setLineEditNetworkSettingsDns1Text(m_settings.primaryDns());
|
|
||||||
setLineEditNetworkSettingsDns2Text(m_settings.secondaryDns());
|
|
||||||
|
|
||||||
QString ver = QString("%1: %2 (%3)")
|
|
||||||
.arg(tr("Software version"))
|
|
||||||
.arg(QString(APP_MAJOR_VERSION))
|
|
||||||
.arg(__DATE__);
|
|
||||||
setLabelAppSettingsVersionText(ver);
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::updateGeneralSettingPage()
|
|
||||||
{
|
|
||||||
setPushButtonGeneralSettingsShareConnectionEnable(m_settings.haveAuthData(m_settings.defaultServerIndex()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::updateServerPage()
|
void UiLogic::updateServerPage()
|
||||||
{
|
{
|
||||||
|
@ -4293,56 +3995,7 @@ void UiLogic::onRadioButtonVpnModeExceptSitesToggled(bool checked)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UiLogic::onPushButtonAppSettingsOpenLogsChecked()
|
|
||||||
{
|
|
||||||
Debug::openLogsFolder();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::onCheckBoxAppSettingsAutostartToggled(bool checked)
|
|
||||||
{
|
|
||||||
if (!checked) {
|
|
||||||
setCheckBoxAppSettingsAutoconnectChecked(false);
|
|
||||||
}
|
|
||||||
Autostart::setAutostart(checked);
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::onCheckBoxAppSettingsAutoconnectToggled(bool checked)
|
|
||||||
{
|
|
||||||
m_settings.setAutoConnect(checked);
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::onCheckBoxAppSettingsStartMinimizedToggled(bool checked)
|
|
||||||
{
|
|
||||||
m_settings.setStartMinimized(checked);
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::onLineEditNetworkSettingsDns1EditFinished(const QString &text)
|
|
||||||
{
|
|
||||||
QRegExp reg{getIpAddressValidatorRegex()};
|
|
||||||
if (reg.exactMatch(text)) {
|
|
||||||
m_settings.setPrimaryDns(text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::onLineEditNetworkSettingsDns2EditFinished(const QString &text)
|
|
||||||
{
|
|
||||||
QRegExp reg{getIpAddressValidatorRegex()};
|
|
||||||
if (reg.exactMatch(text)) {
|
|
||||||
m_settings.setSecondaryDns(text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::onPushButtonNetworkSettingsResetdns1Clicked()
|
|
||||||
{
|
|
||||||
m_settings.setPrimaryDns(m_settings.cloudFlareNs1);
|
|
||||||
updateAppSettingsPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::onPushButtonNetworkSettingsResetdns2Clicked()
|
|
||||||
{
|
|
||||||
m_settings.setSecondaryDns(m_settings.cloudFlareNs2);
|
|
||||||
updateAppSettingsPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::updateServersListPage()
|
void UiLogic::updateServersListPage()
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,30 +6,34 @@
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include "3rd/QRCodeGenerator/QRCodeGenerator.h"
|
#include "3rd/QRCodeGenerator/QRCodeGenerator.h"
|
||||||
|
|
||||||
|
#include "pages.h"
|
||||||
#include "protocols/vpnprotocol.h"
|
#include "protocols/vpnprotocol.h"
|
||||||
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "sites_model.h"
|
|
||||||
#include "serversmodel.h"
|
#include "serversmodel.h"
|
||||||
|
|
||||||
|
class AppSettingsLogic;
|
||||||
|
class GeneralSettingsLogic;
|
||||||
|
class NetworkSettingsLogic;
|
||||||
|
class NewServerLogic;
|
||||||
|
class ProtocolSettingsLogic;
|
||||||
|
class ServerListLogic;
|
||||||
|
class ServerSettingsLogic;
|
||||||
|
class ServerVpnProtocolsLogic;
|
||||||
|
class ShareConnectionLogic;
|
||||||
|
class SitesLogic;
|
||||||
|
class VpnLogic;
|
||||||
|
class WizardLogic;
|
||||||
|
|
||||||
class VpnConnection;
|
class VpnConnection;
|
||||||
|
|
||||||
namespace PageEnumNS
|
|
||||||
{
|
|
||||||
Q_NAMESPACE
|
|
||||||
enum Page {Start = 0, NewServer, NewServerProtocols, Vpn,
|
|
||||||
Wizard, WizardLow, WizardMedium, WizardHigh, WizardVpnMode, ServerConfiguring,
|
|
||||||
GeneralSettings, AppSettings, NetworkSettings, ServerSettings,
|
|
||||||
ServerVpnProtocols, ServersList, ShareConnection, Sites,
|
|
||||||
OpenVpnSettings, ShadowSocksSettings, CloakSettings};
|
|
||||||
Q_ENUM_NS(Page)
|
|
||||||
}
|
|
||||||
|
|
||||||
class UiLogic : public QObject
|
class UiLogic : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool frameWireguardSettingsVisible READ getFrameWireguardSettingsVisible WRITE setFrameWireguardSettingsVisible NOTIFY frameWireguardSettingsVisibleChanged)
|
Q_PROPERTY(bool frameWireguardSettingsVisible READ getFrameWireguardSettingsVisible WRITE setFrameWireguardSettingsVisible NOTIFY frameWireguardSettingsVisibleChanged)
|
||||||
Q_PROPERTY(bool frameFireguardVisible READ getFrameFireguardVisible WRITE setFrameFireguardVisible NOTIFY frameFireguardVisibleChanged)
|
Q_PROPERTY(bool frameWireguardVisible READ getFrameWireguardVisible WRITE setFrameWireguardVisible NOTIFY frameWireguardVisibleChanged)
|
||||||
Q_PROPERTY(bool frameNewServerSettingsParentWireguardVisible READ getFrameNewServerSettingsParentWireguardVisible WRITE setFrameNewServerSettingsParentWireguardVisible NOTIFY frameNewServerSettingsParentWireguardVisibleChanged)
|
Q_PROPERTY(bool frameNewServerSettingsParentWireguardVisible READ getFrameNewServerSettingsParentWireguardVisible WRITE setFrameNewServerSettingsParentWireguardVisible NOTIFY frameNewServerSettingsParentWireguardVisibleChanged)
|
||||||
Q_PROPERTY(bool radioButtonSetupWizardMediumChecked READ getRadioButtonSetupWizardMediumChecked WRITE setRadioButtonSetupWizardMediumChecked NOTIFY radioButtonSetupWizardMediumCheckedChanged)
|
Q_PROPERTY(bool radioButtonSetupWizardMediumChecked READ getRadioButtonSetupWizardMediumChecked WRITE setRadioButtonSetupWizardMediumChecked NOTIFY radioButtonSetupWizardMediumCheckedChanged)
|
||||||
Q_PROPERTY(QString lineEditSetupWizardHighWebsiteMaskingText READ getLineEditSetupWizardHighWebsiteMaskingText WRITE setLineEditSetupWizardHighWebsiteMaskingText NOTIFY lineEditSetupWizardHighWebsiteMaskingTextChanged)
|
Q_PROPERTY(QString lineEditSetupWizardHighWebsiteMaskingText READ getLineEditSetupWizardHighWebsiteMaskingText WRITE setLineEditSetupWizardHighWebsiteMaskingText NOTIFY lineEditSetupWizardHighWebsiteMaskingTextChanged)
|
||||||
|
@ -55,17 +59,7 @@ class UiLogic : public QObject
|
||||||
Q_PROPERTY(double progressBarNewServerConnectionMaximum READ getProgressBarNewServerConnectionMaximum WRITE setProgressBarNewServerConnectionMaximum NOTIFY progressBarNewServerConnectionMaximumChanged)
|
Q_PROPERTY(double progressBarNewServerConnectionMaximum READ getProgressBarNewServerConnectionMaximum WRITE setProgressBarNewServerConnectionMaximum NOTIFY progressBarNewServerConnectionMaximumChanged)
|
||||||
Q_PROPERTY(bool pushButtonBackFromStartVisible READ getPushButtonBackFromStartVisible WRITE setPushButtonBackFromStartVisible NOTIFY pushButtonBackFromStartVisibleChanged)
|
Q_PROPERTY(bool pushButtonBackFromStartVisible READ getPushButtonBackFromStartVisible WRITE setPushButtonBackFromStartVisible NOTIFY pushButtonBackFromStartVisibleChanged)
|
||||||
Q_PROPERTY(bool pushButtonNewServerConnectVisible READ getPushButtonNewServerConnectVisible WRITE setPushButtonNewServerConnectVisible NOTIFY pushButtonNewServerConnectVisibleChanged)
|
Q_PROPERTY(bool pushButtonNewServerConnectVisible READ getPushButtonNewServerConnectVisible WRITE setPushButtonNewServerConnectVisible NOTIFY pushButtonNewServerConnectVisibleChanged)
|
||||||
Q_PROPERTY(bool radioButtonVpnModeAllSitesChecked READ getRadioButtonVpnModeAllSitesChecked WRITE setRadioButtonVpnModeAllSitesChecked NOTIFY radioButtonVpnModeAllSitesCheckedChanged)
|
|
||||||
Q_PROPERTY(bool radioButtonVpnModeForwardSitesChecked READ getRadioButtonVpnModeForwardSitesChecked WRITE setRadioButtonVpnModeForwardSitesChecked NOTIFY radioButtonVpnModeForwardSitesCheckedChanged)
|
|
||||||
Q_PROPERTY(bool radioButtonVpnModeExceptSitesChecked READ getRadioButtonVpnModeExceptSitesChecked WRITE setRadioButtonVpnModeExceptSitesChecked NOTIFY radioButtonVpnModeExceptSitesCheckedChanged)
|
|
||||||
Q_PROPERTY(bool pushButtonVpnAddSiteEnabled READ getPushButtonVpnAddSiteEnabled WRITE setPushButtonVpnAddSiteEnabled NOTIFY pushButtonVpnAddSiteEnabledChanged)
|
|
||||||
Q_PROPERTY(bool checkBoxAppSettingsAutostartChecked READ getCheckBoxAppSettingsAutostartChecked WRITE setCheckBoxAppSettingsAutostartChecked NOTIFY checkBoxAppSettingsAutostartCheckedChanged)
|
|
||||||
Q_PROPERTY(bool checkBoxAppSettingsAutoconnectChecked READ getCheckBoxAppSettingsAutoconnectChecked WRITE setCheckBoxAppSettingsAutoconnectChecked NOTIFY checkBoxAppSettingsAutoconnectCheckedChanged)
|
|
||||||
Q_PROPERTY(bool checkBoxAppSettingsStartMinimizedChecked READ getCheckBoxAppSettingsStartMinimizedChecked WRITE setCheckBoxAppSettingsStartMinimizedChecked NOTIFY checkBoxAppSettingsStartMinimizedCheckedChanged)
|
|
||||||
Q_PROPERTY(QString lineEditNetworkSettingsDns1Text READ getLineEditNetworkSettingsDns1Text WRITE setLineEditNetworkSettingsDns1Text NOTIFY lineEditNetworkSettingsDns1TextChanged)
|
|
||||||
Q_PROPERTY(QString lineEditNetworkSettingsDns2Text READ getLineEditNetworkSettingsDns2Text WRITE setLineEditNetworkSettingsDns2Text NOTIFY lineEditNetworkSettingsDns2TextChanged)
|
|
||||||
Q_PROPERTY(QString labelAppSettingsVersionText READ getLabelAppSettingsVersionText WRITE setLabelAppSettingsVersionText NOTIFY labelAppSettingsVersionTextChanged)
|
|
||||||
Q_PROPERTY(bool pushButtonGeneralSettingsShareConnectionEnable READ getPushButtonGeneralSettingsShareConnectionEnable WRITE setPushButtonGeneralSettingsShareConnectionEnable NOTIFY pushButtonGeneralSettingsShareConnectionEnableChanged)
|
|
||||||
Q_PROPERTY(bool labelServerSettingsWaitInfoVisible READ getLabelServerSettingsWaitInfoVisible WRITE setLabelServerSettingsWaitInfoVisible NOTIFY labelServerSettingsWaitInfoVisibleChanged)
|
Q_PROPERTY(bool labelServerSettingsWaitInfoVisible READ getLabelServerSettingsWaitInfoVisible WRITE setLabelServerSettingsWaitInfoVisible NOTIFY labelServerSettingsWaitInfoVisibleChanged)
|
||||||
Q_PROPERTY(QString labelServerSettingsWaitInfoText READ getLabelServerSettingsWaitInfoText WRITE setLabelServerSettingsWaitInfoText NOTIFY labelServerSettingsWaitInfoTextChanged)
|
Q_PROPERTY(QString labelServerSettingsWaitInfoText READ getLabelServerSettingsWaitInfoText WRITE setLabelServerSettingsWaitInfoText NOTIFY labelServerSettingsWaitInfoTextChanged)
|
||||||
Q_PROPERTY(bool pushButtonServerSettingsClearVisible READ getPushButtonServerSettingsClearVisible WRITE setPushButtonServerSettingsClearVisible NOTIFY pushButtonServerSettingsClearVisibleChanged)
|
Q_PROPERTY(bool pushButtonServerSettingsClearVisible READ getPushButtonServerSettingsClearVisible WRITE setPushButtonServerSettingsClearVisible NOTIFY pushButtonServerSettingsClearVisibleChanged)
|
||||||
|
@ -97,11 +91,8 @@ class UiLogic : public QObject
|
||||||
Q_PROPERTY(bool radioButtonSetupWizardHighChecked READ getRadioButtonSetupWizardHighChecked WRITE setRadioButtonSetupWizardHighChecked NOTIFY radioButtonSetupWizardHighCheckedChanged)
|
Q_PROPERTY(bool radioButtonSetupWizardHighChecked READ getRadioButtonSetupWizardHighChecked WRITE setRadioButtonSetupWizardHighChecked NOTIFY radioButtonSetupWizardHighCheckedChanged)
|
||||||
Q_PROPERTY(bool radioButtonSetupWizardLowChecked READ getRadioButtonSetupWizardLowChecked WRITE setRadioButtonSetupWizardLowChecked NOTIFY radioButtonSetupWizardLowCheckedChanged)
|
Q_PROPERTY(bool radioButtonSetupWizardLowChecked READ getRadioButtonSetupWizardLowChecked WRITE setRadioButtonSetupWizardLowChecked NOTIFY radioButtonSetupWizardLowCheckedChanged)
|
||||||
Q_PROPERTY(bool checkBoxSetupWizardVpnModeChecked READ getCheckBoxSetupWizardVpnModeChecked WRITE setCheckBoxSetupWizardVpnModeChecked NOTIFY checkBoxSetupWizardVpnModeCheckedChanged)
|
Q_PROPERTY(bool checkBoxSetupWizardVpnModeChecked READ getCheckBoxSetupWizardVpnModeChecked WRITE setCheckBoxSetupWizardVpnModeChecked NOTIFY checkBoxSetupWizardVpnModeCheckedChanged)
|
||||||
Q_PROPERTY(QString ipAddressValidatorRegex READ getIpAddressValidatorRegex CONSTANT)
|
|
||||||
Q_PROPERTY(bool pushButtonConnectChecked READ getPushButtonConnectChecked WRITE setPushButtonConnectChecked NOTIFY pushButtonConnectCheckedChanged)
|
Q_PROPERTY(bool pushButtonConnectChecked READ getPushButtonConnectChecked WRITE setPushButtonConnectChecked NOTIFY pushButtonConnectCheckedChanged)
|
||||||
Q_PROPERTY(QString labelSitesAddCustomText READ getLabelSitesAddCustomText WRITE setLabelSitesAddCustomText NOTIFY labelSitesAddCustomTextChanged)
|
|
||||||
Q_PROPERTY(QObject* tableViewSitesModel READ getTableViewSitesModel NOTIFY tableViewSitesModelChanged)
|
|
||||||
Q_PROPERTY(QString lineEditSitesAddCustomText READ getLineEditSitesAddCustomText WRITE setLineEditSitesAddCustomText NOTIFY lineEditSitesAddCustomTextChanged)
|
|
||||||
Q_PROPERTY(bool widgetProtoCloakEnabled READ getWidgetProtoCloakEnabled WRITE setWidgetProtoCloakEnabled NOTIFY widgetProtoCloakEnabledChanged)
|
Q_PROPERTY(bool widgetProtoCloakEnabled READ getWidgetProtoCloakEnabled WRITE setWidgetProtoCloakEnabled NOTIFY widgetProtoCloakEnabledChanged)
|
||||||
Q_PROPERTY(bool pushButtonProtoCloakSaveVisible READ getPushButtonProtoCloakSaveVisible WRITE setPushButtonProtoCloakSaveVisible NOTIFY pushButtonProtoCloakSaveVisibleChanged)
|
Q_PROPERTY(bool pushButtonProtoCloakSaveVisible READ getPushButtonProtoCloakSaveVisible WRITE setPushButtonProtoCloakSaveVisible NOTIFY pushButtonProtoCloakSaveVisibleChanged)
|
||||||
Q_PROPERTY(bool progressBarProtoCloakResetVisible READ getProgressBarProtoCloakResetVisible WRITE setProgressBarProtoCloakResetVisible NOTIFY progressBarProtoCloakResetVisibleChanged)
|
Q_PROPERTY(bool progressBarProtoCloakResetVisible READ getProgressBarProtoCloakResetVisible WRITE setProgressBarProtoCloakResetVisible NOTIFY progressBarProtoCloakResetVisibleChanged)
|
||||||
|
@ -213,25 +204,37 @@ class UiLogic : public QObject
|
||||||
Q_PROPERTY(QString pushButtonServerSettingsClearClientCacheText READ getPushButtonServerSettingsClearClientCacheText WRITE setPushButtonServerSettingsClearClientCacheText NOTIFY pushButtonServerSettingsClearClientCacheTextChanged)
|
Q_PROPERTY(QString pushButtonServerSettingsClearClientCacheText READ getPushButtonServerSettingsClearClientCacheText WRITE setPushButtonServerSettingsClearClientCacheText NOTIFY pushButtonServerSettingsClearClientCacheTextChanged)
|
||||||
|
|
||||||
|
|
||||||
|
Q_PROPERTY(bool pushButtonVpnAddSiteEnabled READ getPushButtonVpnAddSiteEnabled WRITE setPushButtonVpnAddSiteEnabled NOTIFY pushButtonVpnAddSiteEnabledChanged)
|
||||||
|
|
||||||
|
Q_PROPERTY(bool radioButtonVpnModeAllSitesChecked READ getRadioButtonVpnModeAllSitesChecked WRITE setRadioButtonVpnModeAllSitesChecked NOTIFY radioButtonVpnModeAllSitesCheckedChanged)
|
||||||
|
Q_PROPERTY(bool radioButtonVpnModeForwardSitesChecked READ getRadioButtonVpnModeForwardSitesChecked WRITE setRadioButtonVpnModeForwardSitesChecked NOTIFY radioButtonVpnModeForwardSitesCheckedChanged)
|
||||||
|
Q_PROPERTY(bool radioButtonVpnModeExceptSitesChecked READ getRadioButtonVpnModeExceptSitesChecked WRITE setRadioButtonVpnModeExceptSitesChecked NOTIFY radioButtonVpnModeExceptSitesCheckedChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit UiLogic(QObject *parent = nullptr);
|
explicit UiLogic(QObject *parent = nullptr);
|
||||||
~UiLogic();
|
~UiLogic();
|
||||||
void showOnStartup();
|
void showOnStartup();
|
||||||
|
|
||||||
|
friend class AppSettingsLogic;
|
||||||
|
friend class GeneralSettingsLogic;
|
||||||
|
friend class NetworkSettingsLogic;
|
||||||
|
friend class NewServerLogic;
|
||||||
|
friend class ProtocolSettingsLogic;
|
||||||
|
friend class ServerListLogic;
|
||||||
|
friend class ServerSettingsLogic;
|
||||||
|
friend class ServerVpnProtocolsLogic;
|
||||||
|
friend class ShareConnectionLogic;
|
||||||
|
friend class SitesLogic;
|
||||||
|
friend class VpnLogic;
|
||||||
|
friend class WizardLogic;
|
||||||
|
|
||||||
Q_INVOKABLE void initalizeUiLogic();
|
Q_INVOKABLE void initalizeUiLogic();
|
||||||
static void declareQML() {
|
|
||||||
qmlRegisterUncreatableMetaObject(
|
|
||||||
PageEnumNS::staticMetaObject,
|
|
||||||
"PageEnum",
|
|
||||||
1, 0,
|
|
||||||
"PageEnum",
|
|
||||||
"Error: only enums"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
bool getFrameWireguardSettingsVisible() const;
|
bool getFrameWireguardSettingsVisible() const;
|
||||||
void setFrameWireguardSettingsVisible(bool frameWireguardSettingsVisible);
|
void setFrameWireguardSettingsVisible(bool frameWireguardSettingsVisible);
|
||||||
bool getFrameFireguardVisible() const;
|
bool getFrameWireguardVisible() const;
|
||||||
void setFrameFireguardVisible(bool frameFireguardVisible);
|
void setFrameWireguardVisible(bool frameWireguardVisible);
|
||||||
bool getFrameNewServerSettingsParentWireguardVisible() const;
|
bool getFrameNewServerSettingsParentWireguardVisible() const;
|
||||||
void setFrameNewServerSettingsParentWireguardVisible(bool frameNewServerSettingsParentWireguardVisible);
|
void setFrameNewServerSettingsParentWireguardVisible(bool frameNewServerSettingsParentWireguardVisible);
|
||||||
bool getRadioButtonSetupWizardMediumChecked() const;
|
bool getRadioButtonSetupWizardMediumChecked() const;
|
||||||
|
@ -282,28 +285,9 @@ public:
|
||||||
void setPushButtonNewServerConnectVisible(bool pushButtonNewServerConnectVisible);
|
void setPushButtonNewServerConnectVisible(bool pushButtonNewServerConnectVisible);
|
||||||
bool getPushButtonNewServerConnectKeyChecked() const;
|
bool getPushButtonNewServerConnectKeyChecked() const;
|
||||||
void setPushButtonNewServerConnectKeyChecked(bool pushButtonNewServerConnectKeyChecked);
|
void setPushButtonNewServerConnectKeyChecked(bool pushButtonNewServerConnectKeyChecked);
|
||||||
bool getRadioButtonVpnModeAllSitesChecked() const;
|
|
||||||
void setRadioButtonVpnModeAllSitesChecked(bool radioButtonVpnModeAllSitesChecked);
|
|
||||||
bool getRadioButtonVpnModeForwardSitesChecked() const;
|
|
||||||
void setRadioButtonVpnModeForwardSitesChecked(bool radioButtonVpnModeForwardSitesChecked);
|
|
||||||
bool getRadioButtonVpnModeExceptSitesChecked() const;
|
|
||||||
void setRadioButtonVpnModeExceptSitesChecked(bool radioButtonVpnModeExceptSitesChecked);
|
|
||||||
bool getPushButtonVpnAddSiteEnabled() const;
|
|
||||||
void setPushButtonVpnAddSiteEnabled(bool pushButtonVpnAddSiteEnabled);
|
|
||||||
bool getCheckBoxAppSettingsAutostartChecked() const;
|
|
||||||
void setCheckBoxAppSettingsAutostartChecked(bool checkBoxAppSettingsAutostartChecked);
|
|
||||||
bool getCheckBoxAppSettingsAutoconnectChecked() const;
|
|
||||||
void setCheckBoxAppSettingsAutoconnectChecked(bool checkBoxAppSettingsAutoconnectChecked);
|
|
||||||
bool getCheckBoxAppSettingsStartMinimizedChecked() const;
|
|
||||||
void setCheckBoxAppSettingsStartMinimizedChecked(bool checkBoxAppSettingsStartMinimizedChecked);
|
|
||||||
QString getLineEditNetworkSettingsDns1Text() const;
|
|
||||||
void setLineEditNetworkSettingsDns1Text(const QString &lineEditNetworkSettingsDns1Text);
|
|
||||||
QString getLineEditNetworkSettingsDns2Text() const;
|
|
||||||
void setLineEditNetworkSettingsDns2Text(const QString &lineEditNetworkSettingsDns2Text);
|
|
||||||
QString getLabelAppSettingsVersionText() const;
|
|
||||||
void setLabelAppSettingsVersionText(const QString &labelAppSettingsVersionText);
|
|
||||||
bool getPushButtonGeneralSettingsShareConnectionEnable() const;
|
|
||||||
void setPushButtonGeneralSettingsShareConnectionEnable(bool pushButtonGeneralSettingsShareConnectionEnable);
|
|
||||||
bool getLabelServerSettingsWaitInfoVisible() const;
|
bool getLabelServerSettingsWaitInfoVisible() const;
|
||||||
void setLabelServerSettingsWaitInfoVisible(bool labelServerSettingsWaitInfoVisible);
|
void setLabelServerSettingsWaitInfoVisible(bool labelServerSettingsWaitInfoVisible);
|
||||||
QString getLabelServerSettingsWaitInfoText() const;
|
QString getLabelServerSettingsWaitInfoText() const;
|
||||||
|
@ -366,15 +350,10 @@ public:
|
||||||
void setRadioButtonSetupWizardLowChecked(bool radioButtonSetupWizardLowChecked);
|
void setRadioButtonSetupWizardLowChecked(bool radioButtonSetupWizardLowChecked);
|
||||||
bool getCheckBoxSetupWizardVpnModeChecked() const;
|
bool getCheckBoxSetupWizardVpnModeChecked() const;
|
||||||
void setCheckBoxSetupWizardVpnModeChecked(bool checkBoxSetupWizardVpnModeChecked);
|
void setCheckBoxSetupWizardVpnModeChecked(bool checkBoxSetupWizardVpnModeChecked);
|
||||||
QString getIpAddressValidatorRegex() const;
|
|
||||||
bool getPushButtonConnectChecked() const;
|
bool getPushButtonConnectChecked() const;
|
||||||
void setPushButtonConnectChecked(bool pushButtonConnectChecked);
|
void setPushButtonConnectChecked(bool pushButtonConnectChecked);
|
||||||
QString getLabelSitesAddCustomText() const;
|
|
||||||
void setLabelSitesAddCustomText(const QString &labelSitesAddCustomText);
|
|
||||||
QObject* getTableViewSitesModel() const;
|
|
||||||
void setTableViewSitesModel(QObject *tableViewSitesModel);
|
|
||||||
QString getLineEditSitesAddCustomText() const;
|
|
||||||
void setLineEditSitesAddCustomText(const QString &lineEditSitesAddCustomText);
|
|
||||||
bool getWidgetProtoCloakEnabled() const;
|
bool getWidgetProtoCloakEnabled() const;
|
||||||
void setWidgetProtoCloakEnabled(bool widgetProtoCloakEnabled);
|
void setWidgetProtoCloakEnabled(bool widgetProtoCloakEnabled);
|
||||||
bool getPushButtonProtoCloakSaveVisible() const;
|
bool getPushButtonProtoCloakSaveVisible() const;
|
||||||
|
@ -593,13 +572,19 @@ public:
|
||||||
QString getPushButtonServerSettingsClearClientCacheText() const;
|
QString getPushButtonServerSettingsClearClientCacheText() const;
|
||||||
void setPushButtonServerSettingsClearClientCacheText(const QString &pushButtonServerSettingsClearClientCacheText);
|
void setPushButtonServerSettingsClearClientCacheText(const QString &pushButtonServerSettingsClearClientCacheText);
|
||||||
|
|
||||||
|
bool getRadioButtonVpnModeAllSitesChecked() const;
|
||||||
|
void setRadioButtonVpnModeAllSitesChecked(bool radioButtonVpnModeAllSitesChecked);
|
||||||
|
bool getRadioButtonVpnModeForwardSitesChecked() const;
|
||||||
|
void setRadioButtonVpnModeForwardSitesChecked(bool radioButtonVpnModeForwardSitesChecked);
|
||||||
|
bool getRadioButtonVpnModeExceptSitesChecked() const;
|
||||||
|
void setRadioButtonVpnModeExceptSitesChecked(bool radioButtonVpnModeExceptSitesChecked);
|
||||||
|
bool getPushButtonVpnAddSiteEnabled() const;
|
||||||
|
void setPushButtonVpnAddSiteEnabled(bool pushButtonVpnAddSiteEnabled);
|
||||||
|
|
||||||
Q_INVOKABLE void updateWizardHighPage();
|
Q_INVOKABLE void updateWizardHighPage();
|
||||||
Q_INVOKABLE void updateNewServerProtocolsPage();
|
Q_INVOKABLE void updateNewServerProtocolsPage();
|
||||||
Q_INVOKABLE void updateStartPage();
|
Q_INVOKABLE void updateStartPage();
|
||||||
Q_INVOKABLE void updateVpnPage();
|
Q_INVOKABLE void updateVpnPage();
|
||||||
Q_INVOKABLE void updateAppSettingsPage();
|
|
||||||
Q_INVOKABLE void updateGeneralSettingPage();
|
|
||||||
Q_INVOKABLE void updateServerPage();
|
Q_INVOKABLE void updateServerPage();
|
||||||
|
|
||||||
Q_INVOKABLE void onPushButtonNewServerConnect();
|
Q_INVOKABLE void onPushButtonNewServerConnect();
|
||||||
|
@ -609,18 +594,11 @@ public:
|
||||||
Q_INVOKABLE void onRadioButtonVpnModeAllSitesToggled(bool checked);
|
Q_INVOKABLE void onRadioButtonVpnModeAllSitesToggled(bool checked);
|
||||||
Q_INVOKABLE void onRadioButtonVpnModeForwardSitesToggled(bool checked);
|
Q_INVOKABLE void onRadioButtonVpnModeForwardSitesToggled(bool checked);
|
||||||
Q_INVOKABLE void onRadioButtonVpnModeExceptSitesToggled(bool checked);
|
Q_INVOKABLE void onRadioButtonVpnModeExceptSitesToggled(bool checked);
|
||||||
Q_INVOKABLE void onPushButtonAppSettingsOpenLogsChecked();
|
|
||||||
Q_INVOKABLE void onCheckBoxAppSettingsAutostartToggled(bool checked);
|
|
||||||
Q_INVOKABLE void onCheckBoxAppSettingsAutoconnectToggled(bool checked);
|
|
||||||
Q_INVOKABLE void onCheckBoxAppSettingsStartMinimizedToggled(bool checked);
|
|
||||||
Q_INVOKABLE void onLineEditNetworkSettingsDns1EditFinished(const QString& text);
|
|
||||||
Q_INVOKABLE void onLineEditNetworkSettingsDns2EditFinished(const QString& text);
|
|
||||||
Q_INVOKABLE void onPushButtonNetworkSettingsResetdns1Clicked();
|
|
||||||
Q_INVOKABLE void onPushButtonNetworkSettingsResetdns2Clicked();
|
|
||||||
Q_INVOKABLE void onPushButtonConnectClicked(bool checked);
|
Q_INVOKABLE void onPushButtonConnectClicked(bool checked);
|
||||||
Q_INVOKABLE void onPushButtonAddCustomSitesClicked();
|
|
||||||
Q_INVOKABLE void onPushButtonSitesDeleteClicked(int row);
|
|
||||||
Q_INVOKABLE void onPushButtonSitesImportClicked(const QString &fileName);
|
|
||||||
Q_INVOKABLE void onPushButtonShareFullCopyClicked();
|
Q_INVOKABLE void onPushButtonShareFullCopyClicked();
|
||||||
Q_INVOKABLE void onPushButtonShareFullSaveClicked();
|
Q_INVOKABLE void onPushButtonShareFullSaveClicked();
|
||||||
Q_INVOKABLE void onPushButtonShareAmneziaCopyClicked();
|
Q_INVOKABLE void onPushButtonShareAmneziaCopyClicked();
|
||||||
|
@ -631,8 +609,7 @@ public:
|
||||||
Q_INVOKABLE void onPushButtonShareAmneziaGenerateClicked();
|
Q_INVOKABLE void onPushButtonShareAmneziaGenerateClicked();
|
||||||
Q_INVOKABLE void onPushButtonShareOpenvpnGenerateClicked();
|
Q_INVOKABLE void onPushButtonShareOpenvpnGenerateClicked();
|
||||||
Q_INVOKABLE void onPushButtonShareOpenvpnSaveClicked();
|
Q_INVOKABLE void onPushButtonShareOpenvpnSaveClicked();
|
||||||
Q_INVOKABLE void onPushButtonGeneralSettingsServerSettingsClicked();
|
|
||||||
Q_INVOKABLE void onPushButtonGeneralSettingsShareConnectionClicked();
|
|
||||||
Q_INVOKABLE void onPushButtonProtoOpenvpnContOpenvpnConfigClicked();
|
Q_INVOKABLE void onPushButtonProtoOpenvpnContOpenvpnConfigClicked();
|
||||||
Q_INVOKABLE void onPushButtonProtoSsOpenvpnContOpenvpnConfigClicked();
|
Q_INVOKABLE void onPushButtonProtoSsOpenvpnContOpenvpnConfigClicked();
|
||||||
Q_INVOKABLE void onPushButtonProtoSsOpenvpnContSsConfigClicked();
|
Q_INVOKABLE void onPushButtonProtoSsOpenvpnContSsConfigClicked();
|
||||||
|
@ -651,13 +628,12 @@ public:
|
||||||
Q_INVOKABLE void onPushButtonForgetServer();
|
Q_INVOKABLE void onPushButtonForgetServer();
|
||||||
Q_INVOKABLE void onPushButtonServerSettingsClearClientCacheClicked();
|
Q_INVOKABLE void onPushButtonServerSettingsClearClientCacheClicked();
|
||||||
Q_INVOKABLE void onLineEditServerSettingsDescriptionEditingFinished();
|
Q_INVOKABLE void onLineEditServerSettingsDescriptionEditingFinished();
|
||||||
Q_INVOKABLE void updateSitesPage();
|
|
||||||
Q_INVOKABLE void updateServersListPage();
|
Q_INVOKABLE void updateServersListPage();
|
||||||
Q_INVOKABLE void updateProtocolsPage();
|
Q_INVOKABLE void updateProtocolsPage();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void frameWireguardSettingsVisibleChanged();
|
void frameWireguardSettingsVisibleChanged();
|
||||||
void frameFireguardVisibleChanged();
|
void frameWireguardVisibleChanged();
|
||||||
void frameNewServerSettingsParentWireguardVisibleChanged();
|
void frameNewServerSettingsParentWireguardVisibleChanged();
|
||||||
void radioButtonSetupWizardMediumCheckedChanged();
|
void radioButtonSetupWizardMediumCheckedChanged();
|
||||||
void lineEditSetupWizardHighWebsiteMaskingTextChanged();
|
void lineEditSetupWizardHighWebsiteMaskingTextChanged();
|
||||||
|
@ -687,15 +663,11 @@ signals:
|
||||||
void radioButtonVpnModeForwardSitesCheckedChanged();
|
void radioButtonVpnModeForwardSitesCheckedChanged();
|
||||||
void radioButtonVpnModeExceptSitesCheckedChanged();
|
void radioButtonVpnModeExceptSitesCheckedChanged();
|
||||||
void pushButtonVpnAddSiteEnabledChanged();
|
void pushButtonVpnAddSiteEnabledChanged();
|
||||||
void checkBoxAppSettingsAutostartCheckedChanged();
|
|
||||||
void checkBoxAppSettingsAutoconnectCheckedChanged();
|
|
||||||
void checkBoxAppSettingsStartMinimizedCheckedChanged();
|
|
||||||
void lineEditNetworkSettingsDns1TextChanged();
|
|
||||||
void lineEditNetworkSettingsDns2TextChanged();
|
|
||||||
void labelAppSettingsVersionTextChanged();
|
|
||||||
void pushButtonGeneralSettingsShareConnectionEnableChanged();
|
|
||||||
void labelServerSettingsWaitInfoVisibleChanged();
|
void labelServerSettingsWaitInfoVisibleChanged();
|
||||||
void labelServerSettingsWaitInfoTextChanged();
|
void labelServerSettingsWaitInfoTextChanged();
|
||||||
|
|
||||||
|
|
||||||
void pushButtonServerSettingsClearVisibleChanged();
|
void pushButtonServerSettingsClearVisibleChanged();
|
||||||
void pushButtonServerSettingsClearClientCacheVisibleChanged();
|
void pushButtonServerSettingsClearClientCacheVisibleChanged();
|
||||||
void pushButtonServerSettingsShareFullVisibleChanged();
|
void pushButtonServerSettingsShareFullVisibleChanged();
|
||||||
|
@ -726,9 +698,7 @@ signals:
|
||||||
void radioButtonSetupWizardLowCheckedChanged();
|
void radioButtonSetupWizardLowCheckedChanged();
|
||||||
void checkBoxSetupWizardVpnModeCheckedChanged();
|
void checkBoxSetupWizardVpnModeCheckedChanged();
|
||||||
void pushButtonConnectCheckedChanged();
|
void pushButtonConnectCheckedChanged();
|
||||||
void labelSitesAddCustomTextChanged();
|
|
||||||
void tableViewSitesModelChanged();
|
|
||||||
void lineEditSitesAddCustomTextChanged();
|
|
||||||
void widgetProtoCloakEnabledChanged();
|
void widgetProtoCloakEnabledChanged();
|
||||||
void pushButtonProtoCloakSaveVisibleChanged();
|
void pushButtonProtoCloakSaveVisibleChanged();
|
||||||
void progressBarProtoCloakResetVisibleChanged();
|
void progressBarProtoCloakResetVisibleChanged();
|
||||||
|
@ -861,7 +831,7 @@ signals:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_frameWireguardSettingsVisible;
|
bool m_frameWireguardSettingsVisible;
|
||||||
bool m_frameFireguardVisible;
|
bool m_frameWireguardVisible;
|
||||||
bool m_frameNewServerSettingsParentWireguardVisible;
|
bool m_frameNewServerSettingsParentWireguardVisible;
|
||||||
bool m_radioButtonSetupWizardMediumChecked;
|
bool m_radioButtonSetupWizardMediumChecked;
|
||||||
QString m_lineEditSetupWizardHighWebsiteMaskingText;
|
QString m_lineEditSetupWizardHighWebsiteMaskingText;
|
||||||
|
@ -891,13 +861,7 @@ private:
|
||||||
bool m_radioButtonVpnModeForwardSitesChecked;
|
bool m_radioButtonVpnModeForwardSitesChecked;
|
||||||
bool m_radioButtonVpnModeExceptSitesChecked;
|
bool m_radioButtonVpnModeExceptSitesChecked;
|
||||||
bool m_pushButtonVpnAddSiteEnabled;
|
bool m_pushButtonVpnAddSiteEnabled;
|
||||||
bool m_checkBoxAppSettingsAutostartChecked;
|
|
||||||
bool m_checkBoxAppSettingsAutoconnectChecked;
|
|
||||||
bool m_checkBoxAppSettingsStartMinimizedChecked;
|
|
||||||
QString m_lineEditNetworkSettingsDns1Text;
|
|
||||||
QString m_lineEditNetworkSettingsDns2Text;
|
|
||||||
QString m_labelAppSettingsVersionText;
|
|
||||||
bool m_pushButtonGeneralSettingsShareConnectionEnable;
|
|
||||||
bool m_labelServerSettingsWaitInfoVisible;
|
bool m_labelServerSettingsWaitInfoVisible;
|
||||||
QString m_labelServerSettingsWaitInfoText;
|
QString m_labelServerSettingsWaitInfoText;
|
||||||
bool m_pushButtonServerSettingsClearVisible;
|
bool m_pushButtonServerSettingsClearVisible;
|
||||||
|
@ -929,11 +893,9 @@ private:
|
||||||
bool m_radioButtonSetupWizardHighChecked;
|
bool m_radioButtonSetupWizardHighChecked;
|
||||||
bool m_radioButtonSetupWizardLowChecked;
|
bool m_radioButtonSetupWizardLowChecked;
|
||||||
bool m_checkBoxSetupWizardVpnModeChecked;
|
bool m_checkBoxSetupWizardVpnModeChecked;
|
||||||
QString m_ipAddressValidatorRegex;
|
|
||||||
bool m_pushButtonConnectChecked;
|
bool m_pushButtonConnectChecked;
|
||||||
QString m_labelSitesAddCustomText;
|
|
||||||
QObject* m_tableViewSitesModel;
|
|
||||||
QString m_lineEditSitesAddCustomText;
|
|
||||||
bool m_widgetProtoCloakEnabled;
|
bool m_widgetProtoCloakEnabled;
|
||||||
bool m_pushButtonProtoCloakSaveVisible;
|
bool m_pushButtonProtoCloakSaveVisible;
|
||||||
bool m_progressBarProtoCloakResetVisible;
|
bool m_progressBarProtoCloakResetVisible;
|
||||||
|
@ -1094,7 +1056,7 @@ private:
|
||||||
void setTrayIcon(const QString &iconPath);
|
void setTrayIcon(const QString &iconPath);
|
||||||
|
|
||||||
void setupNewServerConnections();
|
void setupNewServerConnections();
|
||||||
void setupSitesPageConnections();
|
// void setupSitesPageConnections();
|
||||||
void setupProtocolsPageConnections();
|
void setupProtocolsPageConnections();
|
||||||
|
|
||||||
void updateOpenVpnPage(const QJsonObject &openvpnConfig, DockerContainer container, bool haveAuthData);
|
void updateOpenVpnPage(const QJsonObject &openvpnConfig, DockerContainer container, bool haveAuthData);
|
||||||
|
@ -1116,7 +1078,6 @@ private:
|
||||||
VpnConnection* m_vpnConnection;
|
VpnConnection* m_vpnConnection;
|
||||||
Settings m_settings;
|
Settings m_settings;
|
||||||
|
|
||||||
QMap<Settings::RouteMode, SitesModel *> sitesModels;
|
|
||||||
|
|
||||||
// QRegExpValidator m_ipAddressValidator;
|
// QRegExpValidator m_ipAddressValidator;
|
||||||
// QRegExpValidator m_ipAddressPortValidator;
|
// QRegExpValidator m_ipAddressPortValidator;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue