port UI Logic to QML

This commit is contained in:
Ngoc Diep 2021-08-09 00:41:52 +07:00
parent 8d36c31cb4
commit d1a3545912
34 changed files with 4386 additions and 12344 deletions

View file

@ -33,11 +33,9 @@ HEADERS += \
protocols/shadowsocksvpnprotocol.h \ protocols/shadowsocksvpnprotocol.h \
protocols/wireguardprotocol.h \ protocols/wireguardprotocol.h \
settings.h \ settings.h \
ui/Controls/SlidingStackedWidget.h \ ui/serversmodel.h \
ui/mainwindow.h \
ui/uilogic.h \ ui/uilogic.h \
ui/qautostart.h \ ui/qautostart.h \
ui/server_widget.h \
ui/sites_model.h \ ui/sites_model.h \
utils.h \ utils.h \
vpnconnection.h \ vpnconnection.h \
@ -64,18 +62,16 @@ SOURCES += \
protocols/shadowsocksvpnprotocol.cpp \ protocols/shadowsocksvpnprotocol.cpp \
protocols/wireguardprotocol.cpp \ protocols/wireguardprotocol.cpp \
settings.cpp \ settings.cpp \
ui/Controls/SlidingStackedWidget.cpp \ ui/serversmodel.cpp \
ui/mainwindow.cpp \
ui/uilogic.cpp \ ui/uilogic.cpp \
ui/qautostart.cpp \ ui/qautostart.cpp \
ui/server_widget.cpp \
ui/sites_model.cpp \ ui/sites_model.cpp \
utils.cpp \ utils.cpp \
vpnconnection.cpp \ vpnconnection.cpp \
protocols/vpnprotocol.cpp \ protocols/vpnprotocol.cpp \
protocols/openvpnprotocol.cpp \ protocols/openvpnprotocol.cpp \
FORMS += ui/mainwindow.ui \ FORMS += \
ui/server_widget.ui ui/server_widget.ui
RESOURCES += \ RESOURCES += \

View file

@ -9,6 +9,7 @@
#include <QQmlApplicationEngine> #include <QQmlApplicationEngine>
#include <QQmlContext> #include <QQmlContext>
#include "ui/uilogic.h" #include "ui/uilogic.h"
#include <QDebug>
#include "debug.h" #include "debug.h"
#include "defines.h" #include "defines.h"
@ -16,8 +17,6 @@
#include "singleapplication.h" #include "singleapplication.h"
#undef QAPPLICATION_CLASS #undef QAPPLICATION_CLASS
#include "ui/mainwindow.h"
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#include "Windows.h" #include "Windows.h"
#endif #endif
@ -85,27 +84,9 @@ int main(int argc, char *argv[])
app.setQuitOnLastWindowClosed(false); app.setQuitOnLastWindowClosed(false);
// MainWindow mainWindow;
//#ifdef Q_OS_WIN
// if (parser.isSet("a")) mainWindow.showOnStartup();
// else mainWindow.show();
//#else
// mainWindow.showOnStartup();
//#endif
// if (app.isPrimary()) {
// QObject::connect(&app, &SingleApplication::instanceStarted, &mainWindow, [&](){
// qDebug() << "Secondary instance started, showing this window instead";
// mainWindow.show();
// mainWindow.showNormal();
// mainWindow.raise();
// });
// }
UiLogic uiLogic; UiLogic uiLogic;
UiLogic::declareQML();
QQmlApplicationEngine engine; QQmlApplicationEngine engine;
UiLogic::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) {

View file

@ -1,238 +0,0 @@
#include "SlidingStackedWidget.h"
#include <QEventLoop>
SlidingStackedWidget::SlidingStackedWidget(QWidget *parent)
: QStackedWidget(parent)
{
if (parent != 0) {
m_mainwindow = parent;
}
else {
m_mainwindow = this;
qDebug().noquote() << "ATTENTION: untested mainwindow case !";
}
// parent should not be 0; not tested for any other case yet !!
#ifdef Q_OS_SYMBIAN
#ifndef __S60_50__
qDebug().noquote() << "WARNING: ONLY TESTED AND 5TH EDITION";
#endif // __S60_50__
#endif // Q_OS_SYMBIAN
// Now, initialize some private variables with default values
m_vertical = false;
// setVerticalMode(true);
m_speed = 500;
m_animationtype = QEasingCurve::OutBack; // check out the QEasingCurve documentation for different styles
m_now = 0;
m_next = 0;
m_wrap = false;
m_pnow = QPoint(0,0);
m_active = false;
animnow = new QPropertyAnimation();
animnext = new QPropertyAnimation();
animgroup = new QParallelAnimationGroup;
animgroup->addAnimation(animnow);
animgroup->addAnimation(animnext);
}
SlidingStackedWidget::~SlidingStackedWidget() {
}
void SlidingStackedWidget::setVerticalMode(bool vertical) {
m_vertical = vertical;
}
void SlidingStackedWidget::setSpeed(int speed) {
m_speed = speed;
}
void SlidingStackedWidget::setAnimation(enum QEasingCurve::Type animationtype) {
m_animationtype = animationtype;
}
void SlidingStackedWidget::setWrap(bool wrap) {
m_wrap = wrap;
}
void SlidingStackedWidget::slideInNext() {
int now = currentIndex();
if (m_wrap || (now < count() - 1))
// count is inherit from QStackedWidget
slideInIdx(now + 1);
}
void SlidingStackedWidget::slideInPrev() {
int now = currentIndex();
if (m_wrap || (now > 0))
slideInIdx(now - 1);
}
void SlidingStackedWidget::slideInIdx(int idx, enum t_direction direction) {
// int idx, t_direction direction=AUTOMATIC
if (idx > count() - 1) {
direction = m_vertical ? TOP2BOTTOM : RIGHT2LEFT;
idx = (idx) % count();
}
else if (idx < 0) {
direction = m_vertical ? BOTTOM2TOP: LEFT2RIGHT;
idx = (idx + count()) % count();
}
slideInWgtImpl(widget(idx), direction);
// widget() is a function inherited from QStackedWidget
}
void SlidingStackedWidget::slideInWidget(QWidget *widget, SlidingStackedWidget::t_direction direction)
{
Q_UNUSED(direction);
#ifdef Q_OS_WIN
int idx = indexOf(widget);
slideInIdx(idx, direction);
#endif
#if defined Q_OS_MAC || defined Q_OS_LINUX
setCurrentWidget(widget);
#endif
}
bool SlidingStackedWidget::isAnimationRunning()
{
return animgroup->state() == QAnimationGroup::Running;
}
void SlidingStackedWidget::waitForAnimation()
{
if (!isAnimationRunning()) return;
//qDebug() << "Wait for stacked widget animation";
QEventLoop l;
connect(animgroup, &QParallelAnimationGroup::finished, &l, &QEventLoop::quit);
l.exec();
}
void SlidingStackedWidget::slideInWgtImpl(QWidget * newwidget, enum t_direction direction) {
if (m_active) {
return;
}
else m_active = true;
m_nextWidget = newwidget;
enum t_direction directionhint;
int now = currentIndex(); // currentIndex() is a function inherited from QStackedWidget
int next = indexOf(newwidget);
if (now == next) {
m_active = false;
return;
}
else if (now < next) {
directionhint = m_vertical ? TOP2BOTTOM : RIGHT2LEFT;
}
else {
directionhint = m_vertical ? BOTTOM2TOP : LEFT2RIGHT;
}
if (direction == AUTOMATIC) {
direction = directionhint;
}
// NOW....
// calculate the shifts
int offsetx = frameRect().width(); // inherited from mother
int offsety = frameRect().height(); // inherited from mother
// the following is important, to ensure that the new widget
// has correct geometry information when sliding in first time
widget(next)->setGeometry(0, 0, offsetx, offsety);
if (direction == BOTTOM2TOP) {
offsetx = 0;
offsety = -offsety;
}
else if (direction == TOP2BOTTOM) {
offsetx = 0;
// offsety = offsety;
}
else if (direction == RIGHT2LEFT) {
offsetx = -offsetx;
offsety = 0;
}
else if (direction == LEFT2RIGHT) {
// offsetx = offsetx;
offsety = 0;
}
// re-position the next widget outside/aside of the display area
QPoint pnext = widget(next)->pos();
QPoint pnow = widget(now)->pos();
m_pnow = pnow;
widget(next)->move(pnext.x() - offsetx, pnext.y() - offsety);
// make it visible/show
widget(next)->show();
widget(next)->raise();
// animate both, the now and next widget to the side, using animation framework
//QPropertyAnimation *animnow = new QPropertyAnimation(widget(now), "pos");
animnow->setTargetObject(widget(now));
animnow->setPropertyName("pos");
animnow->setDuration(m_speed);
animnow->setEasingCurve(m_animationtype);
animnow->setStartValue(QPoint(pnow.x(), pnow.y()));
animnow->setEndValue(QPoint(offsetx + pnow.x(), offsety + pnow.y()));
//QPropertyAnimation *animnext = new QPropertyAnimation(widget(next), "pos");
animnext->setTargetObject(widget(next));
animnext->setPropertyName("pos");
animnext->setDuration(m_speed);
animnext->setEasingCurve(m_animationtype);
animnext->setStartValue(QPoint(-offsetx + pnext.x(), offsety + pnext.y()));
animnext->setEndValue(QPoint(pnext.x(), pnext.y()));
// QParallelAnimationGroup *animgroup = new QParallelAnimationGroup;
// animgroup->addAnimation(animnow);
// animgroup->addAnimation(animnext);
QObject::connect(animgroup, SIGNAL(finished()),this,SLOT(animationDoneSlot()));
m_next = next;
m_now = now;
m_active = true;
animgroup->start();
// note; the rest is done via a connect from the animation ready;
// animation->finished() provides a signal when animation is done;
// so we connect this to some post processing slot,
// that we implement here below in animationDoneSlot.
}
void SlidingStackedWidget::setCurrentWidget(QWidget *w)
{
m_nextWidget = w;
QStackedWidget::setCurrentWidget(w);
}
QWidget *SlidingStackedWidget::nextWidget() const
{
if (m_nextWidget == nullptr) return currentWidget();
return m_nextWidget;
}
void SlidingStackedWidget::animationDoneSlot(void) {
// when ready, call the QStackedWidget slot setCurrentIndex(int)
setCurrentIndex(m_next); // this function is inherited from QStackedWidget
// then hide the outshifted widget now, and (may be done already implicitely by QStackedWidget)
widget(m_now)->hide();
// then set the position of the outshifted widget now back to its original
widget(m_now)->move(m_pnow);
// so that the application could also still call the QStackedWidget original functions/slots for changings
// widget(m_now)->update();
// setCurrentIndex(m_next); // this function is inherit from QStackedWidget
m_active = false;
emit animationFinished();
}

View file

@ -1,87 +0,0 @@
#ifndef SLIDINGSTACKEDWIDGET_H
#define SLIDINGSTACKEDWIDGET_H
#include <QStackedWidget>
#include <QWidget>
#include <QDebug>
#include <QEasingCurve>
#include <QPropertyAnimation>
#include <QParallelAnimationGroup>
/* Description
SlidingStackedWidget is a class that is derived from QtStackedWidget
and allows smooth side shifting of widgets, in addition
to the original hard switching from one to another as offered by
QStackedWidget itself.
*/
class SlidingStackedWidget : public QStackedWidget {
Q_OBJECT
public:
// This enumeration is used to define the animation direction
enum t_direction {
LEFT2RIGHT,
RIGHT2LEFT,
TOP2BOTTOM,
BOTTOM2TOP,
AUTOMATIC
};
// The Constructor and Destructor
SlidingStackedWidget(QWidget *parent);
~SlidingStackedWidget(void);
QWidget *nextWidget() const;
void setCurrentWidget(QWidget *w);
public slots:
// Some basic settings API
void setSpeed(int speed); // animation duration in milliseconds
void setAnimation(enum QEasingCurve::Type animationtype); // check out the QEasingCurve documentation for different styles
void setVerticalMode(bool vertical=true);
void setWrap(bool wrap); // wrapping is related to slideInNext/Prev;it defines the behaviour when reaching last/first page
// The Animation / Page Change API
void slideInNext();
void slideInPrev();
void slideInIdx(int idx, enum t_direction direction = AUTOMATIC);
void slideInWidget(QWidget *widget, enum t_direction direction = AUTOMATIC);
bool isAnimationRunning();
void waitForAnimation();
signals:
// this is used for internal purposes in the class engine
void animationFinished(void);
protected slots:
// this is used for internal purposes in the class engine
void animationDoneSlot(void);
protected:
// this is used for internal purposes in the class engine
void slideInWgtImpl(QWidget *widget, enum t_direction direction = AUTOMATIC);
QWidget *m_mainwindow;
int m_speed;
enum QEasingCurve::Type m_animationtype;
bool m_vertical;
int m_now;
int m_next;
bool m_wrap;
QPoint m_pnow;
bool m_active;
QList<QWidget*> blockedPageList;
QPropertyAnimation *animnow;
QPropertyAnimation *animnext;
QParallelAnimationGroup *animgroup;
QWidget *m_nextWidget = nullptr;
};
#endif // SLIDINGSTACKEDWIDGET_H

File diff suppressed because it is too large Load diff

View file

@ -1,174 +0,0 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QLabel>
#include <QListWidget>
#include <QMainWindow>
#include <QProgressBar>
#include <QPushButton>
#include <QRegExpValidator>
#include <QStack>
#include <QStringListModel>
#include <QSystemTrayIcon>
#include "3rd/QRCodeGenerator/QRCodeGenerator.h"
#include "framelesswindow.h"
#include "protocols/vpnprotocol.h"
#include "settings.h"
#include "sites_model.h"
class VpnConnection;
namespace Ui {
class MainWindow;
}
/**
* @brief The MainWindow class - Main application window
*/
#ifdef Q_OS_WIN
class MainWindow : public CFramelessWindow
#else
class MainWindow : public QMainWindow
#endif
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow();
enum Page {Start, NewServer, NewServerProtocols, Vpn,
Wizard, WizardLow, WizardMedium, WizardHigh, WizardVpnMode, ServerConfiguring,
GeneralSettings, AppSettings, NetworkSettings, ServerSettings,
ServerVpnProtocols, ServersList, ShareConnection, Sites,
OpenVpnSettings, ShadowSocksSettings, CloakSettings};
Q_ENUM(Page)
void showOnStartup();
private slots:
void onBytesChanged(quint64 receivedBytes, quint64 sentBytes);
void onConnectionStateChanged(VpnProtocol::ConnectionState state);
void onVpnProtocolError(amnezia::ErrorCode errorCode);
void onPushButtonConnectClicked(bool checked);
void onPushButtonNewServerConnect(bool);
void installServer(const QMap<DockerContainer, QJsonObject> &containers);
void onPushButtonNewServerImport(bool);
void onPushButtonClearServer(bool);
void onPushButtonForgetServer(bool);
void onPushButtonAddCustomSitesClicked();
void onTrayActionConnect(); // connect from context menu
void setTrayState(VpnProtocol::ConnectionState state);
void onTrayActivated(QSystemTrayIcon::ActivationReason reason);
void onConnect();
void onConnectWorker(int serverIndex, const ServerCredentials &credentials, DockerContainer container, const QJsonObject &containerConfig);
void onDisconnect();
private:
void goToPage(Page page, bool reset = true, bool slide = true);
void setStartPage(Page page, bool slide = true);
void closePage();
QWidget *getPageWidget(Page page);
Page currentPage();
bool installContainers(ServerCredentials credentials, const QMap<DockerContainer, QJsonObject> &containers,
QWidget *page, QProgressBar *progress, QPushButton *button, QLabel *info);
ErrorCode doInstallAction(const std::function<ErrorCode()> &action, QWidget *page, QProgressBar *progress, QPushButton *button, QLabel *info);
void setupTray();
void setTrayIcon(const QString &iconPath);
void setupUiConnections();
void setupNewServerConnections();
void setupWizardConnections();
void setupVpnPageConnections();
void setupSitesPageConnections();
void setupAppSettingsConnections();
void setupGeneralSettingsConnections();
void setupNetworkSettingsConnections();
void setupProtocolsPageConnections();
void setupNewServerPageConnections();
void setupServerSettingsPageConnections();
void setupSharePageConnections();
void updateStartPage();
void updateSitesPage();
void updateVpnPage();
void updateAppSettingsPage();
void updateGeneralSettingPage();
void updateServerPage();
void updateServersListPage();
void updateProtocolsPage();
void updateOpenVpnPage(const QJsonObject &openvpnConfig, DockerContainer container, bool haveAuthData);
void updateShadowSocksPage(const QJsonObject &ssConfig, DockerContainer container, bool haveAuthData);
void updateCloakPage(const QJsonObject &ckConfig, DockerContainer container, bool haveAuthData);
void updateSharingPage(int serverIndex, const ServerCredentials &credentials,
DockerContainer container);
void makeServersListItem(QListWidget* listWidget, const QJsonObject &server, bool isDefault, int index);
void updateQRCodeImage(const QString &text, QLabel *label);
QJsonObject getOpenVpnConfigFromPage(QJsonObject oldConfig);
QJsonObject getShadowSocksConfigFromPage(QJsonObject oldConfig);
QJsonObject getCloakConfigFromPage(QJsonObject oldConfig);
QMap<DockerContainer, QJsonObject> getInstallConfigsFromProtocolsPage() const;
QMap<DockerContainer, QJsonObject> getInstallConfigsFromWizardPage() const;
private:
Ui::MainWindow *ui;
VpnConnection* m_vpnConnection;
Settings m_settings;
QMap<Settings::RouteMode, SitesModel *> sitesModels;
QAction* m_trayActionConnect;
QAction* m_trayActionDisconnect;
QSystemTrayIcon m_tray;
QMenu* m_menu;
QRegExpValidator m_ipAddressValidator;
QRegExpValidator m_ipAddressPortValidator;
QRegExpValidator m_ipNetwok24Validator;
QRegExpValidator m_ipPortValidator;
CQR_Encode m_qrEncode;
bool canMove = false;
QPoint offset;
bool needToHideCustomTitlebar = false;
bool eventFilter(QObject *obj, QEvent *event) override;
void keyPressEvent(QKeyEvent* event) override;
void closeEvent(QCloseEvent *event) override;
void showEvent(QShowEvent *event) override;
void hideEvent(QHideEvent *event) override;
const QString ConnectedTrayIconName = "active.png";
const QString DisconnectedTrayIconName = "default.png";
const QString ErrorTrayIconName = "error.png";
QStack<Page> pagesStack;
int selectedServerIndex = -1; // server index to use when proto settings page opened
DockerContainer selectedDockerContainer; // same
ServerCredentials installCredentials; // used to save cred between pages new_server and new_server_protocols and wizard
};
#endif // MAINWINDOW_H

File diff suppressed because it is too large Load diff

View file

@ -3,11 +3,12 @@ import QtQuick.Controls 2.12
Button { Button {
id: root id: root
property alias containsMouse: mouseArea.containsMouse hoverEnabled: true
property bool containsMouse: hovered
MouseArea { MouseArea {
id: mouseArea id: mouseArea
anchors.fill: parent anchors.fill: parent
hoverEnabled: true enabled: false
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
} }
} }

View file

@ -1,5 +1,6 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Controls 2.12 import QtQuick.Controls 2.12
import PageEnum 1.0
import "./" import "./"
Item { Item {
@ -87,6 +88,9 @@ Item {
height: 30 height: 30
icon.source: "qrc:/images/plus.png" icon.source: "qrc:/images/plus.png"
text: qsTr("Add server") text: qsTr("Add server")
onClicked: {
UiLogic.goToPage(PageEnum.Start)
}
} }
SettingButtonType { SettingButtonType {
x: 30 x: 30
@ -95,6 +99,9 @@ Item {
height: 30 height: 30
icon.source: "qrc:/images/settings.png" icon.source: "qrc:/images/settings.png"
text: qsTr("App settings") text: qsTr("App settings")
onClicked: {
UiLogic.goToPage(PageEnum.AppSettings)
}
} }
SettingButtonType { SettingButtonType {
x: 30 x: 30
@ -103,6 +110,9 @@ Item {
height: 30 height: 30
icon.source: "qrc:/images/settings.png" icon.source: "qrc:/images/settings.png"
text: qsTr("Exit") text: qsTr("Exit")
onClicked: {
Qt.quit()
}
} }
SettingButtonType { SettingButtonType {
x: 30 x: 30
@ -111,6 +121,9 @@ Item {
height: 30 height: 30
icon.source: "qrc:/images/settings.png" icon.source: "qrc:/images/settings.png"
text: qsTr("Network settings") text: qsTr("Network settings")
onClicked: {
UiLogic.goToPage(PageEnum.NetworkSettings)
}
} }
SettingButtonType { SettingButtonType {
x: 30 x: 30
@ -119,6 +132,9 @@ Item {
height: 30 height: 30
icon.source: "qrc:/images/server_settings.png" icon.source: "qrc:/images/server_settings.png"
text: qsTr("Server management") text: qsTr("Server management")
onClicked: {
UiLogic.onPushButtonGeneralSettingsServerSettingsClicked()
}
} }
SettingButtonType { SettingButtonType {
x: 30 x: 30
@ -127,6 +143,9 @@ Item {
height: 30 height: 30
icon.source: "qrc:/images/server_settings.png" icon.source: "qrc:/images/server_settings.png"
text: qsTr("Servers") text: qsTr("Servers")
onClicked: {
UiLogic.goToPage(PageEnum.ServersList)
}
} }
SettingButtonType { SettingButtonType {
x: 30 x: 30
@ -136,5 +155,8 @@ Item {
icon.source: "qrc:/images/share.png" icon.source: "qrc:/images/share.png"
text: qsTr("Share connection") text: qsTr("Share connection")
enabled: UiLogic.pushButtonGeneralSettingsShareConnectionEnable enabled: UiLogic.pushButtonGeneralSettingsShareConnectionEnable
onClicked: {
UiLogic.onPushButtonGeneralSettingsShareConnectionClicked()
}
} }
} }

View file

@ -1,6 +1,6 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Controls 2.12 import QtQuick.Controls 2.12
import Page 1.0 import PageEnum 1.0
import "./" import "./"
Item { Item {
@ -47,7 +47,7 @@ Item {
height: 40 height: 40
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
onClicked: { onClicked: {
UiLogic.goToPage(Page.Wizard); UiLogic.goToPage(PageEnum.Wizard);
} }
} }
BlueButtonType { BlueButtonType {
@ -57,7 +57,7 @@ Item {
height: 40 height: 40
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
onClicked: { onClicked: {
UiLogic.goToPage(Page.NewServerProtocols); UiLogic.goToPage(PageEnum.NewServerProtocols);
} }
} }

View file

@ -6,6 +6,7 @@ Item {
id: root id: root
width: GC.screenWidth width: GC.screenWidth
height: GC.screenHeight height: GC.screenHeight
enabled: UiLogic.pageNewServerConfiguringEnabled
Text { Text {
font.family: "Lato" font.family: "Lato"
font.styleName: "normal" font.styleName: "normal"
@ -31,7 +32,8 @@ Item {
y: 560 y: 560
width: 301 width: 301
height: 41 height: 41
text: qsTr("Please wait, configuring process may take up to 5 minutes") text: UiLogic.labelNewServerConfiguringWaitInfoText
visible: UiLogic.labelNewServerConfiguringWaitInfoVisible
} }
ProgressBar { ProgressBar {
id: pr id: pr
@ -40,8 +42,9 @@ Item {
width: 301 width: 301
height: 40 height: 40
from: 0 from: 0
to: 100 to: UiLogic.progressBarNewServerConfiguringMaximium
value: UiLogic.progressBarNewServerConfiguringValue value: UiLogic.progressBarNewServerConfiguringValue
visible: UiLogic.progressBarNewServerConfiguringVisible
background: Rectangle { background: Rectangle {
implicitWidth: parent.width implicitWidth: parent.width
implicitHeight: parent.height implicitHeight: parent.height
@ -62,12 +65,13 @@ Item {
LabelType { LabelType {
anchors.fill: parent anchors.fill: parent
text: qsTr("Configuring...") text: UiLogic.progressBarNewServerConfiguringText
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
font.family: "Lato" font.family: "Lato"
font.styleName: "normal" font.styleName: "normal"
font.pixelSize: 16 font.pixelSize: 16
color: "#D4D4D4" color: "#D4D4D4"
visible: UiLogic.progressBarNewServerConfiguringTextVisible
} }
} }
} }

View file

@ -102,6 +102,7 @@ Item {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.bottomMargin: 5 anchors.bottomMargin: 5
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
visible: false
radius: 2 radius: 2
Grid { Grid {
anchors.fill: parent anchors.fill: parent
@ -164,6 +165,11 @@ Item {
checked: UiLogic.pushButtonNewServerSettingsCloakChecked checked: UiLogic.pushButtonNewServerSettingsCloakChecked
onCheckedChanged: { onCheckedChanged: {
UiLogic.pushButtonNewServerSettingsCloakChecked = checked UiLogic.pushButtonNewServerSettingsCloakChecked = checked
if (checked) {
frame_new_server_setting_cloak.visible = true
} else {
frame_new_server_setting_cloak.visible = false
}
} }
} }
} }
@ -186,6 +192,7 @@ Item {
anchors.bottomMargin: 5 anchors.bottomMargin: 5
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
radius: 2 radius: 2
visible: false
Grid { Grid {
anchors.fill: parent anchors.fill: parent
columns: 2 columns: 2
@ -258,8 +265,14 @@ Item {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
icon.source: "qrc:/images/settings.png" icon.source: "qrc:/images/settings.png"
checked: UiLogic.pushButtonNewServerSettingsSsChecked checked: UiLogic.pushButtonNewServerSettingsSsChecked
checkable: true
onCheckedChanged: { onCheckedChanged: {
UiLogic.pushButtonNewServerSettingsSsChecked = checked UiLogic.pushButtonNewServerSettingsSsChecked = checked
if (checked) {
frame_new_server_settings_ss.visible = true
} else {
frame_new_server_settings_ss.visible = false
}
} }
} }
} }
@ -282,6 +295,7 @@ Item {
anchors.bottomMargin: 5 anchors.bottomMargin: 5
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
radius: 2 radius: 2
visible: false
Grid { Grid {
anchors.fill: parent anchors.fill: parent
columns: 2 columns: 2
@ -351,8 +365,14 @@ Item {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
icon.source: "qrc:/images/settings.png" icon.source: "qrc:/images/settings.png"
checked: UiLogic.pushButtonNewServerSettingsOpenvpnChecked checked: UiLogic.pushButtonNewServerSettingsOpenvpnChecked
checkable: true
onCheckedChanged: { onCheckedChanged: {
UiLogic.pushButtonNewServerSettingsOpenvpnChecked = checked UiLogic.pushButtonNewServerSettingsOpenvpnChecked = checked
if (checked) {
frame_new_server_settings_openvpn.visible = true
} else {
frame_new_server_settings_openvpn.visible = false
}
} }
} }
} }
@ -377,6 +397,7 @@ Item {
anchors.bottomMargin: 5 anchors.bottomMargin: 5
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
radius: 2 radius: 2
visible: false
Grid { Grid {
anchors.fill: parent anchors.fill: parent
columns: 2 columns: 2
@ -414,6 +435,14 @@ Item {
height: 35 height: 35
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
icon.source: "qrc:/images/settings.png" icon.source: "qrc:/images/settings.png"
checkable: true
onCheckedChanged: {
if (checked) {
frame_new_server_settings_wireguard.visible = true
} else {
frame_new_server_settings_wireguard.visible = false
}
}
} }
} }
} }

View file

@ -6,6 +6,7 @@ Item {
id: root id: root
width: GC.screenWidth width: GC.screenWidth
height: GC.screenHeight height: GC.screenHeight
enabled: UiLogic.pageProtoCloakEnabled
ImageButtonType { ImageButtonType {
id: back id: back
x: 10 x: 10
@ -22,6 +23,7 @@ Item {
y: 40 y: 40
width: 380 width: 380
height: 600 height: 600
enabled: UiLogic.widgetProtoCloakEnabled
ComboBoxType { ComboBoxType {
x: 190 x: 190
y: 60 y: 60
@ -86,6 +88,8 @@ Item {
y: 550 y: 550
width: 321 width: 321
height: 41 height: 41
visible: UiLogic.labelProtoCloakInfoVisible
text: UiLogic.labelProtoCloakInfoText
} }
TextFieldType { TextFieldType {
id: lineEdit_proto_cloak_port id: lineEdit_proto_cloak_port
@ -97,6 +101,7 @@ Item {
onEditingFinished: { onEditingFinished: {
UiLogic.lineEditProtoCloakPortText = text UiLogic.lineEditProtoCloakPortText = text
} }
enabled: UiLogic.lineEditProtoCloakPortEnabled
} }
TextFieldType { TextFieldType {
id: lineEdit_proto_cloak_site id: lineEdit_proto_cloak_site
@ -116,8 +121,8 @@ Item {
width: 321 width: 321
height: 40 height: 40
from: 0 from: 0
to: 100 to: UiLogic.progressBarProtoCloakResetMaximium
value: 0 value: UiLogic.progressBarProtoCloakResetValue
background: Rectangle { background: Rectangle {
implicitWidth: parent.width implicitWidth: parent.width
implicitHeight: parent.height implicitHeight: parent.height
@ -135,6 +140,7 @@ Item {
color: Qt.rgba(255, 255, 255, 0.15); color: Qt.rgba(255, 255, 255, 0.15);
} }
} }
visible: UiLogic.progressBarProtoCloakResetVisible
} }
BlueButtonType { BlueButtonType {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
@ -142,6 +148,10 @@ Item {
width: 321 width: 321
height: 40 height: 40
text: qsTr("Save and restart VPN") text: qsTr("Save and restart VPN")
visible: UiLogic.pushButtonProtoCloakSaveVisible
onClicked: {
UiLogic.pushButtonProtoCloakSaveClicked()
}
} }
} }
} }

View file

@ -6,6 +6,7 @@ Item {
id: root id: root
width: GC.screenWidth width: GC.screenWidth
height: GC.screenHeight height: GC.screenHeight
enabled: UiLogic.pageProtoOpenvpnEnabled
ImageButtonType { ImageButtonType {
id: back id: back
x: 10 x: 10
@ -22,6 +23,7 @@ Item {
y: 40 y: 40
width: 380 width: 380
height: 600 height: 600
enabled: UiLogic.widgetProtoOpenvpnEnabled
CheckBoxType { CheckBoxType {
x: 30 x: 30
y: 280 y: 280
@ -32,6 +34,9 @@ Item {
onCheckedChanged: { onCheckedChanged: {
UiLogic.checkBoxProtoOpenvpnAutoEncryptionChecked = checked UiLogic.checkBoxProtoOpenvpnAutoEncryptionChecked = checked
} }
onClicked: {
UiLogic.checkBoxProtoOpenvpnAutoEncryptionClicked()
}
} }
CheckBoxType { CheckBoxType {
x: 30 x: 30
@ -84,6 +89,7 @@ Item {
onCurrentTextChanged: { onCurrentTextChanged: {
UiLogic.comboBoxProtoOpenvpnCipherText = currentText UiLogic.comboBoxProtoOpenvpnCipherText = currentText
} }
enabled: UiLogic.comboBoxProtoOpenvpnCipherEnabled
} }
ComboBoxType { ComboBoxType {
x: 200 x: 200
@ -113,6 +119,7 @@ Item {
onCurrentTextChanged: { onCurrentTextChanged: {
UiLogic.comboBoxProtoOpenvpnHashText = currentText UiLogic.comboBoxProtoOpenvpnHashText = currentText
} }
enabled: UiLogic.comboBoxProtoOpenvpnHashEnabled
} }
Rectangle { Rectangle {
x: 30 x: 30
@ -128,6 +135,11 @@ Item {
width: 171 width: 171
height: 19 height: 19
text: qsTr("TCP") text: qsTr("TCP")
enabled: UiLogic.radioButtonProtoOpenvpnTcpEnabled
checked: UiLogic.radioButtonProtoOpenvpnTcpChecked
onCheckedChanged: {
UiLogic.radioButtonProtoOpenvpnTcpChecked = checked
}
} }
RadioButtonType { RadioButtonType {
x: 10 x: 10
@ -139,6 +151,7 @@ Item {
onCheckedChanged: { onCheckedChanged: {
UiLogic.radioButtonProtoOpenvpnUdpChecked = checked UiLogic.radioButtonProtoOpenvpnUdpChecked = checked
} }
enabled: UiLogic.radioButtonProtoOpenvpnUdpEnabled
} }
} }
LabelType { LabelType {
@ -195,6 +208,8 @@ Item {
y: 550 y: 550
width: 321 width: 321
height: 41 height: 41
visible: UiLogic.labelProtoOpenvpnInfoVisible
text: UiLogic.labelProtoOpenvpnInfoText
} }
TextFieldType { TextFieldType {
id: lineEdit_proto_openvpn_port id: lineEdit_proto_openvpn_port
@ -206,6 +221,7 @@ Item {
onEditingFinished: { onEditingFinished: {
UiLogic.lineEditProtoOpenvpnPortText = text UiLogic.lineEditProtoOpenvpnPortText = text
} }
enabled: UiLogic.lineEditProtoOpenvpnPortEnabled
} }
TextFieldType { TextFieldType {
id: lineEdit_proto_openvpn_subnet id: lineEdit_proto_openvpn_subnet
@ -225,8 +241,9 @@ Item {
width: 321 width: 321
height: 40 height: 40
from: 0 from: 0
to: 100 to: UiLogic.progressBarProtoOpenvpnResetMaximium
value: 0 value: UiLogic.progressBarProtoOpenvpnResetValue
visible: UiLogic.progressBarProtoOpenvpnResetVisible
background: Rectangle { background: Rectangle {
implicitWidth: parent.width implicitWidth: parent.width
implicitHeight: parent.height implicitHeight: parent.height
@ -251,6 +268,10 @@ Item {
width: 321 width: 321
height: 40 height: 40
text: qsTr("Save and restart VPN") text: qsTr("Save and restart VPN")
visible: UiLogic.pushButtonProtoOpenvpnSaveVisible
onClicked: {
UiLogic.pushButtonProtoOpenvpnSaveClicked()
}
} }
} }
} }

View file

@ -6,6 +6,7 @@ Item {
id: root id: root
width: GC.screenWidth width: GC.screenWidth
height: GC.screenHeight height: GC.screenHeight
enabled: UiLogic.pageProtoShadowsocksEnabled
ImageButtonType { ImageButtonType {
id: back id: back
x: 10 x: 10
@ -22,6 +23,7 @@ Item {
y: 40 y: 40
width: 380 width: 380
height: 600 height: 600
enabled: UiLogic.widgetProtoSsEnabled
ComboBoxType { ComboBoxType {
x: 190 x: 190
y: 60 y: 60
@ -77,6 +79,8 @@ Item {
y: 550 y: 550
width: 321 width: 321
height: 41 height: 41
visible: UiLogic.labelProtoShadowsocksInfoVisible
text: UiLogic.labelProtoShadowsocksInfoText
} }
TextFieldType { TextFieldType {
id: lineEdit_proto_shadowsocks_port id: lineEdit_proto_shadowsocks_port
@ -88,6 +92,7 @@ Item {
onEditingFinished: { onEditingFinished: {
UiLogic.lineEditProtoShadowsocksPortText = text UiLogic.lineEditProtoShadowsocksPortText = text
} }
enabled: UiLogic.lineEditProtoShadowsocksPortEnabled
} }
ProgressBar { ProgressBar {
id: progressBar_proto_shadowsocks_reset id: progressBar_proto_shadowsocks_reset
@ -96,8 +101,9 @@ Item {
width: 321 width: 321
height: 40 height: 40
from: 0 from: 0
to: 100 to: UiLogic.progressBarProtoShadowsocksResetMaximium
value: 0 value: UiLogic.progressBarProtoShadowsocksResetValue
visible: UiLogic.progressBarProtoShadowsocksResetVisible
background: Rectangle { background: Rectangle {
implicitWidth: parent.width implicitWidth: parent.width
implicitHeight: parent.height implicitHeight: parent.height
@ -122,6 +128,10 @@ Item {
width: 321 width: 321
height: 40 height: 40
text: qsTr("Save and restart VPN") text: qsTr("Save and restart VPN")
visible: UiLogic.pushButtonProtoShadowsocksSaveVisible
onClicked: {
UiLogic.pushButtonProtoShadowsocksSaveClicked()
}
} }
} }
} }

View file

@ -2,6 +2,7 @@ import QtQuick 2.12
import QtQuick.Controls 2.12 import QtQuick.Controls 2.12
import "./" import "./"
import QtGraphicalEffects 1.12 import QtGraphicalEffects 1.12
import PageEnum 1.0
Item { Item {
id: root id: root
@ -37,34 +38,38 @@ Item {
width: 24 width: 24
height: 24 height: 24
icon.source: "qrc:/images/plus.png" icon.source: "qrc:/images/plus.png"
} onClicked: {
ListModel { UiLogic.goToPage(PageEnum.Start);
id: md
ListElement {
description: "Bill Smith"
address: "555 3264"
}
ListElement {
description: "John Brown"
address: "555 8426"
}
ListElement {
description: "Sam Wise"
address: "555 0473"
} }
} }
ListView { ListView {
id: listWidget_servers id: listWidget_servers
x: 20 x: 20
y: 90 y: 90
width: 340 width: 340
height: 501 height: 501
model: md model: UiLogic.serverListModel
spacing: 5 spacing: 5
delegate: Item { delegate: Item {
height: 60 height: 60
width: 341 width: 341
MouseArea {
id: ms
anchors.fill: parent
hoverEnabled: true
onClicked: {
listWidget_servers.currentIndex = index
mouse.accepted = false
}
onEntered: {
mouseExitAni.stop()
mouseEnterAni.start()
}
onExited: {
mouseEnterAni.stop()
mouseExitAni.start()
}
}
LinearGradient { LinearGradient {
visible: !ms.containsMouse visible: !ms.containsMouse
anchors.fill: parent anchors.fill: parent
@ -106,7 +111,7 @@ Item {
horizontalAlignment: Text.AlignLeft horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
wrapMode: Text.Wrap wrapMode: Text.Wrap
text: description text: desc
} }
ImageButtonType { ImageButtonType {
x: 212 x: 212
@ -117,6 +122,7 @@ Item {
iconMargin: 0 iconMargin: 0
icon.source: checked ? "qrc:/images/connect_button_connected.png" icon.source: checked ? "qrc:/images/connect_button_connected.png"
: "qrc:/images/connect_button_disconnected.png" : "qrc:/images/connect_button_disconnected.png"
visible: false
} }
ImageButtonType { ImageButtonType {
x: 300 x: 300
@ -126,21 +132,39 @@ Item {
checkable: true checkable: true
icon.source: checked ? "qrc:/images/check.png" icon.source: checked ? "qrc:/images/check.png"
: "qrc:/images/uncheck.png" : "qrc:/images/uncheck.png"
onClicked: {
UiLogic.onServerListPushbuttonDefaultClicked(index)
}
checked: is_default
enabled: !is_default
} }
ImageButtonType { ImageButtonType {
id: pushButtonSetting
x: 260 x: 260
y: 25 y: 25
width: 24 width: 24
height: 24 height: 24
icon.source: "qrc:/images/settings.png" icon.source: "qrc:/images/settings.png"
}
MouseArea {
id: ms
anchors.fill: parent
hoverEnabled: true
onClicked: { onClicked: {
listWidget_servers.currentIndex = index UiLogic.onServerListPushbuttonSettingsClicked(index)
mouse.accepted = false }
OpacityAnimator {
id: mouseEnterAni
target: pushButtonSetting;
from: 0;
to: 1;
duration: 150
running: false
easing.type: Easing.InOutQuad
}
OpacityAnimator {
id: mouseExitAni
target: pushButtonSetting;
from: 1;
to: 0;
duration: 150
running: false
easing.type: Easing.InOutQuad
} }
} }
} }

View file

@ -6,6 +6,7 @@ Item {
id: root id: root
width: GC.screenWidth width: GC.screenWidth
height: GC.screenHeight height: GC.screenHeight
enabled: UiLogic.pageServerProtocolsEnabled
ImageButtonType { ImageButtonType {
id: back id: back
x: 10 x: 10
@ -37,8 +38,9 @@ Item {
width: 301 width: 301
height: 40 height: 40
from: 0 from: 0
to: 100 to: UiLogic.progressBarProtocolsContainerReinstallMaximium
value: 0 value: UiLogic.progressBarProtocolsContainerReinstallValue
visible: UiLogic.progressBarProtocolsContainerReinstallVisible
background: Rectangle { background: Rectangle {
implicitWidth: parent.width implicitWidth: parent.width
implicitHeight: parent.height implicitHeight: parent.height
@ -83,6 +85,7 @@ Item {
border.width: 1 border.width: 1
border.color: "lightgray" border.color: "lightgray"
radius: 2 radius: 2
visible: UiLogic.frameOpenvpnSsCloakSettingsVisible
Item { Item {
x: 5 x: 5
y: 5 y: 5
@ -102,6 +105,15 @@ Item {
icon.source: checked ? "qrc:/images/check.png" : "qrc:/images/uncheck.png" icon.source: checked ? "qrc:/images/check.png" : "qrc:/images/uncheck.png"
width: 24 width: 24
height: 24 height: 24
checked: UiLogic.pushButtonProtoCloakOpenvpnContDefaultChecked
onCheckedChanged: {
UiLogic.pushButtonProtoCloakOpenvpnContDefaultChecked = checked
}
onClicked: {
UiLogic.pushButtonProtoCloakOpenvpnContDefaultClicked(checked)
}
visible: UiLogic.pushButtonProtoCloakOpenvpnContDefaultVisible
} }
ImageButtonType { ImageButtonType {
@ -111,6 +123,10 @@ Item {
icon.source: "qrc:/images/share.png" icon.source: "qrc:/images/share.png"
width: 24 width: 24
height: 24 height: 24
visible: UiLogic.pushButtonProtoCloakOpenvpnContShareVisible
onClicked: {
UiLogic.pushButtonProtoCloakOpenvpnContShareClicked(false)
}
} }
ImageButtonType { ImageButtonType {
id: cn1 id: cn1
@ -120,6 +136,14 @@ Item {
: "qrc:/images/connect_button_disconnected.png" : "qrc:/images/connect_button_disconnected.png"
width: 36 width: 36
height: 24 height: 24
checked: UiLogic.pushButtonProtoCloakOpenvpnContInstallChecked
onCheckedChanged: {
UiLogic.pushButtonProtoCloakOpenvpnContInstallChecked = checked
}
onClicked: {
UiLogic.pushButtonProtoCloakOpenvpnContInstallClicked(checked)
}
enabled: UiLogic.pushButtonProtoCloakOpenvpnContInstallEnabled
} }
} }
Rectangle { Rectangle {
@ -137,6 +161,9 @@ Item {
height: 24 height: 24
text: qsTr("OpenVPN settings") text: qsTr("OpenVPN settings")
icon.source: "qrc:/images/settings.png" icon.source: "qrc:/images/settings.png"
onClicked: {
UiLogic.pushButtonProtoCloakOpenvpnContOpenvpnConfigClicked()
}
} }
SettingButtonType { SettingButtonType {
x: 10 x: 10
@ -145,6 +172,9 @@ Item {
height: 24 height: 24
text: qsTr("ShadowSocks settings") text: qsTr("ShadowSocks settings")
icon.source: "qrc:/images/settings.png" icon.source: "qrc:/images/settings.png"
onClicked: {
UiLogic.pushButtonProtoCloakOpenvpnContSsConfigClicked()
}
} }
SettingButtonType { SettingButtonType {
x: 10 x: 10
@ -153,6 +183,9 @@ Item {
height: 24 height: 24
text: qsTr("Cloak settings") text: qsTr("Cloak settings")
icon.source: "qrc:/images/settings.png" icon.source: "qrc:/images/settings.png"
onClicked: {
UiLogic.pushButtonProtoCloakOpenvpnContCloakConfigClicked()
}
} }
} }
} }
@ -164,6 +197,7 @@ Item {
border.width: 1 border.width: 1
border.color: "lightgray" border.color: "lightgray"
radius: 2 radius: 2
visible: UiLogic.frameOpenvpnSsSettingsVisible
Item { Item {
x: 5 x: 5
y: 5 y: 5
@ -183,6 +217,15 @@ Item {
icon.source: checked ? "qrc:/images/check.png" : "qrc:/images/uncheck.png" icon.source: checked ? "qrc:/images/check.png" : "qrc:/images/uncheck.png"
width: 24 width: 24
height: 24 height: 24
checked: UiLogic.pushButtonProtoSsOpenvpnContDefaultChecked
onCheckedChanged: {
UiLogic.pushButtonProtoSsOpenvpnContDefaultChecked = checked
}
onClicked: {
UiLogic.pushButtonProtoSsOpenvpnContDefaultClicked(checked)
}
visible: UiLogic.pushButtonProtoSsOpenvpnContDefaultVisible
} }
ImageButtonType { ImageButtonType {
@ -192,6 +235,10 @@ Item {
icon.source: "qrc:/images/share.png" icon.source: "qrc:/images/share.png"
width: 24 width: 24
height: 24 height: 24
visible: UiLogic.pushButtonProtoSsOpenvpnContShareVisible
onClicked: {
UiLogic.pushButtonProtoSsOpenvpnContShareClicked(false)
}
} }
ImageButtonType { ImageButtonType {
id: cn2 id: cn2
@ -201,6 +248,14 @@ Item {
: "qrc:/images/connect_button_disconnected.png" : "qrc:/images/connect_button_disconnected.png"
width: 36 width: 36
height: 24 height: 24
checked: UiLogic.pushButtonProtoSsOpenvpnContInstallChecked
onCheckedChanged: {
UiLogic.pushButtonProtoSsOpenvpnContInstallChecked = checked
}
onClicked: {
UiLogic.pushButtonProtoSsOpenvpnContInstallClicked(checked)
}
enabled: UiLogic.pushButtonProtoSsOpenvpnContInstallEnabled
} }
} }
Rectangle { Rectangle {
@ -218,6 +273,9 @@ Item {
height: 24 height: 24
text: qsTr("OpenVPN settings") text: qsTr("OpenVPN settings")
icon.source: "qrc:/images/settings.png" icon.source: "qrc:/images/settings.png"
onClicked: {
UiLogic.pushButtonProtoSsOpenvpnContOpenvpnConfigClicked()
}
} }
SettingButtonType { SettingButtonType {
x: 10 x: 10
@ -226,6 +284,9 @@ Item {
height: 24 height: 24
text: qsTr("ShadowSocks settings") text: qsTr("ShadowSocks settings")
icon.source: "qrc:/images/settings.png" icon.source: "qrc:/images/settings.png"
onClicked: {
UiLogic.pushButtonProtoSsOpenvpnContSsConfigClicked()
}
} }
} }
} }
@ -237,6 +298,7 @@ Item {
border.width: 1 border.width: 1
border.color: "lightgray" border.color: "lightgray"
radius: 2 radius: 2
visible: UiLogic.frameOpenvpnSettingsVisible
Item { Item {
x: 5 x: 5
y: 5 y: 5
@ -256,6 +318,15 @@ Item {
icon.source: checked ? "qrc:/images/check.png" : "qrc:/images/uncheck.png" icon.source: checked ? "qrc:/images/check.png" : "qrc:/images/uncheck.png"
width: 24 width: 24
height: 24 height: 24
checked: UiLogic.pushButtonProtoOpenvpnContDefaultChecked
onCheckedChanged: {
UiLogic.pushButtonProtoOpenvpnContDefaultChecked = checked
}
onClicked: {
UiLogic.pushButtonProtoOpenvpnContDefaultClicked(checked)
}
visible: UiLogic.pushButtonProtoOpenvpnContDefaultVisible
} }
ImageButtonType { ImageButtonType {
@ -265,6 +336,10 @@ Item {
icon.source: "qrc:/images/share.png" icon.source: "qrc:/images/share.png"
width: 24 width: 24
height: 24 height: 24
visible: UiLogic.pushButtonProtoOpenvpnContShareVisible
onClicked: {
UiLogic.pushButtonProtoOpenvpnContShareClicked(false)
}
} }
ImageButtonType { ImageButtonType {
id: cn3 id: cn3
@ -274,6 +349,14 @@ Item {
: "qrc:/images/connect_button_disconnected.png" : "qrc:/images/connect_button_disconnected.png"
width: 36 width: 36
height: 24 height: 24
checked: UiLogic.pushButtonProtoOpenvpnContInstallChecked
onCheckedChanged: {
UiLogic.pushButtonProtoOpenvpnContInstallChecked = checked
}
onClicked: {
UiLogic.pushButtonProtoOpenvpnContInstallClicked(checked)
}
enabled: UiLogic.pushButtonProtoOpenvpnContInstallEnabled
} }
} }
Rectangle { Rectangle {
@ -291,6 +374,9 @@ Item {
height: 24 height: 24
text: qsTr("OpenVPN settings") text: qsTr("OpenVPN settings")
icon.source: "qrc:/images/settings.png" icon.source: "qrc:/images/settings.png"
onClicked: {
UiLogic.pushButtonProtoOpenvpnContOpenvpnConfigClicked()
}
} }
} }
} }
@ -322,6 +408,15 @@ Item {
icon.source: checked ? "qrc:/images/check.png" : "qrc:/images/uncheck.png" icon.source: checked ? "qrc:/images/check.png" : "qrc:/images/uncheck.png"
width: 24 width: 24
height: 24 height: 24
checked: UiLogic.pushButtonProtoWireguardContDefaultChecked
onCheckedChanged: {
UiLogic.pushButtonProtoWireguardContDefaultChecked = checked
}
onClicked: {
UiLogic.pushButtonProtoWireguardContDefaultClicked(checked)
}
visible: UiLogic.pushButtonProtoWireguardContDefaultVisible
} }
ImageButtonType { ImageButtonType {
@ -331,6 +426,10 @@ Item {
icon.source: "qrc:/images/share.png" icon.source: "qrc:/images/share.png"
width: 24 width: 24
height: 24 height: 24
visible: UiLogic.pushButtonProtoWireguardContShareVisible
onClicked: {
UiLogic.pushButtonProtoWireguardContShareClicked(false)
}
} }
ImageButtonType { ImageButtonType {
id: cn4 id: cn4
@ -340,6 +439,14 @@ Item {
: "qrc:/images/connect_button_disconnected.png" : "qrc:/images/connect_button_disconnected.png"
width: 36 width: 36
height: 24 height: 24
checked: UiLogic.pushButtonProtoWireguardContInstallChecked
onCheckedChanged: {
UiLogic.pushButtonProtoWireguardContInstallChecked = checked
}
onClicked: {
UiLogic.pushButtonProtoWireguardContInstallClicked(checked)
}
enabled: UiLogic.pushButtonProtoWireguardContInstallEnabled
} }
} }
Rectangle { Rectangle {

View file

@ -1,11 +1,14 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Controls 2.12 import QtQuick.Controls 2.12
import "./" import "./"
import PageEnum 1.0
Item { Item {
id: root id: root
width: GC.screenWidth width: GC.screenWidth
height: GC.screenHeight height: GC.screenHeight
enabled: UiLogic.pageServerSettingsEnabled
ImageButtonType { ImageButtonType {
id: back id: back
x: 10 x: 10
@ -72,6 +75,7 @@ Item {
text: UiLogic.lineEditServerSettingsDescriptionText text: UiLogic.lineEditServerSettingsDescriptionText
onEditingFinished: { onEditingFinished: {
UiLogic.lineEditServerSettingsDescriptionText = text UiLogic.lineEditServerSettingsDescriptionText = text
UiLogic.onLineEditServerSettingsDescriptionEditingFinished()
} }
} }
BlueButtonType { BlueButtonType {
@ -79,16 +83,22 @@ Item {
y: 410 y: 410
width: 300 width: 300
height: 40 height: 40
text: qsTr("Clear server from Amnezia software") text: UiLogic.pushButtonServerSettingsClearText
visible: UiLogic.pushButtonServerSettingsClearVisible visible: UiLogic.pushButtonServerSettingsClearVisible
onClicked: {
UiLogic.onPushButtonClearServer()
}
} }
BlueButtonType { BlueButtonType {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
y: 350 y: 350
width: 300 width: 300
height: 40 height: 40
text: qsTr("Clear client cached profile") text: UiLogic.pushButtonServerSettingsClearClientCacheText
visible: UiLogic.pushButtonServerSettingsClearClientCacheVisible visible: UiLogic.pushButtonServerSettingsClearClientCacheVisible
onClicked: {
UiLogic.onPushButtonServerSettingsClearClientCacheClicked()
}
} }
BlueButtonType { BlueButtonType {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
@ -96,6 +106,9 @@ Item {
width: 300 width: 300
height: 40 height: 40
text: qsTr("Forget this server") text: qsTr("Forget this server")
onClicked: {
UiLogic.onPushButtonForgetServer()
}
} }
BlueButtonType { BlueButtonType {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
@ -103,6 +116,9 @@ Item {
width: 300 width: 300
height: 40 height: 40
text: qsTr("VPN protocols") text: qsTr("VPN protocols")
onClicked: {
UiLogic.goToPage(PageEnum.ServerVpnProtocols)
}
} }
BlueButtonType { BlueButtonType {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
@ -111,5 +127,8 @@ Item {
height: 40 height: 40
text: qsTr("Share Server (FULL ACCESS)") text: qsTr("Share Server (FULL ACCESS)")
visible: UiLogic.pushButtonServerSettingsShareFullVisible visible: UiLogic.pushButtonServerSettingsShareFullVisible
onClicked: {
UiLogic.onPushButtonServerSettingsShareFullClicked()
}
} }
} }

View file

@ -1,6 +1,6 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Controls 2.12 import QtQuick.Controls 2.12
import Page 1.0 import PageEnum 1.0
import "./" import "./"
Item { Item {
@ -74,11 +74,11 @@ Item {
text: qsTr("Next") text: qsTr("Next")
onClicked: { onClicked: {
if (radioButton_setup_wizard_high.checked) { if (radioButton_setup_wizard_high.checked) {
UiLogic.goToPage(Page.WizardHigh); UiLogic.goToPage(PageEnum.WizardHigh);
} else if (radioButton_setup_wizard_medium.checked) { } else if (radioButton_setup_wizard_medium.checked) {
UiLogic.goToPage(Page.WizardMedium); UiLogic.goToPage(PageEnum.WizardMedium);
} else if (radioButton_setup_wizard_low.checked) { } else if (radioButton_setup_wizard_low.checked) {
UiLogic.goToPage(Page.WizardLow); UiLogic.goToPage(PageEnum.WizardLow);
} }
} }
} }

View file

@ -1,6 +1,6 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Controls 2.12 import QtQuick.Controls 2.12
import Page 1.0 import PageEnum 1.0
import "./" import "./"
Item { Item {
@ -90,7 +90,7 @@ Item {
if (!domain || !domain.includes(".")) { if (!domain || !domain.includes(".")) {
return return
} }
UiLogic.goToPage(Page.WizardVpnMode) UiLogic.goToPage(PageEnum.WizardVpnMode)
} }
} }
} }

View file

@ -1,6 +1,6 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Controls 2.12 import QtQuick.Controls 2.12
import Page 1.0 import PageEnum 1.0
import "./" import "./"
Item { Item {
@ -60,7 +60,7 @@ Item {
height: 40 height: 40
text: qsTr("Next") text: qsTr("Next")
onClicked: { onClicked: {
UiLogic.goToPage(Page.WizardVpnMode) UiLogic.goToPage(PageEnum.WizardVpnMode)
} }
} }
} }

View file

@ -34,10 +34,23 @@ Item {
share_shadowshock, share_shadowshock,
share_cloak share_cloak
] ]
property int currentIndex: UiLogic.toolBoxShareConnectionCurrentIndex
onCurrentIndexChanged: {
UiLogic.toolBoxShareConnectionCurrentIndex = currentIndex
for (let i = 0; i < contentList.length; ++i) {
if (i == currentIndex) {
contentList[i].active = true
} else {
contentList[i].active = false
}
}
}
function clearActive() { function clearActive() {
for (let i = 0; i < contentList.length; ++i) { for (let i = 0; i < contentList.length; ++i) {
contentList[i].active = false contentList[i].active = false
} }
currentIndex = -1;
} }
Column { Column {
spacing: 5 spacing: 5
@ -45,6 +58,7 @@ Item {
id: full_access id: full_access
x: 0 x: 0
text: qsTr("Full access") text: qsTr("Full access")
visible: UiLogic.pageShareFullAccessVisible
content: Component { content: Component {
Item { Item {
width: 360 width: 360
@ -68,7 +82,10 @@ Item {
y: 130 y: 130
width: 341 width: 341
height: 40 height: 40
text: qsTr("Copy") text: UiLogic.pushButtonShareFullCopyText
onClicked: {
UiLogic.onPushButtonShareFullCopyClicked()
}
} }
ShareConnectionButtonType { ShareConnectionButtonType {
x: 10 x: 10
@ -76,6 +93,9 @@ Item {
width: 341 width: 341
height: 40 height: 40
text: qsTr("Save file") text: qsTr("Save file")
onClicked: {
UiLogic.onPushButtonShareFullSaveClicked()
}
} }
TextFieldType { TextFieldType {
x: 10 x: 10
@ -83,15 +103,19 @@ Item {
width: 341 width: 341
height: 100 height: 100
verticalAlignment: Text.AlignTop verticalAlignment: Text.AlignTop
text: UiLogic.textEditShareFullCodeText
onEditingFinished: {
UiLogic.textEditShareFullCodeText = text
}
} }
} }
} }
onClicked: { onClicked: {
if (active) { if (active) {
active = false ct.currentIndex = -1
} else { } else {
ct.clearActive() ct.clearActive()
active = true ct.currentIndex = 0
} }
} }
} }
@ -99,6 +123,7 @@ Item {
id: share_amezia id: share_amezia
x: 0 x: 0
text: qsTr("Share for Amnezia client") text: qsTr("Share for Amnezia client")
visible: UiLogic.pageShareAmneziaVisible
content: Component { content: Component {
Item { Item {
width: 360 width: 360
@ -122,14 +147,22 @@ Item {
y: 180 y: 180
width: 341 width: 341
height: 40 height: 40
text: qsTr("Copy") text: UiLogic.pushButtonShareAmneziaCopyText
onClicked: {
UiLogic.onPushButtonShareAmneziaCopyClicked()
}
enabled: UiLogic.pushButtonShareAmneziaCopyEnabled
} }
ShareConnectionButtonType { ShareConnectionButtonType {
x: 10 x: 10
y: 130 y: 130
width: 341 width: 341
height: 40 height: 40
text: qsTr("Generate config") text: UiLogic.pushButtonShareAmneziaGenerateText
enabled: UiLogic.pushButtonShareAmneziaGenerateEnabled
onClicked: {
UiLogic.onPushButtonShareAmneziaGenerateClicked()
}
} }
ShareConnectionButtonType { ShareConnectionButtonType {
x: 10 x: 10
@ -137,6 +170,9 @@ Item {
width: 341 width: 341
height: 40 height: 40
text: qsTr("Save file") text: qsTr("Save file")
onClicked: {
UiLogic.onPushButtonShareAmneziaSaveClicked()
}
} }
TextFieldType { TextFieldType {
x: 10 x: 10
@ -144,15 +180,19 @@ Item {
width: 341 width: 341
height: 100 height: 100
verticalAlignment: Text.AlignTop verticalAlignment: Text.AlignTop
text: UiLogic.textEditShareAmneziaCodeText
onEditingFinished: {
UiLogic.textEditShareAmneziaCodeText = text
}
} }
} }
} }
onClicked: { onClicked: {
if (active) { if (active) {
active = false ct.currentIndex = -1
} else { } else {
ct.clearActive() ct.clearActive()
active = true ct.currentIndex = 1
} }
} }
} }
@ -160,6 +200,7 @@ Item {
id: share_openvpn id: share_openvpn
x: 0 x: 0
text: qsTr("Share for OpenVPN client") text: qsTr("Share for OpenVPN client")
visible: UiLogic.pageShareOpenvpnVisible
content: Component { content: Component {
Item { Item {
width: 360 width: 360
@ -169,14 +210,22 @@ Item {
y: 180 y: 180
width: 341 width: 341
height: 40 height: 40
text: qsTr("Copy") text: UiLogic.pushButtonShareOpenvpnCopyText
enabled: UiLogic.pushButtonShareOpenvpnCopyEnabled
onClicked: {
UiLogic.onPushButtonShareOpenvpnCopyClicked()
}
} }
ShareConnectionButtonType { ShareConnectionButtonType {
x: 10 x: 10
y: 130 y: 130
width: 341 width: 341
height: 40 height: 40
text: qsTr("Generate config") text: UiLogic.pushButtonShareOpenvpnGenerateText
onClicked: {
UiLogic.onPushButtonShareOpenvpnGenerateClicked()
}
enabled: UiLogic.pushButtonShareOpenvpnGenerateEnabled
} }
ShareConnectionButtonType { ShareConnectionButtonType {
x: 10 x: 10
@ -184,6 +233,10 @@ Item {
width: 341 width: 341
height: 40 height: 40
text: qsTr("Save file") text: qsTr("Save file")
enabled: UiLogic.pushButtonShareOpenvpnSaveEnabled
onClicked: {
UiLogic.onPushButtonShareOpenvpnSaveClicked()
}
} }
TextFieldType { TextFieldType {
x: 10 x: 10
@ -191,15 +244,19 @@ Item {
width: 341 width: 341
height: 100 height: 100
verticalAlignment: Text.AlignTop verticalAlignment: Text.AlignTop
text: UiLogic.textEditShareOpenvpnCodeText
onEditingFinished: {
UiLogic.textEditShareOpenvpnCodeText = text
}
} }
} }
} }
onClicked: { onClicked: {
if (active) { if (active) {
active = false ct.currentIndex = -1
} else { } else {
ct.clearActive() ct.clearActive()
active = true ct.currentIndex = 2
} }
} }
} }
@ -207,6 +264,7 @@ Item {
id: share_shadowshock id: share_shadowshock
x: 0 x: 0
text: qsTr("Share for ShadowSocks client") text: qsTr("Share for ShadowSocks client")
visible: UiLogic.pageShareShadowsocksVisible
content: Component { content: Component {
Item { Item {
width: 360 width: 360
@ -251,28 +309,28 @@ Item {
y: 70 y: 70
width: 100 width: 100
height: 20 height: 20
text: qsTr("Password") text: UiLogic.labelShareSsPasswordText
} }
LabelType { LabelType {
x: 130 x: 130
y: 10 y: 10
width: 100 width: 100
height: 20 height: 20
text: qsTr("Server:") text: UiLogic.labelShareSsServerText
} }
LabelType { LabelType {
x: 130 x: 130
y: 50 y: 50
width: 100 width: 100
height: 20 height: 20
text: qsTr("Encryption:") text: UiLogic.labelShareSsMethodText
} }
LabelType { LabelType {
x: 130 x: 130
y: 30 y: 30
width: 100 width: 100
height: 20 height: 20
text: qsTr("Port:") text: UiLogic.labelShareSsPortText
} }
Image { Image {
id: label_share_ss_qr_code id: label_share_ss_qr_code
@ -280,15 +338,18 @@ Item {
y: 235 y: 235
width: 200 width: 200
height: 200 height: 200
source: UiLogic.labelShareSsQrCodeText == "" ? "" : "data:image/png;base64," + UiLogic.labelShareSsQrCodeText
// source: "file"
} }
ShareConnectionButtonType { ShareConnectionButtonType {
x: 10 x: 10
y: 180 y: 180
width: 331 width: 331
height: 40 height: 40
text: qsTr("Copy") text: UiLogic.pushButtonShareSsCopyText
enabled: UiLogic.pushButtonShareSsCopyEnabled
onClicked: {
UiLogic.onPushButtonShareSsCopyClicked()
}
} }
TextFieldType { TextFieldType {
x: 10 x: 10
@ -296,15 +357,19 @@ Item {
width: 331 width: 331
height: 100 height: 100
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
text: UiLogic.lineEditShareSsStringText
onEditingFinished: {
UiLogic.lineEditShareSsStringText = text
}
} }
} }
} }
onClicked: { onClicked: {
if (active) { if (active) {
active = false ct.currentIndex = -1
} else { } else {
ct.clearActive() ct.clearActive()
active = true ct.currentIndex = 3
} }
} }
} }
@ -312,6 +377,7 @@ Item {
id: share_cloak id: share_cloak
x: 0 x: 0
text: qsTr("Share for Cloak client") text: qsTr("Share for Cloak client")
visible: UiLogic.pageShareCloakVisible
content: Component { content: Component {
Item { Item {
width: 360 width: 360
@ -321,22 +387,30 @@ Item {
y: 290 y: 290
width: 331 width: 331
height: 40 height: 40
text: qsTr("Copy") text: UiLogic.pushButtonShareCloakCopyText
enabled: UiLogic.pushButtonShareCloakCopyEnabled
onClicked: {
UiLogic.onPushButtonShareCloakCopyClicked()
}
} }
TextInput { TextInput {
x: 10 x: 10
y: 30 y: 30
width: 331 width: 331
height: 100 height: 100
text: UiLogic.plainTextEditShareCloakText
onEditingFinished: {
UiLogic.plainTextEditShareCloakText = text
}
} }
} }
} }
onClicked: { onClicked: {
if (active) { if (active) {
active = false ct.currentIndex = -1
} else { } else {
ct.clearActive() ct.clearActive()
active = true ct.currentIndex = 4
} }
} }
} }

View file

@ -1,7 +1,9 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Controls 2.12 import QtQuick.Controls 2.12
import "./" import "./"
import Qt.labs.qmlmodels 1.0 import Qt.labs.platform 1.0
import QtQuick.Dialogs 1.0
Item { Item {
id: root id: root
width: GC.screenWidth width: GC.screenWidth
@ -26,7 +28,7 @@ Item {
color: "#100A44" color: "#100A44"
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignTop verticalAlignment: Text.AlignTop
text: qsTr("These sites will be opened using VPN") text: UiLogic.labelSitesAddCustomText
x: 20 x: 20
y: 40 y: 40
width: 340 width: 340
@ -38,6 +40,13 @@ 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
onEditingFinished: {
UiLogic.lineEditSitesAddCustomText = text
}
onAccepted: {
UiLogic.onPushButtonAddCustomSitesClicked()
}
} }
ImageButtonType { ImageButtonType {
id: back id: back
@ -58,6 +67,9 @@ Item {
height: 31 height: 31
font.pixelSize: 24 font.pixelSize: 24
text: "+" text: "+"
onClicked: {
UiLogic.onPushButtonAddCustomSitesClicked()
}
} }
BlueButtonType { BlueButtonType {
id: sites_delete id: sites_delete
@ -67,6 +79,9 @@ Item {
height: 31 height: 31
font.pixelSize: 16 font.pixelSize: 16
text: qsTr("Delete selected") text: qsTr("Delete selected")
onClicked: {
UiLogic.onPushButtonSitesDeleteClicked(tb.currentRow)
}
} }
BasicButtonType { BasicButtonType {
@ -92,6 +107,18 @@ Item {
} }
} }
antialiasing: true antialiasing: true
onClicked: {
fileDialog.open()
}
}
FileDialog {
id: fileDialog
title: qsTr("Import IP addresses")
visible: false
folder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation)
onAccepted: {
UiLogic.onPushButtonSitesImportClicked(fileUrl)
}
} }
TableView { TableView {
id: tb id: tb
@ -103,25 +130,7 @@ Item {
clip: true clip: true
property int currentRow: -1 property int currentRow: -1
columnSpacing: 0 columnSpacing: 0
model: TableModel { model: UiLogic.tableViewSitesModel
TableModelColumn { display: "name" }
TableModelColumn { display: "color" }
rows: [
{
"name": "cat",
"color": "black"
},
{
"name": "dog",
"color": "brown"
},
{
"name": "bird",
"color": "white"
}
]
}
delegate: Item { delegate: Item {
implicitWidth: 170 implicitWidth: 170

View file

@ -25,15 +25,16 @@ Item {
checked: false checked: false
checkable: true checkable: true
onCheckedChanged: { onCheckedChanged: {
// if (checked){ if (checked) {
// ui->stackedWidget_start->setCurrentWidget(ui->page_start_new_server); page_start_new_server.visible = true
// ui->pushButton_start_switch_page->setText(tr("Import connection")); page_start_import.visible = false
// } text = qsTr("Import connection");
// else { }
// ui->stackedWidget_start->setCurrentWidget(ui->page_start_import); else {
// ui->pushButton_start_switch_page->setText(tr("Set up your own server")); page_start_new_server.visible = false
// } page_start_import.visible = true
text = qsTr("Set up your own server");
}
} }
background: Rectangle { background: Rectangle {
@ -57,20 +58,14 @@ Item {
} }
StackView {
id: page_start_stack_view
x: 0
y: 35
width: 380
height: 481
initialItem: page_start_new_server
}
Component {
id: page_start_import
Item { Item {
id: page_start_import
width: 380 width: 380
height: 481 height: 481
x: 0
y: 35
visible: true
Text { Text {
x: 0 x: 0
y: 20 y: 20
@ -120,13 +115,15 @@ Item {
} }
} }
} }
}
Component {
id: page_start_new_server
Item { Item {
id: page_start_new_server
width: 380 width: 380
height: 481 height: 481
x: 0
y: 35
visible: false
Label { Label {
x:10 x:10
y:0 y:0
@ -157,6 +154,7 @@ Item {
text: qsTr("Login to connect via SSH") text: qsTr("Login to connect via SSH")
} }
LabelType { LabelType {
id: label_new_server_password
x: 40 x: 40
y: 230 y: 230
width: 171 width: 171
@ -212,11 +210,12 @@ Item {
y: 350 y: 350
width: 301 width: 301
height: 40 height: 40
text: qsTr("Connect") text: UiLogic.pushButtonNewServerConnectText
visible: UiLogic.pushButtonNewServerConnectVisible visible: UiLogic.pushButtonNewServerConnectVisible
onClicked: { onClicked: {
UiLogic.onPushButtonNewServerConnect() UiLogic.onPushButtonNewServerConnect()
} }
enabled: UiLogic.pushButtonNewServerConnectEnabled
} }
BasicButtonType { BasicButtonType {
id: new_sever_connect_key id: new_sever_connect_key
@ -244,6 +243,10 @@ Item {
checked: UiLogic.pushButtonNewServerConnectKeyChecked checked: UiLogic.pushButtonNewServerConnectKeyChecked
onCheckedChanged: { onCheckedChanged: {
UiLogic.pushButtonNewServerConnectKeyChecked = checked UiLogic.pushButtonNewServerConnectKeyChecked = checked
label_new_server_password.text = checked ? qsTr("Private key") : qsTr("Password")
new_sever_connect_key.text = checked ? qsTr("Connect using SSH password") : qsTr("Connect using SSH key")
new_server_password.visible = !checked
new_server_ssh_key.visible = checked
} }
} }
BasicButtonType { BasicButtonType {
@ -287,9 +290,10 @@ Item {
onEditingFinished: { onEditingFinished: {
UiLogic.textEditNewServerSshKeyText = text UiLogic.textEditNewServerSshKeyText = text
} }
visible: false
} }
} }
}
ImageButtonType { ImageButtonType {
id: back_from_start id: back_from_start

View file

@ -1,6 +1,6 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Controls 2.12 import QtQuick.Controls 2.12
import Page 1.0 import PageEnum 1.0
import "./" import "./"
Item { Item {
@ -37,7 +37,7 @@ Item {
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
wrapMode: Text.Wrap wrapMode: Text.Wrap
text: qsTr("Error text") text: UiLogic.labelErrorText
} }
Text { Text {
x: 0 x: 0
@ -51,7 +51,7 @@ Item {
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
wrapMode: Text.Wrap wrapMode: Text.Wrap
text: qsTr("Connected") text: UiLogic.labelStateText
} }
Image { Image {
x: 0 x: 0
@ -79,6 +79,7 @@ Item {
} }
contentItem: Item {} contentItem: Item {}
antialiasing: true antialiasing: true
enabled: UiLogic.pushButtonConnectEnabled
} }
ImageButtonType { ImageButtonType {
@ -87,6 +88,9 @@ Item {
width: 31 width: 31
height: 31 height: 31
icon.source: "qrc:/images/settings_grey.png" icon.source: "qrc:/images/settings_grey.png"
onClicked: {
UiLogic.goToPage(PageEnum.GeneralSettings)
}
} }
BasicButtonType { BasicButtonType {
id: button_add_site id: button_add_site
@ -122,7 +126,7 @@ Item {
} }
antialiasing: true antialiasing: true
onClicked: { onClicked: {
UiLogic.goToPage(Page.Sites) UiLogic.goToPage(PageEnum.Sites)
} }
} }
Item { Item {
@ -156,7 +160,7 @@ Item {
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
wrapMode: Text.Wrap wrapMode: Text.Wrap
text: qsTr("0 Mbps") text: UiLogic.labelSpeedReceivedText
} }
Text { Text {
x: 260 x: 260
@ -170,7 +174,7 @@ Item {
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
wrapMode: Text.Wrap wrapMode: Text.Wrap
text: qsTr("0 Mbps") text: UiLogic.labelSpeedSentText
} }
} }
Item { Item {
@ -178,6 +182,7 @@ Item {
y: 470 y: 470
width: 351 width: 351
height: 91 height: 91
enabled: UiLogic.widgetVpnModeEnabled
RadioButtonType { RadioButtonType {
x: 0 x: 0
y: 0 y: 0
@ -215,6 +220,5 @@ Item {
UiLogic.onRadioButtonVpnModeForwardSitesToggled(checked) UiLogic.onRadioButtonVpnModeForwardSitesToggled(checked)
} }
} }
} }
} }

View file

@ -1,7 +1,7 @@
import QtQuick 2.14 import QtQuick 2.14
import QtQuick.Window 2.14 import QtQuick.Window 2.14
import QtQuick.Controls 2.12 import QtQuick.Controls 2.12
import Page 1.0 import PageEnum 1.0
import Qt.labs.platform 1.1 import Qt.labs.platform 1.1
import QtQuick.Dialogs 1.1 import QtQuick.Dialogs 1.1
import "./" import "./"
@ -11,51 +11,55 @@ Window {
visible: true visible: true
width: GC.screenWidth width: GC.screenWidth
height: GC.isDesktop() ? GC.screenHeight + titleBar.height : GC.screenHeight height: GC.isDesktop() ? GC.screenHeight + titleBar.height : GC.screenHeight
onClosing: {
UiLogic.onCloseWindow()
}
// flags: Qt.FramelessWindowHint // flags: Qt.FramelessWindowHint
title: "AmneziaVPN" title: "AmneziaVPN"
function getPageComponent(page) { function getPageComponent(page) {
switch (page) { switch (page) {
case Page.Start: case PageEnum.Start:
return page_start; return page_start;
case Page.NewServer: case PageEnum.NewServer:
return page_new_server return page_new_server
case Page.NewServerProtocols: case PageEnum.NewServerProtocols:
return page_new_server_protocols return page_new_server_protocols
case Page.Wizard: case PageEnum.Wizard:
return page_setup_wizard return page_setup_wizard
case Page.WizardHigh: case PageEnum.WizardHigh:
return page_setup_wizard_high_level return page_setup_wizard_high_level
case Page.WizardLow: case PageEnum.WizardLow:
return page_setup_wizard_low_level return page_setup_wizard_low_level
case Page.WizardMedium: case PageEnum.WizardMedium:
return page_setup_wizard_medium_level return page_setup_wizard_medium_level
case Page.WizardVpnMode: case PageEnum.WizardVpnMode:
return page_setup_wizard_vpn_mode return page_setup_wizard_vpn_mode
case Page.ServerConfiguring: case PageEnum.ServerConfiguring:
return page_new_server_configuring return page_new_server_configuring
case Page.Vpn: case PageEnum.Vpn:
return page_vpn return page_vpn
case Page.GeneralSettings: case PageEnum.GeneralSettings:
return page_general_settings return page_general_settings
case Page.AppSettings: case PageEnum.AppSettings:
return page_app_settings return page_app_settings
case Page.NetworkSettings: case PageEnum.NetworkSettings:
return page_network_settings return page_network_settings
case Page.ServerSettings: case PageEnum.ServerSettings:
return page_server_settings return page_server_settings
case Page.ServerVpnProtocols: case PageEnum.ServerVpnProtocols:
return page_server_protocols return page_server_protocols
case Page.ServersList: case PageEnum.ServersList:
return page_servers return page_servers
case Page.ShareConnection: case PageEnum.ShareConnection:
return page_share_connection return page_share_connection
case Page.Sites: case PageEnum.Sites:
return page_sites return page_sites
case Page.OpenVpnSettings: case PageEnum.OpenVpnSettings:
return page_proto_openvpn return page_proto_openvpn
case Page.ShadowSocksSettings: case PageEnum.ShadowSocksSettings:
return page_proto_shadowsocks return page_proto_shadowsocks
case Page.CloakSettings: case PageEnum.CloakSettings:
return page_proto_cloak return page_proto_cloak
} }
return undefined; return undefined;
@ -63,113 +67,114 @@ Window {
function getPageEnum(item) { function getPageEnum(item) {
if (item instanceof PageStart) { if (item instanceof PageStart) {
return Page.Start return PageEnum.Start
} }
if (item instanceof PageNewServer) { if (item instanceof PageNewServer) {
return Page.NewServer return PageEnum.NewServer
} }
if (item instanceof PageNewServerProtocol) { if (item instanceof PageNewServerProtocol) {
return Page.NewServerProtocols return PageEnum.NewServerProtocols
} }
if (item instanceof PageSetupWizard) { if (item instanceof PageSetupWizard) {
return Page.Wizard return PageEnum.Wizard
} }
if (item instanceof PageSetupWizardHighLevel) { if (item instanceof PageSetupWizardHighLevel) {
return Page.WizardHigh return PageEnum.WizardHigh
} }
if (item instanceof PageSetupWizardLowLevel) { if (item instanceof PageSetupWizardLowLevel) {
return Page.WizardLow return PageEnum.WizardLow
} }
if (item instanceof PageSetupWizardMediumLevel) { if (item instanceof PageSetupWizardMediumLevel) {
return Page.WizardMedium return PageEnum.WizardMedium
} }
if (item instanceof PageSetupWizardVPNMode) { if (item instanceof PageSetupWizardVPNMode) {
return Page.WizardVpnMode return PageEnum.WizardVpnMode
} }
if (item instanceof PageNewServerConfiguring) { if (item instanceof PageNewServerConfiguring) {
return Page.ServerConfiguring return PageEnum.ServerConfiguring
} }
if (item instanceof PageVPN) { if (item instanceof PageVPN) {
return Page.Vpn return PageEnum.Vpn
} }
if (item instanceof PageGeneralSettings) { if (item instanceof PageGeneralSettings) {
return Page.GeneralSettings return PageEnum.GeneralSettings
} }
if (item instanceof PageAppSetting) { if (item instanceof PageAppSetting) {
return Page.AppSettings return PageEnum.AppSettings
} }
if (item instanceof PageNetworkSetting) { if (item instanceof PageNetworkSetting) {
return Page.NetworkSettings return PageEnum.NetworkSettings
} }
if (item instanceof PageServerSetting) { if (item instanceof PageServerSetting) {
return Page.ServerSettings return PageEnum.ServerSettings
} }
if (item instanceof PageServerProtocols) { if (item instanceof PageServerProtocols) {
return Page.ServerVpnProtocols return PageEnum.ServerVpnProtocols
} }
if (item instanceof PageServer) { if (item instanceof PageServer) {
return Page.ServersList return PageEnum.ServersList
} }
if (item instanceof PageShareConnection) { if (item instanceof PageShareConnection) {
return Page.ShareConnection return PageEnum.ShareConnection
} }
if (item instanceof PageSites) { if (item instanceof PageSites) {
return Page.Sites return PageEnum.Sites
} }
if (item instanceof PageProtoOpenVPN) { if (item instanceof PageProtoOpenVPN) {
return Page.OpenVpnSettings return PageEnum.OpenVpnSettings
} }
if (item instanceof PageProtoShadowSock) { if (item instanceof PageProtoShadowSock) {
return Page.ShadowSocksSettings return PageEnum.ShadowSocksSettings
} }
if (item instanceof PageProtoCloak) { if (item instanceof PageProtoCloak) {
return Page.CloakSettings return PageEnum.CloakSettings
} }
return Page.Start return PageEnum.Start
} }
function gotoPage(page, reset, slide) { function gotoPage(page, reset, slide) {
let pageComponent = getPageComponent(page) let pageComponent = getPageComponent(page)
console.debug(pageComponent)
if (reset) { if (reset) {
if (page === Page.ServerSettings) { if (page === PageEnum.ServerSettings) {
UiLogic.updateServerPage(); UiLogic.updateServerPage();
} }
if (page === Page.ShareConnection) {} if (page === PageEnum.ShareConnection) {}
if (page === Page.Wizard) { if (page === PageEnum.Wizard) {
UiLogic.radioButtonSetupWizardMediumChecked = true UiLogic.radioButtonSetupWizardMediumChecked = true
} }
if (page === Page.WizardHigh) { if (page === PageEnum.WizardHigh) {
UiLogic.updateWizardHighPage(); UiLogic.updateWizardHighPage();
} }
if (page === Page.ServerConfiguring) { if (page === PageEnum.ServerConfiguring) {
UiLogic.progressBarNewServerConfiguringValue = 0; UiLogic.progressBarNewServerConfiguringValue = 0;
} }
if (page === Page.GeneralSettings) { if (page === PageEnum.GeneralSettings) {
UiLogic.updateGeneralSettingPage(); UiLogic.updateGeneralSettingPage();
} }
if (page === Page.ServersList) { if (page === PageEnum.ServersList) {
UiLogic.updateServersListPage(); UiLogic.updateServersListPage();
} }
if (page === Page.Start) { if (page === PageEnum.Start) {
UiLogic.pushButtonBackFromStartVisible = !pageLoader.empty UiLogic.pushButtonBackFromStartVisible = !pageLoader.empty
UiLogic.updateStartPage(); UiLogic.updateStartPage();
} }
if (page === Page.NewServerProtocols) { if (page === PageEnum.NewServerProtocols) {
UiLogic.updateNewServerProtocolsPage() UiLogic.updateNewServerProtocolsPage()
} }
if (page === Page.ServerVpnProtocols) { if (page === PageEnum.ServerVpnProtocols) {
UiLogic.updateProtocolsPage() UiLogic.updateProtocolsPage()
} }
if (page === Page.AppSettings) { if (page === PageEnum.AppSettings) {
UiLogic.updateAppSettingsPage() UiLogic.updateAppSettingsPage()
} }
if (page === Page.NetworkSettings) { if (page === PageEnum.NetworkSettings) {
UiLogic.updateAppSettingsPage() UiLogic.updateAppSettingsPage()
} }
if (page === Page.Sites) { if (page === PageEnum.Sites) {
UiLogic.updateSitesPage() UiLogic.updateSitesPage()
} }
if (page === Page.Vpn) { if (page === PageEnum.Vpn) {
UiLogic.updateVpnPage() UiLogic.updateVpnPage()
} }
UiLogic.pushButtonNewServerConnectKeyChecked = false UiLogic.pushButtonNewServerConnectKeyChecked = false
@ -196,7 +201,7 @@ Window {
} else { } else {
pageLoader.push(pageComponent, {}, StackView.Immediate) pageLoader.push(pageComponent, {}, StackView.Immediate)
} }
if (page === Page.Start) { if (page === PageEnum.Start) {
UiLogic.pushButtonBackFromStartVisible = !pageLoader.empty UiLogic.pushButtonBackFromStartVisible = !pageLoader.empty
UiLogic.updateStartPage(); UiLogic.updateStartPage();
} }
@ -216,8 +221,8 @@ Window {
target: null target: null
} }
onCloseButtonClicked: { onCloseButtonClicked: {
if (UiLogic.currentPageValue === Page.Start || if (UiLogic.currentPageValue === PageEnum.Start ||
UiLogic.currentPageValue === Page.NewServer) { UiLogic.currentPageValue === PageEnum.NewServer) {
Qt.quit() Qt.quit()
} else { } else {
root.hide() root.hide()
@ -237,10 +242,9 @@ Window {
y: GC.isDesktop() ? titleBar.height : 0 y: GC.isDesktop() ? titleBar.height : 0
width: GC.screenWidth width: GC.screenWidth
height: GC.screenHeight height: GC.screenHeight
initialItem: page_vpn // initialItem: page_servers
onCurrentItemChanged: { onCurrentItemChanged: {
let pageEnum = root.getPageEnum(currentItem) let pageEnum = root.getPageEnum(currentItem)
console.debug(pageEnum)
UiLogic.currentPageValue = pageEnum UiLogic.currentPageValue = pageEnum
} }
} }
@ -345,6 +349,18 @@ Window {
onSetStartPage: { onSetStartPage: {
root.set_start_page(page, slide) root.set_start_page(page, slide)
} }
onShowPublicKeyWarning: {
publicKeyWarning.visible = true
}
onShowConnectErrorDialog: {
connectErrorDialog.visible = true
}
onShow: {
root.show()
}
onHide: {
root.hide()
}
} }
MessageDialog { MessageDialog {
id: closePrompt id: closePrompt
@ -414,4 +430,17 @@ Window {
} }
} }
} }
MessageDialog {
id: publicKeyWarning
title: "AmneziaVPN"
text: qsTr("It's public key. Private key required")
visible: false
}
MessageDialog {
id: connectErrorDialog
title: "AmneziaVPN"
text: UiLogic.dialogConnectErrorText
visible: false
}
} }

View file

@ -1,61 +0,0 @@
#include "server_widget.h"
#include "ui_server_widget.h"
#include "settings.h"
#include "protocols/protocols_defs.h"
ServerWidget::ServerWidget(const QJsonObject &server, bool isDefault, QWidget *parent) :
QWidget(parent),
ui(new Ui::ServerWidget)
{
ui->setupUi(this);
ui->pushButton_connect->hide();
ui->pushButton_share->hide();
//ui->pushButton_settings->hide();\\
ui->pushButton_settings->setGraphicsEffect(&eff);
animation.setTargetObject(&eff);
animation.setPropertyName("opacity");
animation.setDuration(150);
animation.setEasingCurve(QEasingCurve::InOutQuad);
eff.setOpacity(0);
QString desc = server.value(config_key::description).toString();
QString address = server.value(config_key::hostName).toString();
ui->label_address->setText(address);
if (desc.isEmpty()) {
ui->label_description->setText(address);
}
else {
ui->label_description->setText(desc);
}
ui->pushButton_default->setChecked(isDefault);
ui->pushButton_default->setDisabled(isDefault);
}
ServerWidget::~ServerWidget()
{
delete ui;
}
void ServerWidget::enterEvent(QEvent *e)
{
animation.setStartValue(0);
animation.setEndValue(1);
animation.start();
}
void ServerWidget::leaveEvent(QEvent *e)
{
animation.setStartValue(1);
animation.setEndValue(0);
animation.start();
}

View file

@ -1,30 +0,0 @@
#ifndef SERVER_WIDGET_H
#define SERVER_WIDGET_H
#include <QJsonObject>
#include <QWidget>
#include <QGraphicsOpacityEffect>
#include <QPropertyAnimation>
namespace Ui {
class ServerWidget;
}
class ServerWidget : public QWidget
{
Q_OBJECT
public:
explicit ServerWidget(const QJsonObject &server, bool isDefault, QWidget *parent = nullptr);
~ServerWidget();
Ui::ServerWidget *ui;
private:
void enterEvent(QEvent *e) override;
void leaveEvent(QEvent *e) override;
QPropertyAnimation animation;
QGraphicsOpacityEffect eff;
};
#endif // SERVER_WIDGET_H

View file

@ -0,0 +1,55 @@
#include "serversmodel.h"
ServersModel::ServersModel(QObject *parent) :
QAbstractListModel(parent)
{
}
void ServersModel::clearData()
{
beginResetModel();
content.clear();
endResetModel();
}
void ServersModel::setContent(const std::vector<ServerModelContent> &data)
{
beginResetModel();
content = data;
endResetModel();
}
int ServersModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return static_cast<int>(content.size());
}
QHash<int, QByteArray> ServersModel::roleNames() const {
QHash<int, QByteArray> roles;
roles[DescRole] = "desc";
roles[AddressRole] = "address";
roles[IsDefaultRole] = "is_default";
return roles;
}
QVariant ServersModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid() || index.row() < 0
|| index.row() >= static_cast<int>(content.size())) {
return QVariant();
}
if (role == DescRole) {
return content[index.row()].desc;
}
if (role == AddressRole) {
return content[index.row()].address;
}
if (role == IsDefaultRole) {
return content[index.row()].isDefault;
}
return QVariant();
}

39
client/ui/serversmodel.h Normal file
View file

@ -0,0 +1,39 @@
#ifndef SERVERSMODEL_H
#define SERVERSMODEL_H
#include <QAbstractListModel>
#include <vector>
#include <utility>
struct ServerModelContent {
QString desc;
QString address;
bool isDefault;
};
class ServersModel : public QAbstractListModel
{
Q_OBJECT
public:
ServersModel(QObject *parent = nullptr);
public:
enum SiteRoles {
DescRole = Qt::UserRole + 1,
AddressRole,
IsDefaultRole
};
void clearData();
void setContent(const std::vector<ServerModelContent>& data);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
protected:
QHash<int, QByteArray> roleNames() const override;
private:
std::vector<ServerModelContent> content;
};
#endif // SERVERSMODEL_H

View file

@ -1,8 +1,8 @@
#include "sites_model.h" #include "sites_model.h"
SitesModel::SitesModel(Settings::RouteMode mode, QObject *parent) SitesModel::SitesModel(Settings::RouteMode mode, QObject *parent)
: m_mode(mode), : QAbstractListModel(parent),
QAbstractTableModel(parent) m_mode(mode)
{ {
} }
@ -14,22 +14,13 @@ void SitesModel::resetCache()
endResetModel(); endResetModel();
} }
QVariant SitesModel::headerData(int section, Qt::Orientation orientation, int role) const
{
// FIXME: Implement me!
return QVariant();
}
int SitesModel::rowCount(const QModelIndex &parent) const int SitesModel::rowCount(const QModelIndex &parent) const
{ {
Q_UNUSED(parent)
if (!m_cacheReady) genCache(); if (!m_cacheReady) genCache();
return m_ipsCache.size(); return m_ipsCache.size();
} }
int SitesModel::columnCount(const QModelIndex &parent) const
{
return 2;
}
QVariant SitesModel::data(const QModelIndex &index, int role) const QVariant SitesModel::data(const QModelIndex &index, int role) const
{ {
@ -38,24 +29,40 @@ QVariant SitesModel::data(const QModelIndex &index, int role) const
if (!m_cacheReady) genCache(); if (!m_cacheReady) genCache();
if (role == Qt::DisplayRole){ if (role == SitesModel::UrlRole || role == SitesModel::IpRole) {
if (m_ipsCache.isEmpty()) return QVariant(); if (m_ipsCache.isEmpty()) return QVariant();
if (index.column() == 0) { if (role == SitesModel::UrlRole) {
return m_ipsCache.at(index.row()).first; return m_ipsCache.at(index.row()).first;
} }
if (index.column() == 1) { if (role == SitesModel::IpRole) {
return m_ipsCache.at(index.row()).second; return m_ipsCache.at(index.row()).second;
} }
} }
// if (role == Qt::TextAlignmentRole && index.column() == 1) { // if (role == Qt::TextAlignmentRole && index.column() == 1) {
// return Qt::AlignRight; // return Qt::AlignRight;
// } // }
return QVariant(); return QVariant();
} }
QVariant SitesModel::data(int row, int column)
{
if (row < 0 || row >= rowCount() || column < 0 || column >= 2) {
return QVariant();
}
if (!m_cacheReady) genCache();
if (column == 0) {
return m_ipsCache.at(row).first;
}
if (column == 1) {
return m_ipsCache.at(row).second;
}
return QVariant();
}
void SitesModel::genCache() const void SitesModel::genCache() const
{ {
qDebug() << "SitesModel::genCache"; qDebug() << "SitesModel::genCache";
@ -70,3 +77,10 @@ void SitesModel::genCache() const
m_cacheReady= true; m_cacheReady= true;
} }
QHash<int, QByteArray> SitesModel::roleNames() const {
QHash<int, QByteArray> roles;
roles[UrlRole] = "url_path";
roles[IpRole] = "ip";
return roles;
}

View file

@ -1,26 +1,31 @@
#ifndef SITESMODEL_H #ifndef SITESMODEL_H
#define SITESMODEL_H #define SITESMODEL_H
#include <QAbstractTableModel> #include <QAbstractListModel>
#include "settings.h" #include "settings.h"
class SitesModel : public QAbstractTableModel class SitesModel : public QAbstractListModel
{ {
Q_OBJECT Q_OBJECT
public: public:
enum SiteRoles {
UrlRole = Qt::UserRole + 1,
IpRole
};
explicit SitesModel(Settings::RouteMode mode, QObject *parent = nullptr); explicit SitesModel(Settings::RouteMode mode, QObject *parent = nullptr);
void resetCache(); void resetCache();
// Header:
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
// Basic functionality: // Basic functionality:
int rowCount(const QModelIndex &parent = QModelIndex()) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QVariant data(int row, int column);
protected:
QHash<int, QByteArray> roleNames() const override;
private: private:
void genCache() const; void genCache() const;

File diff suppressed because it is too large Load diff

View file

@ -1,25 +1,30 @@
#ifndef UILOGIC_H #ifndef UILOGIC_H
#define UILOGIC_H #define UILOGIC_H
#include <QLabel>
#include <QListWidget>
#include <QProgressBar>
#include <QPushButton>
#include <QRegExpValidator> #include <QRegExpValidator>
#include <QStack>
#include <QStringListModel>
#include <QSystemTrayIcon>
#include <QQmlEngine> #include <QQmlEngine>
#include <functional>
#include "3rd/QRCodeGenerator/QRCodeGenerator.h" #include "3rd/QRCodeGenerator/QRCodeGenerator.h"
#include "framelesswindow.h"
#include "protocols/vpnprotocol.h" #include "protocols/vpnprotocol.h"
#include "settings.h" #include "settings.h"
#include "sites_model.h" #include "sites_model.h"
#include "serversmodel.h"
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
@ -94,24 +99,134 @@ class UiLogic : public QObject
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(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 pushButtonProtoCloakSaveVisible READ getPushButtonProtoCloakSaveVisible WRITE setPushButtonProtoCloakSaveVisible NOTIFY pushButtonProtoCloakSaveVisibleChanged)
Q_PROPERTY(bool progressBarProtoCloakResetVisible READ getProgressBarProtoCloakResetVisible WRITE setProgressBarProtoCloakResetVisible NOTIFY progressBarProtoCloakResetVisibleChanged)
Q_PROPERTY(bool lineEditProtoCloakPortEnabled READ getLineEditProtoCloakPortEnabled WRITE setLineEditProtoCloakPortEnabled NOTIFY lineEditProtoCloakPortEnabledChanged)
Q_PROPERTY(bool widgetProtoSsEnabled READ getWidgetProtoSsEnabled WRITE setWidgetProtoSsEnabled NOTIFY widgetProtoSsEnabledChanged)
Q_PROPERTY(bool pushButtonProtoShadowsocksSaveVisible READ getPushButtonProtoShadowsocksSaveVisible WRITE setPushButtonProtoShadowsocksSaveVisible NOTIFY pushButtonProtoShadowsocksSaveVisibleChanged)
Q_PROPERTY(bool progressBarProtoShadowsocksResetVisible READ getProgressBarProtoShadowsocksResetVisible WRITE setProgressBarProtoShadowsocksResetVisible NOTIFY progressBarProtoShadowsocksResetVisibleChanged)
Q_PROPERTY(bool lineEditProtoShadowsocksPortEnabled READ getLineEditProtoShadowsocksPortEnabled WRITE setLineEditProtoShadowsocksPortEnabled NOTIFY lineEditProtoShadowsocksPortEnabledChanged)
Q_PROPERTY(bool widgetProtoOpenvpnEnabled READ getWidgetProtoOpenvpnEnabled WRITE setWidgetProtoOpenvpnEnabled NOTIFY widgetProtoOpenvpnEnabledChanged)
Q_PROPERTY(bool pushButtonProtoOpenvpnSaveVisible READ getPushButtonProtoOpenvpnSaveVisible WRITE setPushButtonProtoOpenvpnSaveVisible NOTIFY pushButtonProtoOpenvpnSaveVisibleChanged)
Q_PROPERTY(bool progressBarProtoOpenvpnResetVisible READ getProgressBarProtoOpenvpnResetVisible WRITE setProgressBarProtoOpenvpnResetVisible NOTIFY progressBarProtoOpenvpnResetVisibleChanged)
Q_PROPERTY(bool radioButtonProtoOpenvpnUdpEnabled READ getRadioButtonProtoOpenvpnUdpEnabled WRITE setRadioButtonProtoOpenvpnUdpEnabled NOTIFY radioButtonProtoOpenvpnUdpEnabledChanged)
Q_PROPERTY(bool radioButtonProtoOpenvpnTcpEnabled READ getRadioButtonProtoOpenvpnTcpEnabled WRITE setRadioButtonProtoOpenvpnTcpEnabled NOTIFY radioButtonProtoOpenvpnTcpEnabledChanged)
Q_PROPERTY(bool radioButtonProtoOpenvpnTcpChecked READ getRadioButtonProtoOpenvpnTcpChecked WRITE setRadioButtonProtoOpenvpnTcpChecked NOTIFY radioButtonProtoOpenvpnTcpCheckedChanged)
Q_PROPERTY(bool lineEditProtoOpenvpnPortEnabled READ getLineEditProtoOpenvpnPortEnabled WRITE setLineEditProtoOpenvpnPortEnabled NOTIFY lineEditProtoOpenvpnPortEnabledChanged)
Q_PROPERTY(bool pushButtonProtoOpenvpnContInstallChecked READ getPushButtonProtoOpenvpnContInstallChecked WRITE setPushButtonProtoOpenvpnContInstallChecked NOTIFY pushButtonProtoOpenvpnContInstallCheckedChanged)
Q_PROPERTY(bool pushButtonProtoSsOpenvpnContInstallChecked READ getPushButtonProtoSsOpenvpnContInstallChecked WRITE setPushButtonProtoSsOpenvpnContInstallChecked NOTIFY pushButtonProtoSsOpenvpnContInstallCheckedChanged)
Q_PROPERTY(bool pushButtonProtoCloakOpenvpnContInstallChecked READ getPushButtonProtoCloakOpenvpnContInstallChecked WRITE setPushButtonProtoCloakOpenvpnContInstallChecked NOTIFY pushButtonProtoCloakOpenvpnContInstallCheckedChanged)
Q_PROPERTY(bool pushButtonProtoWireguardContInstallChecked READ getPushButtonProtoWireguardContInstallChecked WRITE setPushButtonProtoWireguardContInstallChecked NOTIFY pushButtonProtoWireguardContInstallCheckedChanged)
Q_PROPERTY(bool pushButtonProtoOpenvpnContInstallEnabled READ getPushButtonProtoOpenvpnContInstallEnabled WRITE setPushButtonProtoOpenvpnContInstallEnabled NOTIFY pushButtonProtoOpenvpnContInstallEnabledChanged)
Q_PROPERTY(bool pushButtonProtoSsOpenvpnContInstallEnabled READ getPushButtonProtoSsOpenvpnContInstallEnabled WRITE setPushButtonProtoSsOpenvpnContInstallEnabled NOTIFY pushButtonProtoSsOpenvpnContInstallEnabledChanged)
Q_PROPERTY(bool pushButtonProtoCloakOpenvpnContInstallEnabled READ getPushButtonProtoCloakOpenvpnContInstallEnabled WRITE setPushButtonProtoCloakOpenvpnContInstallEnabled NOTIFY pushButtonProtoCloakOpenvpnContInstallEnabledChanged)
Q_PROPERTY(bool pushButtonProtoWireguardContInstallEnabled READ getPushButtonProtoWireguardContInstallEnabled WRITE setPushButtonProtoWireguardContInstallEnabled NOTIFY pushButtonProtoWireguardContInstallEnabledChanged)
Q_PROPERTY(bool pushButtonProtoOpenvpnContDefaultChecked READ getPushButtonProtoOpenvpnContDefaultChecked WRITE setPushButtonProtoOpenvpnContDefaultChecked NOTIFY pushButtonProtoOpenvpnContDefaultCheckedChanged)
Q_PROPERTY(bool pushButtonProtoSsOpenvpnContDefaultChecked READ getPushButtonProtoSsOpenvpnContDefaultChecked WRITE setPushButtonProtoSsOpenvpnContDefaultChecked NOTIFY pushButtonProtoSsOpenvpnContDefaultCheckedChanged)
Q_PROPERTY(bool pushButtonProtoCloakOpenvpnContDefaultChecked READ getPushButtonProtoCloakOpenvpnContDefaultChecked WRITE setPushButtonProtoCloakOpenvpnContDefaultChecked NOTIFY pushButtonProtoCloakOpenvpnContDefaultCheckedChanged)
Q_PROPERTY(bool pushButtonProtoWireguardContDefaultChecked READ getPushButtonProtoWireguardContDefaultChecked WRITE setPushButtonProtoWireguardContDefaultChecked NOTIFY pushButtonProtoWireguardContDefaultCheckedChanged)
Q_PROPERTY(bool pushButtonProtoOpenvpnContDefaultVisible READ getPushButtonProtoOpenvpnContDefaultVisible WRITE setPushButtonProtoOpenvpnContDefaultVisible NOTIFY pushButtonProtoOpenvpnContDefaultVisibleChanged)
Q_PROPERTY(bool pushButtonProtoSsOpenvpnContDefaultVisible READ getPushButtonProtoSsOpenvpnContDefaultVisible WRITE setPushButtonProtoSsOpenvpnContDefaultVisible NOTIFY pushButtonProtoSsOpenvpnContDefaultVisibleChanged)
Q_PROPERTY(bool pushButtonProtoCloakOpenvpnContDefaultVisible READ getPushButtonProtoCloakOpenvpnContDefaultVisible WRITE setPushButtonProtoCloakOpenvpnContDefaultVisible NOTIFY pushButtonProtoCloakOpenvpnContDefaultVisibleChanged)
Q_PROPERTY(bool pushButtonProtoWireguardContDefaultVisible READ getPushButtonProtoWireguardContDefaultVisible WRITE setPushButtonProtoWireguardContDefaultVisible NOTIFY pushButtonProtoWireguardContDefaultVisibleChanged)
Q_PROPERTY(bool pushButtonProtoOpenvpnContShareVisible READ getPushButtonProtoOpenvpnContShareVisible WRITE setPushButtonProtoOpenvpnContShareVisible NOTIFY pushButtonProtoOpenvpnContShareVisibleChanged)
Q_PROPERTY(bool pushButtonProtoSsOpenvpnContShareVisible READ getPushButtonProtoSsOpenvpnContShareVisible WRITE setPushButtonProtoSsOpenvpnContShareVisible NOTIFY pushButtonProtoSsOpenvpnContShareVisibleChanged)
Q_PROPERTY(bool pushButtonProtoCloakOpenvpnContShareVisible READ getPushButtonProtoCloakOpenvpnContShareVisible WRITE setPushButtonProtoCloakOpenvpnContShareVisible NOTIFY pushButtonProtoCloakOpenvpnContShareVisibleChanged)
Q_PROPERTY(bool pushButtonProtoWireguardContShareVisible READ getPushButtonProtoWireguardContShareVisible WRITE setPushButtonProtoWireguardContShareVisible NOTIFY pushButtonProtoWireguardContShareVisibleChanged)
Q_PROPERTY(bool frameOpenvpnSettingsVisible READ getFrameOpenvpnSettingsVisible WRITE setFrameOpenvpnSettingsVisible NOTIFY frameOpenvpnSettingsVisibleChanged)
Q_PROPERTY(bool frameOpenvpnSsSettingsVisible READ getFrameOpenvpnSsSettingsVisible WRITE setFrameOpenvpnSsSettingsVisible NOTIFY frameOpenvpnSsSettingsVisibleChanged)
Q_PROPERTY(bool frameOpenvpnSsCloakSettingsVisible READ getFrameOpenvpnSsCloakSettingsVisible WRITE setFrameOpenvpnSsCloakSettingsVisible NOTIFY frameOpenvpnSsCloakSettingsVisibleChanged)
Q_PROPERTY(bool progressBarProtocolsContainerReinstallVisible READ getProgressBarProtocolsContainerReinstallVisible WRITE setProgressBarProtocolsContainerReinstallVisible NOTIFY progressBarProtocolsContainerReinstallVisibleChanged)
Q_PROPERTY(QString labelSpeedReceivedText READ getLabelSpeedReceivedText WRITE setLabelSpeedReceivedText NOTIFY labelSpeedReceivedTextChanged)
Q_PROPERTY(QString labelSpeedSentText READ getLabelSpeedSentText WRITE setLabelSpeedSentText NOTIFY labelSpeedSentTextChanged)
Q_PROPERTY(QString labelStateText READ getLabelStateText WRITE setLabelStateText NOTIFY labelStateTextChanged)
Q_PROPERTY(bool pushButtonConnectEnabled READ getPushButtonConnectEnabled WRITE setPushButtonConnectEnabled NOTIFY pushButtonConnectEnabledChanged)
Q_PROPERTY(bool widgetVpnModeEnabled READ getWidgetVpnModeEnabled WRITE setWidgetVpnModeEnabled NOTIFY widgetVpnModeEnabledChanged)
Q_PROPERTY(QString labelErrorText READ getLabelErrorText WRITE setLabelErrorText NOTIFY labelErrorTextChanged)
Q_PROPERTY(bool pushButtonNewServerConnectEnabled READ getPushButtonNewServerConnectEnabled WRITE setPushButtonNewServerConnectEnabled NOTIFY pushButtonNewServerConnectEnabledChanged)
Q_PROPERTY(QString pushButtonNewServerConnectText READ getPushButtonNewServerConnectText WRITE setPushButtonNewServerConnectText NOTIFY pushButtonNewServerConnectTextChanged)
Q_PROPERTY(QString dialogConnectErrorText READ getDialogConnectErrorText WRITE setDialogConnectErrorText NOTIFY dialogConnectErrorTextChanged)
Q_PROPERTY(bool pageServerSettingsEnabled READ getPageServerSettingsEnabled WRITE setPageServerSettingsEnabled NOTIFY pageServerSettingsEnabledChanged)
Q_PROPERTY(QString pushButtonServerSettingsClearText READ getPushButtonServerSettingsClearText WRITE setPushButtonServerSettingsClearText NOTIFY pushButtonServerSettingsClearTextChanged)
Q_PROPERTY(bool pageShareAmneziaVisible READ getPageShareAmneziaVisible WRITE setPageShareAmneziaVisible NOTIFY pageShareAmneziaVisibleChanged)
Q_PROPERTY(bool pageShareOpenvpnVisible READ getPageShareOpenvpnVisible WRITE setPageShareOpenvpnVisible NOTIFY pageShareOpenvpnVisibleChanged)
Q_PROPERTY(bool pageShareShadowsocksVisible READ getPageShareShadowsocksVisible WRITE setPageShareShadowsocksVisible NOTIFY pageShareShadowsocksVisibleChanged)
Q_PROPERTY(bool pageShareCloakVisible READ getPageShareCloakVisible WRITE setPageShareCloakVisible NOTIFY pageShareCloakVisibleChanged)
Q_PROPERTY(bool pageShareFullAccessVisible READ getPageShareFullAccessVisible WRITE setPageShareFullAccessVisible NOTIFY pageShareFullAccessVisibleChanged)
Q_PROPERTY(QString textEditShareOpenvpnCodeText READ getTextEditShareOpenvpnCodeText WRITE setTextEditShareOpenvpnCodeText NOTIFY textEditShareOpenvpnCodeTextChanged)
Q_PROPERTY(bool pushButtonShareOpenvpnCopyEnabled READ getPushButtonShareOpenvpnCopyEnabled WRITE setPushButtonShareOpenvpnCopyEnabled NOTIFY pushButtonShareOpenvpnCopyEnabledChanged)
Q_PROPERTY(bool pushButtonShareOpenvpnSaveEnabled READ getPushButtonShareOpenvpnSaveEnabled WRITE setPushButtonShareOpenvpnSaveEnabled NOTIFY pushButtonShareOpenvpnSaveEnabledChanged)
Q_PROPERTY(int toolBoxShareConnectionCurrentIndex READ getToolBoxShareConnectionCurrentIndex WRITE setToolBoxShareConnectionCurrentIndex NOTIFY toolBoxShareConnectionCurrentIndexChanged)
Q_PROPERTY(bool pushButtonShareSsCopyEnabled READ getPushButtonShareSsCopyEnabled WRITE setPushButtonShareSsCopyEnabled NOTIFY pushButtonShareSsCopyEnabledChanged)
Q_PROPERTY(QString lineEditShareSsStringText READ getLineEditShareSsStringText WRITE setLineEditShareSsStringText NOTIFY lineEditShareSsStringTextChanged)
Q_PROPERTY(QString labelShareSsQrCodeText READ getLabelShareSsQrCodeText WRITE setLabelShareSsQrCodeText NOTIFY labelShareSsQrCodeTextChanged)
Q_PROPERTY(QString labelShareSsServerText READ getLabelShareSsServerText WRITE setLabelShareSsServerText NOTIFY labelShareSsServerTextChanged)
Q_PROPERTY(QString labelShareSsPortText READ getLabelShareSsPortText WRITE setLabelShareSsPortText NOTIFY labelShareSsPortTextChanged)
Q_PROPERTY(QString labelShareSsMethodText READ getLabelShareSsMethodText WRITE setLabelShareSsMethodText NOTIFY labelShareSsMethodTextChanged)
Q_PROPERTY(QString labelShareSsPasswordText READ getLabelShareSsPasswordText WRITE setLabelShareSsPasswordText NOTIFY labelShareSsPasswordTextChanged)
Q_PROPERTY(QString plainTextEditShareCloakText READ getPlainTextEditShareCloakText WRITE setPlainTextEditShareCloakText NOTIFY plainTextEditShareCloakTextChanged)
Q_PROPERTY(bool pushButtonShareCloakCopyEnabled READ getPushButtonShareCloakCopyEnabled WRITE setPushButtonShareCloakCopyEnabled NOTIFY pushButtonShareCloakCopyEnabledChanged)
Q_PROPERTY(QString textEditShareFullCodeText READ getTextEditShareFullCodeText WRITE setTextEditShareFullCodeText NOTIFY textEditShareFullCodeTextChanged)
Q_PROPERTY(QString textEditShareAmneziaCodeText READ getTextEditShareAmneziaCodeText WRITE setTextEditShareAmneziaCodeText NOTIFY textEditShareAmneziaCodeTextChanged)
Q_PROPERTY(QString pushButtonShareFullCopyText READ getPushButtonShareFullCopyText WRITE setPushButtonShareFullCopyText NOTIFY pushButtonShareFullCopyTextChanged)
Q_PROPERTY(QString pushButtonShareAmneziaCopyText READ getPushButtonShareAmneziaCopyText WRITE setPushButtonShareAmneziaCopyText NOTIFY pushButtonShareAmneziaCopyTextChanged)
Q_PROPERTY(QString pushButtonShareOpenvpnCopyText READ getPushButtonShareOpenvpnCopyText WRITE setPushButtonShareOpenvpnCopyText NOTIFY pushButtonShareOpenvpnCopyTextChanged)
Q_PROPERTY(QString pushButtonShareSsCopyText READ getPushButtonShareSsCopyText WRITE setPushButtonShareSsCopyText NOTIFY pushButtonShareSsCopyTextChanged)
Q_PROPERTY(QString pushButtonShareCloakCopyText READ getPushButtonShareCloakCopyText WRITE setPushButtonShareCloakCopyText NOTIFY pushButtonShareCloakCopyTextChanged)
Q_PROPERTY(bool pushButtonShareAmneziaGenerateEnabled READ getPushButtonShareAmneziaGenerateEnabled WRITE setPushButtonShareAmneziaGenerateEnabled NOTIFY pushButtonShareAmneziaGenerateEnabledChanged)
Q_PROPERTY(bool pushButtonShareAmneziaCopyEnabled READ getPushButtonShareAmneziaCopyEnabled WRITE setPushButtonShareAmneziaCopyEnabled NOTIFY pushButtonShareAmneziaCopyEnabledChanged)
Q_PROPERTY(QString pushButtonShareAmneziaGenerateText READ getPushButtonShareAmneziaGenerateText WRITE setPushButtonShareAmneziaGenerateText NOTIFY pushButtonShareAmneziaGenerateTextChanged)
Q_PROPERTY(bool pushButtonShareOpenvpnGenerateEnabled READ getPushButtonShareOpenvpnGenerateEnabled WRITE setPushButtonShareOpenvpnGenerateEnabled NOTIFY pushButtonShareOpenvpnGenerateEnabledChanged)
Q_PROPERTY(QString pushButtonShareOpenvpnGenerateText READ getPushButtonShareOpenvpnGenerateText WRITE setPushButtonShareOpenvpnGenerateText NOTIFY pushButtonShareOpenvpnGenerateTextChanged)
Q_PROPERTY(bool pageNewServerConfiguringEnabled READ getPageNewServerConfiguringEnabled WRITE setPageNewServerConfiguringEnabled NOTIFY pageNewServerConfiguringEnabledChanged)
Q_PROPERTY(bool labelNewServerConfiguringWaitInfoVisible READ getLabelNewServerConfiguringWaitInfoVisible WRITE setLabelNewServerConfiguringWaitInfoVisible NOTIFY labelNewServerConfiguringWaitInfoVisibleChanged)
Q_PROPERTY(QString labelNewServerConfiguringWaitInfoText READ getLabelNewServerConfiguringWaitInfoText WRITE setLabelNewServerConfiguringWaitInfoText NOTIFY labelNewServerConfiguringWaitInfoTextChanged)
Q_PROPERTY(bool progressBarNewServerConfiguringVisible READ getProgressBarNewServerConfiguringVisible WRITE setProgressBarNewServerConfiguringVisible NOTIFY progressBarNewServerConfiguringVisibleChanged)
Q_PROPERTY(int progressBarNewServerConfiguringMaximium READ getProgressBarNewServerConfiguringMaximium WRITE setProgressBarNewServerConfiguringMaximium NOTIFY progressBarNewServerConfiguringMaximiumChanged)
Q_PROPERTY(bool progressBarNewServerConfiguringTextVisible READ getProgressBarNewServerConfiguringTextVisible WRITE setProgressBarNewServerConfiguringTextVisible NOTIFY progressBarNewServerConfiguringTextVisibleChanged)
Q_PROPERTY(QString progressBarNewServerConfiguringText READ getProgressBarNewServerConfiguringText WRITE setProgressBarNewServerConfiguringText NOTIFY progressBarNewServerConfiguringTextChanged)
Q_PROPERTY(bool pageServerProtocolsEnabled READ getPageServerProtocolsEnabled WRITE setPageServerProtocolsEnabled NOTIFY pageServerProtocolsEnabledChanged)
Q_PROPERTY(int progressBarProtocolsContainerReinstallValue READ getProgressBarProtocolsContainerReinstallValue WRITE setProgressBarProtocolsContainerReinstallValue NOTIFY progressBarProtocolsContainerReinstallValueChanged)
Q_PROPERTY(int progressBarProtocolsContainerReinstallMaximium READ getProgressBarProtocolsContainerReinstallMaximium WRITE setProgressBarProtocolsContainerReinstallMaximium NOTIFY progressBarProtocolsContainerReinstallMaximiumChanged)
Q_PROPERTY(bool comboBoxProtoOpenvpnCipherEnabled READ getComboBoxProtoOpenvpnCipherEnabled WRITE setComboBoxProtoOpenvpnCipherEnabled NOTIFY comboBoxProtoOpenvpnCipherEnabledChanged)
Q_PROPERTY(bool comboBoxProtoOpenvpnHashEnabled READ getComboBoxProtoOpenvpnHashEnabled WRITE setComboBoxProtoOpenvpnHashEnabled NOTIFY comboBoxProtoOpenvpnHashEnabledChanged)
Q_PROPERTY(bool pageProtoOpenvpnEnabled READ getPageProtoOpenvpnEnabled WRITE setPageProtoOpenvpnEnabled NOTIFY pageProtoOpenvpnEnabledChanged)
Q_PROPERTY(bool labelProtoOpenvpnInfoVisible READ getLabelProtoOpenvpnInfoVisible WRITE setLabelProtoOpenvpnInfoVisible NOTIFY labelProtoOpenvpnInfoVisibleChanged)
Q_PROPERTY(QString labelProtoOpenvpnInfoText READ getLabelProtoOpenvpnInfoText WRITE setLabelProtoOpenvpnInfoText NOTIFY labelProtoOpenvpnInfoTextChanged)
Q_PROPERTY(int progressBarProtoOpenvpnResetValue READ getProgressBarProtoOpenvpnResetValue WRITE setProgressBarProtoOpenvpnResetValue NOTIFY progressBarProtoOpenvpnResetValueChanged)
Q_PROPERTY(int progressBarProtoOpenvpnResetMaximium READ getProgressBarProtoOpenvpnResetMaximium WRITE setProgressBarProtoOpenvpnResetMaximium NOTIFY progressBarProtoOpenvpnResetMaximiumChanged)
Q_PROPERTY(bool pageProtoShadowsocksEnabled READ getPageProtoShadowsocksEnabled WRITE setPageProtoShadowsocksEnabled NOTIFY pageProtoShadowsocksEnabledChanged)
Q_PROPERTY(bool labelProtoShadowsocksInfoVisible READ getLabelProtoShadowsocksInfoVisible WRITE setLabelProtoShadowsocksInfoVisible NOTIFY labelProtoShadowsocksInfoVisibleChanged)
Q_PROPERTY(QString labelProtoShadowsocksInfoText READ getLabelProtoShadowsocksInfoText WRITE setLabelProtoShadowsocksInfoText NOTIFY labelProtoShadowsocksInfoTextChanged)
Q_PROPERTY(int progressBarProtoShadowsocksResetValue READ getProgressBarProtoShadowsocksResetValue WRITE setProgressBarProtoShadowsocksResetValue NOTIFY progressBarProtoShadowsocksResetValueChanged)
Q_PROPERTY(int progressBarProtoShadowsocksResetMaximium READ getProgressBarProtoShadowsocksResetMaximium WRITE setProgressBarProtoShadowsocksResetMaximium NOTIFY progressBarProtoShadowsocksResetMaximiumChanged)
Q_PROPERTY(bool pageProtoCloakEnabled READ getPageProtoCloakEnabled WRITE setPageProtoCloakEnabled NOTIFY pageProtoCloakEnabledChanged)
Q_PROPERTY(bool labelProtoCloakInfoVisible READ getLabelProtoCloakInfoVisible WRITE setLabelProtoCloakInfoVisible NOTIFY labelProtoCloakInfoVisibleChanged)
Q_PROPERTY(QString labelProtoCloakInfoText READ getLabelProtoCloakInfoText WRITE setLabelProtoCloakInfoText NOTIFY labelProtoCloakInfoTextChanged)
Q_PROPERTY(int progressBarProtoCloakResetValue READ getProgressBarProtoCloakResetValue WRITE setProgressBarProtoCloakResetValue NOTIFY progressBarProtoCloakResetValueChanged)
Q_PROPERTY(int progressBarProtoCloakResetMaximium READ getProgressBarProtoCloakResetMaximium WRITE setProgressBarProtoCloakResetMaximium NOTIFY progressBarProtoCloakResetMaximiumChanged)
Q_PROPERTY(QObject* serverListModel READ getServerListModel CONSTANT)
Q_PROPERTY(QString pushButtonServerSettingsClearClientCacheText READ getPushButtonServerSettingsClearClientCacheText WRITE setPushButtonServerSettingsClearClientCacheText NOTIFY pushButtonServerSettingsClearClientCacheTextChanged)
public: public:
explicit UiLogic(QObject *parent = nullptr); explicit UiLogic(QObject *parent = nullptr);
// ~UiLogic(); ~UiLogic();
void showOnStartup();
enum Page {Start, NewServer, NewServerProtocols, Vpn,
Wizard, WizardLow, WizardMedium, WizardHigh, WizardVpnMode, ServerConfiguring,
GeneralSettings, AppSettings, NetworkSettings, ServerSettings,
ServerVpnProtocols, ServersList, ShareConnection, Sites,
OpenVpnSettings, ShadowSocksSettings, CloakSettings};
Q_ENUM(Page)
// void showOnStartup();
Q_INVOKABLE void initalizeUiLogic(); Q_INVOKABLE void initalizeUiLogic();
static void declareQML() { static void declareQML() {
qmlRegisterType<UiLogic>("Page", 1, 0, "Style"); qmlRegisterUncreatableMetaObject(
PageEnumNS::staticMetaObject,
"PageEnum",
1, 0,
"PageEnum",
"Error: only enums"
);
} }
bool getFrameWireguardSettingsVisible() const; bool getFrameWireguardSettingsVisible() const;
void setFrameWireguardSettingsVisible(bool frameWireguardSettingsVisible); void setFrameWireguardSettingsVisible(bool frameWireguardSettingsVisible);
@ -254,6 +369,229 @@ public:
QString getIpAddressValidatorRegex() const; 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;
void setWidgetProtoCloakEnabled(bool widgetProtoCloakEnabled);
bool getPushButtonProtoCloakSaveVisible() const;
void setPushButtonProtoCloakSaveVisible(bool pushButtonProtoCloakSaveVisible);
bool getProgressBarProtoCloakResetVisible() const;
void setProgressBarProtoCloakResetVisible(bool progressBarProtoCloakResetVisible);
bool getLineEditProtoCloakPortEnabled() const;
void setLineEditProtoCloakPortEnabled(bool lineEditProtoCloakPortEnabled);
bool getWidgetProtoSsEnabled() const;
void setWidgetProtoSsEnabled(bool widgetProtoSsEnabled);
bool getPushButtonProtoShadowsocksSaveVisible() const;
void setPushButtonProtoShadowsocksSaveVisible(bool pushButtonProtoShadowsocksSaveVisible);
bool getProgressBarProtoShadowsocksResetVisible() const;
void setProgressBarProtoShadowsocksResetVisible(bool progressBarProtoShadowsocksResetVisible);
bool getLineEditProtoShadowsocksPortEnabled() const;
void setLineEditProtoShadowsocksPortEnabled(bool lineEditProtoShadowsocksPortEnabled);
bool getWidgetProtoOpenvpnEnabled() const;
void setWidgetProtoOpenvpnEnabled(bool widgetProtoOpenvpnEnabled);
bool getPushButtonProtoOpenvpnSaveVisible() const;
void setPushButtonProtoOpenvpnSaveVisible(bool pushButtonProtoOpenvpnSaveVisible);
bool getProgressBarProtoOpenvpnResetVisible() const;
void setProgressBarProtoOpenvpnResetVisible(bool progressBarProtoOpenvpnResetVisible);
bool getRadioButtonProtoOpenvpnUdpEnabled() const;
void setRadioButtonProtoOpenvpnUdpEnabled(bool radioButtonProtoOpenvpnUdpEnabled);
bool getRadioButtonProtoOpenvpnTcpEnabled() const;
void setRadioButtonProtoOpenvpnTcpEnabled(bool radioButtonProtoOpenvpnTcpEnabled);
bool getRadioButtonProtoOpenvpnTcpChecked() const;
void setRadioButtonProtoOpenvpnTcpChecked(bool radioButtonProtoOpenvpnTcpChecked);
bool getLineEditProtoOpenvpnPortEnabled() const;
void setLineEditProtoOpenvpnPortEnabled(bool lineEditProtoOpenvpnPortEnabled);
bool getPushButtonProtoOpenvpnContInstallChecked() const;
void setPushButtonProtoOpenvpnContInstallChecked(bool pushButtonProtoOpenvpnContInstallChecked);
bool getPushButtonProtoSsOpenvpnContInstallChecked() const;
void setPushButtonProtoSsOpenvpnContInstallChecked(bool pushButtonProtoSsOpenvpnContInstallChecked);
bool getPushButtonProtoCloakOpenvpnContInstallChecked() const;
void setPushButtonProtoCloakOpenvpnContInstallChecked(bool pushButtonProtoCloakOpenvpnContInstallChecked);
bool getPushButtonProtoWireguardContInstallChecked() const;
void setPushButtonProtoWireguardContInstallChecked(bool pushButtonProtoWireguardContInstallChecked);
bool getPushButtonProtoOpenvpnContInstallEnabled() const;
void setPushButtonProtoOpenvpnContInstallEnabled(bool pushButtonProtoOpenvpnContInstallEnabled);
bool getPushButtonProtoSsOpenvpnContInstallEnabled() const;
void setPushButtonProtoSsOpenvpnContInstallEnabled(bool pushButtonProtoSsOpenvpnContInstallEnabled);
bool getPushButtonProtoCloakOpenvpnContInstallEnabled() const;
void setPushButtonProtoCloakOpenvpnContInstallEnabled(bool pushButtonProtoCloakOpenvpnContInstallEnabled);
bool getPushButtonProtoWireguardContInstallEnabled() const;
void setPushButtonProtoWireguardContInstallEnabled(bool pushButtonProtoWireguardContInstallEnabled);
bool getPushButtonProtoOpenvpnContDefaultChecked() const;
void setPushButtonProtoOpenvpnContDefaultChecked(bool pushButtonProtoOpenvpnContDefaultChecked);
bool getPushButtonProtoSsOpenvpnContDefaultChecked() const;
void setPushButtonProtoSsOpenvpnContDefaultChecked(bool pushButtonProtoSsOpenvpnContDefaultChecked);
bool getPushButtonProtoCloakOpenvpnContDefaultChecked() const;
void setPushButtonProtoCloakOpenvpnContDefaultChecked(bool pushButtonProtoCloakOpenvpnContDefaultChecked);
bool getPushButtonProtoWireguardContDefaultChecked() const;
void setPushButtonProtoWireguardContDefaultChecked(bool pushButtonProtoWireguardContDefaultChecked);
bool getPushButtonProtoOpenvpnContDefaultVisible() const;
void setPushButtonProtoOpenvpnContDefaultVisible(bool pushButtonProtoOpenvpnContDefaultVisible);
bool getPushButtonProtoSsOpenvpnContDefaultVisible() const;
void setPushButtonProtoSsOpenvpnContDefaultVisible(bool pushButtonProtoSsOpenvpnContDefaultVisible);
bool getPushButtonProtoCloakOpenvpnContDefaultVisible() const;
void setPushButtonProtoCloakOpenvpnContDefaultVisible(bool pushButtonProtoCloakOpenvpnContDefaultVisible);
bool getPushButtonProtoWireguardContDefaultVisible() const;
void setPushButtonProtoWireguardContDefaultVisible(bool pushButtonProtoWireguardContDefaultVisible);
bool getPushButtonProtoOpenvpnContShareVisible() const;
void setPushButtonProtoOpenvpnContShareVisible(bool pushButtonProtoOpenvpnContShareVisible);
bool getPushButtonProtoSsOpenvpnContShareVisible() const;
void setPushButtonProtoSsOpenvpnContShareVisible(bool pushButtonProtoSsOpenvpnContShareVisible);
bool getPushButtonProtoCloakOpenvpnContShareVisible() const;
void setPushButtonProtoCloakOpenvpnContShareVisible(bool pushButtonProtoCloakOpenvpnContShareVisible);
bool getPushButtonProtoWireguardContShareVisible() const;
void setPushButtonProtoWireguardContShareVisible(bool pushButtonProtoWireguardContShareVisible);
bool getFrameOpenvpnSettingsVisible() const;
void setFrameOpenvpnSettingsVisible(bool frameOpenvpnSettingsVisible);
bool getFrameOpenvpnSsSettingsVisible() const;
void setFrameOpenvpnSsSettingsVisible(bool frameOpenvpnSsSettingsVisible);
bool getFrameOpenvpnSsCloakSettingsVisible() const;
void setFrameOpenvpnSsCloakSettingsVisible(bool frameOpenvpnSsCloakSettingsVisible);
bool getProgressBarProtocolsContainerReinstallVisible() const;
void setProgressBarProtocolsContainerReinstallVisible(bool progressBarProtocolsContainerReinstallVisible);
QString getLabelSpeedReceivedText() const;
void setLabelSpeedReceivedText(const QString &labelSpeedReceivedText);
QString getLabelSpeedSentText() const;
void setLabelSpeedSentText(const QString &labelSpeedSentText);
QString getLabelStateText() const;
void setLabelStateText(const QString &labelStateText);
bool getPushButtonConnectEnabled() const;
void setPushButtonConnectEnabled(bool pushButtonConnectEnabled);
bool getWidgetVpnModeEnabled() const;
void setWidgetVpnModeEnabled(bool widgetVpnModeEnabled);
QString getLabelErrorText() const;
void setLabelErrorText(const QString &labelErrorText);
bool getPushButtonNewServerConnectEnabled() const;
void setPushButtonNewServerConnectEnabled(bool pushButtonNewServerConnectEnabled);
QString getPushButtonNewServerConnectText() const;
void setPushButtonNewServerConnectText(const QString &pushButtonNewServerConnectText);
QString getDialogConnectErrorText() const;
void setDialogConnectErrorText(const QString &dialogConnectErrorText);
bool getPageServerSettingsEnabled() const;
void setPageServerSettingsEnabled(bool pageServerSettingsEnabled);
QString getPushButtonServerSettingsClearText() const;
void setPushButtonServerSettingsClearText(const QString &pushButtonServerSettingsClearText);
bool getPageShareAmneziaVisible() const;
void setPageShareAmneziaVisible(bool pageShareAmneziaVisible);
bool getPageShareOpenvpnVisible() const;
void setPageShareOpenvpnVisible(bool pageShareOpenvpnVisible);
bool getPageShareShadowsocksVisible() const;
void setPageShareShadowsocksVisible(bool pageShareShadowsocksVisible);
bool getPageShareCloakVisible() const;
void setPageShareCloakVisible(bool pageShareCloakVisible);
bool getPageShareFullAccessVisible() const;
void setPageShareFullAccessVisible(bool pageShareFullAccessVisible);
QString getTextEditShareOpenvpnCodeText() const;
void setTextEditShareOpenvpnCodeText(const QString &textEditShareOpenvpnCodeText);
bool getPushButtonShareOpenvpnCopyEnabled() const;
void setPushButtonShareOpenvpnCopyEnabled(bool pushButtonShareOpenvpnCopyEnabled);
bool getPushButtonShareOpenvpnSaveEnabled() const;
void setPushButtonShareOpenvpnSaveEnabled(bool pushButtonShareOpenvpnSaveEnabled);
int getToolBoxShareConnectionCurrentIndex() const;
void setToolBoxShareConnectionCurrentIndex(int toolBoxShareConnectionCurrentIndex);
bool getPushButtonShareSsCopyEnabled() const;
void setPushButtonShareSsCopyEnabled(bool pushButtonShareSsCopyEnabled);
QString getLineEditShareSsStringText() const;
void setLineEditShareSsStringText(const QString &lineEditShareSsStringText);
QString getLabelShareSsQrCodeText() const;
void setLabelShareSsQrCodeText(const QString &labelShareSsQrCodeText);
QString getLabelShareSsServerText() const;
void setLabelShareSsServerText(const QString &labelShareSsServerText);
QString getLabelShareSsPortText() const;
void setLabelShareSsPortText(const QString &labelShareSsPortText);
QString getLabelShareSsMethodText() const;
void setLabelShareSsMethodText(const QString &labelShareSsMethodText);
QString getLabelShareSsPasswordText() const;
void setLabelShareSsPasswordText(const QString &labelShareSsPasswordText);
QString getPlainTextEditShareCloakText() const;
void setPlainTextEditShareCloakText(const QString &plainTextEditShareCloakText);
bool getPushButtonShareCloakCopyEnabled() const;
void setPushButtonShareCloakCopyEnabled(bool pushButtonShareCloakCopyEnabled);
QString getTextEditShareFullCodeText() const;
void setTextEditShareFullCodeText(const QString &textEditShareFullCodeText);
QString getTextEditShareAmneziaCodeText() const;
void setTextEditShareAmneziaCodeText(const QString &textEditShareAmneziaCodeText);
QString getPushButtonShareFullCopyText() const;
void setPushButtonShareFullCopyText(const QString &pushButtonShareFullCopyText);
QString getPushButtonShareAmneziaCopyText() const;
void setPushButtonShareAmneziaCopyText(const QString &pushButtonShareAmneziaCopyText);
QString getPushButtonShareOpenvpnCopyText() const;
void setPushButtonShareOpenvpnCopyText(const QString &pushButtonShareOpenvpnCopyText);
QString getPushButtonShareSsCopyText() const;
void setPushButtonShareSsCopyText(const QString &pushButtonShareSsCopyText);
QString getPushButtonShareCloakCopyText() const;
void setPushButtonShareCloakCopyText(const QString &pushButtonShareCloakCopyText);
bool getPushButtonShareAmneziaGenerateEnabled() const;
void setPushButtonShareAmneziaGenerateEnabled(bool pushButtonShareAmneziaGenerateEnabled);
bool getPushButtonShareAmneziaCopyEnabled() const;
void setPushButtonShareAmneziaCopyEnabled(bool pushButtonShareAmneziaCopyEnabled);
QString getPushButtonShareAmneziaGenerateText() const;
void setPushButtonShareAmneziaGenerateText(const QString &pushButtonShareAmneziaGenerateText);
bool getPushButtonShareOpenvpnGenerateEnabled() const;
void setPushButtonShareOpenvpnGenerateEnabled(bool pushButtonShareOpenvpnGenerateEnabled);
QString getPushButtonShareOpenvpnGenerateText() const;
void setPushButtonShareOpenvpnGenerateText(const QString &pushButtonShareOpenvpnGenerateText);
bool getPageNewServerConfiguringEnabled() const;
void setPageNewServerConfiguringEnabled(bool pageNewServerConfiguringEnabled);
bool getLabelNewServerConfiguringWaitInfoVisible() const;
void setLabelNewServerConfiguringWaitInfoVisible(bool labelNewServerConfiguringWaitInfoVisible);
QString getLabelNewServerConfiguringWaitInfoText() const;
void setLabelNewServerConfiguringWaitInfoText(const QString &labelNewServerConfiguringWaitInfoText);
bool getProgressBarNewServerConfiguringVisible() const;
void setProgressBarNewServerConfiguringVisible(bool progressBarNewServerConfiguringVisible);
int getProgressBarNewServerConfiguringMaximium() const;
void setProgressBarNewServerConfiguringMaximium(int progressBarNewServerConfiguringMaximium);
bool getProgressBarNewServerConfiguringTextVisible() const;
void setProgressBarNewServerConfiguringTextVisible(bool progressBarNewServerConfiguringTextVisible);
QString getProgressBarNewServerConfiguringText() const;
void setProgressBarNewServerConfiguringText(const QString &progressBarNewServerConfiguringText);
bool getPageServerProtocolsEnabled() const;
void setPageServerProtocolsEnabled(bool pageServerProtocolsEnabled);
int getProgressBarProtocolsContainerReinstallValue() const;
void setProgressBarProtocolsContainerReinstallValue(int progressBarProtocolsContainerReinstallValue);
int getProgressBarProtocolsContainerReinstallMaximium() const;
void setProgressBarProtocolsContainerReinstallMaximium(int progressBarProtocolsContainerReinstallMaximium);
bool getComboBoxProtoOpenvpnCipherEnabled() const;
void setComboBoxProtoOpenvpnCipherEnabled(bool comboBoxProtoOpenvpnCipherEnabled);
bool getComboBoxProtoOpenvpnHashEnabled() const;
void setComboBoxProtoOpenvpnHashEnabled(bool comboBoxProtoOpenvpnHashEnabled);
bool getPageProtoOpenvpnEnabled() const;
void setPageProtoOpenvpnEnabled(bool pageProtoOpenvpnEnabled);
bool getLabelProtoOpenvpnInfoVisible() const;
void setLabelProtoOpenvpnInfoVisible(bool labelProtoOpenvpnInfoVisible);
QString getLabelProtoOpenvpnInfoText() const;
void setLabelProtoOpenvpnInfoText(const QString &labelProtoOpenvpnInfoText);
int getProgressBarProtoOpenvpnResetValue() const;
void setProgressBarProtoOpenvpnResetValue(int progressBarProtoOpenvpnResetValue);
int getProgressBarProtoOpenvpnResetMaximium() const;
void setProgressBarProtoOpenvpnResetMaximium(int progressBarProtoOpenvpnResetMaximium);
bool getPageProtoShadowsocksEnabled() const;
void setPageProtoShadowsocksEnabled(bool pageProtoShadowsocksEnabled);
bool getLabelProtoShadowsocksInfoVisible() const;
void setLabelProtoShadowsocksInfoVisible(bool labelProtoShadowsocksInfoVisible);
QString getLabelProtoShadowsocksInfoText() const;
void setLabelProtoShadowsocksInfoText(const QString &labelProtoShadowsocksInfoText);
int getProgressBarProtoShadowsocksResetValue() const;
void setProgressBarProtoShadowsocksResetValue(int progressBarProtoShadowsocksResetValue);
int getProgressBarProtoShadowsocksResetMaximium() const;
void setProgressBarProtoShadowsocksResetMaximium(int progressBarProtoShadowsocksResetMaximium);
bool getPageProtoCloakEnabled() const;
void setPageProtoCloakEnabled(bool pageProtoCloakEnabled);
bool getLabelProtoCloakInfoVisible() const;
void setLabelProtoCloakInfoVisible(bool labelProtoCloakInfoVisible);
QString getLabelProtoCloakInfoText() const;
void setLabelProtoCloakInfoText(const QString &labelProtoCloakInfoText);
int getProgressBarProtoCloakResetValue() const;
void setProgressBarProtoCloakResetValue(int progressBarProtoCloakResetValue);
int getProgressBarProtoCloakResetMaximium() const;
void setProgressBarProtoCloakResetMaximium(int progressBarProtoCloakResetMaximium);
QObject* getServerListModel() const;
QString getPushButtonServerSettingsClearClientCacheText() const;
void setPushButtonServerSettingsClearClientCacheText(const QString &pushButtonServerSettingsClearClientCacheText);
Q_INVOKABLE void updateWizardHighPage(); Q_INVOKABLE void updateWizardHighPage();
@ -280,8 +618,39 @@ public:
Q_INVOKABLE void onPushButtonNetworkSettingsResetdns1Clicked(); Q_INVOKABLE void onPushButtonNetworkSettingsResetdns1Clicked();
Q_INVOKABLE void onPushButtonNetworkSettingsResetdns2Clicked(); 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 onPushButtonShareFullSaveClicked();
Q_INVOKABLE void onPushButtonShareAmneziaCopyClicked();
Q_INVOKABLE void onPushButtonShareAmneziaSaveClicked();
Q_INVOKABLE void onPushButtonShareOpenvpnCopyClicked();
Q_INVOKABLE void onPushButtonShareSsCopyClicked();
Q_INVOKABLE void onPushButtonShareCloakCopyClicked();
Q_INVOKABLE void onPushButtonShareAmneziaGenerateClicked();
Q_INVOKABLE void onPushButtonShareOpenvpnGenerateClicked();
Q_INVOKABLE void onPushButtonShareOpenvpnSaveClicked();
Q_INVOKABLE void onPushButtonGeneralSettingsServerSettingsClicked();
Q_INVOKABLE void onPushButtonGeneralSettingsShareConnectionClicked();
Q_INVOKABLE void onPushButtonProtoOpenvpnContOpenvpnConfigClicked();
Q_INVOKABLE void onPushButtonProtoSsOpenvpnContOpenvpnConfigClicked();
Q_INVOKABLE void onPushButtonProtoSsOpenvpnContSsConfigClicked();
Q_INVOKABLE void onPushButtonProtoCloakOpenvpnContOpenvpnConfigClicked();
Q_INVOKABLE void onPushButtonProtoCloakOpenvpnContSsConfigClicked();
Q_INVOKABLE void onPushButtonProtoCloakOpenvpnContCloakConfigClicked();
Q_INVOKABLE void onCheckBoxProtoOpenvpnAutoEncryptionClicked();
Q_INVOKABLE void onPushButtonProtoOpenvpnSaveClicked();
Q_INVOKABLE void onPushButtonProtoShadowsocksSaveClicked();
Q_INVOKABLE void onPushButtonProtoCloakSaveClicked();
Q_INVOKABLE void onCloseWindow();
Q_INVOKABLE void onServerListPushbuttonDefaultClicked(int index);
Q_INVOKABLE void onServerListPushbuttonSettingsClicked(int index);
Q_INVOKABLE void onPushButtonServerSettingsShareFullClicked();
Q_INVOKABLE void onPushButtonClearServer();
Q_INVOKABLE void onPushButtonForgetServer();
Q_INVOKABLE void onPushButtonServerSettingsClearClientCacheClicked();
Q_INVOKABLE void onLineEditServerSettingsDescriptionEditingFinished();
signals: signals:
void frameWireguardSettingsVisibleChanged(); void frameWireguardSettingsVisibleChanged();
@ -354,11 +723,138 @@ signals:
void radioButtonSetupWizardLowCheckedChanged(); void radioButtonSetupWizardLowCheckedChanged();
void checkBoxSetupWizardVpnModeCheckedChanged(); void checkBoxSetupWizardVpnModeCheckedChanged();
void pushButtonConnectCheckedChanged(); void pushButtonConnectCheckedChanged();
void labelSitesAddCustomTextChanged();
void tableViewSitesModelChanged();
void lineEditSitesAddCustomTextChanged();
void widgetProtoCloakEnabledChanged();
void pushButtonProtoCloakSaveVisibleChanged();
void progressBarProtoCloakResetVisibleChanged();
void lineEditProtoCloakPortEnabledChanged();
void widgetProtoSsEnabledChanged();
void pushButtonProtoShadowsocksSaveVisibleChanged();
void progressBarProtoShadowsocksResetVisibleChanged();
void lineEditProtoShadowsocksPortEnabledChanged();
void widgetProtoOpenvpnEnabledChanged();
void pushButtonProtoOpenvpnSaveVisibleChanged();
void progressBarProtoOpenvpnResetVisibleChanged();
void radioButtonProtoOpenvpnUdpEnabledChanged();
void radioButtonProtoOpenvpnTcpEnabledChanged();
void radioButtonProtoOpenvpnTcpCheckedChanged();
void lineEditProtoOpenvpnPortEnabledChanged();
void pushButtonProtoOpenvpnContInstallCheckedChanged();
void pushButtonProtoSsOpenvpnContInstallCheckedChanged();
void pushButtonProtoCloakOpenvpnContInstallCheckedChanged();
void pushButtonProtoWireguardContInstallCheckedChanged();
void pushButtonProtoOpenvpnContInstallEnabledChanged();
void pushButtonProtoSsOpenvpnContInstallEnabledChanged();
void pushButtonProtoCloakOpenvpnContInstallEnabledChanged();
void pushButtonProtoWireguardContInstallEnabledChanged();
void pushButtonProtoOpenvpnContDefaultCheckedChanged();
void pushButtonProtoSsOpenvpnContDefaultCheckedChanged();
void pushButtonProtoCloakOpenvpnContDefaultCheckedChanged();
void pushButtonProtoWireguardContDefaultCheckedChanged();
void pushButtonProtoOpenvpnContDefaultVisibleChanged();
void pushButtonProtoSsOpenvpnContDefaultVisibleChanged();
void pushButtonProtoCloakOpenvpnContDefaultVisibleChanged();
void pushButtonProtoWireguardContDefaultVisibleChanged();
void pushButtonProtoOpenvpnContShareVisibleChanged();
void pushButtonProtoSsOpenvpnContShareVisibleChanged();
void pushButtonProtoCloakOpenvpnContShareVisibleChanged();
void pushButtonProtoWireguardContShareVisibleChanged();
void frameOpenvpnSettingsVisibleChanged();
void frameOpenvpnSsSettingsVisibleChanged();
void frameOpenvpnSsCloakSettingsVisibleChanged();
void progressBarProtocolsContainerReinstallVisibleChanged();
void labelSpeedReceivedTextChanged();
void labelSpeedSentTextChanged();
void labelStateTextChanged();
void pushButtonConnectEnabledChanged();
void widgetVpnModeEnabledChanged();
void labelErrorTextChanged();
void pushButtonNewServerConnectEnabledChanged();
void pushButtonNewServerConnectTextChanged();
void dialogConnectErrorTextChanged();
void pageServerSettingsEnabledChanged();
void pushButtonServerSettingsClearTextChanged();
void pageShareAmneziaVisibleChanged();
void pageShareOpenvpnVisibleChanged();
void pageShareShadowsocksVisibleChanged();
void pageShareCloakVisibleChanged();
void pageShareFullAccessVisibleChanged();
void textEditShareOpenvpnCodeTextChanged();
void pushButtonShareOpenvpnCopyEnabledChanged();
void pushButtonShareOpenvpnSaveEnabledChanged();
void toolBoxShareConnectionCurrentIndexChanged();
void pushButtonShareSsCopyEnabledChanged();
void lineEditShareSsStringTextChanged();
void labelShareSsQrCodeTextChanged();
void labelShareSsServerTextChanged();
void labelShareSsPortTextChanged();
void labelShareSsMethodTextChanged();
void labelShareSsPasswordTextChanged();
void plainTextEditShareCloakTextChanged();
void pushButtonShareCloakCopyEnabledChanged();
void textEditShareFullCodeTextChanged();
void textEditShareAmneziaCodeTextChanged();
void pushButtonShareFullCopyTextChanged();
void pushButtonShareAmneziaCopyTextChanged();
void pushButtonShareOpenvpnCopyTextChanged();
void pushButtonShareSsCopyTextChanged();
void pushButtonShareCloakCopyTextChanged();
void pushButtonShareAmneziaGenerateEnabledChanged();
void pushButtonShareAmneziaCopyEnabledChanged();
void pushButtonShareAmneziaGenerateTextChanged();
void pushButtonShareOpenvpnGenerateEnabledChanged();
void pushButtonShareOpenvpnGenerateTextChanged();
void pageNewServerConfiguringEnabledChanged();
void labelNewServerConfiguringWaitInfoVisibleChanged();
void labelNewServerConfiguringWaitInfoTextChanged();
void progressBarNewServerConfiguringVisibleChanged();
void progressBarNewServerConfiguringMaximiumChanged();
void progressBarNewServerConfiguringTextVisibleChanged();
void progressBarNewServerConfiguringTextChanged();
void pageServerProtocolsEnabledChanged();
void progressBarProtocolsContainerReinstallValueChanged();
void progressBarProtocolsContainerReinstallMaximiumChanged();
void comboBoxProtoOpenvpnCipherEnabledChanged();
void comboBoxProtoOpenvpnHashEnabledChanged();
void pageProtoOpenvpnEnabledChanged();
void labelProtoOpenvpnInfoVisibleChanged();
void labelProtoOpenvpnInfoTextChanged();
void progressBarProtoOpenvpnResetValueChanged();
void progressBarProtoOpenvpnResetMaximiumChanged();
void pageProtoShadowsocksEnabledChanged();
void labelProtoShadowsocksInfoVisibleChanged();
void labelProtoShadowsocksInfoTextChanged();
void progressBarProtoShadowsocksResetValueChanged();
void progressBarProtoShadowsocksResetMaximiumChanged();
void pageProtoCloakEnabledChanged();
void labelProtoCloakInfoVisibleChanged();
void labelProtoCloakInfoTextChanged();
void progressBarProtoCloakResetValueChanged();
void progressBarProtoCloakResetMaximiumChanged();
void pushButtonServerSettingsClearClientCacheTextChanged();
void goToPage(Page page, bool reset = true, bool slide = true); void goToPage(int page, bool reset = true, bool slide = true);
void closePage(); void closePage();
void setStartPage(Page page, bool slide = true); void setStartPage(int page, bool slide = true);
void pushButtonNewServerConnectConfigureClicked(); void pushButtonNewServerConnectConfigureClicked();
void showPublicKeyWarning();
void showConnectErrorDialog();
void show();
void hide();
void pushButtonProtoOpenvpnContDefaultClicked(bool checked);
void pushButtonProtoSsOpenvpnContDefaultClicked(bool checked);
void pushButtonProtoCloakOpenvpnContDefaultClicked(bool checked);
void pushButtonProtoWireguardContDefaultClicked(bool checked);
void pushButtonProtoOpenvpnContInstallClicked(bool checked);
void pushButtonProtoSsOpenvpnContInstallClicked(bool checked);
void pushButtonProtoCloakOpenvpnContInstallClicked(bool checked);
void pushButtonProtoWireguardContInstallClicked(bool checked);
void pushButtonProtoOpenvpnContShareClicked(bool checked);
void pushButtonProtoSsOpenvpnContShareClicked(bool checked);
void pushButtonProtoCloakOpenvpnContShareClicked(bool checked);
void pushButtonProtoWireguardContShareClicked(bool checked);
private: private:
bool m_frameWireguardSettingsVisible; bool m_frameWireguardSettingsVisible;
@ -432,60 +928,182 @@ private:
bool m_checkBoxSetupWizardVpnModeChecked; bool m_checkBoxSetupWizardVpnModeChecked;
QString m_ipAddressValidatorRegex; QString m_ipAddressValidatorRegex;
bool m_pushButtonConnectChecked; bool m_pushButtonConnectChecked;
QString m_labelSitesAddCustomText;
QObject* m_tableViewSitesModel;
QString m_lineEditSitesAddCustomText;
bool m_widgetProtoCloakEnabled;
bool m_pushButtonProtoCloakSaveVisible;
bool m_progressBarProtoCloakResetVisible;
bool m_lineEditProtoCloakPortEnabled;
bool m_widgetProtoSsEnabled;
bool m_pushButtonProtoShadowsocksSaveVisible;
bool m_progressBarProtoShadowsocksResetVisible;
bool m_lineEditProtoShadowsocksPortEnabled;
bool m_widgetProtoOpenvpnEnabled;
bool m_pushButtonProtoOpenvpnSaveVisible;
bool m_progressBarProtoOpenvpnResetVisible;
bool m_radioButtonProtoOpenvpnUdpEnabled;
bool m_radioButtonProtoOpenvpnTcpEnabled;
bool m_radioButtonProtoOpenvpnTcpChecked;
bool m_lineEditProtoOpenvpnPortEnabled;
bool m_pushButtonProtoOpenvpnContInstallChecked;
bool m_pushButtonProtoSsOpenvpnContInstallChecked;
bool m_pushButtonProtoCloakOpenvpnContInstallChecked;
bool m_pushButtonProtoWireguardContInstallChecked;
bool m_pushButtonProtoOpenvpnContInstallEnabled;
bool m_pushButtonProtoSsOpenvpnContInstallEnabled;
bool m_pushButtonProtoCloakOpenvpnContInstallEnabled;
bool m_pushButtonProtoWireguardContInstallEnabled;
bool m_pushButtonProtoOpenvpnContDefaultChecked;
bool m_pushButtonProtoSsOpenvpnContDefaultChecked;
bool m_pushButtonProtoCloakOpenvpnContDefaultChecked;
bool m_pushButtonProtoWireguardContDefaultChecked;
bool m_pushButtonProtoOpenvpnContDefaultVisible;
bool m_pushButtonProtoSsOpenvpnContDefaultVisible;
bool m_pushButtonProtoCloakOpenvpnContDefaultVisible;
bool m_pushButtonProtoWireguardContDefaultVisible;
bool m_pushButtonProtoOpenvpnContShareVisible;
bool m_pushButtonProtoSsOpenvpnContShareVisible;
bool m_pushButtonProtoCloakOpenvpnContShareVisible;
bool m_pushButtonProtoWireguardContShareVisible;
bool m_frameOpenvpnSettingsVisible;
bool m_frameOpenvpnSsSettingsVisible;
bool m_frameOpenvpnSsCloakSettingsVisible;
bool m_progressBarProtocolsContainerReinstallVisible;
QString m_labelSpeedReceivedText;
QString m_labelSpeedSentText;
QString m_labelStateText;
bool m_pushButtonConnectEnabled;
bool m_widgetVpnModeEnabled;
QString m_labelErrorText;
bool m_pushButtonNewServerConnectEnabled;
QString m_pushButtonNewServerConnectText;
QString m_dialogConnectErrorText;
bool m_pageServerSettingsEnabled;
QString m_pushButtonServerSettingsClearText;
bool m_pageShareAmneziaVisible;
bool m_pageShareOpenvpnVisible;
bool m_pageShareShadowsocksVisible;
bool m_pageShareCloakVisible;
bool m_pageShareFullAccessVisible;
QString m_textEditShareOpenvpnCodeText;
bool m_pushButtonShareOpenvpnCopyEnabled;
bool m_pushButtonShareOpenvpnSaveEnabled;
int m_toolBoxShareConnectionCurrentIndex;
bool m_pushButtonShareSsCopyEnabled;
QString m_lineEditShareSsStringText;
QString m_labelShareSsQrCodeText;
QString m_labelShareSsServerText;
QString m_labelShareSsPortText;
QString m_labelShareSsMethodText;
QString m_labelShareSsPasswordText;
QString m_plainTextEditShareCloakText;
bool m_pushButtonShareCloakCopyEnabled;
QString m_textEditShareFullCodeText;
QString m_textEditShareAmneziaCodeText;
QString m_pushButtonShareFullCopyText;
QString m_pushButtonShareAmneziaCopyText;
QString m_pushButtonShareOpenvpnCopyText;
QString m_pushButtonShareSsCopyText;
QString m_pushButtonShareCloakCopyText;
bool m_pushButtonShareAmneziaGenerateEnabled;
bool m_pushButtonShareAmneziaCopyEnabled;
QString m_pushButtonShareAmneziaGenerateText;
bool m_pushButtonShareOpenvpnGenerateEnabled;
QString m_pushButtonShareOpenvpnGenerateText;
bool m_pageNewServerConfiguringEnabled;
bool m_labelNewServerConfiguringWaitInfoVisible;
QString m_labelNewServerConfiguringWaitInfoText;
bool m_progressBarNewServerConfiguringVisible;
int m_progressBarNewServerConfiguringMaximium;
bool m_progressBarNewServerConfiguringTextVisible;
QString m_progressBarNewServerConfiguringText;
bool m_pageServerProtocolsEnabled;
int m_progressBarProtocolsContainerReinstallValue;
int m_progressBarProtocolsContainerReinstallMaximium;
bool m_comboBoxProtoOpenvpnCipherEnabled;
bool m_comboBoxProtoOpenvpnHashEnabled;
bool m_pageProtoOpenvpnEnabled;
bool m_labelProtoOpenvpnInfoVisible;
QString m_labelProtoOpenvpnInfoText;
int m_progressBarProtoOpenvpnResetValue;
int m_progressBarProtoOpenvpnResetMaximium;
bool m_pageProtoShadowsocksEnabled;
bool m_labelProtoShadowsocksInfoVisible;
QString m_labelProtoShadowsocksInfoText;
int m_progressBarProtoShadowsocksResetValue;
int m_progressBarProtoShadowsocksResetMaximium;
bool m_pageProtoCloakEnabled;
bool m_labelProtoCloakInfoVisible;
QString m_labelProtoCloakInfoText;
int m_progressBarProtoCloakResetValue;
int m_progressBarProtoCloakResetMaximium;
ServersModel* m_serverListModel;
QString m_pushButtonServerSettingsClearClientCacheText;
//private slots: private slots:
// void onBytesChanged(quint64 receivedBytes, quint64 sentBytes); void onBytesChanged(quint64 receivedBytes, quint64 sentBytes);
// void onConnectionStateChanged(VpnProtocol::ConnectionState state); void onConnectionStateChanged(VpnProtocol::ConnectionState state);
// void onVpnProtocolError(amnezia::ErrorCode errorCode); void onVpnProtocolError(amnezia::ErrorCode errorCode);
void installServer(const QMap<DockerContainer, QJsonObject> &containers); void installServer(const QMap<DockerContainer, QJsonObject> &containers);
// void onPushButtonClearServer(bool);
// void onPushButtonForgetServer(bool);
// void onPushButtonAddCustomSitesClicked();
void setTrayState(VpnProtocol::ConnectionState state); void setTrayState(VpnProtocol::ConnectionState state);
void onConnect(); void onConnect();
// void onConnectWorker(int serverIndex, const ServerCredentials &credentials, DockerContainer container, const QJsonObject &containerConfig); void onConnectWorker(int serverIndex, const ServerCredentials &credentials, DockerContainer container, const QJsonObject &containerConfig);
void onDisconnect(); void onDisconnect();
private: private:
PageEnumNS::Page currentPage();
struct ProgressFunc {
std::function<void(bool)> setVisibleFunc;
std::function<void(int)> setValueFunc;
std::function<int(void)> getValueFunc;
std::function<int(void)> getMaximiumFunc;
std::function<void(bool)> setTextVisibleFunc;
std::function<void(const QString&)> setTextFunc;
};
struct PageFunc {
std::function<void(bool)> setEnabledFunc;
};
struct ButtonFunc {
std::function<void(bool)> setVisibleFunc;
};
struct LabelFunc {
std::function<void(bool)> setVisibleFunc;
std::function<void(const QString&)> setTextFunc;
};
Page currentPage(); bool installContainers(ServerCredentials credentials,
const QMap<DockerContainer, QJsonObject> &containers,
const PageFunc& page,
const ProgressFunc& progress,
const ButtonFunc& button,
const LabelFunc& info);
// bool installContainers(ServerCredentials credentials, const QMap<DockerContainer, QJsonObject> &containers, ErrorCode doInstallAction(const std::function<ErrorCode()> &action,
// QWidget *page, QProgressBar *progress, QPushButton *button, QLabel *info); const PageFunc& page,
const ProgressFunc& progress,
// ErrorCode doInstallAction(const std::function<ErrorCode()> &action, QWidget *page, QProgressBar *progress, QPushButton *button, QLabel *info); const ButtonFunc& button,
const LabelFunc& info);
void setupTray(); void setupTray();
void setTrayIcon(const QString &iconPath); void setTrayIcon(const QString &iconPath);
void setupNewServerConnections(); void setupNewServerConnections();
// void setupSitesPageConnections(); void setupSitesPageConnections();
// void setupGeneralSettingsConnections(); void setupProtocolsPageConnections();
// void setupProtocolsPageConnections();
void setupNewServerPageConnections();
// void setupServerSettingsPageConnections();
// void setupSharePageConnections();
// void updateSitesPage(); void updateSitesPage();
// void updateServersListPage(); void updateServersListPage();
// void updateProtocolsPage(); void updateProtocolsPage();
// void updateOpenVpnPage(const QJsonObject &openvpnConfig, DockerContainer container, bool haveAuthData); void updateOpenVpnPage(const QJsonObject &openvpnConfig, DockerContainer container, bool haveAuthData);
// void updateShadowSocksPage(const QJsonObject &ssConfig, DockerContainer container, bool haveAuthData); void updateShadowSocksPage(const QJsonObject &ssConfig, DockerContainer container, bool haveAuthData);
// void updateCloakPage(const QJsonObject &ckConfig, DockerContainer container, bool haveAuthData); void updateCloakPage(const QJsonObject &ckConfig, DockerContainer container, bool haveAuthData);
// void updateSharingPage(int serverIndex, const ServerCredentials &credentials, void updateSharingPage(int serverIndex, const ServerCredentials &credentials,
// DockerContainer container); DockerContainer container);
void updateQRCodeImage(const QString &text, const std::function<void(const QString&)>& setLabelFunc);
// void makeServersListItem(QListWidget* listWidget, const QJsonObject &server, bool isDefault, int index);
// void updateQRCodeImage(const QString &text, QLabel *label);
QJsonObject getOpenVpnConfigFromPage(QJsonObject oldConfig); QJsonObject getOpenVpnConfigFromPage(QJsonObject oldConfig);
QJsonObject getShadowSocksConfigFromPage(QJsonObject oldConfig); QJsonObject getShadowSocksConfigFromPage(QJsonObject oldConfig);
@ -498,22 +1116,19 @@ private:
VpnConnection* m_vpnConnection; VpnConnection* m_vpnConnection;
Settings m_settings; Settings m_settings;
// QMap<Settings::RouteMode, SitesModel *> sitesModels; QMap<Settings::RouteMode, SitesModel *> sitesModels;
// QRegExpValidator m_ipAddressValidator; // QRegExpValidator m_ipAddressValidator;
// QRegExpValidator m_ipAddressPortValidator; // QRegExpValidator m_ipAddressPortValidator;
// QRegExpValidator m_ipNetwok24Validator; // QRegExpValidator m_ipNetwok24Validator;
// QRegExpValidator m_ipPortValidator; // QRegExpValidator m_ipPortValidator;
// CQR_Encode m_qrEncode; CQR_Encode m_qrEncode;
// bool canMove = false;
// QPoint offset; // QPoint offset;
// bool needToHideCustomTitlebar = false; // bool needToHideCustomTitlebar = false;
// bool eventFilter(QObject *obj, QEvent *event) override;
// void keyPressEvent(QKeyEvent* event) override; // void keyPressEvent(QKeyEvent* event) override;
// void closeEvent(QCloseEvent *event) override;
// void showEvent(QShowEvent *event) override; // void showEvent(QShowEvent *event) override;
// void hideEvent(QHideEvent *event) override; // void hideEvent(QHideEvent *event) override;