From d1a35459128e22d457614d0e0f5f41d65cc80a89 Mon Sep 17 00:00:00 2001 From: Ngoc Diep Date: Mon, 9 Aug 2021 00:41:52 +0700 Subject: [PATCH] port UI Logic to QML --- client/client.pro | 10 +- client/main.cpp | 23 +- client/ui/Controls/SlidingStackedWidget.cpp | 238 - client/ui/Controls/SlidingStackedWidget.h | 87 - client/ui/mainwindow.cpp | 2325 ------ client/ui/mainwindow.h | 174 - client/ui/mainwindow.ui | 7754 ------------------ client/ui/qml/BasicButtonType.qml | 5 +- client/ui/qml/PageGeneralSettings.qml | 22 + client/ui/qml/PageNewServer.qml | 6 +- client/ui/qml/PageNewServerConfiguring.qml | 10 +- client/ui/qml/PageNewServerProtocol.qml | 29 + client/ui/qml/PageProtoCloak.qml | 14 +- client/ui/qml/PageProtoOpenVPN.qml | 25 +- client/ui/qml/PageProtoShadowSock.qml | 14 +- client/ui/qml/PageServer.qml | 72 +- client/ui/qml/PageServerProtocols.qml | 111 +- client/ui/qml/PageServerSetting.qml | 23 +- client/ui/qml/PageSetupWizard.qml | 8 +- client/ui/qml/PageSetupWizardHighLevel.qml | 4 +- client/ui/qml/PageSetupWizardMediumLevel.qml | 4 +- client/ui/qml/PageShareConnection.qml | 120 +- client/ui/qml/PageSites.qml | 51 +- client/ui/qml/PageStart.qml | 52 +- client/ui/qml/PageVPN.qml | 18 +- client/ui/qml/main.qml | 155 +- client/ui/server_widget.cpp | 61 - client/ui/server_widget.h | 30 - client/ui/serversmodel.cpp | 55 + client/ui/serversmodel.h | 39 + client/ui/sites_model.cpp | 50 +- client/ui/sites_model.h | 17 +- client/ui/uilogic.cpp | 4381 ++++++---- client/ui/uilogic.h | 743 +- 34 files changed, 4386 insertions(+), 12344 deletions(-) delete mode 100644 client/ui/Controls/SlidingStackedWidget.cpp delete mode 100644 client/ui/Controls/SlidingStackedWidget.h delete mode 100644 client/ui/mainwindow.cpp delete mode 100644 client/ui/mainwindow.h delete mode 100644 client/ui/mainwindow.ui delete mode 100644 client/ui/server_widget.cpp delete mode 100644 client/ui/server_widget.h create mode 100644 client/ui/serversmodel.cpp create mode 100644 client/ui/serversmodel.h diff --git a/client/client.pro b/client/client.pro index d50d09af..a440b0ca 100644 --- a/client/client.pro +++ b/client/client.pro @@ -33,11 +33,9 @@ HEADERS += \ protocols/shadowsocksvpnprotocol.h \ protocols/wireguardprotocol.h \ settings.h \ - ui/Controls/SlidingStackedWidget.h \ - ui/mainwindow.h \ + ui/serversmodel.h \ ui/uilogic.h \ ui/qautostart.h \ - ui/server_widget.h \ ui/sites_model.h \ utils.h \ vpnconnection.h \ @@ -64,18 +62,16 @@ SOURCES += \ protocols/shadowsocksvpnprotocol.cpp \ protocols/wireguardprotocol.cpp \ settings.cpp \ - ui/Controls/SlidingStackedWidget.cpp \ - ui/mainwindow.cpp \ + ui/serversmodel.cpp \ ui/uilogic.cpp \ ui/qautostart.cpp \ - ui/server_widget.cpp \ ui/sites_model.cpp \ utils.cpp \ vpnconnection.cpp \ protocols/vpnprotocol.cpp \ protocols/openvpnprotocol.cpp \ -FORMS += ui/mainwindow.ui \ +FORMS += \ ui/server_widget.ui RESOURCES += \ diff --git a/client/main.cpp b/client/main.cpp index 8731051c..139a4b82 100644 --- a/client/main.cpp +++ b/client/main.cpp @@ -9,6 +9,7 @@ #include #include #include "ui/uilogic.h" +#include #include "debug.h" #include "defines.h" @@ -16,8 +17,6 @@ #include "singleapplication.h" #undef QAPPLICATION_CLASS -#include "ui/mainwindow.h" - #ifdef Q_OS_WIN #include "Windows.h" #endif @@ -85,27 +84,9 @@ int main(int argc, char *argv[]) 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::declareQML(); QQmlApplicationEngine engine; + UiLogic::declareQML(); const QUrl url(QStringLiteral("qrc:/ui/qml/main.qml")); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) { diff --git a/client/ui/Controls/SlidingStackedWidget.cpp b/client/ui/Controls/SlidingStackedWidget.cpp deleted file mode 100644 index f0ee14cd..00000000 --- a/client/ui/Controls/SlidingStackedWidget.cpp +++ /dev/null @@ -1,238 +0,0 @@ -#include "SlidingStackedWidget.h" - -#include - -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(); -} diff --git a/client/ui/Controls/SlidingStackedWidget.h b/client/ui/Controls/SlidingStackedWidget.h deleted file mode 100644 index 6a72f592..00000000 --- a/client/ui/Controls/SlidingStackedWidget.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef SLIDINGSTACKEDWIDGET_H -#define SLIDINGSTACKEDWIDGET_H - -#include - -#include -#include -#include -#include -#include - -/* 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 blockedPageList; - - QPropertyAnimation *animnow; - QPropertyAnimation *animnext; - QParallelAnimationGroup *animgroup; - - QWidget *m_nextWidget = nullptr; -}; - -#endif // SLIDINGSTACKEDWIDGET_H diff --git a/client/ui/mainwindow.cpp b/client/ui/mainwindow.cpp deleted file mode 100644 index e4d5b2b3..00000000 --- a/client/ui/mainwindow.cpp +++ /dev/null @@ -1,2325 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "configurators/cloak_configurator.h" -#include "configurators/vpn_configurator.h" -#include "configurators/openvpn_configurator.h" -#include "configurators/shadowsocks_configurator.h" -#include "configurators/ssh_configurator.h" - -#include "core/servercontroller.h" -#include "core/server_defs.h" -#include "core/errorstrings.h" - -#include "protocols/protocols_defs.h" -#include "protocols/shadowsocksvpnprotocol.h" - -#include "ui/qautostart.h" - -#include "debug.h" -#include "defines.h" -#include "mainwindow.h" -#include "utils.h" -#include "vpnconnection.h" -#include "ui_mainwindow.h" -#include "ui/server_widget.h" -#include "ui_server_widget.h" - -#if defined Q_OS_MAC || defined Q_OS_LINUX -#include "ui/macos_util.h" -#endif - -using namespace amnezia; - -MainWindow::MainWindow(QWidget *parent) : - #ifdef Q_OS_WIN - CFramelessWindow(parent), - #else - QMainWindow(parent), - #endif - ui(new Ui::MainWindow), - m_vpnConnection(nullptr) -{ - ui->setupUi(this); - - ui->frame_wireguard_settings->hide(); - ui->frame_wireguard->hide(); - ui->frame_new_server_settings_parent_wireguard->hide(); - - setupTray(); - setupUiConnections(); - setupNewServerConnections(); - setupWizardConnections(); - setupVpnPageConnections(); - setupSitesPageConnections(); - setupGeneralSettingsConnections(); - setupAppSettingsConnections(); - setupNetworkSettingsConnections(); - setupProtocolsPageConnections(); - setupNewServerPageConnections(); - setupSharePageConnections(); - setupServerSettingsPageConnections(); - - ui->label_error_text->clear(); - installEventFilter(this); - ui->widget_tittlebar->installEventFilter(this); - - ui->stackedWidget_main->setSpeed(200); - ui->stackedWidget_main->setAnimation(QEasingCurve::Linear); - - - ui->tableView_sites->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); -// ui->tableView_sites->setColumnWidth(0, 450); -// ui->tableView_sites->setColumnWidth(1, 120); - - if (QOperatingSystemVersion::current() <= QOperatingSystemVersion::Windows7) { - needToHideCustomTitlebar = true; - } - -#if defined Q_OS_MAC - fixWidget(this); - needToHideCustomTitlebar = true; -#endif - - if (needToHideCustomTitlebar) { - ui->widget_tittlebar->hide(); - resize(width(), 640); - ui->stackedWidget_main->move(0,0); - } - - // Post initialization - goToPage(Page::Start, true, false); - - if (m_settings.defaultServerIndex() >= 0 && m_settings.serversCount() > 0) { - goToPage(Page::Vpn, true, false); - } - - //ui->pushButton_general_settings_exit->hide(); - updateSharingPage(selectedServerIndex, m_settings.serverCredentials(selectedServerIndex), selectedDockerContainer); - - setFixedSize(width(),height()); - - qInfo().noquote() << QString("Started %1 version %2").arg(APPLICATION_NAME).arg(APP_VERSION); - qInfo().noquote() << QString("%1 (%2)").arg(QSysInfo::prettyProductName()).arg(QSysInfo::currentCpuArchitecture()); - - - m_vpnConnection = new VpnConnection(this); - connect(m_vpnConnection, SIGNAL(bytesChanged(quint64, quint64)), this, SLOT(onBytesChanged(quint64, quint64))); - connect(m_vpnConnection, SIGNAL(connectionStateChanged(VpnProtocol::ConnectionState)), this, SLOT(onConnectionStateChanged(VpnProtocol::ConnectionState))); - connect(m_vpnConnection, SIGNAL(vpnProtocolError(amnezia::ErrorCode)), this, SLOT(onVpnProtocolError(amnezia::ErrorCode))); - - onConnectionStateChanged(VpnProtocol::Disconnected); - - if (m_settings.isAutoConnect() && m_settings.defaultServerIndex() >= 0) { - QTimer::singleShot(1000, this, [this](){ - ui->pushButton_connect->setEnabled(false); - onConnect(); - }); - } - - m_ipAddressValidator.setRegExp(Utils::ipAddressRegExp()); - m_ipAddressPortValidator.setRegExp(Utils::ipAddressPortRegExp()); - m_ipNetwok24Validator.setRegExp(Utils::ipNetwork24RegExp()); - m_ipPortValidator.setRegExp(Utils::ipPortRegExp()); - - ui->lineEdit_new_server_ip->setValidator(&m_ipAddressPortValidator); - ui->lineEdit_network_settings_dns1->setValidator(&m_ipAddressValidator); - ui->lineEdit_network_settings_dns2->setValidator(&m_ipAddressValidator); - - ui->lineEdit_proto_openvpn_subnet->setValidator(&m_ipNetwok24Validator); - - ui->lineEdit_proto_openvpn_port->setValidator(&m_ipPortValidator); - ui->lineEdit_proto_shadowsocks_port->setValidator(&m_ipPortValidator); - ui->lineEdit_proto_cloak_port->setValidator(&m_ipPortValidator); - - //ui->toolBox_share_connection->removeItem(ui->toolBox_share_connection->indexOf(ui->page_share_shadowsocks)); - //ui->page_share_shadowsocks->setVisible(false); - - - sitesModels.insert(Settings::VpnOnlyForwardSites, new SitesModel(Settings::VpnOnlyForwardSites)); - sitesModels.insert(Settings::VpnAllExceptSites, new SitesModel(Settings::VpnAllExceptSites)); -} - -MainWindow::~MainWindow() -{ - hide(); - - m_vpnConnection->disconnectFromVpn(); - for (int i = 0; i < 50; i++) { - qApp->processEvents(QEventLoop::ExcludeUserInputEvents); - QThread::msleep(100); - if (m_vpnConnection->isDisconnected()) { - break; - } - } - - delete m_vpnConnection; - delete ui; - - qDebug() << "Application closed"; -} - -void MainWindow::showOnStartup() -{ - if (! m_settings.isStartMinimized()) show(); - else { -#if defined Q_OS_MACX - setDockIconVisible(false); -#endif - } -} - -void MainWindow::goToPage(Page page, bool reset, bool slide) -{ - //qDebug() << "goToPage" << page; - if (ui->stackedWidget_main->nextWidget() == getPageWidget(page)) return; - - if (reset) { - if (page == Page::ServerSettings) { - updateServerPage(); - } - if (page == Page::ShareConnection) { - - } - if (page == Page::Wizard) { - ui->radioButton_setup_wizard_medium->setChecked(true); - } - if (page == Page::WizardHigh) { - ui->lineEdit_setup_wizard_high_website_masking->setText(protocols::cloak::defaultRedirSite); - } - if (page == Page::ServerConfiguring) { - ui->progressBar_new_server_configuring->setValue(0); - } - if (page == Page::GeneralSettings) { - updateGeneralSettingPage(); - } - if (page == Page::ServersList) { - updateServersListPage(); - } - if (page == Page::Start) { - updateStartPage(); - } - if (page == Page::NewServerProtocols) { - ui->pushButton_new_server_settings_cloak->setChecked(true); - ui->pushButton_new_server_settings_cloak->setChecked(false); - ui->pushButton_new_server_settings_ss->setChecked(true); - ui->pushButton_new_server_settings_ss->setChecked(false); - ui->pushButton_new_server_settings_openvpn->setChecked(true); - ui->pushButton_new_server_settings_openvpn->setChecked(false); - - ui->lineEdit_new_server_cloak_port->setText(amnezia::protocols::cloak::defaultPort); - ui->lineEdit_new_server_cloak_site->setText(amnezia::protocols::cloak::defaultRedirSite); - - ui->lineEdit_new_server_ss_port->setText(amnezia::protocols::shadowsocks::defaultPort); - ui->comboBox_new_server_ss_cipher->setCurrentText(amnezia::protocols::shadowsocks::defaultCipher); - - ui->lineEdit_new_server_openvpn_port->setText(amnezia::protocols::openvpn::defaultPort); - ui->comboBox_new_server_openvpn_proto->setCurrentText(amnezia::protocols::openvpn::defaultTransportProto); - } - if (page == Page::ServerVpnProtocols) { - updateProtocolsPage(); - } - if (page == Page::AppSettings) { - updateAppSettingsPage(); - } - if (page == Page::NetworkSettings) { - updateAppSettingsPage(); - } - if (page == Page::Sites) { - updateSitesPage(); - } - if (page == Page::Vpn) { - updateVpnPage(); - } - - ui->pushButton_new_server_connect_key->setChecked(false); - } - - if (slide) - ui->stackedWidget_main->slideInWidget(getPageWidget(page), SlidingStackedWidget::RIGHT2LEFT); - else - ui->stackedWidget_main->setCurrentWidget(getPageWidget(page)); - - pagesStack.push(page); -} - -void MainWindow::setStartPage(MainWindow::Page page, bool slide) -{ - if (slide) - ui->stackedWidget_main->slideInWidget(getPageWidget(page), SlidingStackedWidget::RIGHT2LEFT); - else - ui->stackedWidget_main->setCurrentWidget(getPageWidget(page)); - - pagesStack.clear(); - pagesStack.push(page); - - if (page == Page::Start) updateStartPage(); -} - -void MainWindow::closePage() -{ - if (pagesStack.size() <= 1) return; - - Page prev = pagesStack.pop(); - //qDebug() << "closePage" << prev << "Set page" << pagesStack.top(); - ui->stackedWidget_main->slideInWidget(getPageWidget(pagesStack.top()), SlidingStackedWidget::LEFT2RIGHT); -} - -QWidget *MainWindow::getPageWidget(MainWindow::Page page) -{ - switch (page) { - case(Page::Start): return ui->page_start; - case(Page::NewServer): return ui->page_new_server; - case(Page::NewServerProtocols): return ui->page_new_server_protocols; - case(Page::Wizard): return ui->page_setup_wizard; - case(Page::WizardHigh): return ui->page_setup_wizard_high_level; - case(Page::WizardLow): return ui->page_setup_wizard_low_level; - case(Page::WizardMedium): return ui->page_setup_wizard_medium_level; - case(Page::WizardVpnMode): return ui->page_setup_wizard_vpn_mode; - case(Page::ServerConfiguring): return ui->page_new_server_configuring; - case(Page::Vpn): return ui->page_vpn; - case(Page::GeneralSettings): return ui->page_general_settings; - case(Page::AppSettings): return ui->page_app_settings; - case(Page::NetworkSettings): return ui->page_network_settings; - case(Page::ServerSettings): return ui->page_server_settings; - case(Page::ServerVpnProtocols): return ui->page_server_protocols; - case(Page::ServersList): return ui->page_servers; - case(Page::ShareConnection): return ui->page_share_connection; - case(Page::Sites): return ui->page_sites; - case(Page::OpenVpnSettings): return ui->page_proto_openvpn; - case(Page::ShadowSocksSettings): return ui->page_proto_shadowsocks; - case(Page::CloakSettings): return ui->page_proto_cloak; - } - return nullptr; -} - - -bool MainWindow::eventFilter(QObject *obj, QEvent *event) -{ - if (obj == ui->widget_tittlebar) { - QMouseEvent *mouseEvent = static_cast(event); - - if (!mouseEvent) - return false; - - if(event->type() == QEvent::MouseButtonPress) { - offset = mouseEvent->pos(); - canMove = true; - } - - if(event->type() == QEvent::MouseButtonRelease) { - canMove = false; - } - - if (event->type() == QEvent::MouseMove) { - if(canMove && (mouseEvent->buttons() & Qt::LeftButton)) { - move(mapToParent(mouseEvent->pos() - offset)); - } - - event->ignore(); - return false; - } - } - - return QMainWindow::eventFilter(obj, event); -} - -void MainWindow::keyPressEvent(QKeyEvent *event) -{ - switch (event->key()) { - case Qt::Key_L: - if (!Debug::openLogsFolder()) { - QMessageBox::warning(this, APPLICATION_NAME, tr("Cannot open logs folder!")); - } - break; -#ifdef QT_DEBUG - case Qt::Key_Q: - qApp->quit(); - break; -// case Qt::Key_0: -// *((char*)-1) = 'x'; -// break; - case Qt::Key_H: - selectedServerIndex = m_settings.defaultServerIndex(); - selectedDockerContainer = m_settings.defaultContainer(selectedServerIndex); - - updateSharingPage(selectedServerIndex, m_settings.serverCredentials(selectedServerIndex), selectedDockerContainer); - goToPage(Page::ShareConnection); - break; -#endif - case Qt::Key_C: - qDebug().noquote() << "Def server" << m_settings.defaultServerIndex() << m_settings.defaultContainerName(m_settings.defaultServerIndex()); - //qDebug().noquote() << QJsonDocument(m_settings.containerConfig(m_settings.defaultServerIndex(), m_settings.defaultContainer(m_settings.defaultServerIndex()))).toJson(); - qDebug().noquote() << QJsonDocument(m_settings.defaultServer()).toJson(); - break; - case Qt::Key_A: - goToPage(Page::Start); - break; - case Qt::Key_S: - selectedServerIndex = m_settings.defaultServerIndex(); - goToPage(Page::ServerSettings); - break; - case Qt::Key_P: - selectedServerIndex = m_settings.defaultServerIndex(); - selectedDockerContainer = m_settings.defaultContainer(selectedServerIndex); - goToPage(Page::ServerVpnProtocols); - break; - case Qt::Key_T: - SshConfigurator::openSshTerminal(m_settings.serverCredentials(m_settings.defaultServerIndex())); - break; - case Qt::Key_Escape: - if (currentPage() == Page::Vpn) break; - if (currentPage() == Page::ServerConfiguring) break; - if (currentPage() == Page::Start && pagesStack.size() < 2) break; - if (currentPage() == Page::Sites && - ui->tableView_sites->selectionModel()->selection().indexes().size() > 0) { - ui->tableView_sites->clearSelection(); - break; - } - - if (! ui->stackedWidget_main->isAnimationRunning() && ui->stackedWidget_main->currentWidget()->isEnabled()) { - closePage(); - } - default: - ; - } -} - -void MainWindow::closeEvent(QCloseEvent *event) -{ - if (m_settings.serversCount() == 0) qApp->quit(); - else { - hide(); - event->ignore(); - } -} - -void MainWindow::showEvent(QShowEvent *event) -{ -#if defined Q_OS_MACX - if (!event->spontaneous()) { - setDockIconVisible(true); - } - if (needToHideCustomTitlebar) { - ui->widget_tittlebar->hide(); - resize(width(), 640); - ui->stackedWidget_main->move(0,0); - } -#endif -} - -void MainWindow::hideEvent(QHideEvent *event) -{ -#if defined Q_OS_MACX - if (!event->spontaneous()) { - setDockIconVisible(false); - } -#endif -} - -void MainWindow::onPushButtonNewServerConnect(bool) -{ - if (ui->pushButton_new_server_connect_key->isChecked()){ - if (ui->lineEdit_new_server_ip->text().isEmpty() || - ui->lineEdit_new_server_login->text().isEmpty() || - ui->textEdit_new_server_ssh_key->toPlainText().isEmpty() ) { - - ui->label_new_server_wait_info->setText(tr("Please fill in all fields")); - return; - } - } - else { - if (ui->lineEdit_new_server_ip->text().isEmpty() || - ui->lineEdit_new_server_login->text().isEmpty() || - ui->lineEdit_new_server_password->text().isEmpty() ) { - - ui->label_new_server_wait_info->setText(tr("Please fill in all fields")); - return; - } - } - - - qDebug() << "MainWindow::onPushButtonNewServerConnect checking new server"; - - - ServerCredentials serverCredentials; - serverCredentials.hostName = ui->lineEdit_new_server_ip->text(); - if (serverCredentials.hostName.contains(":")) { - serverCredentials.port = serverCredentials.hostName.split(":").at(1).toInt(); - serverCredentials.hostName = serverCredentials.hostName.split(":").at(0); - } - serverCredentials.userName = ui->lineEdit_new_server_login->text(); - if (ui->pushButton_new_server_connect_key->isChecked()){ - QString key = ui->textEdit_new_server_ssh_key->toPlainText(); - if (key.startsWith("ssh-rsa")) { - QMessageBox::warning(this, APPLICATION_NAME, - tr("It's public key. Private key required")); - - return; - } - - if (key.contains("OPENSSH") && key.contains("BEGIN") && key.contains("PRIVATE KEY")) { - key = SshConfigurator::convertOpenSShKey(key); - } - - serverCredentials.password = key; - } - else { - serverCredentials.password = ui->lineEdit_new_server_password->text(); - } - - ui->pushButton_new_server_connect->setEnabled(false); - ui->pushButton_new_server_connect->setText(tr("Connecting...")); - - ErrorCode e = ErrorCode::NoError; -#ifdef Q_DEBUG - //QString output = ServerController::checkSshConnection(serverCredentials, &e); -#else - QString output; -#endif - - bool ok = true; - if (e) { - ui->label_new_server_wait_info->show(); - ui->label_new_server_wait_info->setText(errorString(e)); - ok = false; - } - else { - if (output.contains("Please login as the user")) { - output.replace("\n", ""); - ui->label_new_server_wait_info->show(); - ui->label_new_server_wait_info->setText(output); - ok = false; - } - } - - ui->pushButton_new_server_connect->setEnabled(true); - ui->pushButton_new_server_connect->setText(tr("Connect")); - - installCredentials = serverCredentials; - if (ok) goToPage(Page::NewServer); -} - -QMap MainWindow::getInstallConfigsFromProtocolsPage() const -{ - QJsonObject cloakConfig { - { config_key::container, amnezia::containerToString(DockerContainer::OpenVpnOverCloak) }, - { config_key::cloak, QJsonObject { - { config_key::port, ui->lineEdit_new_server_cloak_port->text() }, - { config_key::site, ui->lineEdit_new_server_cloak_site->text() }} - } - }; - QJsonObject ssConfig { - { config_key::container, amnezia::containerToString(DockerContainer::OpenVpnOverShadowSocks) }, - { config_key::shadowsocks, QJsonObject { - { config_key::port, ui->lineEdit_new_server_ss_port->text() }, - { config_key::cipher, ui->comboBox_new_server_ss_cipher->currentText() }} - } - }; - QJsonObject openVpnConfig { - { config_key::container, amnezia::containerToString(DockerContainer::OpenVpn) }, - { config_key::openvpn, QJsonObject { - { config_key::port, ui->lineEdit_new_server_openvpn_port->text() }, - { config_key::transport_proto, ui->comboBox_new_server_openvpn_proto->currentText() }} - } - }; - - QMap containers; - - if (ui->checkBox_new_server_cloak->isChecked()) { - containers.insert(DockerContainer::OpenVpnOverCloak, cloakConfig); - } - - if (ui->checkBox_new_server_ss->isChecked()) { - containers.insert(DockerContainer::OpenVpnOverShadowSocks, ssConfig); - } - - if (ui->checkBox_new_server_openvpn->isChecked()) { - containers.insert(DockerContainer::OpenVpn, openVpnConfig); - } - - return containers; -} - -QMap MainWindow::getInstallConfigsFromWizardPage() const -{ - QJsonObject cloakConfig { - { config_key::container, amnezia::containerToString(DockerContainer::OpenVpnOverCloak) }, - { config_key::cloak, QJsonObject { - { config_key::site, ui->lineEdit_setup_wizard_high_website_masking->text() }} - } - }; - QJsonObject ssConfig { - { config_key::container, amnezia::containerToString(DockerContainer::OpenVpnOverShadowSocks) } - }; - QJsonObject openVpnConfig { - { config_key::container, amnezia::containerToString(DockerContainer::OpenVpn) } - }; - - QMap containers; - - if (ui->radioButton_setup_wizard_high->isChecked()) { - containers.insert(DockerContainer::OpenVpnOverCloak, cloakConfig); - } - - if (ui->radioButton_setup_wizard_medium->isChecked()) { - containers.insert(DockerContainer::OpenVpnOverShadowSocks, ssConfig); - } - - if (ui->radioButton_setup_wizard_low->isChecked()) { - containers.insert(DockerContainer::OpenVpn, openVpnConfig); - } - - return containers; -} - -void MainWindow::installServer(const QMap &containers) -{ - if (containers.isEmpty()) return; - - goToPage(Page::ServerConfiguring); - QEventLoop loop; - QTimer::singleShot(500, &loop, SLOT(quit())); - loop.exec(); - qApp->processEvents(); - - bool ok = installContainers(installCredentials, containers, - ui->page_new_server_configuring, - ui->progressBar_new_server_configuring, - nullptr, - ui->label_new_server_configuring_wait_info); - - if (ok) { - QJsonObject server; - server.insert(config_key::hostName, installCredentials.hostName); - server.insert(config_key::userName, installCredentials.userName); - server.insert(config_key::password, installCredentials.password); - server.insert(config_key::port, installCredentials.port); - server.insert(config_key::description, m_settings.nextAvailableServerName()); - - QJsonArray containerConfigs; - for (const QJsonObject &cfg : containers) { - containerConfigs.append(cfg); - } - server.insert(config_key::containers, containerConfigs); - server.insert(config_key::defaultContainer, containerToString(containers.firstKey())); - - m_settings.addServer(server); - m_settings.setDefaultServer(m_settings.serversCount() - 1); - - setStartPage(Page::Vpn); - qApp->processEvents(); - } - else { - closePage(); - } -} - -void MainWindow::onPushButtonNewServerImport(bool) -{ - QString s = ui->lineEdit_start_existing_code->text(); - s.replace("vpn://", ""); - QJsonObject o = QJsonDocument::fromJson(QByteArray::fromBase64(s.toUtf8(), QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals)).object(); - - ServerCredentials credentials; - credentials.hostName = o.value("h").toString(); - if (credentials.hostName.isEmpty()) credentials.hostName = o.value(config_key::hostName).toString(); - - credentials.port = o.value("p").toInt(); - if (credentials.port == 0) credentials.port = o.value(config_key::port).toInt(); - - credentials.userName = o.value("u").toString(); - if (credentials.userName.isEmpty()) credentials.userName = o.value(config_key::userName).toString(); - - credentials.password = o.value("w").toString(); - if (credentials.password.isEmpty()) credentials.password = o.value(config_key::password).toString(); - - if (credentials.isValid()) { - o.insert(config_key::hostName, credentials.hostName); - o.insert(config_key::port, credentials.port); - o.insert(config_key::userName, credentials.userName); - o.insert(config_key::password, credentials.password); - - o.remove("h"); - o.remove("p"); - o.remove("u"); - o.remove("w"); - } - qDebug() << QString("Added server %3@%1:%2"). - arg(credentials.hostName). - arg(credentials.port). - arg(credentials.userName); - - //qDebug() << QString("Password") << credentials.password; - - if (credentials.isValid() || o.contains(config_key::containers)) { - m_settings.addServer(o); - m_settings.setDefaultServer(m_settings.serversCount() - 1); - - setStartPage(Page::Vpn); - } - else { - qDebug() << "Failed to import profile"; - qDebug().noquote() << QJsonDocument(o).toJson(); - return; - } - - if (!o.contains(config_key::containers)) { - selectedServerIndex = m_settings.defaultServerIndex(); - selectedDockerContainer = m_settings.defaultContainer(selectedServerIndex); - goToPage(Page::ServerVpnProtocols); - } -} - -bool MainWindow::installContainers(ServerCredentials credentials, - const QMap &containers, - QWidget *page, QProgressBar *progress, QPushButton *button, QLabel *info) -{ - if (!progress) return false; - - if (page) page->setEnabled(false); - if (button) button->setVisible(false); - - if (info) info->setVisible(true); - if (info) info->setText(tr("Please wait, configuring process may take up to 5 minutes")); - - - int cnt = 0; - for (QMap::const_iterator i = containers.constBegin(); i != containers.constEnd(); i++, cnt++) { - QTimer timer; - connect(&timer, &QTimer::timeout, [progress](){ - progress->setValue(progress->value() + 1); - }); - - progress->setValue(0); - timer.start(1000); - - progress->setTextVisible(true); - progress->setFormat(QString("Installing %1 %2 %3").arg(cnt+1).arg(tr("of")).arg(containers.size())); - - ErrorCode e = ServerController::setupContainer(credentials, i.key(), i.value()); - qDebug() << "Setup server finished with code" << e; - ServerController::disconnectFromHost(credentials); - - if (e) { - if (page) page->setEnabled(true); - if (button) button->setVisible(true); - if (info) info->setVisible(false); - - QMessageBox::warning(this, APPLICATION_NAME, - tr("Error occurred while configuring server.") + "\n" + - errorString(e)); - - return false; - } - - // just ui progressbar tweak - timer.stop(); - - int remaining_val = progress->maximum() - progress->value(); - - if (remaining_val > 0) { - QTimer timer1; - QEventLoop loop1; - - connect(&timer1, &QTimer::timeout, [&](){ - progress->setValue(progress->value() + 1); - if (progress->value() >= progress->maximum()) { - loop1.quit(); - } - }); - - timer1.start(5); - loop1.exec(); - } - } - - - if (button) button->show(); - if (page) page->setEnabled(true); - if (info) info->setText(tr("Amnezia server installed")); - - return true; -} - -ErrorCode MainWindow::doInstallAction(const std::function &action, QWidget *page, QProgressBar *progress, QPushButton *button, QLabel *info) -{ - progress->show(); - if (page) page->setEnabled(false); - if (button) button->setVisible(false); - - if (info) info->setVisible(true); - if (info) info->setText(tr("Please wait, configuring process may take up to 5 minutes")); - - - QTimer timer; - connect(&timer, &QTimer::timeout, [progress](){ - progress->setValue(progress->value() + 1); - }); - - progress->setValue(0); - timer.start(1000); - - ErrorCode e = action(); - qDebug() << "doInstallAction finished with code" << e; - - if (e) { - if (page) page->setEnabled(true); - if (button) button->setVisible(true); - if (info) info->setVisible(false); - - QMessageBox::warning(this, APPLICATION_NAME, - tr("Error occurred while configuring server.") + "\n" + - errorString(e)); - - progress->hide(); - return e; - } - - // just ui progressbar tweak - timer.stop(); - - int remaining_val = progress->maximum() - progress->value(); - - if (remaining_val > 0) { - QTimer timer1; - QEventLoop loop1; - - connect(&timer1, &QTimer::timeout, [&](){ - progress->setValue(progress->value() + 1); - if (progress->value() >= progress->maximum()) { - loop1.quit(); - } - }); - - timer1.start(5); - loop1.exec(); - } - - - progress->hide(); - if (button) button->show(); - if (page) page->setEnabled(true); - if (info) info->setText(tr("Operation finished")); - - return ErrorCode::NoError; -} - -void MainWindow::onPushButtonClearServer(bool) -{ - ui->page_server_settings->setEnabled(false); - ui->pushButton_server_settings_clear->setText(tr("Uninstalling Amnezia software...")); - - if (m_settings.defaultServerIndex() == selectedServerIndex) { - onDisconnect(); - } - - ErrorCode e = ServerController::removeAllContainers(m_settings.serverCredentials(selectedServerIndex)); - ServerController::disconnectFromHost(m_settings.serverCredentials(selectedServerIndex)); - if (e) { - QMessageBox::warning(this, APPLICATION_NAME, - tr("Error occurred while configuring server.") + "\n" + - errorString(e) + "\n" + - tr("See logs for details.")); - - } - else { - ui->label_server_settings_wait_info->show(); - ui->label_server_settings_wait_info->setText(tr("Amnezia server successfully uninstalled")); - } - - m_settings.setContainers(selectedServerIndex, {}); - m_settings.setDefaultContainer(selectedServerIndex, DockerContainer::None); - - ui->page_server_settings->setEnabled(true); - ui->pushButton_server_settings_clear->setText(tr("Clear server from Amnezia software")); -} - -void MainWindow::onPushButtonForgetServer(bool) -{ - if (m_settings.defaultServerIndex() == selectedServerIndex && m_vpnConnection->isConnected()) { - onDisconnect(); - } - m_settings.removeServer(selectedServerIndex); - - if (m_settings.defaultServerIndex() == selectedServerIndex) { - m_settings.setDefaultServer(0); - } - else if (m_settings.defaultServerIndex() > selectedServerIndex) { - m_settings.setDefaultServer(m_settings.defaultServerIndex() - 1); - } - - if (m_settings.serversCount() == 0) { - m_settings.setDefaultServer(-1); - } - - - selectedServerIndex = -1; - - updateServersListPage(); - - if (m_settings.serversCount() == 0) { - setStartPage(Page::Start); - } - else { - closePage(); - } -} - -void MainWindow::onBytesChanged(quint64 receivedData, quint64 sentData) -{ - ui->label_speed_received->setText(VpnConnection::bytesPerSecToText(receivedData)); - ui->label_speed_sent->setText(VpnConnection::bytesPerSecToText(sentData)); -} - -void MainWindow::onConnectionStateChanged(VpnProtocol::ConnectionState state) -{ - qDebug() << "MainWindow::onConnectionStateChanged" << VpnProtocol::textConnectionState(state); - - bool pushButtonConnectEnabled = false; - bool radioButtonsModeEnabled = false; - ui->label_state->setText(VpnProtocol::textConnectionState(state)); - - setTrayState(state); - - switch (state) { - case VpnProtocol::Disconnected: - onBytesChanged(0,0); - ui->pushButton_connect->setChecked(false); - pushButtonConnectEnabled = true; - radioButtonsModeEnabled = true; - break; - case VpnProtocol::Preparing: - pushButtonConnectEnabled = false; - radioButtonsModeEnabled = false; - break; - case VpnProtocol::Connecting: - pushButtonConnectEnabled = false; - radioButtonsModeEnabled = false; - break; - case VpnProtocol::Connected: - pushButtonConnectEnabled = true; - radioButtonsModeEnabled = false; - break; - case VpnProtocol::Disconnecting: - pushButtonConnectEnabled = false; - radioButtonsModeEnabled = false; - break; - case VpnProtocol::Reconnecting: - pushButtonConnectEnabled = true; - radioButtonsModeEnabled = false; - break; - case VpnProtocol::Error: - ui->pushButton_connect->setChecked(false); - pushButtonConnectEnabled = true; - radioButtonsModeEnabled = true; - break; - case VpnProtocol::Unknown: - pushButtonConnectEnabled = true; - radioButtonsModeEnabled = true; - } - - ui->pushButton_connect->setEnabled(pushButtonConnectEnabled); - ui->widget_vpn_mode->setEnabled(radioButtonsModeEnabled); -} - -void MainWindow::onVpnProtocolError(ErrorCode errorCode) -{ - ui->label_error_text->setText(errorString(errorCode)); -} - -void MainWindow::onPushButtonConnectClicked(bool checked) -{ - if (checked) { - onConnect(); - } else { - onDisconnect(); - } -} - -void MainWindow::setupTray() -{ - m_menu = new QMenu(); - - m_menu->addAction(QIcon(":/images/tray/application.png"), tr("Show") + " " + APPLICATION_NAME, this, [this](){ - show(); - raise(); - }); - m_menu->addSeparator(); - m_trayActionConnect = m_menu->addAction(tr("Connect"), this, SLOT(onConnect())); - m_trayActionDisconnect = m_menu->addAction(tr("Disconnect"), this, SLOT(onDisconnect())); - - m_menu->addSeparator(); - - m_menu->addAction(QIcon(":/images/tray/link.png"), tr("Visit Website"), [&](){ - QDesktopServices::openUrl(QUrl("https://amnezia.org")); - }); - - m_menu->addAction(QIcon(":/images/tray/cancel.png"), tr("Quit") + " " + APPLICATION_NAME, this, [&](){ -// QMessageBox::question(this, QMessageBox::question(this, tr("Exit"), tr("Do you really want to quit?"), QMessageBox::Yes | QMessageBox::No, ); - - QMessageBox msgBox(QMessageBox::Question, tr("Exit"), tr("Do you really want to quit?"), - QMessageBox::Yes | QMessageBox::No, this, Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowStaysOnTopHint); - msgBox.setDefaultButton(QMessageBox::Yes); - msgBox.raise(); - if (msgBox.exec() == QMessageBox::Yes) { - qApp->quit(); - } - }); - - m_tray.setContextMenu(m_menu); - setTrayState(VpnProtocol::Disconnected); - - m_tray.show(); - - connect(&m_tray, &QSystemTrayIcon::activated, this, &MainWindow::onTrayActivated); -} - -void MainWindow::setTrayIcon(const QString &iconPath) -{ - m_tray.setIcon(QIcon(QPixmap(iconPath).scaled(128,128))); -} - -MainWindow::Page MainWindow::currentPage() -{ - ui->stackedWidget_main->waitForAnimation(); - - QWidget *currentPage = ui->stackedWidget_main->currentWidget(); - QMetaEnum e = QMetaEnum::fromType(); - - for (int k = 0; k < e.keyCount(); k++) { - Page p = static_cast(e.value(k)); - if (currentPage == getPageWidget(p)) return p; - } - - return Page::Start; -} - -void MainWindow::setupUiConnections() -{ - connect(ui->pushButton_close, &QPushButton::clicked, this, [this](){ - if (currentPage() == Page::Start || currentPage() == Page::NewServer) qApp->quit(); - else hide(); - }); - - connect(ui->pushButton_vpn_add_site, &QPushButton::clicked, this, [this](){ goToPage(Page::Sites); }); - - - QVector backButtons { - ui->pushButton_back_from_sites, - ui->pushButton_back_from_general_settings, - ui->pushButton_back_from_start, - ui->pushButton_back_from_new_server, - ui->pushButton_back_from_new_server_protocols, - ui->pushButton_back_from_setup_wizard, - ui->pushButton_back_from_setup_wizard_high, - ui->pushButton_back_from_setup_wizard_low, - ui->pushButton_back_from_setup_wizard_medium, - ui->pushButton_back_from_setup_wizard_vpn_mode, - ui->pushButton_back_from_app_settings, - ui->pushButton_back_from_network_settings, - ui->pushButton_back_from_server_settings, - ui->pushButton_back_from_servers, - ui->pushButton_back_from_share, - ui->pushButton_back_from_server_vpn_protocols, - ui->pushButton_back_from_openvpn_settings, - ui->pushButton_back_from_cloak_settings, - ui->pushButton_back_from_shadowsocks_settings - }; - - for (QPushButton *b : backButtons) { - connect(b, &QPushButton::clicked, this, [this](){ closePage(); }); - } - -} - -void MainWindow::setupNewServerConnections() -{ - connect(ui->pushButton_new_server_get_info, &QPushButton::clicked, this, [](){ - QDesktopServices::openUrl(QUrl("https://amnezia.org")); - }); - - connect(ui->pushButton_new_server_connect, SIGNAL(clicked(bool)), this, SLOT(onPushButtonNewServerConnect(bool))); - connect(ui->pushButton_new_server_import, SIGNAL(clicked(bool)), this, SLOT(onPushButtonNewServerImport(bool))); - - connect(ui->pushButton_new_server_connect_configure, &QPushButton::clicked, this, [this](){ - installServer(getInstallConfigsFromProtocolsPage()); - }); - -} - -void MainWindow::setupWizardConnections() -{ - connect(ui->pushButton_new_server_wizard, &QPushButton::clicked, this, [this](){ goToPage(Page::Wizard); }); - connect(ui->pushButton_new_server_advanced, &QPushButton::clicked, this, [this](){ goToPage(Page::NewServerProtocols); }); - connect(ui->pushButton_setup_wizard_next, &QPushButton::clicked, this, [this](){ - if (ui->radioButton_setup_wizard_high->isChecked()) goToPage(Page::WizardHigh); - else if (ui->radioButton_setup_wizard_medium->isChecked()) goToPage(Page::WizardMedium); - else if (ui->radioButton_setup_wizard_low->isChecked()) goToPage(Page::WizardLow); - }); - - connect(ui->pushButton_setup_wizard_high_next, &QPushButton::clicked, this, [this](){ - QString domain = ui->lineEdit_setup_wizard_high_website_masking->text(); - if (domain.isEmpty() || !domain.contains(".")) return; - goToPage(Page::WizardVpnMode); - }); - - connect(ui->lineEdit_setup_wizard_high_website_masking, &QLineEdit::textEdited, this, [this](){ - QString text = ui->lineEdit_setup_wizard_high_website_masking->text(); - text.replace("http://", ""); - text.replace("https://", ""); - if (text.isEmpty()) return; - text = text.split("/").first(); - ui->lineEdit_setup_wizard_high_website_masking->setText(text); - }); - - connect(ui->pushButton_setup_wizard_medium_next, &QPushButton::clicked, this, [this](){ goToPage(Page::WizardVpnMode); }); - - connect(ui->pushButton_setup_wizard_vpn_mode_finish, &QPushButton::clicked, this, [this](){ - installServer(getInstallConfigsFromWizardPage()); - if (ui->checkBox_setup_wizard_vpn_mode->isChecked()) m_settings.setRouteMode(Settings::VpnOnlyForwardSites); - else m_settings.setRouteMode(Settings::VpnAllSites); - }); - - connect(ui->pushButton_setup_wizard_low_finish, &QPushButton::clicked, this, [this](){ - installServer(getInstallConfigsFromWizardPage()); - }); - - connect(ui->lineEdit_setup_wizard_high_website_masking, &QLineEdit::returnPressed, this, [this](){ - ui->pushButton_setup_wizard_high_next->click(); - }); -} - -void MainWindow::setupVpnPageConnections() -{ - connect(ui->radioButton_vpn_mode_all_sites, &QRadioButton::toggled, ui->pushButton_vpn_add_site, &QPushButton::setDisabled); - - connect(ui->radioButton_vpn_mode_all_sites, &QRadioButton::toggled, this, [this](bool toggled) { - m_settings.setRouteMode(Settings::VpnAllSites); - }); - - connect(ui->radioButton_vpn_mode_forward_sites, &QRadioButton::toggled, this, [this](bool toggled) { - m_settings.setRouteMode(Settings::VpnOnlyForwardSites); - }); - - connect(ui->radioButton_vpn_mode_except_sites, &QRadioButton::toggled, this, [this](bool toggled) { - m_settings.setRouteMode(Settings::VpnAllExceptSites); - }); -} - -void MainWindow::setupSitesPageConnections() -{ - connect(ui->pushButton_sites_add_custom, &QPushButton::clicked, this, [this](){ onPushButtonAddCustomSitesClicked(); }); - - connect(ui->lineEdit_sites_add_custom, &QLineEdit::returnPressed, [&](){ - ui->pushButton_sites_add_custom->click(); - }); - - connect(ui->pushButton_sites_delete, &QPushButton::clicked, this, [this](){ - Settings::RouteMode mode = m_settings.routeMode(); - - QItemSelectionModel* selection = ui->tableView_sites->selectionModel(); - if (!selection) return; - - { - QModelIndexList indexesSites = selection->selectedRows(0); - - QStringList sites; - for (const QModelIndex &index : indexesSites) { - sites.append(index.data().toString()); - } - - m_settings.removeVpnSites(mode, sites); - } - - if (m_vpnConnection->connectionState() == VpnProtocol::Connected) { - QModelIndexList indexesIps = selection->selectedRows(1); - - QStringList ips; - for (const QModelIndex &index : indexesIps) { - if (index.data().toString().isEmpty()) { - ips.append(index.sibling(index.row(), 0).data().toString()); - } - else { - ips.append(index.data().toString()); - } - } - - m_vpnConnection->deleteRoutes(ips); - m_vpnConnection->flushDns(); - } - - updateSitesPage(); - }); - - connect(ui->pushButton_sites_import, &QPushButton::clicked, this, [this](){ - QString fileName = QFileDialog::getOpenFileName(this, tr("Import IP addresses"), - QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)); - - QFile file(fileName); - if (!file.open(QIODevice::ReadOnly)) return; - - Settings::RouteMode mode = m_settings.routeMode(); - - QStringList ips; - while (!file.atEnd()) { - QString line = file.readLine(); - - int pos = 0; - QRegExp rx = Utils::ipAddressWithSubnetRegExp(); - while ((pos = rx.indexIn(line, pos)) != -1) { - ips << rx.cap(0); - pos += rx.matchedLength(); - } - } - - m_settings.addVpnIps(mode, ips); - - m_vpnConnection->addRoutes(QStringList() << ips); - m_vpnConnection->flushDns(); - - updateSitesPage(); - }); -} - -void MainWindow::setupAppSettingsConnections() -{ - connect(ui->checkBox_app_settings_autostart, &QCheckBox::stateChanged, this, [this](int state){ - if (state == Qt::Unchecked) { - ui->checkBox_app_settings_autoconnect->setChecked(false); - } - Autostart::setAutostart(state == Qt::Checked); - }); - - connect(ui->checkBox_app_settings_autoconnect, &QCheckBox::stateChanged, this, [this](int state){ - m_settings.setAutoConnect(state == Qt::Checked); - }); - - connect(ui->checkBox_app_settings_start_minimized, &QCheckBox::stateChanged, this, [this](int state){ - m_settings.setStartMinimized(state == Qt::Checked); - }); - - connect(ui->pushButton_app_settings_check_for_updates, &QPushButton::clicked, this, [this](){ - QDesktopServices::openUrl(QUrl("https://github.com/amnezia-vpn/desktop-client/releases/latest")); - }); - - connect(ui->pushButton_app_settings_open_logs, &QPushButton::clicked, this, [this](){ - Debug::openLogsFolder(); - //QDesktopServices::openUrl(QUrl::fromLocalFile(Utils::systemLogPath())); - }); -} - -void MainWindow::setupGeneralSettingsConnections() -{ - connect(ui->pushButton_general_settings_exit, &QPushButton::clicked, this, [&](){ qApp->quit(); }); - - connect(ui->pushButton_settings, &QPushButton::clicked, this, [this](){ goToPage(Page::GeneralSettings); }); - connect(ui->pushButton_general_settings_app_settings, &QPushButton::clicked, this, [this](){ goToPage(Page::AppSettings); }); - connect(ui->pushButton_general_settings_network_settings, &QPushButton::clicked, this, [this](){ goToPage(Page::NetworkSettings); }); - connect(ui->pushButton_general_settings_server_settings, &QPushButton::clicked, this, [this](){ - selectedServerIndex = m_settings.defaultServerIndex(); - goToPage(Page::ServerSettings); - }); - connect(ui->pushButton_general_settings_servers_list, &QPushButton::clicked, this, [this](){ goToPage(Page::ServersList); }); - connect(ui->pushButton_general_settings_share_connection, &QPushButton::clicked, this, [this](){ - selectedServerIndex = m_settings.defaultServerIndex(); - selectedDockerContainer = m_settings.defaultContainer(selectedServerIndex); - - updateSharingPage(selectedServerIndex, m_settings.serverCredentials(selectedServerIndex), selectedDockerContainer); - goToPage(Page::ShareConnection); - }); - - connect(ui->pushButton_general_settings_add_server, &QPushButton::clicked, this, [this](){ goToPage(Page::Start); }); - -} - -void MainWindow::setupNetworkSettingsConnections() -{ - connect(ui->lineEdit_network_settings_dns1, &QLineEdit::textEdited, this, [this](const QString &newText){ - if (m_ipAddressValidator.regExp().exactMatch(newText)) { - m_settings.setPrimaryDns(newText); - } - }); - connect(ui->lineEdit_network_settings_dns2, &QLineEdit::textEdited, this, [this](const QString &newText){ - if (m_ipAddressValidator.regExp().exactMatch(newText)) { - m_settings.setSecondaryDns(newText); - } - }); - - connect(ui->pushButton_network_settings_resetdns1, &QPushButton::clicked, this, [this](){ - m_settings.setPrimaryDns(m_settings.cloudFlareNs1); - updateAppSettingsPage(); - }); - - connect(ui->pushButton_network_settings_resetdns2, &QPushButton::clicked, this, [this](){ - m_settings.setSecondaryDns(m_settings.cloudFlareNs2); - updateAppSettingsPage(); - }); -} - -void MainWindow::setupProtocolsPageConnections() -{ - QJsonObject openvpnConfig; - - // all containers - QList containers { - DockerContainer::OpenVpn, - DockerContainer::OpenVpnOverShadowSocks, - DockerContainer::OpenVpnOverCloak, - DockerContainer::WireGuard - }; - - // default buttons - QList defaultButtons { - ui->pushButton_proto_openvpn_cont_default, - ui->pushButton_proto_ss_openvpn_cont_default, - ui->pushButton_proto_cloak_openvpn_cont_default, - ui->pushButton_proto_wireguard_cont_default - }; - - for (int i = 0; i < containers.size(); ++i) { - connect(defaultButtons.at(i), &QPushButton::clicked, this, [this, containers, i](){ - m_settings.setDefaultContainer(selectedServerIndex, containers.at(i)); - updateProtocolsPage(); - }); - } - - // install buttons - QList installButtons { - ui->pushButton_proto_openvpn_cont_install, - ui->pushButton_proto_ss_openvpn_cont_install, - ui->pushButton_proto_cloak_openvpn_cont_install, - ui->pushButton_proto_wireguard_cont_install - }; - - for (int i = 0; i < containers.size(); ++i) { - QPushButton *button = installButtons.at(i); - DockerContainer container = containers.at(i); - - connect(button, &QPushButton::clicked, this, [this, container, button](bool checked){ - if (checked) { - ErrorCode e = doInstallAction([this, container](){ - return ServerController::setupContainer(m_settings.serverCredentials(selectedServerIndex), container); - }, - ui->page_server_protocols, ui->progressBar_protocols_container_reinstall, - nullptr, nullptr); - - if (!e) { - m_settings.setContainerConfig(selectedServerIndex, container, QJsonObject()); - m_settings.setDefaultContainer(selectedServerIndex, container); - } - } - else { - button->setEnabled(false); - ErrorCode e = ServerController::removeContainer(m_settings.serverCredentials(selectedServerIndex), container); - m_settings.removeContainerConfig(selectedServerIndex, container); - button->setEnabled(true); - - if (m_settings.defaultContainer(selectedServerIndex) == container) { - const auto &c = m_settings.containers(selectedServerIndex); - if (c.isEmpty()) m_settings.setDefaultContainer(selectedServerIndex, DockerContainer::None); - else m_settings.setDefaultContainer(selectedServerIndex, c.keys().first()); - } - } - - updateProtocolsPage(); - }); - } - - // share buttons - QList shareButtons { - ui->pushButton_proto_openvpn_cont_share, - ui->pushButton_proto_ss_openvpn_cont_share, - ui->pushButton_proto_cloak_openvpn_cont_share, - ui->pushButton_proto_wireguard_cont_share - }; - - for (int i = 0; i < containers.size(); ++i) { - QPushButton *button = shareButtons.at(i); - DockerContainer container = containers.at(i); - - connect(button, &QPushButton::clicked, this, [this, button, container](){ - updateSharingPage(selectedServerIndex, m_settings.serverCredentials(selectedServerIndex), container); - goToPage(Page::ShareConnection); - }); - } - - // settings buttons - - // settings openvpn container - connect(ui->pushButton_proto_openvpn_cont_openvpn_config, &QPushButton::clicked, this, [this](){ - selectedDockerContainer = DockerContainer::OpenVpn; - updateOpenVpnPage(m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, Protocol::OpenVpn), - selectedDockerContainer, m_settings.haveAuthData(selectedServerIndex)); - goToPage(Page::OpenVpnSettings); - }); - - // settings shadowsocks container - connect(ui->pushButton_proto_ss_openvpn_cont_openvpn_config, &QPushButton::clicked, this, [this](){ - selectedDockerContainer = DockerContainer::OpenVpnOverShadowSocks; - updateOpenVpnPage(m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, Protocol::OpenVpn), - selectedDockerContainer, m_settings.haveAuthData(selectedServerIndex)); - goToPage(Page::OpenVpnSettings); - }); - connect(ui->pushButton_proto_ss_openvpn_cont_ss_config, &QPushButton::clicked, this, [this](){ - selectedDockerContainer = DockerContainer::OpenVpnOverShadowSocks; - updateShadowSocksPage(m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, Protocol::ShadowSocks), - selectedDockerContainer, m_settings.haveAuthData(selectedServerIndex)); - goToPage(Page::ShadowSocksSettings); - }); - - // settings cloak container - connect(ui->pushButton_proto_cloak_openvpn_cont_openvpn_config, &QPushButton::clicked, this, [this](){ - selectedDockerContainer = DockerContainer::OpenVpnOverCloak; - updateOpenVpnPage(m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, Protocol::OpenVpn), - selectedDockerContainer, m_settings.haveAuthData(selectedServerIndex)); - goToPage(Page::OpenVpnSettings); - }); - connect(ui->pushButton_proto_cloak_openvpn_cont_ss_config, &QPushButton::clicked, this, [this](){ - selectedDockerContainer = DockerContainer::OpenVpnOverCloak; - updateShadowSocksPage(m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, Protocol::ShadowSocks), - selectedDockerContainer, m_settings.haveAuthData(selectedServerIndex)); - goToPage(Page::ShadowSocksSettings); - }); - connect(ui->pushButton_proto_cloak_openvpn_cont_cloak_config, &QPushButton::clicked, this, [this](){ - selectedDockerContainer = DockerContainer::OpenVpnOverCloak; - updateCloakPage(m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, Protocol::Cloak), - selectedDockerContainer, m_settings.haveAuthData(selectedServerIndex)); - goToPage(Page::CloakSettings); - }); - - /// - // Protocols pages - connect(ui->checkBox_proto_openvpn_auto_encryption, &QCheckBox::stateChanged, this, [this](){ - ui->comboBox_proto_openvpn_cipher->setDisabled(ui->checkBox_proto_openvpn_auto_encryption->isChecked()); - ui->comboBox_proto_openvpn_hash->setDisabled(ui->checkBox_proto_openvpn_auto_encryption->isChecked()); - }); - - connect(ui->pushButton_proto_openvpn_save, &QPushButton::clicked, this, [this](){ - QJsonObject protocolConfig = m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, Protocol::OpenVpn); - protocolConfig = getOpenVpnConfigFromPage(protocolConfig); - - QJsonObject containerConfig = m_settings.containerConfig(selectedServerIndex, selectedDockerContainer); - QJsonObject newContainerConfig = containerConfig; - newContainerConfig.insert(config_key::openvpn, protocolConfig); - - ErrorCode e = doInstallAction([this, containerConfig, newContainerConfig](){ - return ServerController::updateContainer(m_settings.serverCredentials(selectedServerIndex), selectedDockerContainer, containerConfig, newContainerConfig); - }, - ui->page_proto_openvpn, ui->progressBar_proto_openvpn_reset, - ui->pushButton_proto_openvpn_save, ui->label_proto_openvpn_info); - - if (!e) { - m_settings.setContainerConfig(selectedServerIndex, selectedDockerContainer, newContainerConfig); - m_settings.clearLastConnectionConfig(selectedServerIndex, selectedDockerContainer); - } - qDebug() << "Protocol saved with code:" << e << "for" << selectedServerIndex << selectedDockerContainer; - }); - - connect(ui->pushButton_proto_shadowsocks_save, &QPushButton::clicked, this, [this](){ - QJsonObject protocolConfig = m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, Protocol::ShadowSocks); - protocolConfig = getShadowSocksConfigFromPage(protocolConfig); - - QJsonObject containerConfig = m_settings.containerConfig(selectedServerIndex, selectedDockerContainer); - QJsonObject newContainerConfig = containerConfig; - newContainerConfig.insert(config_key::shadowsocks, protocolConfig); - - ErrorCode e = doInstallAction([this, containerConfig, newContainerConfig](){ - return ServerController::updateContainer(m_settings.serverCredentials(selectedServerIndex), selectedDockerContainer, containerConfig, newContainerConfig); - }, - ui->page_proto_shadowsocks, ui->progressBar_proto_shadowsocks_reset, - ui->pushButton_proto_shadowsocks_save, ui->label_proto_shadowsocks_info); - - if (!e) { - m_settings.setContainerConfig(selectedServerIndex, selectedDockerContainer, newContainerConfig); - m_settings.clearLastConnectionConfig(selectedServerIndex, selectedDockerContainer); - } - qDebug() << "Protocol saved with code:" << e << "for" << selectedServerIndex << selectedDockerContainer; - }); - - connect(ui->pushButton_proto_cloak_save, &QPushButton::clicked, this, [this](){ - QJsonObject protocolConfig = m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, Protocol::Cloak); - protocolConfig = getCloakConfigFromPage(protocolConfig); - - QJsonObject containerConfig = m_settings.containerConfig(selectedServerIndex, selectedDockerContainer); - QJsonObject newContainerConfig = containerConfig; - newContainerConfig.insert(config_key::cloak, protocolConfig); - - ErrorCode e = doInstallAction([this, containerConfig, newContainerConfig](){ - return ServerController::updateContainer(m_settings.serverCredentials(selectedServerIndex), selectedDockerContainer, containerConfig, newContainerConfig); - }, - ui->page_proto_cloak, ui->progressBar_proto_cloak_reset, - ui->pushButton_proto_cloak_save, ui->label_proto_cloak_info); - - if (!e) { - m_settings.setContainerConfig(selectedServerIndex, selectedDockerContainer, newContainerConfig); - m_settings.clearLastConnectionConfig(selectedServerIndex, selectedDockerContainer); - } - - qDebug() << "Protocol saved with code:" << e << "for" << selectedServerIndex << selectedDockerContainer; - }); -} - -void MainWindow::setupNewServerPageConnections() -{ - connect(ui->pushButton_connect, SIGNAL(clicked(bool)), this, SLOT(onPushButtonConnectClicked(bool))); - connect(ui->pushButton_start_switch_page, &QPushButton::toggled, this, [this](bool toggled){ - if (toggled){ - ui->stackedWidget_start->setCurrentWidget(ui->page_start_new_server); - ui->pushButton_start_switch_page->setText(tr("Import connection")); - } - else { - ui->stackedWidget_start->setCurrentWidget(ui->page_start_import); - ui->pushButton_start_switch_page->setText(tr("Set up your own server")); - } - //goToPage(Page::NewServer); - }); - - connect(ui->pushButton_new_server_connect_key, &QPushButton::toggled, this, [this](bool checked){ - ui->label_new_server_password->setText(checked ? tr("Private key") : tr("Password")); - ui->pushButton_new_server_connect_key->setText(checked ? tr("Connect using SSH password") : tr("Connect using SSH key")); - ui->lineEdit_new_server_password->setVisible(!checked); - ui->textEdit_new_server_ssh_key->setVisible(checked); - }); - - connect(ui->pushButton_new_server_settings_cloak, &QPushButton::toggled, this, [this](bool toggle){ - ui->frame_new_server_settings_cloak->setMaximumHeight(toggle * 200); - if (toggle) - ui->frame_new_server_settings_parent_cloak->layout()->addWidget(ui->frame_new_server_settings_cloak); - else - ui->frame_new_server_settings_parent_cloak->layout()->removeWidget(ui->frame_new_server_settings_cloak); - }); - connect(ui->pushButton_new_server_settings_ss, &QPushButton::toggled, this, [this](bool toggle){ - ui->frame_new_server_settings_ss->setMaximumHeight(toggle * 200); - if (toggle) - ui->frame_new_server_settings_parent_ss->layout()->addWidget(ui->frame_new_server_settings_ss); - else - ui->frame_new_server_settings_parent_ss->layout()->removeWidget(ui->frame_new_server_settings_ss); - }); - connect(ui->pushButton_new_server_settings_openvpn, &QPushButton::toggled, this, [this](bool toggle){ - ui->frame_new_server_settings_openvpn->setMaximumHeight(toggle * 200); - if (toggle) - ui->frame_new_server_settings_parent_openvpn->layout()->addWidget(ui->frame_new_server_settings_openvpn); - else - ui->frame_new_server_settings_parent_openvpn->layout()->removeWidget(ui->frame_new_server_settings_ss); - }); -} - -void MainWindow::setupServerSettingsPageConnections() -{ - connect(ui->pushButton_servers_add_new, &QPushButton::clicked, this, [this](){ goToPage(Page::Start); }); - - connect(ui->pushButton_server_settings_protocols, &QPushButton::clicked, this, [this](){ goToPage(Page::ServerVpnProtocols); }); - connect(ui->pushButton_server_settings_share_full, &QPushButton::clicked, this, [this](){ - updateSharingPage(selectedServerIndex, m_settings.serverCredentials(selectedServerIndex), DockerContainer::None); - goToPage(Page::ShareConnection); - }); - - connect(ui->pushButton_server_settings_clear, SIGNAL(clicked(bool)), this, SLOT(onPushButtonClearServer(bool))); - connect(ui->pushButton_server_settings_forget, SIGNAL(clicked(bool)), this, SLOT(onPushButtonForgetServer(bool))); - - connect(ui->pushButton_server_settings_clear_client_cache, &QPushButton::clicked, this, [this](){ - ui->pushButton_server_settings_clear_client_cache->setText(tr("Cache cleared")); - - const auto &containers = m_settings.containers(selectedServerIndex); - for (DockerContainer container: containers.keys()) { - m_settings.clearLastConnectionConfig(selectedServerIndex, container); - } - - QTimer::singleShot(3000, this, [this]() { - ui->pushButton_server_settings_clear_client_cache->setText(tr("Clear client cached profile")); - }); - }); - - connect(ui->lineEdit_server_settings_description, &QLineEdit::editingFinished, this, [this](){ - const QString &newText = ui->lineEdit_server_settings_description->text(); - QJsonObject server = m_settings.server(selectedServerIndex); - server.insert(config_key::description, newText); - m_settings.editServer(selectedServerIndex, server); - updateServersListPage(); - }); - - connect(ui->lineEdit_server_settings_description, &QLineEdit::returnPressed, this, [this](){ - ui->lineEdit_server_settings_description->clearFocus(); - }); -} - -void MainWindow::setupSharePageConnections() -{ - connect(ui->pushButton_share_full_copy, &QPushButton::clicked, this, [this](){ - QGuiApplication::clipboard()->setText(ui->textEdit_share_full_code->toPlainText()); - ui->pushButton_share_full_copy->setText(tr("Copied")); - - QTimer::singleShot(3000, this, [this]() { - ui->pushButton_share_full_copy->setText(tr("Copy")); - }); - }); - - connect(ui->pushButton_share_full_save, &QPushButton::clicked, this, [this](){ - if (ui->textEdit_share_full_code->toPlainText().isEmpty()) return; - - QString fileName = QFileDialog::getSaveFileName(this, tr("Save AmneziaVPN config"), - QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.amnezia"); - QSaveFile save(fileName); - save.open(QIODevice::WriteOnly); - save.write(ui->textEdit_share_full_code->toPlainText().toUtf8()); - save.commit(); - }); - - connect(ui->pushButton_share_amnezia_copy, &QPushButton::clicked, this, [this](){ - if (ui->textEdit_share_amnezia_code->toPlainText().isEmpty()) return; - - QGuiApplication::clipboard()->setText(ui->textEdit_share_amnezia_code->toPlainText()); - ui->pushButton_share_amnezia_copy->setText(tr("Copied")); - - QTimer::singleShot(3000, this, [this]() { - ui->pushButton_share_amnezia_copy->setText(tr("Copy")); - }); - }); - - connect(ui->pushButton_share_amnezia_save, &QPushButton::clicked, this, [this](){ - if (ui->textEdit_share_amnezia_code->toPlainText().isEmpty()) return; - - QString fileName = QFileDialog::getSaveFileName(this, tr("Save AmneziaVPN config"), - QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.amnezia"); - QSaveFile save(fileName); - save.open(QIODevice::WriteOnly); - save.write(ui->textEdit_share_amnezia_code->toPlainText().toUtf8()); - save.commit(); - }); - - connect(ui->pushButton_share_openvpn_copy, &QPushButton::clicked, this, [this](){ - QGuiApplication::clipboard()->setText(ui->textEdit_share_openvpn_code->toPlainText()); - ui->pushButton_share_openvpn_copy->setText(tr("Copied")); - - QTimer::singleShot(3000, this, [this]() { - ui->pushButton_share_openvpn_copy->setText(tr("Copy")); - }); - }); - - connect(ui->pushButton_share_ss_copy, &QPushButton::clicked, this, [this](){ - QGuiApplication::clipboard()->setText(ui->lineEdit_share_ss_string->text()); - ui->pushButton_share_ss_copy->setText(tr("Copied")); - - QTimer::singleShot(3000, this, [this]() { - ui->pushButton_share_ss_copy->setText(tr("Copy")); - }); - }); - - connect(ui->pushButton_share_cloak_copy, &QPushButton::clicked, this, [this](){ - QGuiApplication::clipboard()->setText(ui->plainTextEdit_share_cloak->toPlainText()); - ui->pushButton_share_cloak_copy->setText(tr("Copied")); - - QTimer::singleShot(3000, this, [this]() { - ui->pushButton_share_cloak_copy->setText(tr("Copy")); - }); - }); - - connect(ui->pushButton_share_amnezia_generate, &QPushButton::clicked, this, [this](){ - ui->pushButton_share_amnezia_generate->setEnabled(false); - ui->pushButton_share_amnezia_copy->setEnabled(false); - ui->pushButton_share_amnezia_generate->setText(tr("Generating...")); - qApp->processEvents(); - - ServerCredentials credentials = m_settings.serverCredentials(selectedServerIndex); - QJsonObject containerConfig = m_settings.containerConfig(selectedServerIndex, selectedDockerContainer); - containerConfig.insert(config_key::container, containerToString(selectedDockerContainer)); - - ErrorCode e = ErrorCode::NoError; - for (Protocol p: amnezia::protocolsForContainer(selectedDockerContainer)) { - QJsonObject protoConfig = m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, p); - - QString cfg = VpnConfigurator::genVpnProtocolConfig(credentials, selectedDockerContainer, containerConfig, p, &e); - if (e) { - cfg = "Error generating config"; - break; - } - protoConfig.insert(config_key::last_config, cfg); - - containerConfig.insert(protoToString(p), protoConfig); - } - - QByteArray ba; - if (!e) { - QJsonObject serverConfig = m_settings.server(selectedServerIndex); - serverConfig.remove(config_key::userName); - serverConfig.remove(config_key::password); - serverConfig.remove(config_key::port); - serverConfig.insert(config_key::containers, QJsonArray {containerConfig}); - serverConfig.insert(config_key::defaultContainer, containerToString(selectedDockerContainer)); - - - ba = QJsonDocument(serverConfig).toJson().toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals); - ui->textEdit_share_amnezia_code->setPlainText(QString("vpn://%1").arg(QString(ba))); - } - else { - ui->textEdit_share_amnezia_code->setPlainText(tr("Error while generating connection profile")); - } - - ui->pushButton_share_amnezia_generate->setEnabled(true); - ui->pushButton_share_amnezia_copy->setEnabled(true); - ui->pushButton_share_amnezia_generate->setText(tr("Generate config")); - }); - - connect(ui->pushButton_share_openvpn_generate, &QPushButton::clicked, this, [this](){ - ui->pushButton_share_openvpn_generate->setEnabled(false); - ui->pushButton_share_openvpn_copy->setEnabled(false); - ui->pushButton_share_openvpn_save->setEnabled(false); - ui->pushButton_share_openvpn_generate->setText(tr("Generating...")); - - ServerCredentials credentials = m_settings.serverCredentials(selectedServerIndex); - const QJsonObject &containerConfig = m_settings.containerConfig(selectedServerIndex, selectedDockerContainer); - - ErrorCode e = ErrorCode::NoError; - QString cfg = OpenVpnConfigurator::genOpenVpnConfig(credentials, selectedDockerContainer, containerConfig, &e); - cfg = OpenVpnConfigurator::processConfigWithExportSettings(cfg); - - ui->textEdit_share_openvpn_code->setPlainText(cfg); - - ui->pushButton_share_openvpn_generate->setEnabled(true); - ui->pushButton_share_openvpn_copy->setEnabled(true); - ui->pushButton_share_openvpn_save->setEnabled(true); - ui->pushButton_share_openvpn_generate->setText(tr("Generate config")); - }); - - connect(ui->pushButton_share_openvpn_save, &QPushButton::clicked, this, [this](){ - QString fileName = QFileDialog::getSaveFileName(this, tr("Save OpenVPN config"), - QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.ovpn"); - - QSaveFile save(fileName); - save.open(QIODevice::WriteOnly); - save.write(ui->textEdit_share_openvpn_code->toPlainText().toUtf8()); - save.commit(); - }); -} - -void MainWindow::setTrayState(VpnProtocol::ConnectionState state) -{ - QString resourcesPath = ":/images/tray/%1"; - - m_trayActionDisconnect->setEnabled(state == VpnProtocol::Connected); - m_trayActionConnect->setEnabled(state == VpnProtocol::Disconnected); - - switch (state) { - case VpnProtocol::Disconnected: - setTrayIcon(QString(resourcesPath).arg(DisconnectedTrayIconName)); - break; - case VpnProtocol::Preparing: - setTrayIcon(QString(resourcesPath).arg(DisconnectedTrayIconName)); - break; - case VpnProtocol::Connecting: - setTrayIcon(QString(resourcesPath).arg(DisconnectedTrayIconName)); - break; - case VpnProtocol::Connected: - setTrayIcon(QString(resourcesPath).arg(ConnectedTrayIconName)); - break; - case VpnProtocol::Disconnecting: - setTrayIcon(QString(resourcesPath).arg(DisconnectedTrayIconName)); - break; - case VpnProtocol::Reconnecting: - setTrayIcon(QString(resourcesPath).arg(DisconnectedTrayIconName)); - break; - case VpnProtocol::Error: - setTrayIcon(QString(resourcesPath).arg(ErrorTrayIconName)); - break; - case VpnProtocol::Unknown: - default: - setTrayIcon(QString(resourcesPath).arg(DisconnectedTrayIconName)); - } - - //#ifdef Q_OS_MAC - // // Get theme from current user (note, this app can be launched as root application and in this case this theme can be different from theme of real current user ) - // bool darkTaskBar = MacOSFunctions::instance().isMenuBarUseDarkTheme(); - // darkTaskBar = forceUseBrightIcons ? true : darkTaskBar; - // resourcesPath = ":/images_mac/tray_icon/%1"; - // useIconName = useIconName.replace(".png", darkTaskBar ? "@2x.png" : " dark@2x.png"); - //#endif - -} - -void MainWindow::onTrayActivated(QSystemTrayIcon::ActivationReason reason) -{ -#if defined Q_OS_MACX || defined Q_OS_LINUX - if(reason == QSystemTrayIcon::DoubleClick || reason == QSystemTrayIcon::Trigger) { - show(); - raise(); - setWindowState(Qt::WindowActive); - } -#endif -} - -void MainWindow::onConnect() -{ - int serverIndex = m_settings.defaultServerIndex(); - ServerCredentials credentials = m_settings.serverCredentials(serverIndex); - DockerContainer container = m_settings.defaultContainer(serverIndex); - - if (m_settings.containers(serverIndex).isEmpty()) { - ui->label_error_text->setText(tr("VPN Protocols is not installed.\n Please install VPN container at first")); - ui->pushButton_connect->setChecked(false); - return; - } - - if (container == DockerContainer::None) { - ui->label_error_text->setText(tr("VPN Protocol not choosen")); - ui->pushButton_connect->setChecked(false); - return; - } - - - const QJsonObject &containerConfig = m_settings.containerConfig(serverIndex, container); - onConnectWorker(serverIndex, credentials, container, containerConfig); -} - -void MainWindow::onConnectWorker(int serverIndex, const ServerCredentials &credentials, DockerContainer container, const QJsonObject &containerConfig) -{ - ui->label_error_text->clear(); - ui->pushButton_connect->setChecked(true); - qApp->processEvents(); - - ErrorCode errorCode = m_vpnConnection->connectToVpn( - serverIndex, credentials, container, containerConfig - ); - - if (errorCode) { - //ui->pushButton_connect->setChecked(false); - QMessageBox::critical(this, APPLICATION_NAME, errorString(errorCode)); - return; - } - - ui->pushButton_connect->setEnabled(false); -} - -void MainWindow::onDisconnect() -{ - ui->pushButton_connect->setChecked(false); - m_vpnConnection->disconnectFromVpn(); -} - -void MainWindow::onTrayActionConnect() -{ - if(m_trayActionConnect->text() == tr("Connect")) { - onConnect(); - } else if(m_trayActionConnect->text() == tr("Disconnect")) { - onDisconnect(); - } -} - -void MainWindow::onPushButtonAddCustomSitesClicked() -{ - if (ui->radioButton_vpn_mode_all_sites->isChecked()) return; - Settings::RouteMode mode = m_settings.routeMode(); - - QString newSite = ui->lineEdit_sites_add_custom->text(); - - if (newSite.isEmpty()) return; - if (!newSite.contains(".")) return; - - if (!Utils::ipAddressWithSubnetRegExp().exactMatch(newSite)) { - // get domain name if it present - newSite.replace("https://", ""); - newSite.replace("http://", ""); - newSite.replace("ftp://", ""); - - newSite = newSite.split("/", QString::SkipEmptyParts).first(); - } - - const auto &cbProcess = [this, mode](const QString &newSite, const QString &ip) { - m_settings.addVpnSite(mode, newSite, ip); - - if (!ip.isEmpty()) { - m_vpnConnection->addRoutes(QStringList() << ip); - m_vpnConnection->flushDns(); - } - else if (Utils::ipAddressWithSubnetRegExp().exactMatch(newSite)) { - m_vpnConnection->addRoutes(QStringList() << newSite); - m_vpnConnection->flushDns(); - } - - updateSitesPage(); - }; - - const auto &cbResolv = [this, cbProcess](const QHostInfo &hostInfo){ - const QList &addresses = hostInfo.addresses(); - QString ipv4Addr; - for (const QHostAddress &addr: hostInfo.addresses()) { - if (addr.protocol() == QAbstractSocket::NetworkLayerProtocol::IPv4Protocol) { - cbProcess(hostInfo.hostName(), addr.toString()); - break; - } - } - }; - - ui->lineEdit_sites_add_custom->clear(); - - if (Utils::ipAddressWithSubnetRegExp().exactMatch(newSite)) { - cbProcess(newSite, ""); - return; - } - else { - cbProcess(newSite, ""); - updateSitesPage(); - QHostInfo::lookupHost(newSite, this, cbResolv); - } -} - -void MainWindow::updateStartPage() -{ - ui->lineEdit_start_existing_code->clear(); - ui->textEdit_new_server_ssh_key->clear(); - ui->lineEdit_new_server_ip->clear(); - ui->lineEdit_new_server_password->clear(); - ui->textEdit_new_server_ssh_key->clear(); - ui->lineEdit_new_server_login->setText("root"); - - ui->label_new_server_wait_info->hide(); - ui->label_new_server_wait_info->clear(); - - ui->progressBar_new_server_connection->setMinimum(0); - ui->progressBar_new_server_connection->setMaximum(300); - - ui->pushButton_back_from_start->setVisible(!pagesStack.isEmpty()); - - ui->pushButton_new_server_connect->setVisible(true); -} - -void MainWindow::updateSitesPage() -{ - Settings::RouteMode m = m_settings.routeMode(); - if (m == Settings::VpnAllSites) return; - - if (m == Settings::VpnOnlyForwardSites) ui->label_sites_add_custom->setText(tr("These sites will be opened using VPN")); - if (m == Settings::VpnAllExceptSites) ui->label_sites_add_custom->setText(tr("These sites will be excepted from VPN")); - - ui->tableView_sites->setModel(sitesModels.value(m)); - sitesModels.value(m)->resetCache(); -} - -void MainWindow::updateVpnPage() -{ - Settings::RouteMode mode = m_settings.routeMode(); - ui->radioButton_vpn_mode_all_sites->setChecked(mode == Settings::VpnAllSites); - ui->radioButton_vpn_mode_forward_sites->setChecked(mode == Settings::VpnOnlyForwardSites); - ui->radioButton_vpn_mode_except_sites->setChecked(mode == Settings::VpnAllExceptSites); - ui->pushButton_vpn_add_site->setEnabled(mode != Settings::VpnAllSites); -} - -void MainWindow::updateAppSettingsPage() -{ - ui->checkBox_app_settings_autostart->setChecked(Autostart::isAutostart()); - ui->checkBox_app_settings_autoconnect->setChecked(m_settings.isAutoConnect()); - ui->checkBox_app_settings_start_minimized->setChecked(m_settings.isStartMinimized()); - - ui->lineEdit_network_settings_dns1->setText(m_settings.primaryDns()); - ui->lineEdit_network_settings_dns2->setText(m_settings.secondaryDns()); - - QString ver = QString("%1: %2 (%3)") - .arg(tr("Software version")) - .arg(QString(APP_MAJOR_VERSION)) - .arg(__DATE__); - ui->label_app_settings_version->setText(ver); -} - -void MainWindow::updateGeneralSettingPage() -{ - ui->pushButton_general_settings_share_connection->setEnabled(m_settings.haveAuthData(m_settings.defaultServerIndex())); -} - -void MainWindow::updateServerPage() -{ - ui->label_server_settings_wait_info->hide(); - ui->label_server_settings_wait_info->clear(); - - ui->pushButton_server_settings_clear->setVisible(m_settings.haveAuthData(selectedServerIndex)); - ui->pushButton_server_settings_clear_client_cache->setVisible(m_settings.haveAuthData(selectedServerIndex)); - ui->pushButton_server_settings_share_full->setVisible(m_settings.haveAuthData(selectedServerIndex)); - - QJsonObject server = m_settings.server(selectedServerIndex); - QString port = server.value(config_key::port).toString(); - ui->label_server_settings_server->setText(QString("%1@%2%3%4") - .arg(server.value(config_key::userName).toString()) - .arg(server.value(config_key::hostName).toString()) - .arg(port.isEmpty() ? "" : ":") - .arg(port)); - ui->lineEdit_server_settings_description->setText(server.value(config_key::description).toString()); - - QString selectedContainerName = m_settings.defaultContainerName(selectedServerIndex); - - ui->label_server_settings_current_vpn_protocol->setText(tr("Protocol: ") + selectedContainerName); - - //qDebug() << "DefaultContainer(selectedServerIndex)" << selectedServerIndex << containerToString(m_settings.defaultContainer(selectedServerIndex)); - -} - -void MainWindow::updateServersListPage() -{ - ui->listWidget_servers->clear(); - const QJsonArray &servers = m_settings.serversArray(); - int defaultServer = m_settings.defaultServerIndex(); - - ui->listWidget_servers->setUpdatesEnabled(false); - for(int i = 0; i < servers.size(); i++) { - makeServersListItem(ui->listWidget_servers, servers.at(i).toObject(), i == defaultServer, i); - } - ui->listWidget_servers->setUpdatesEnabled(true); -} - -void MainWindow::updateProtocolsPage() -{ - ui->progressBar_protocols_container_reinstall->hide(); - - auto containers = m_settings.containers(selectedServerIndex); - DockerContainer defaultContainer = m_settings.defaultContainer(selectedServerIndex); - bool haveAuthData = m_settings.haveAuthData(selectedServerIndex); - - // all containers - QList allContainers { - DockerContainer::OpenVpn, - DockerContainer::OpenVpnOverShadowSocks, - DockerContainer::OpenVpnOverCloak, - DockerContainer::WireGuard - }; - - // install buttons - QList installButtons { - ui->pushButton_proto_openvpn_cont_install, - ui->pushButton_proto_ss_openvpn_cont_install, - ui->pushButton_proto_cloak_openvpn_cont_install, - ui->pushButton_proto_wireguard_cont_install - }; - - // default buttons - QList defaultButtons { - ui->pushButton_proto_openvpn_cont_default, - ui->pushButton_proto_ss_openvpn_cont_default, - ui->pushButton_proto_cloak_openvpn_cont_default, - ui->pushButton_proto_wireguard_cont_default - }; - - // share buttons - QList shareButtons { - ui->pushButton_proto_openvpn_cont_share, - ui->pushButton_proto_ss_openvpn_cont_share, - ui->pushButton_proto_cloak_openvpn_cont_share, - ui->pushButton_proto_wireguard_cont_share - }; - - // frames - QList frames { - ui->frame_openvpn_settings, - ui->frame_openvpn_ss_settings, - ui->frame_openvpn_ss_cloak_settings, - ui->frame_wireguard_settings - }; - - for (int i = 0; i < allContainers.size(); ++i) { - defaultButtons.at(i)->setChecked(defaultContainer == allContainers.at(i)); - defaultButtons.at(i)->setVisible(haveAuthData && containers.contains(allContainers.at(i))); - shareButtons.at(i)->setVisible(haveAuthData && containers.contains(allContainers.at(i))); - installButtons.at(i)->setChecked(containers.contains(allContainers.at(i))); - installButtons.at(i)->setEnabled(haveAuthData); - frames.at(i)->setVisible(containers.contains(allContainers.at(i))); - - } -} - -void MainWindow::updateOpenVpnPage(const QJsonObject &openvpnConfig, DockerContainer container, bool haveAuthData) -{ - ui->widget_proto_openvpn->setEnabled(haveAuthData); - ui->pushButton_proto_openvpn_save->setVisible(haveAuthData); - ui->progressBar_proto_openvpn_reset->setVisible(haveAuthData); - - ui->radioButton_proto_openvpn_udp->setEnabled(true); - ui->radioButton_proto_openvpn_tcp->setEnabled(true); - - ui->lineEdit_proto_openvpn_subnet->setText(openvpnConfig.value(config_key::subnet_address). - toString(protocols::openvpn::defaultSubnetAddress)); - - QString trasnsport = openvpnConfig.value(config_key::transport_proto). - toString(protocols::openvpn::defaultTransportProto); - - ui->radioButton_proto_openvpn_udp->setChecked(trasnsport == protocols::openvpn::defaultTransportProto); - ui->radioButton_proto_openvpn_tcp->setChecked(trasnsport != protocols::openvpn::defaultTransportProto); - - ui->comboBox_proto_openvpn_cipher->setCurrentText(openvpnConfig.value(config_key::cipher). - toString(protocols::openvpn::defaultCipher)); - - ui->comboBox_proto_openvpn_hash->setCurrentText(openvpnConfig.value(config_key::hash). - toString(protocols::openvpn::defaultHash)); - - bool blockOutsideDns = openvpnConfig.value(config_key::block_outside_dns).toBool(protocols::openvpn::defaultBlockOutsideDns); - ui->checkBox_proto_openvpn_block_dns->setChecked(blockOutsideDns); - - bool isNcpDisabled = openvpnConfig.value(config_key::ncp_disable).toBool(protocols::openvpn::defaultNcpDisable); - ui->checkBox_proto_openvpn_auto_encryption->setChecked(!isNcpDisabled); - - bool isTlsAuth = openvpnConfig.value(config_key::tls_auth).toBool(protocols::openvpn::defaultTlsAuth); - ui->checkBox_proto_openvpn_tls_auth->setChecked(isTlsAuth); - - if (container == DockerContainer::OpenVpnOverShadowSocks) { - ui->radioButton_proto_openvpn_udp->setEnabled(false); - ui->radioButton_proto_openvpn_tcp->setEnabled(false); - ui->radioButton_proto_openvpn_tcp->setChecked(true); - } - - ui->lineEdit_proto_openvpn_port->setText(openvpnConfig.value(config_key::port). - toString(protocols::openvpn::defaultPort)); - - ui->lineEdit_proto_openvpn_port->setEnabled(container == DockerContainer::OpenVpn); -} - -void MainWindow::updateShadowSocksPage(const QJsonObject &ssConfig, DockerContainer container, bool haveAuthData) -{ - ui->widget_proto_ss->setEnabled(haveAuthData); - ui->pushButton_proto_shadowsocks_save->setVisible(haveAuthData); - ui->progressBar_proto_shadowsocks_reset->setVisible(haveAuthData); - - ui->comboBox_proto_shadowsocks_cipher->setCurrentText(ssConfig.value(config_key::cipher). - toString(protocols::shadowsocks::defaultCipher)); - - ui->lineEdit_proto_shadowsocks_port->setText(ssConfig.value(config_key::port). - toString(protocols::shadowsocks::defaultPort)); - - ui->lineEdit_proto_shadowsocks_port->setEnabled(container == DockerContainer::OpenVpnOverShadowSocks); -} - -void MainWindow::updateCloakPage(const QJsonObject &ckConfig, DockerContainer container, bool haveAuthData) -{ - ui->widget_proto_cloak->setEnabled(haveAuthData); - ui->pushButton_proto_cloak_save->setVisible(haveAuthData); - ui->progressBar_proto_cloak_reset->setVisible(haveAuthData); - - ui->comboBox_proto_cloak_cipher->setCurrentText(ckConfig.value(config_key::cipher). - toString(protocols::cloak::defaultCipher)); - - ui->lineEdit_proto_cloak_site->setText(ckConfig.value(config_key::site). - toString(protocols::cloak::defaultRedirSite)); - - ui->lineEdit_proto_cloak_port->setText(ckConfig.value(config_key::port). - toString(protocols::cloak::defaultPort)); - - ui->lineEdit_proto_cloak_port->setEnabled(container == DockerContainer::OpenVpnOverCloak); -} - -void MainWindow::updateSharingPage(int serverIndex, const ServerCredentials &credentials, - DockerContainer container) -{ - selectedDockerContainer = container; - selectedServerIndex = serverIndex; - - //const QJsonObject &containerConfig = m_settings.containerConfig(serverIndex, container); - - for (QWidget *page : { - ui->page_share_amnezia, - ui->page_share_openvpn, - ui->page_share_shadowsocks, - ui->page_share_cloak, - ui->page_share_full_access }) { - - ui->toolBox_share_connection->removeItem(ui->toolBox_share_connection->indexOf(page)); - page->hide(); - } - - if (container == DockerContainer::OpenVpn) { - ui->toolBox_share_connection->addItem(ui->page_share_amnezia, tr(" Share for Amnezia client")); - ui->toolBox_share_connection->addItem(ui->page_share_openvpn, tr(" Share for OpenVPN client")); - - QString cfg = tr("Press Generate config"); - ui->textEdit_share_openvpn_code->setPlainText(cfg); - ui->pushButton_share_openvpn_copy->setEnabled(false); - ui->pushButton_share_openvpn_save->setEnabled(false); - - ui->toolBox_share_connection->setCurrentWidget(ui->page_share_openvpn); - } - - if (container == DockerContainer::OpenVpnOverShadowSocks || - container == DockerContainer::OpenVpnOverCloak) { - ui->toolBox_share_connection->addItem(ui->page_share_amnezia, tr(" Share for Amnezia client")); - ui->toolBox_share_connection->addItem(ui->page_share_shadowsocks, tr(" Share for ShadowSocks client")); - - QJsonObject protoConfig = m_settings.protocolConfig(serverIndex, container, Protocol::ShadowSocks); - QString cfg = protoConfig.value(config_key::last_config).toString(); - - if (cfg.isEmpty()) { - const QJsonObject &containerConfig = m_settings.containerConfig(serverIndex, container); - - ErrorCode e = ErrorCode::NoError; - cfg = ShadowSocksConfigurator::genShadowSocksConfig(credentials, container, containerConfig, &e); - - ui->pushButton_share_ss_copy->setEnabled(true); - } - - QJsonObject ssConfig = QJsonDocument::fromJson(cfg.toUtf8()).object(); - - QString ssString = QString("%1:%2@%3:%4") - .arg(ssConfig.value("method").toString()) - .arg(ssConfig.value("password").toString()) - .arg(ssConfig.value("server").toString()) - .arg(ssConfig.value("server_port").toString()); - - ssString = "ss://" + ssString.toUtf8().toBase64(); - ui->lineEdit_share_ss_string->setText(ssString); - updateQRCodeImage(ssString, ui->label_share_ss_qr_code); - - ui->label_share_ss_server->setText(ssConfig.value("server").toString()); - ui->label_share_ss_port->setText(ssConfig.value("server_port").toString()); - ui->label_share_ss_method->setText(ssConfig.value("method").toString()); - ui->label_share_ss_password->setText(ssConfig.value("password").toString()); - - ui->toolBox_share_connection->setCurrentWidget(ui->page_share_shadowsocks); - ui->page_share_shadowsocks->show(); - ui->page_share_shadowsocks->raise(); - qDebug() << ui->page_share_shadowsocks->size(); - ui->toolBox_share_connection->layout()->update(); - } - - if (container == DockerContainer::OpenVpnOverCloak) { - //ui->toolBox_share_connection->addItem(ui->page_share_amnezia, tr(" Share for Amnezia client")); - ui->toolBox_share_connection->addItem(ui->page_share_cloak, tr(" Share for Cloak client")); - ui->plainTextEdit_share_cloak->setPlainText(QString("")); - - QJsonObject protoConfig = m_settings.protocolConfig(serverIndex, container, Protocol::Cloak); - QString cfg = protoConfig.value(config_key::last_config).toString(); - - if (cfg.isEmpty()) { - const QJsonObject &containerConfig = m_settings.containerConfig(serverIndex, container); - - ErrorCode e = ErrorCode::NoError; - cfg = CloakConfigurator::genCloakConfig(credentials, container, containerConfig, &e); - - ui->pushButton_share_cloak_copy->setEnabled(true); - } - - QJsonObject cloakConfig = QJsonDocument::fromJson(cfg.toUtf8()).object(); - cloakConfig.remove(config_key::transport_proto); - cloakConfig.insert("ProxyMethod", "shadowsocks"); - - ui->plainTextEdit_share_cloak->setPlainText(QJsonDocument(cloakConfig).toJson()); - } - - // Full access - if (container == DockerContainer::None) { - ui->toolBox_share_connection->addItem(ui->page_share_full_access, tr(" Share server full access")); - - const QJsonObject &server = m_settings.server(selectedServerIndex); - - QByteArray ba = QJsonDocument(server).toJson().toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals); - - ui->textEdit_share_full_code->setText(QString("vpn://%1").arg(QString(ba))); - ui->toolBox_share_connection->setCurrentWidget(ui->page_share_full_access); - } - - //ui->toolBox_share_connection->addItem(ui->page_share_amnezia, tr(" Share for Amnezia client")); - - // Amnezia sharing -// QJsonObject exportContainer; -// for (Protocol p: protocolsForContainer(container)) { -// QJsonObject protocolConfig = containerConfig.value(protoToString(p)).toObject(); -// protocolConfig.remove(config_key::last_config); -// exportContainer.insert(protoToString(p), protocolConfig); -// } -// exportContainer.insert(config_key::container, containerToString(container)); - -// ui->textEdit_share_amnezia_code->setPlainText(QJsonDocument(exportContainer).toJson()); - - ui->textEdit_share_amnezia_code->setPlainText(tr("")); -} - -void MainWindow::makeServersListItem(QListWidget *listWidget, const QJsonObject &server, bool isDefault, int index) -{ - QSize size(310, 70); - ServerWidget* widget = new ServerWidget(server, isDefault); - - widget->resize(size); - - connect(widget->ui->pushButton_default, &QPushButton::clicked, this, [this, index](){ - m_settings.setDefaultServer(index); - updateServersListPage(); - }); - -// connect(widget->ui->pushButton_share, &QPushButton::clicked, this, [this, index](){ -// goToPage(Page::ShareConnection); -// // update share page -// }); - - connect(widget->ui->pushButton_settings, &QPushButton::clicked, this, [this, index](){ - selectedServerIndex = index; - goToPage(Page::ServerSettings); - }); - - QListWidgetItem* item = new QListWidgetItem(listWidget); - item->setSizeHint(size); - listWidget->setItemWidget(item, widget); - - widget->setStyleSheet(styleSheet()); -} - -void MainWindow::updateQRCodeImage(const QString &text, QLabel *label) -{ - int levelIndex = 1; - int versionIndex = 0; - bool bExtent = true; - int maskIndex = -1; - - m_qrEncode.EncodeData( levelIndex, versionIndex, bExtent, maskIndex, text.toUtf8().data() ); - - int qrImageSize = m_qrEncode.m_nSymbleSize; - - int encodeImageSize = qrImageSize + ( QR_MARGIN * 2 ); - QImage encodeImage( encodeImageSize, encodeImageSize, QImage::Format_Mono ); - - encodeImage.fill( 1 ); - - for ( int i = 0; i < qrImageSize; i++ ) - for ( int j = 0; j < qrImageSize; j++ ) - if ( m_qrEncode.m_byModuleData[i][j] ) - encodeImage.setPixel( i + QR_MARGIN, j + QR_MARGIN, 0 ); - - label->setPixmap(QPixmap::fromImage(encodeImage.scaledToWidth(label->width()))); -} - -QJsonObject MainWindow::getOpenVpnConfigFromPage(QJsonObject oldConfig) -{ - oldConfig.insert(config_key::subnet_address, ui->lineEdit_proto_openvpn_subnet->text()); - oldConfig.insert(config_key::transport_proto, ui->radioButton_proto_openvpn_udp->isChecked() ? protocols::UDP : protocols::TCP); - oldConfig.insert(config_key::ncp_disable, ! ui->checkBox_proto_openvpn_auto_encryption->isChecked()); - oldConfig.insert(config_key::cipher, ui->comboBox_proto_openvpn_cipher->currentText()); - oldConfig.insert(config_key::hash, ui->comboBox_proto_openvpn_hash->currentText()); - oldConfig.insert(config_key::block_outside_dns, ui->checkBox_proto_openvpn_block_dns->isChecked()); - oldConfig.insert(config_key::port, ui->lineEdit_proto_openvpn_port->text()); - oldConfig.insert(config_key::tls_auth, ui->checkBox_proto_openvpn_tls_auth->isChecked()); - - return oldConfig; -} - -QJsonObject MainWindow::getShadowSocksConfigFromPage(QJsonObject oldConfig) -{ - oldConfig.insert(config_key::cipher, ui->comboBox_proto_shadowsocks_cipher->currentText()); - oldConfig.insert(config_key::port, ui->lineEdit_proto_shadowsocks_port->text()); - - return oldConfig; -} - -QJsonObject MainWindow::getCloakConfigFromPage(QJsonObject oldConfig) -{ - oldConfig.insert(config_key::cipher, ui->comboBox_proto_cloak_cipher->currentText()); - oldConfig.insert(config_key::site, ui->lineEdit_proto_cloak_site->text()); - oldConfig.insert(config_key::port, ui->lineEdit_proto_cloak_port->text()); - - return oldConfig; -} diff --git a/client/ui/mainwindow.h b/client/ui/mainwindow.h deleted file mode 100644 index 32fa99f4..00000000 --- a/client/ui/mainwindow.h +++ /dev/null @@ -1,174 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#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 &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 &containers, - QWidget *page, QProgressBar *progress, QPushButton *button, QLabel *info); - - ErrorCode doInstallAction(const std::function &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 getInstallConfigsFromProtocolsPage() const; - QMap getInstallConfigsFromWizardPage() const; - -private: - Ui::MainWindow *ui; - VpnConnection* m_vpnConnection; - Settings m_settings; - - QMap 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 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 diff --git a/client/ui/mainwindow.ui b/client/ui/mainwindow.ui deleted file mode 100644 index 0cbd7c6d..00000000 --- a/client/ui/mainwindow.ui +++ /dev/null @@ -1,7754 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 380 - 670 - - - - AmneziaVPN - - - QMainWindow { - background: white; -} - - -QWidget { -font-family: "Lato"; -} - -/*----------------------*/ - -QPushButton { - font-size: 16px; - outline: none; - font-style: normal; - font-weight: normal; - - border: none; -} -QPushButton:disabled { - border: none; -} - -QLabel { - outline: none; - font-size: 16px; - - font-style: normal; - font-weight: normal; - color: #181922; -} -QLabel:disabled { - color: #A7A7A7; -} - -QMessageBox QLabel { - font: 16px "Lato"; -} - - -/*----------------------*/ - -QTextEdit { -background: #F4F4F4; - -/* grey */ -border: 1px solid #A7A7A7; -color: #333333; - -} - -QComboBox { -font-size: 16px; -} - -QLineEdit { -font-size: 16px; -selection-background-color: darkgray; - -background: #F4F4F4; - -border: 1px solid #A7A7A7; -color: #333333; -} - -QLineEdit:focus { - border-bottom:2px solid rgb(200, 200, 200); -} -QLineEdit[error] { - border-bottom:2px solid rgb(213, 40, 60); - color: rgb(213, 40, 60); -} -QLineEdit:disabled { - border-bottom:2px solid rgb(127, 127, 127); - color: rgb(127, 127, 127); -} - -QRadioButton { - color: #181922; - font-size: 16px; - background: transparent; -} - -QCheckBox { - color: #181922; - font-size: 16px; - background: transparent; -} - -QCheckBox::indicator { -min-height: 20px; -min-width: 20px; - -border-image: url(:/images/controls/check_off.png) 0 0 0 0 stretch stretch; -} - -QCheckBox::indicator:unchecked { -border-image: url(:/images/controls/check_off.png) 0 0 0 0 stretch stretch; -} - -QCheckBox::indicator:checked { -border-image: url(:/images/controls/check_on.png); - -} - - -QScrollBar:vertical { /* The area behind the scrollbar covering entire height. */ - background-color: rgba(0, 0, 0,0); - opacity: 100; - width: 10px; /* set width to zero to hide scrollbar entirely. Can look quite clean and scrolling still works with mousewheel. */ - margin: 10px px; /* Takes the height of the buttons + 3 extra pixels to leave some free space between handle and buttons */ - -} - -QScrollBar::handle:vertical { /* The handle you scroll with */ - image-position: center; /* image is used as a small gripper in the center of the scrollbar.. You can also use background-image to use two images */ - background-color: rgb(200, 200, 200); - border: 2px solid rgb(240,240,240); - border-radius: 1px; - min-height: 10px; -} -QScrollBar::handle:vertical:hover { /* state when you hover over the handle */ - background-color: rgb(160, 160, 160); -} -QScrollBar::handle:vertical:pressed { /* state when you hover over the handle */ - background-color: rgb(120, 120, 120); -} -QScrollBar::sub-line:vertical { /* button to scroll up */ - background-color: rgb(240,240,240); - height: 10px; - subcontrol-position: top; - subcontrol-origin: margin; -} - -QScrollBar::sub-line:vertical:hover { /* hover state of button to scroll up */ - background-color: rgb(200, 200, 200); -} - -QScrollBar::up-arrow:vertical { /* arrow to scroll up with */ - top: 2px; -} - -QScrollBar::add-line:vertical { /* Button to scroll down */ - background-color: rgb(240,240,240); - height: 10px; - padding-top: 2px; - subcontrol-position: bottom; - subcontrol-origin: margin; -} -QScrollBar::add-line:vertical:hover { /* hover state of button to scroll down */ - background-color: rgb(200, 200, 200); -} - -QScrollBar::down-arrow:vertical { /* arrow to scroll down with */ - bottom: 3px; -} - -QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { - background-color: rgb(240,240,240); - -} - - - - - - - - - 0 - 0 - 380 - 670 - - - - QWidget #widget_main { - background: white; -} - - - - - - 0 - 0 - 380 - 30 - - - - true - - - background: #F5F5F5; - - - - - - 330 - 10 - 16 - 16 - - - - PointingHandCursor - - - image: url(:/images/listitembg.png); -image-position: right; - - - - - - - - - - 360 - 8 - 13 - 13 - - - - PointingHandCursor - - - QPushButton { -image-position: right; -image: url(:/images/close.png); - - padding:1px; -} -QPushButton:hover { - padding:0px; -} - - - - - - - - - - - 0 - 30 - 380 - 640 - - - - - - - 17 - - - - - - 110 - 590 - 150 - 22 - - - - image: url(:/images/AmneziaVPN.png); - - - - - - - - - 40 - 530 - 301 - 40 - - - - PointingHandCursor - - - QPushButton { - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; - -color: #100A44; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -border: 1px solid #211C4A; -border-radius: 4px; -} - - - - Set up your own server - - - true - - - - - - 10 - 10 - 26 - 20 - - - - PointingHandCursor - - - QPushButton { - image: url(:/images/arrow_right.png); - image-position: left; - text-align: left; - /*font: 17pt "Ancient";*/ - - padding: 1px; - image: url(:/images/arrow_left.png); -} -QPushButton:hover { - padding: 0px; -} - - - - - - - - - - - 0 - 35 - 380 - 481 - - - - - - - 40 - 210 - 301 - 40 - - - - PointingHandCursor - - - QPushButton { - font-size: 13pt; - font: "Open Sans Semibold"; - color:rgb(212, 212, 212); - -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -background: #100A44; -border-radius: 4px; -} - -QPushButton:hover { -background: #211966; -} - - - - Connect - - - - - - 40 - 140 - 300 - 40 - - - - - - - - - - vpn://... - - - - - - 0 - 20 - 381 - 71 - - - - QLabel { -font-family: Lato; -font-style: normal; -font-weight: bold; -font-size: 24px; -color: #100A44; -} - - - - Connect to the already created VPN server - - - Qt::AlignCenter - - - true - - - - - - 40 - 110 - 301 - 21 - - - - - - - Connection code - - - - - - - - 40 - 260 - 300 - 71 - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Lato'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> - - - - - - 50 - 40 - 281 - 21 - - - - PointingHandCursor - - - font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 20px; -text-align: center; - -/* акцент */ -color: #15CDCB; - - - Where to get connection data → - - - - - - 10 - 0 - 361 - 31 - - - - QLabel { -font-family: Lato; -font-style: normal; -font-weight: bold; -font-size: 24px; -color: #100A44; -} - - - - Setup your server to use VPN - - - Qt::AlignCenter - - - true - - - - - - 40 - 100 - 300 - 40 - - - - - - - - - - - - - 40 - 350 - 301 - 40 - - - - PointingHandCursor - - - QPushButton { -color:rgb(212, 212, 212); -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -background: #100A44; -border-radius: 4px; -} -QPushButton:hover { -background: #211966; -} - - - Connect - - - - - - 40 - 180 - 300 - 40 - - - - - - - root - - - - - - 40 - 450 - 281 - 21 - - - - PointingHandCursor - - - font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 20px; -text-align: center; - -/* акцент */ -color: #15CDCB; - - - Connect using SSH key - - - true - - - true - - - - - - 40 - 260 - 300 - 40 - - - - QLineEdit { - background: #F4F4F4; - border: 1px solid #A7A7A7; - color: #333333; -} - - - - - - QLineEdit::Password - - - - - - 40 - 70 - 171 - 21 - - - - - - - Server IP address - - - - - - 40 - 150 - 261 - 21 - - - - - - - Login to connect via SSH - - - - - - 40 - 230 - 171 - 21 - - - - - - - Password - - - - - true - - - - 40 - 390 - 301 - 41 - - - - Please wait, configuring process may take up to 5 minutes - - - true - - - textEdit_new_server_ssh_key - pushButton_new_server_get_info - lineEdit_new_server_ip - pushButton_new_server_connect - lineEdit_new_server_login - pushButton_new_server_connect_key - lineEdit_new_server_password - label_4 - label_5 - label_new_server_password - label_2 - label_new_server_wait_info - - - - - - QLabel { -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -color: #211C4A; -} - -QLineEdit { -padding-left: 10px; -border: 1px solid #A7A7A7; -} - - - - - 10 - 10 - 26 - 20 - - - - PointingHandCursor - - - QPushButton { - image: url(:/images/arrow_right.png); - image-position: left; - text-align: left; - /*font: 17pt "Ancient";*/ - - padding: 1px; - image: url(:/images/arrow_left.png); -} -QPushButton:hover { - padding: 0px; -} - - - - - - - - - - - 110 - 590 - 150 - 22 - - - - image: url(:/images/AmneziaVPN.png); - - - - - - - - - 40 - 310 - 301 - 40 - - - - PointingHandCursor - - - QPushButton { -color:rgb(212, 212, 212); -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -background: #100A44; -border-radius: 4px; -} -QPushButton:hover { -background: #211966; -} - - - Configure VPN protocols manually - - - - - - 10 - 35 - 361 - 31 - - - - QLabel { -font-family: Lato; -font-style: normal; -font-weight: bold; -font-size: 24px; -color: #100A44; -} - - - - Setup your server to use VPN - - - Qt::AlignCenter - - - true - - - - - - 40 - 150 - 301 - 40 - - - - PointingHandCursor - - - QPushButton { -color:rgb(212, 212, 212); -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -background: #100A44; -border-radius: 4px; -} -QPushButton:hover { -background: #211966; -} - - - Run Setup Wizard - - - - - - 40 - 100 - 301 - 41 - - - - - - - If you want easily configure your server just run Wizard - - - Qt::AlignBottom|Qt::AlignHCenter - - - true - - - - - - 40 - 260 - 301 - 41 - - - - - - - Press configure manually to choose VPN protocols you want to install - - - Qt::AlignBottom|Qt::AlignHCenter - - - true - - - - - - - - 0 - 35 - 381 - 31 - - - - QLabel { -font-family: Lato; -font-style: normal; -font-weight: bold; -font-size: 24px; -color: #100A44; -} - - - - Setup Wizard - - - Qt::AlignCenter - - - true - - - - - - 10 - 10 - 26 - 20 - - - - PointingHandCursor - - - QPushButton { - image: url(:/images/arrow_right.png); - image-position: left; - text-align: left; - /*font: 17pt "Ancient";*/ - - padding: 1px; - image: url(:/images/arrow_left.png); -} -QPushButton:hover { - padding: 0px; -} - - - - - - - - - - - 10 - 70 - 361 - 561 - - - - - - 10 - 10 - 331 - 25 - - - - High censorship level - - - - - - 10 - 180 - 331 - 30 - - - - Medium censorship level - - - true - - - - - - 10 - 330 - 331 - 30 - - - - Low censorship level - - - - - - 30 - 40 - 321 - 121 - - - - I'm living in country with high censorship level. Many of foreign web sites and VPNs blocked by my government. I want to setup reliable VPN, which is invisible for government. - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - 30 - 210 - 321 - 101 - - - - I'm living in country with medium censorship level. Some web sites blocked by my government, but VPNs are not blocked at all. I want to setup flexible solution. - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - 30 - 360 - 321 - 51 - - - - I just want to improve my privacy in internet. - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - 30 - 490 - 301 - 40 - - - - PointingHandCursor - - - QPushButton { -color:rgb(212, 212, 212); -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -background: #100A44; -border-radius: 4px; -} -QPushButton:hover { -background: #211966; -} - - - Next - - - - - - - - - 0 - 35 - 381 - 31 - - - - QLabel { -font-family: Lato; -font-style: normal; -font-weight: bold; -font-size: 24px; -color: #100A44; -} - - - - Setup Wizard - - - Qt::AlignCenter - - - true - - - - - - 10 - 70 - 361 - 561 - - - - QLabel { - font-size: 16px; -} - - - - - 30 - 10 - 321 - 321 - - - - AmneziaVPN will install VPN protocol which is not visible for your internet provider and government firewall. Your VPN connection will be detected by your provider as regular web traffic to particular web site. - -You SHOULD set this web site address to some foreign web site which is not blocked by your internet provider. Other words you need to type below some foreign web site address which is accessible without VPN. - -Please note, this protocol still does not support export connection profile to mobile devices. Keep for updates. - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - 30 - 400 - 321 - 71 - - - - OpenVPN over Cloak (VPN obfuscation) profile will be installed - - - Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft - - - true - - - - - - 30 - 490 - 301 - 40 - - - - PointingHandCursor - - - QPushButton { -color:rgb(212, 212, 212); -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -background: #100A44; -border-radius: 4px; -} -QPushButton:hover { -background: #211966; -} - - - Next - - - - - - 30 - 360 - 301 - 41 - - - - - - - 30 - 330 - 291 - 21 - - - - Type web site address for mask - - - - - - - 10 - 10 - 26 - 20 - - - - PointingHandCursor - - - QPushButton { - image: url(:/images/arrow_right.png); - image-position: left; - text-align: left; - /*font: 17pt "Ancient";*/ - - padding: 1px; - image: url(:/images/arrow_left.png); -} -QPushButton:hover { - padding: 0px; -} - - - - - - - - - - - - - 10 - 70 - 361 - 561 - - - - QLabel { - font-size: 16px; -} - - - - - 30 - 10 - 321 - 341 - - - - Optional. - -We recommend to enable VPN mode "For selected sites" and add blocked sites you need to visit manually. If you will choose this option, you will need add every bloked site you want to visit to the access list. You may switch between modes later. - -Please note, you should add addresses to the list after VPN connection established. You may add any domain, URL or IP address, it will be resolved to IP address. - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - 30 - 490 - 301 - 40 - - - - PointingHandCursor - - - QPushButton { -color:rgb(212, 212, 212); -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -background: #100A44; -border-radius: 4px; -} -QPushButton:hover { -background: #211966; -} - - - Start configuring - - - - - - 30 - 350 - 301 - 71 - - - - Turn on mode "VPN for selected sites" - - - - - - - 10 - 10 - 26 - 20 - - - - PointingHandCursor - - - QPushButton { - image: url(:/images/arrow_right.png); - image-position: left; - text-align: left; - /*font: 17pt "Ancient";*/ - - padding: 1px; - image: url(:/images/arrow_left.png); -} -QPushButton:hover { - padding: 0px; -} - - - - - - - - - - - 0 - 35 - 381 - 31 - - - - QLabel { -font-family: Lato; -font-style: normal; -font-weight: bold; -font-size: 24px; -color: #100A44; -} - - - - Setup Wizard - - - Qt::AlignCenter - - - true - - - - - - - - 0 - 35 - 381 - 31 - - - - QLabel { -font-family: Lato; -font-style: normal; -font-weight: bold; -font-size: 24px; -color: #100A44; -} - - - - Setup Wizard - - - Qt::AlignCenter - - - true - - - - - - 10 - 70 - 361 - 561 - - - - QLabel { - font-size: 16px; -} - - - - - 30 - 10 - 321 - 341 - - - - AmneziaVPN will install VPN protocol which is difficult to detect by your internet provider and government firewall (but possible). In most cases, this is the most suitable protocol. This protocol is faster compared to the VPN protocols with "web traffic masking". - -This protocol support export connection profile to mobile devices using QR code (you should launch 3rd party opensource VPN client - ShadowSocks VPN). - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - 30 - 400 - 321 - 71 - - - - OpenVPN over ShadowSocks profile will be installed - - - Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft - - - true - - - - - - 30 - 490 - 301 - 40 - - - - PointingHandCursor - - - QPushButton { -color:rgb(212, 212, 212); -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -background: #100A44; -border-radius: 4px; -} -QPushButton:hover { -background: #211966; -} - - - Next - - - - - - - 10 - 10 - 26 - 20 - - - - PointingHandCursor - - - QPushButton { - image: url(:/images/arrow_right.png); - image-position: left; - text-align: left; - /*font: 17pt "Ancient";*/ - - padding: 1px; - image: url(:/images/arrow_left.png); -} -QPushButton:hover { - padding: 0px; -} - - - - - - - - - - - - - 0 - 35 - 381 - 31 - - - - QLabel { -font-family: Lato; -font-style: normal; -font-weight: bold; -font-size: 24px; -color: #100A44; -} - - - - Setup Wizard - - - Qt::AlignCenter - - - true - - - - - - 10 - 70 - 361 - 561 - - - - QLabel { - font-size: 16px; -} - - - - - 30 - 10 - 321 - 341 - - - - AmneziaVPN will install OpenVPN protocol with public/private key pairs generated on server and client sides. You can also configure connection on your mobile device by copying exported ".ovpn" file to your device and setting up official OpenVPN client. We recommend do not use messengers for sending connection profile - it contains VPN private keys. - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - 30 - 400 - 321 - 71 - - - - OpenVPN profile will be installed - - - Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft - - - true - - - - - - 30 - 490 - 301 - 40 - - - - PointingHandCursor - - - QPushButton { -color:rgb(212, 212, 212); -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -background: #100A44; -border-radius: 4px; -} -QPushButton:hover { -background: #211966; -} - - - Start configuring - - - - - - - 10 - 10 - 26 - 20 - - - - PointingHandCursor - - - QPushButton { - image: url(:/images/arrow_right.png); - image-position: left; - text-align: left; - /*font: 17pt "Ancient";*/ - - padding: 1px; - image: url(:/images/arrow_left.png); -} -QPushButton:hover { - padding: 0px; -} - - - - - - - - - - - - - 40 - 510 - 301 - 40 - - - - QProgressBar{ -color:rgb(212, 212, 212); -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -background: #100A44; -border-radius: 4px; -} - -QProgressBar::chunk { -background: rgba(255, 255, 255, 0.15); -border-radius: 4px 0px 0px 4px; - -} - - - - 0 - - - Qt::AlignCenter - - - true - - - Configuring... - - - - - - 0 - 35 - 381 - 31 - - - - QLabel { -font-family: Lato; -font-style: normal; -font-weight: bold; -font-size: 24px; -color: #100A44; -} - - - - Configuring... - - - Qt::AlignCenter - - - true - - - - - - 30 - 90 - 321 - 31 - - - - Please wait. - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - true - - - - 40 - 560 - 301 - 41 - - - - Please wait, configuring process may take up to 5 minutes - - - true - - - - - - - - 10 - 35 - 361 - 31 - - - - font-family: Lato; -font-style: normal; -font-weight: bold; -font-size: 24px; -line-height: 25px; -color: #100A44; - - - - Select VPN protocols - - - Qt::AlignCenter - - - true - - - - - - 10 - 10 - 26 - 20 - - - - PointingHandCursor - - - QPushButton { - image: url(:/images/arrow_right.png); - image-position: left; - text-align: left; - /*font: 17pt "Ancient";*/ - - padding: 1px; - image: url(:/images/arrow_left.png); -} -QPushButton:hover { - padding: 0px; -} - - - - - - - - - - - 0 - 70 - 380 - 471 - - - - - 380 - 0 - - - - - 380 - 16777215 - - - - QScrollArea { background: transparent; } -QScrollArea > QWidget > QWidget { background: transparent; } -QScrollArea > QWidget > QScrollBar { background: palette(base); } - -QLineEdit { -background: transparent; -} -QPushButton { - text-align: left; - background-repeat:no-repeat; - background-position:left top; - - background-image: url(:/images/settings.png); - padding-left: 30px; - min-height: 24px; -} -QFrame { -background: transparent; -border: 1px solid lightgrey; -border-radius: 2px; -} -QFrame#scrollArea_server_protocols { -border: none; -} -QLabel { -border: none; -} - - - true - - - - - 0 - 0 - 378 - 469 - - - - - 5 - - - 5 - - - 5 - - - 5 - - - - - - 0 - 0 - - - - - 0 - 100 - - - - - - - - QLayout::SetMinAndMaxSize - - - 5 - - - 5 - - - 5 - - - 5 - - - - - - - - - - - OpenVPN and ShadowSocks - with masking using Cloak plugin - - - true - - - - - - - - 0 - 0 - - - - - 24 - 24 - - - - PointingHandCursor - - - - - - true - - - - - - - - - - - - - - 130 - 0 - - - - - 130 - 16777215 - - - - Port (TCP) - - - - - - - - 185 - 0 - - - - - 185 - 16777215 - - - - 443 - - - - - - - - 130 - 0 - - - - - 130 - 16777215 - - - - Fake Web Site - - - - - - - - 185 - 0 - - - - - 185 - 16777215 - - - - tile.openstreetmap.org - - - - - - - - - - - - - - 0 - 100 - - - - - - - - QLayout::SetMinAndMaxSize - - - 5 - - - 5 - - - 5 - - - 5 - - - - - - - - - 0 - 24 - - - - ShadowSocks - - - - - - - - 0 - 0 - - - - - 24 - 24 - - - - PointingHandCursor - - - - - - true - - - - - - - - - - - - - - 130 - 0 - - - - - 130 - 16777215 - - - - Port(TCP) - - - - - - - - 185 - 0 - - - - - 185 - 16777215 - - - - 6789 - - - - - - - - 130 - 0 - - - - - 130 - 16777215 - - - - Encryption - - - - - - - - 185 - 0 - - - - - 185 - 16777215 - - - - - chacha20-ietf-poly1305 - - - - - xchacha20-ietf-poly1305 - - - - - aes-256-gcm - - - - - aes-192-gcm - - - - - aes-128-gcm - - - - - - - - - - - - - - - 0 - 100 - - - - - - - - QLayout::SetMinAndMaxSize - - - 5 - - - 5 - - - 5 - - - 5 - - - - - - - - - 0 - 0 - - - - - 0 - 24 - - - - OpenVPN - - - - - - - - 0 - 0 - - - - - 24 - 24 - - - - PointingHandCursor - - - - - - true - - - - - - - - - - - - - - 130 - 0 - - - - - 130 - 16777215 - - - - Port - - - - - - - - 185 - 0 - - - - - 185 - 16777215 - - - - - - - - - 130 - 0 - - - - - 130 - 16777215 - - - - Protocol - - - - - - - - 185 - 0 - - - - - 185 - 16777215 - - - - - udp - - - - - tcp - - - - - - - - - - - - - - - 0 - 100 - - - - - - - - QLayout::SetMinAndMaxSize - - - 5 - - - 5 - - - 5 - - - 5 - - - - - - - - - 0 - 0 - - - - - 0 - 24 - - - - WireGuard - - - - - - - - 0 - 0 - - - - - 24 - 24 - - - - PointingHandCursor - - - - - - true - - - - - - - - - - - - - - 130 - 0 - - - - - 130 - 16777215 - - - - Port - - - - - - - - 185 - 0 - - - - - 185 - 16777215 - - - - - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 40 - - - - - - - - - - - 40 - 570 - 301 - 40 - - - - QProgressBar{ -color:rgb(212, 212, 212); -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -background: #100A44; -border-radius: 4px; -} - -QProgressBar::chunk { -background: rgba(255, 255, 255, 0.15); -border-radius: 4px 0px 0px 4px; - -} - - - - 24 - - - Qt::AlignCenter - - - true - - - Configuring... - - - - - - 40 - 570 - 301 - 40 - - - - PointingHandCursor - - - QPushButton { -color:rgb(212, 212, 212); -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -background: #100A44; -border-radius: 4px; -} -QPushButton:hover { -background: #211966; -} - - - Setup server - - - - - - - - - - - 0 - 0 - 380 - 325 - - - - border-image: url(:/images/background_connected.png); - - - - - - true - - - - - - 0 - 360 - 380 - 51 - - - - - - - - - 53 - 10 - 15 - 15 - - - - image: url(:/images/download.png); - - - - - - - - - 311 - 10 - 15 - 15 - - - - image: url(:/images/upload.png); - - - - - - - - - 260 - 20 - 118 - 30 - - - - - Lato - -1 - 50 - false - false - - - - color: rgb(66, 209, 133); -font: 16px "Lato"; - - - 0 Mbps - - - Qt::AlignCenter - - - - - - 0 - 20 - 127 - 30 - - - - - Lato - -1 - 50 - false - false - - - - color: rgb(65, 113, 214); -font: 16px "Lato"; - - - 0 Mbps - - - Qt::AlignCenter - - - - - - true - - - - 20 - 560 - 341 - 40 - - - - PointingHandCursor - - - QPushButton { - font-size: 13pt; - font: "Open Sans Semibold"; - color:rgb(212, 212, 212); - -background: #181922; -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -} - -QPushButton:!enabled { -background: #484952; -} - -QPushButton:hover { -background: #282932; -} - - - + Add site - - - - - - 340 - 10 - 31 - 31 - - - - PointingHandCursor - - - image: url(:/images/settings_grey.png); -background: transparent - - - - - - - - - 150 - 200 - 80 - 40 - - - - PointingHandCursor - - - QPushButton:!checked { -image: url(:/images/connect_button_disconnected.png); -} - -QPushButton:checked { -image: url(:/images/connect_button_connected.png); -} - - - - - - true - - - false - - - - - - 0 - 250 - 380 - 31 - - - - font-family: "Lato"; - -font-style: normal; -font-weight: 600; -font-size: 15px; - -color: #181922; - - - - Connected - - - Qt::AlignCenter - - - - - - 20 - 424 - 341 - 1 - - - - background-image: url(:/images/Line.png); - - - - - - - - - 20 - 440 - 281 - 21 - - - - font-family: "Lato"; - -font-style: normal; -font-weight: 600; -font-size: 15px; - -color: #181922; - - - - - How to use VPN - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 0 - 280 - 381 - 61 - - - - Error text - - - false - - - Qt::AlignCenter - - - true - - - - - - 20 - 470 - 351 - 91 - - - - - true - - - - 0 - 60 - 341 - 19 - - - - Except selected sites - - - false - - - - - true - - - - 0 - 30 - 341 - 19 - - - - For selected sites - - - false - - - - - true - - - - 0 - 0 - 341 - 19 - - - - For all connections - - - true - - - - - - - /*QListView { - outline: 0; - background: transparent; - border: none; - gridline-color: darkgray; -} - -QListView::item -{ - padding-left: 5px; - border: none; - color: #181922; -} - -QListView::item:disabled -{ - padding-left: 5px; - border: none; - color: #181922; -} - -QListView::item:selected { - border: none; - background: rgba(167, 167, 167, 0.1); - color: #181922; -} -*/ - - - - - 10 - 10 - 28 - 20 - - - - PointingHandCursor - - - QPushButton { - image: url(:/images/arrow_right.png); - image-position: left; - text-align: left; - /*font: 17pt "Ancient";*/ - - padding: 1px; - image: url(:/images/arrow_left.png); -} -QPushButton:hover { - padding: 0px; -} - - - - - - - - - - - 10 - 0 - 360 - 0 - - - - List of the most popular prohibited sites - - - Qt::AlignCenter - - - true - - - - - true - - - - 20 - 40 - 340 - 60 - - - - font-family: Lato; -font-style: normal; -font-weight: bold; -font-size: 20px; -line-height: 25px; -color: #100A44; - - - - These sites will be opened using VPN - - - Qt::AlignHCenter|Qt::AlignTop - - - true - - - - - - 20 - 140 - 231 - 31 - - - - - Lato - -1 - 50 - false - false - - - - QLineEdit { - border: none; - - font-size: 16px; - background:transparent; - - selection-background-color: darkgray; - border: 1px solid #A7A7A7; -} - - - - - - Qt::AlignCenter - - - yousite.com or IP address - - - - - true - - - - 260 - 140 - 51 - 31 - - - - PointingHandCursor - - - QPushButton { -background: #100A44; -border-radius: 4px; -font-size: 24px; -color: white -} -QPushButton:hover { -background: #211966; -} - - - + - - - - - - 20 - 110 - 311 - 21 - - - - font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 150%; - -/* identical to box height, or 24px */ - -/* text */ -color: #333333; - - - Web site/Hostname/IP address/Subnet - - - - - - 20 - 200 - 341 - 371 - - - - QTableView { - background: transparent; - gridline-color: transparent; - - border: none; - outline: none; - show-decoration-selected: 1; -} - -QTableView::item -{ - padding-left: 5px; - border-top: 1px solid lightgray; - color: #181922; -} - -QTableView::item::selected -{ - border: 0px; - padding-left: 5px; - background-color: rgb(99, 180, 251); - border: : rgb(99, 180, 251); -} - - - QAbstractItemView::ExtendedSelection - - - QAbstractItemView::SelectRows - - - false - - - Qt::NoPen - - - false - - - false - - - false - - - - - - 80 - 589 - 231 - 31 - - - - PointingHandCursor - - - QPushButton { -color:rgb(212, 212, 212); -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -background: #100A44; -border-radius: 4px; -} -QPushButton:hover { -background: #211966; -} - - - Delete selected - - - - - true - - - - 320 - 140 - 51 - 31 - - - - PointingHandCursor - - - QPushButton { -background: #100A44; -border-radius: 4px; -padding: 5px; -image: url(:/images/folder.png); -} -QPushButton:hover { -background: #211966; -} - - - - - - - - - QPushButton { -font-family: Lato; -font-style: normal; -font-weight: bold; -font-size: 20px; -line-height: 25px; -Text-align:left; -padding-left: 30px; - - -/* black */ -color: #100A44; - -background-repeat: no-repeat; - background-position: left center; -} - -QPushButton:!enabled { -color: #AAAAAA; -} - - - - - 10 - 10 - 26 - 20 - - - - PointingHandCursor - - - QPushButton { - image: url(:/images/arrow_right.png); - image-position: left; - text-align: left; - /*font: 17pt "Ancient";*/ - - padding: 1px; - image: url(:/images/arrow_left.png); -} -QPushButton:hover { - padding: 0px; -} - - - - - - - - - - - 10 - 40 - 360 - 10 - - - - image: url(:/images/line.png); - - - - - - - - - 30 - 180 - 330 - 30 - - - - PointingHandCursor - - - Reinstall server, clear server - - - background-image: url(:/images/server_settings.png); - - - Server management - - - - - - 10 - 160 - 360 - 10 - - - - image: url(:/images/line.png); - - - - - - - - true - - - - 30 - 240 - 330 - 30 - - - - PointingHandCursor - - - background-image: url(:/images/share.png); - - - Share connection - - - - - - 10 - 220 - 360 - 10 - - - - image: url(:/images/line.png); - - - - - - - - - 10 - 620 - 360 - 10 - - - - image: url(:/images/line.png); - - - - - - - - true - - - - 30 - 580 - 330 - 30 - - - - PointingHandCursor - - - - - - Exit - - - - - - 10 - 560 - 360 - 10 - - - - image: url(:/images/line.png); - - - - - - - - - 30 - 60 - 330 - 30 - - - - PointingHandCursor - - - Auto start, Auto connect - - - background-image: url(:/images/settings.png); - - - - App settings - - - - - - 10 - 280 - 360 - 10 - - - - image: url(:/images/line.png); - - - - - - - - - 10 - 100 - 360 - 10 - - - - image: url(:/images/line.png); - - - - - - - - - 30 - 120 - 330 - 30 - - - - PointingHandCursor - - - DNS settings - - - background-image: url(:/images/settings.png); - - - - Network settings - - - - - - 30 - 300 - 330 - 30 - - - - PointingHandCursor - - - Reinstall server, clear server - - - background-image: url(:/images/server_settings.png); - - - Servers - - - - - - 10 - 340 - 360 - 10 - - - - image: url(:/images/line.png); - - - - - - - - - 10 - 400 - 360 - 10 - - - - image: url(:/images/line.png); - - - - - - - - - 30 - 360 - 330 - 30 - - - - PointingHandCursor - - - Add or import new server - - - background-image: url(:/images/plus.png); - - - - Add server - - - - - - - - - - - 20 - 90 - 340 - 501 - - - - QWidget { - margin: 0px; - padding: 0px; -} - -QPushButton:hover { - image: url(:/images/close.png); - image-position: right center; -} - -QListView { - outline: 0; - background: transparent; - border: none; - gridline-color: darkgray; - show-decoration-selected: 1; -} - -QListView::item -{ - padding-left: 5px; - color: #181922; - border: none; - background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, - stop: 0 #FAFBFE, stop: 1 #ECEEFF); -} - -QListView::item:disabled -{ - padding-left: 5px; - border: none; - color: #181922; -} - -QListView::item:selected { - border: none; - background: rgba(167, 167, 167, 0.1); - color: #181922; -} - -QListView::item:selected:!active { - background: transparent; - border: none; -} - -QListView::item:selected:active { - background: transparent; - border: none; -} - -QListView::item:hover { - background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, - stop: 0 #FAFBFE, stop: 1 #DCDEDF); -} - - - QAbstractItemView::NoEditTriggers - - - QAbstractItemView::NoSelection - - - - - - 10 - 10 - 26 - 20 - - - - PointingHandCursor - - - QPushButton { - image: url(:/images/arrow_right.png); - image-position: left; - text-align: left; - /*font: 17pt "Ancient";*/ - - padding: 1px; - image: url(:/images/arrow_left.png); -} -QPushButton:hover { - padding: 0px; -} - - - - - - - - - - - 50 - 30 - 171 - 40 - - - - font-family: Lato; -font-style: normal; -font-weight: bold; -font-size: 20px; -line-height: 25px; -color: #100A44; - - - - Servers list - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 240 - 39 - 24 - 24 - - - - PointingHandCursor - - - QPushButton { - image: url(:/images/plus.png); - padding:1px; -} -QPushButton:hover { - padding:0px; -} - - - - - - - - - - - - 10 - 10 - 26 - 20 - - - - PointingHandCursor - - - QPushButton { - image: url(:/images/arrow_right.png); - image-position: left; - text-align: left; - /*font: 17pt "Ancient";*/ - - padding: 1px; - image: url(:/images/arrow_left.png); -} -QPushButton:hover { - padding: 0px; -} - - - - - - - - - - - 110 - 590 - 150 - 22 - - - - image: url(:/images/AmneziaVPN.png); - - - - - - - - - 30 - 100 - 211 - 31 - - - - Auto start - - - - - - 20 - 30 - 340 - 40 - - - - font-family: Lato; -font-style: normal; -font-weight: bold; -font-size: 20px; -line-height: 25px; -color: #100A44; - - - - Application Settings - - - Qt::AlignCenter - - - - - - 30 - 140 - 211 - 31 - - - - Auto connect - - - - - - 30 - 280 - 321 - 41 - - - - PointingHandCursor - - - QPushButton { -color:rgb(212, 212, 212); -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -background: #100A44; -border-radius: 4px; -} - -QPushButton:hover { -background: #211966; -} - - - Check for updates - - - - - - 30 - 240 - 281 - 21 - - - - Software version: X.X.X (01.06.2021) - - - - - - 30 - 180 - 211 - 31 - - - - Start minimized - - - - - - 30 - 340 - 321 - 41 - - - - PointingHandCursor - - - QPushButton { -color:rgb(212, 212, 212); -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -background: #100A44; -border-radius: 4px; -} - -QPushButton:hover { -background: #211966; -} - - - Open logs folder - - - - - - - - 10 - 10 - 26 - 20 - - - - PointingHandCursor - - - QPushButton { - image: url(:/images/arrow_right.png); - image-position: left; - text-align: left; - /*font: 17pt "Ancient";*/ - - padding: 1px; - image: url(:/images/arrow_left.png); -} -QPushButton:hover { - padding: 0px; -} - - - - - - - - - - - 110 - 590 - 150 - 22 - - - - image: url(:/images/AmneziaVPN.png); - - - - - - - - - 40 - 120 - 271 - 40 - - - - - - - - - - - - - 20 - 30 - 340 - 40 - - - - font-family: Lato; -font-style: normal; -font-weight: bold; -font-size: 20px; -line-height: 25px; -color: #100A44; - - - - DNS Servers - - - Qt::AlignCenter - - - - - - 40 - 200 - 271 - 40 - - - - - - - - - - - - true - - - - 320 - 130 - 18 - 18 - - - - PointingHandCursor - - - Reset to default value - - - QPushButton { -image: url(:/images/reload.png); -padding:1px; -} -QPushButton:hover { -padding:0px; -} - - - - - - - - - true - - - - 320 - 210 - 18 - 18 - - - - PointingHandCursor - - - Reset to default value - - - QPushButton { -image: url(:/images/reload.png); -padding:1px; -} -QPushButton:hover { -padding:0px; -} - - - - - - - - - true - - - - 40 - 95 - 291 - 21 - - - - Primary DNS server - - - true - - - - - true - - - - 40 - 175 - 291 - 21 - - - - Secondray DNS server - - - true - - - - - - - true - - - - 40 - 530 - 301 - 41 - - - - Please wait, configuring process may take up to 5 minutes - - - true - - - - - - 40 - 350 - 300 - 40 - - - - PointingHandCursor - - - QPushButton { -color:rgb(212, 212, 212); -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -background: #100A44; -border-radius: 4px; -} -QPushButton:hover { -background: #211966; -} - - - Clear client cached profile - - - - - - 10 - 10 - 26 - 20 - - - - PointingHandCursor - - - QPushButton { - image: url(:/images/arrow_right.png); - image-position: left; - text-align: left; - /*font: 17pt "Ancient";*/ - - padding: 1px; - image: url(:/images/arrow_left.png); -} -QPushButton:hover { - padding: 0px; -} - - - - - - - - - - - 20 - 30 - 340 - 40 - - - - font-family: Lato; -font-style: normal; -font-weight: bold; -font-size: 20px; -line-height: 25px; -color: #100A44; - - - - Server settings - - - Qt::AlignCenter - - - true - - - - - - 110 - 590 - 150 - 22 - - - - image: url(:/images/AmneziaVPN.png); - - - - - - - - - 40 - 410 - 300 - 40 - - - - PointingHandCursor - - - QPushButton { -color:rgb(212, 212, 212); -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -background: #100A44; -border-radius: 4px; -} -QPushButton:hover { -background: #211966; -} - - - Clear server from Amnezia software - - - - - - 40 - 470 - 300 - 40 - - - - PointingHandCursor - - - QPushButton { -color:rgb(212, 212, 212); -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -background: #100A44; -border-radius: 4px; -} -QPushButton:hover { -background: #211966; -} - - - Forget this server - - - - - - 20 - 120 - 341 - 31 - - - - QLabel { -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 20px; -} - - - root@yourserver.org - - - Qt::AlignCenter - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - 70 - 80 - 251 - 31 - - - - QLineEdit { -border: none; -outline: none; -border-bottom: 1px solid lightgrey; -font-size: 18px; -font-weight: bold; -} - - - - Qt::AlignCenter - - - false - - - - - - 40 - 210 - 300 - 40 - - - - PointingHandCursor - - - QPushButton { -color:rgb(212, 212, 212); -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -background: #100A44; -border-radius: 4px; -} -QPushButton:hover { -background: #211966; -} - - - VPN protocols - - - - - - 20 - 150 - 341 - 31 - - - - QLabel { -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 20px; -} - - - VPN Protocol: - - - Qt::AlignCenter - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - 40 - 260 - 300 - 40 - - - - PointingHandCursor - - - QPushButton { -color:rgb(212, 212, 212); -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -background: #100A44; -border-radius: 4px; -} -QPushButton:hover { -background: #211966; -} - - - Share Server (FULL ACCESS) - - - label_server_settings_wait_info - label_16 - label_17 - pushButton_server_settings_clear_client_cache - pushButton_server_settings_clear - pushButton_server_settings_forget - label_server_settings_server - lineEdit_server_settings_description - pushButton_server_settings_protocols - pushButton_back_from_server_settings - label_server_settings_current_vpn_protocol - pushButton_server_settings_share_full - - - - - - - - - 20 - 440 - 340 - 121 - - - - QWidget { - margin: 0px; - padding: 0px; -} - -QPushButton:hover { - image: url(:/images/close.png); - image-position: right center; -} - -QListView { - outline: 0; - background: transparent; - border: none; - gridline-color: darkgray; - show-decoration-selected: 1; -} - -QListView::item -{ - padding-left: 5px; - color: #181922; - border: none; - background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, - stop: 0 #FAFBFE, stop: 1 #ECEEFF); -} - -QListView::item:disabled -{ - padding-left: 5px; - border: none; - color: #181922; -} - -QListView::item:selected { - border: none; - background: rgba(167, 167, 167, 0.1); - color: #181922; -} - -QListView::item:selected:!active { - background: transparent; - border: none; -} - -QListView::item:selected:active { - background: transparent; - border: none; -} - -QListView::item:hover { - background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, - stop: 0 #FAFBFE, stop: 1 #DCDEDF); -} - - - QAbstractItemView::NoEditTriggers - - - QAbstractItemView::NoSelection - - - - - - 20 - 30 - 340 - 40 - - - - font-family: Lato; -font-style: normal; -font-weight: bold; -font-size: 20px; -line-height: 25px; -color: #100A44; - - - - Protocols - - - Qt::AlignCenter - - - true - - - - - - 10 - 10 - 26 - 20 - - - - PointingHandCursor - - - QPushButton { - image: url(:/images/arrow_right.png); - image-position: left; - text-align: left; - /*font: 17pt "Ancient";*/ - - padding: 1px; - image: url(:/images/arrow_left.png); -} -QPushButton:hover { - padding: 0px; -} - - - - - - - - - - - 0 - 70 - 381 - 511 - - - - QWidget { -background: transparent; -} -QPushButton { - text-align: left; - background-repeat:no-repeat; - background-position:left top; - - background-image: url(:/images/settings.png); - padding-left: 30px; - min-height: 24px; -} -QFrame { -border: 1px solid lightgrey; -border-radius: 2px; -} -QFrame#scrollArea_server_protocols { -border: none; -} -QLabel { -border: none; -} - - - true - - - - - 0 - 0 - 381 - 511 - - - - - 19 - - - - - - 0 - 100 - - - - - - - - QLayout::SetMinAndMaxSize - - - - - - - Cloak container - - - - - - - - 24 - 24 - - - - - 24 - 24 - - - - PointingHandCursor - - - QPushButton { - background: transparent; - image: url(:/images/check.png); - padding: 0px; - margin: 0px; -} -QPushButton:checked { - image: url(:/images/check.png); -} -QPushButton:!checked { - image: url(:/images/uncheck.png); -} - - - - - - - - true - - - false - - - - - - - - 24 - 24 - - - - - 24 - 24 - - - - PointingHandCursor - - - background: transparent; -image: url(:/images/share.png); -padding: 0px; -margin: 0px; - - - - - - - - - - - 36 - 24 - - - - - 24 - 24 - - - - PointingHandCursor - - - QPushButton { - background: transparent; - padding: 0px; - margin: 0px; -} -QPushButton:checked { - image: url(:/images/connect_button_connected.png); -} -QPushButton:!checked { - image: url(:/images/connect_button_disconnected.png); -} - - - - - - - true - - - false - - - - - - - - - - - - PointingHandCursor - - - OpenVPN settings - - - - - - - PointingHandCursor - - - ShadowSocks settings - - - - - - - PointingHandCursor - - - Cloak settings - - - - - - - - - - - - - - 0 - 100 - - - - - QLayout::SetMinAndMaxSize - - - - - - - ShadowSocks container - - - - - - - - 24 - 24 - - - - - 24 - 24 - - - - PointingHandCursor - - - QPushButton { - background: transparent; - image: url(:/images/check.png); - padding: 0px; - margin: 0px; -} -QPushButton:checked { - image: url(:/images/check.png); -} -QPushButton:!checked { - image: url(:/images/uncheck.png); -} - - - - - - - true - - - false - - - - - - - - 24 - 24 - - - - - 24 - 24 - - - - PointingHandCursor - - - background: transparent; -image: url(:/images/share.png); -padding: 0px; -margin: 0px; - - - - - - - - - - - 36 - 24 - - - - - 24 - 24 - - - - PointingHandCursor - - - QPushButton { - background: transparent; - padding: 0px; - margin: 0px; -} -QPushButton:checked { - image: url(:/images/connect_button_connected.png); -} -QPushButton:!checked { - image: url(:/images/connect_button_disconnected.png); -} - - - - - - - true - - - - - - - - - - - - PointingHandCursor - - - OpenVPN settings - - - - - - - PointingHandCursor - - - ShadowSocks settings - - - - - - - - - - - - - - 0 - 100 - - - - - - - - QLayout::SetMinAndMaxSize - - - - - - - OpenVPN container - - - - - - - - 24 - 24 - - - - - 24 - 24 - - - - PointingHandCursor - - - QPushButton { - background: transparent; - image: url(:/images/check.png); - padding: 0px; - margin: 0px; -} -QPushButton:checked { - image: url(:/images/check.png); -} -QPushButton:!checked { - image: url(:/images/uncheck.png); -} - - - - - - - true - - - false - - - - - - - - 24 - 24 - - - - - 24 - 24 - - - - PointingHandCursor - - - background: transparent; -image: url(:/images/share.png); -padding: 0px; -margin: 0px; - - - - - - - - - - - 36 - 24 - - - - - 24 - 24 - - - - PointingHandCursor - - - QPushButton { - background: transparent; - padding: 0px; - margin: 0px; -} -QPushButton:checked { - image: url(:/images/connect_button_connected.png); -} -QPushButton:!checked { - image: url(:/images/connect_button_disconnected.png); -} - - - - - - - true - - - - - - - - - - - - PointingHandCursor - - - OpenVPN settings - - - - - - - - - - - - - - 0 - 100 - - - - - - - - QLayout::SetMinAndMaxSize - - - - - - - WireGuard container - - - - - - - - 24 - 24 - - - - - 24 - 24 - - - - PointingHandCursor - - - QPushButton { - background: transparent; - image: url(:/images/check.png); - padding: 0px; - margin: 0px; -} -QPushButton:checked { - image: url(:/images/check.png); -} -QPushButton:!checked { - image: url(:/images/uncheck.png); -} - - - - - - - true - - - false - - - - - - - - 24 - 24 - - - - - 24 - 24 - - - - PointingHandCursor - - - background: transparent; -image: url(:/images/share.png); -padding: 0px; -margin: 0px; - - - - - - - - - - - 36 - 24 - - - - - 24 - 24 - - - - PointingHandCursor - - - QPushButton { - background: transparent; - padding: 0px; - margin: 0px; -} -QPushButton:checked { - image: url(:/images/connect_button_connected.png); -} -QPushButton:!checked { - image: url(:/images/connect_button_disconnected.png); -} - - - - - - - true - - - - - - - - - - - - PointingHandCursor - - - WireGuard settings - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - 40 - 580 - 300 - 40 - - - - QProgressBar{ -color:rgb(212, 212, 212); -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -background: #100A44; -border-radius: 4px; -} - -QProgressBar::chunk { -background: rgba(255, 255, 255, 0.15); -border-radius: 4px 0px 0px 4px; - -} - - - - 24 - - - Qt::AlignCenter - - - true - - - Configuring... - - - - - - QScrollBar::sub-line:vertical { /* button to scroll up */ - border-top-right-radius: 3px; - background-color: rgb(240,240,240); - height: 10px; - subcontrol-position: top; - subcontrol-origin: margin; - margin-top: 3px; -} - - -QScrollBar::add-line:vertical { /* Button to scroll down */ - border-bottom-right-radius: 3px; - background-color: rgb(240,240,240); - height: 10px; - padding-top: 2px; - subcontrol-position: bottom; - subcontrol-origin: margin; - margin-bottom: 3px; -} - - -QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { - background-color: rgb(240,240,240); -} - - - - - 10 - 10 - 26 - 20 - - - - PointingHandCursor - - - QPushButton { - image: url(:/images/arrow_right.png); - image-position: left; - text-align: left; - /*font: 17pt "Ancient";*/ - - padding: 1px; - image: url(:/images/arrow_left.png); -} -QPushButton:hover { - padding: 0px; -} - - - - - - - - - - - 10 - 40 - 360 - 580 - - - - - 0 - 0 - - - - - Lato - 50 - false - false - - - - QToolBox { -margins: 0px; -} - -QToolBox QFrame { -background: transparent; -} - -QToolBox > QWidget { -font: 25px "Lato"; -background: transparent; -border-radius: 5px; - - background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, - stop: 0 #F1F1F1, stop: 0.4 #FFFFFF, - stop: 0.5 #F8F8F8, stop: 1.0 #FFFFFF); - -} - -QToolBox::tab { - background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, - stop: 0 #E1E1E1, stop: 0.4 #DDDDDD, - stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3); -border-radius: 2px; -font-family: Lato; -font-style: normal; -font-weight: bold; -font-size: 18px; -color: #100A44; -image: url(:/images/share.png); -image-position: left; -padding-left: 10px; - - border-color: #DDDDDD; - border-bottom: 2px solid #DDDDDD; -} - -QToolBox::tab:hover { - border-color: #148CD2; - border-bottom: 2px solid #148CD2; -} - - - QFrame::NoFrame - - - 0 - - - 3 - - - 6 - - - - - 0 - 0 - 360 - 360 - - - - - - - Full access - - - - - 10 - 10 - 341 - 100 - - - - QTextEdit { - -background: #F5F5F5; -border-radius: 10px; - - -font-family: Consolas; -font-style: normal; -font-weight: bold; -font-size: 20px; - -text-align: center; - -color: #15CDCB; - -} - - - - QTextEdit::FixedColumnWidth - - - 30 - - - true - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Consolas'; font-size:20px; font-weight:600; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:20pt;">vpn:\\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</span></p></body></html> - - - - - - 10 - 260 - 341 - 111 - - - - font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 150%; - -color: #181922; - - - - Anyone who logs in with this code will have the same permissions to use VPN and your server as you. -This code includes your server credentials! -Provide this code only to TRUSTED users. - - - Qt::AlignJustify|Qt::AlignTop - - - true - - - - - - 10 - 130 - 341 - 40 - - - - PointingHandCursor - - - QPushButton { - font-size: 13pt; - font: "Open Sans Semibold"; - color:rgb(212, 212, 212); - -background: #181922; -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -} -QPushButton:hover { -background: #282932; -} - - - Copy - - - - - - 10 - 180 - 341 - 40 - - - - PointingHandCursor - - - QPushButton { - font-size: 13pt; - font: "Open Sans Semibold"; - color:rgb(212, 212, 212); - -background: #181922; -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -} -QPushButton:hover { -background: #282932; -} - - - Save file - - - - - - - 0 - 0 - 360 - 360 - - - - Share for Amnezia client - - - - - 10 - 10 - 341 - 100 - - - - QTextEdit { - -background: #F5F5F5; -border-radius: 10px; - - -font-family: Consolas; -font-style: normal; -font-weight: bold; -font-size: 20px; - -text-align: center; - -color: #15CDCB; - -} - - - - QTextEdit::FixedColumnWidth - - - 30 - - - true - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Consolas'; font-size:20px; font-weight:600; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:20pt;">vpn:\\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</span></p></body></html> - - - - - - 10 - 280 - 341 - 81 - - - - font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 150%; - -color: #181922; - - - - Anyone who logs in with this code will be able to connect to this VPN server. -This code does not include server credentials. - - - Qt::AlignJustify|Qt::AlignTop - - - true - - - - - - 10 - 180 - 341 - 40 - - - - PointingHandCursor - - - QPushButton { - font-size: 13pt; - font: "Open Sans Semibold"; - color:rgb(212, 212, 212); - -background: #181922; -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -} -QPushButton:hover { -background: #282932; -} - - - Copy - - - - - - 10 - 130 - 341 - 40 - - - - PointingHandCursor - - - QPushButton { - font-size: 13pt; - font: "Open Sans Semibold"; - color:rgb(212, 212, 212); - -background: #181922; -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -} -QPushButton:hover { -background: #282932; -} - - - Generate config - - - - - - 10 - 230 - 341 - 40 - - - - PointingHandCursor - - - QPushButton { - font-size: 13pt; - font: "Open Sans Semibold"; - color:rgb(212, 212, 212); - -background: #181922; -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -} -QPushButton:hover { -background: #282932; -} - - - Save file - - - - - - - 0 - 0 - 360 - 360 - - - - Share for OpenVPN client - - - - - 10 - 10 - 341 - 100 - - - - QTextEdit { - -background: #F5F5F5; -border-radius: 10px; - - -font-family: Consolas; -font-style: normal; -font-weight: bold; -font-size: 20px; - -text-align: center; - -color: #15CDCB; - -} - - - - QTextEdit::FixedColumnWidth - - - 30 - - - true - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Consolas'; font-size:20px; font-weight:600; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:20pt;">vpn:\\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</span></p></body></html> - - - - - - 10 - 180 - 341 - 40 - - - - PointingHandCursor - - - QPushButton { - font-size: 13pt; - font: "Open Sans Semibold"; - color:rgb(212, 212, 212); - -background: #181922; -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -} -QPushButton:hover { -background: #282932; -} - - - Copy - - - - - - 10 - 230 - 341 - 40 - - - - PointingHandCursor - - - QPushButton { - font-size: 13pt; - font: "Open Sans Semibold"; - color:rgb(212, 212, 212); - -background: #181922; -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -} -QPushButton:hover { -background: #282932; -} - - - Save file - - - - - - 10 - 130 - 341 - 40 - - - - PointingHandCursor - - - QPushButton { - font-size: 13pt; - font: "Open Sans Semibold"; - color:rgb(212, 212, 212); - -background: #181922; -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -} -QPushButton:hover { -background: #282932; -} - - - Generate config - - - - - - - 0 - 0 - 360 - 360 - - - - - - - Share for ShadowSocks client - - - - - 10 - 70 - 100 - 20 - - - - Password - - - - - - 10 - 10 - 100 - 20 - - - - Server: - - - - - - 10 - 50 - 100 - 20 - - - - Encryption: - - - - - - 10 - 30 - 100 - 20 - - - - Port: - - - - - - 130 - 10 - 111 - 20 - - - - Server: - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - 130 - 50 - 201 - 20 - - - - Encryption: - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - 130 - 30 - 111 - 20 - - - - Port: - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - 130 - 70 - 201 - 20 - - - - Password: - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - 10 - 100 - 191 - 20 - - - - Connection string - - - - - - 10 - 180 - 331 - 40 - - - - PointingHandCursor - - - QPushButton { - font-size: 13pt; - font: "Open Sans Semibold"; - color:rgb(212, 212, 212); - -background: #181922; -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -} -QPushButton:hover { -background: #282932; -} - - - Copy - - - - - - 85 - 235 - 200 - 200 - - - - - - - - - - - - - 10 - 130 - 331 - 40 - - - - QLineEdit { -background: #F5F5F5; -border-radius: 10px; - - -font-family: Consolas; -font-style: normal; -font-weight: bold; -font-size: 20px; - -text-align: center; - -color: #15CDCB; - -} - - - - - - - 0 - 0 - 360 - 360 - - - - Share for Cloak client - - - - - 10 - 290 - 331 - 40 - - - - PointingHandCursor - - - QPushButton { - font-size: 13pt; - font: "Open Sans Semibold"; - color:rgb(212, 212, 212); - -background: #181922; -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -} -QPushButton:hover { -background: #282932; -} - - - Copy - - - - - - 10 - 30 - 331 - 221 - - - - - - - - - - - 10 - 10 - 26 - 20 - - - - PointingHandCursor - - - QPushButton { - image: url(:/images/arrow_right.png); - image-position: left; - text-align: left; - /*font: 17pt "Ancient";*/ - - padding: 1px; - image: url(:/images/arrow_left.png); -} -QPushButton:hover { - padding: 0px; -} - - - - - - - - - - - 0 - 40 - 380 - 600 - - - - - - 10 - 0 - 340 - 30 - - - - font-family: Lato; -font-style: normal; -font-weight: bold; -font-size: 20px; -line-height: 25px; -color: #100A44; - - - - OpenVPN Settings - - - Qt::AlignCenter - - - true - - - - - true - - - - 200 - 310 - 151 - 21 - - - - Hash - - - true - - - - - true - - - - 30 - 310 - 151 - 21 - - - - Cipher - - - true - - - - - true - - - - 30 - 110 - 151 - 21 - - - - Network protocol - - - true - - - - - - 30 - 65 - 321 - 31 - - - - - - - - - - - - - 30 - 340 - 151 - 31 - - - - - AES-256-GCM - - - - - AES-192-GCM - - - - - AES-128-GCM - - - - - AES-256-CBC - - - - - AES-192-CBC - - - - - AES-128-CBC - - - - - ChaCha20-Poly1305 - - - - - ARIA-256-CBC - - - - - CAMELLIA-256-CBC - - - - - none - - - - - - true - - - - 30 - 40 - 291 - 21 - - - - VPN Addresses Subnet - - - true - - - - - - 30 - 500 - 321 - 40 - - - - PointingHandCursor - - - QPushButton { -color:rgb(212, 212, 212); -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -background: #100A44; -border-radius: 4px; -} -QPushButton:hover { -background: #211966; -} - - - Save and restart VPN - - - - - - 30 - 140 - 321 - 71 - - - - QFrame{ - border: 1px solid lightgray; - border-radius: 2px; - margin-top: 0px; -} - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - 10 - 40 - 171 - 19 - - - - TCP - - - - - - 10 - 10 - 171 - 19 - - - - UDP - - - - - - - 200 - 230 - 151 - 31 - - - - - - - - - - - - - 30 - 280 - 321 - 21 - - - - Auto-negotiate encryption - - - false - - - - - - 200 - 340 - 151 - 31 - - - - - SHA512 - - - - - SHA384 - - - - - SHA256 - - - - - SHA3-512 - - - - - SHA3-384 - - - - - SHA3-256 - - - - - whirlpool - - - - - BLAKE2b512 - - - - - BLAKE2s256 - - - - - SHA1 - - - - - - true - - - - 30 - 230 - 151 - 31 - - - - Port - - - true - - - - - - 30 - 430 - 321 - 21 - - - - Block DNS requests outside of VPN - - - false - - - - - - 30 - 500 - 321 - 40 - - - - QProgressBar{ -color:rgb(212, 212, 212); -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -background: #100A44; -border-radius: 4px; -} - -QProgressBar::chunk { -background: rgba(255, 255, 255, 0.15); -border-radius: 4px 0px 0px 4px; - -} - - - - 24 - - - Qt::AlignCenter - - - true - - - Configuring... - - - - - true - - - - 30 - 550 - 321 - 41 - - - - - - - Qt::AlignCenter - - - true - - - - - - 30 - 390 - 321 - 21 - - - - Enable TLS auth - - - false - - - progressBar_proto_openvpn_reset - label_38 - label_97 - label_99 - label_100 - lineEdit_proto_openvpn_subnet - comboBox_proto_openvpn_cipher - label_98 - pushButton_proto_openvpn_save - frame_3 - lineEdit_proto_openvpn_port - checkBox_proto_openvpn_auto_encryption - comboBox_proto_openvpn_hash - label_103 - checkBox_proto_openvpn_block_dns - label_proto_openvpn_info - checkBox_proto_openvpn_tls_auth - - - - - - - 10 - 10 - 26 - 20 - - - - PointingHandCursor - - - QPushButton { - image: url(:/images/arrow_right.png); - image-position: left; - text-align: left; - /*font: 17pt "Ancient";*/ - - padding: 1px; - image: url(:/images/arrow_left.png); -} -QPushButton:hover { - padding: 0px; -} - - - - - - - - - - - 0 - 40 - 380 - 600 - - - - - - 190 - 110 - 151 - 31 - - - - - - - - - - - - - 20 - 0 - 340 - 30 - - - - font-family: Lato; -font-style: normal; -font-weight: bold; -font-size: 20px; -line-height: 25px; -color: #100A44; - - - - ShadowSocks Settings - - - Qt::AlignCenter - - - true - - - - - true - - - - 30 - 110 - 151 - 31 - - - - Port - - - true - - - - - - 190 - 60 - 151 - 31 - - - - - chacha20-poly1305 - - - - - aes-256-gcm - - - - - aes-128-gcm - - - - - - true - - - - 30 - 60 - 151 - 31 - - - - Cipher - - - true - - - - - - 30 - 500 - 321 - 40 - - - - PointingHandCursor - - - QPushButton { -color:rgb(212, 212, 212); -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -background: #100A44; -border-radius: 4px; -} -QPushButton:hover { -background: #211966; -} - - - Save and restart VPN - - - - - - 30 - 500 - 321 - 40 - - - - QProgressBar{ -color:rgb(212, 212, 212); -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -background: #100A44; -border-radius: 4px; -} - -QProgressBar::chunk { -background: rgba(255, 255, 255, 0.15); -border-radius: 4px 0px 0px 4px; - -} - - - - 24 - - - Qt::AlignCenter - - - true - - - Configuring... - - - - - true - - - - 30 - 550 - 321 - 41 - - - - - - - Qt::AlignCenter - - - true - - - progressBar_proto_shadowsocks_reset - lineEdit_proto_shadowsocks_port - label_43 - label_104 - comboBox_proto_shadowsocks_cipher - label_101 - pushButton_proto_shadowsocks_save - label_proto_shadowsocks_info - - - - - - - 10 - 10 - 26 - 20 - - - - PointingHandCursor - - - QPushButton { - image: url(:/images/arrow_right.png); - image-position: left; - text-align: left; - /*font: 17pt "Ancient";*/ - - padding: 1px; - image: url(:/images/arrow_left.png); -} -QPushButton:hover { - padding: 0px; -} - - - - - - - - - - - 0 - 40 - 381 - 600 - - - - - - 190 - 160 - 151 - 31 - - - - - - - - - - - - true - - - - 30 - 160 - 151 - 31 - - - - Port - - - true - - - - - - 20 - 0 - 340 - 30 - - - - font-family: Lato; -font-style: normal; -font-weight: bold; -font-size: 20px; -line-height: 25px; -color: #100A44; - - - - Cloak Settings - - - Qt::AlignCenter - - - true - - - - - - 190 - 110 - 151 - 31 - - - - - - - tile.openstreetmap.org - - - - - true - - - - 30 - 60 - 151 - 31 - - - - Cipher - - - true - - - - - - 30 - 110 - 130 - 31 - - - - - 130 - 0 - - - - - 130 - 16777215 - - - - Fake Web Site - - - - - - 190 - 60 - 151 - 31 - - - - - chacha20-poly1305 - - - - - aes-256-gcm - - - - - aes-192-gcm - - - - - aes-128-gcm - - - - - plain - - - - - - - 30 - 500 - 321 - 40 - - - - PointingHandCursor - - - QPushButton { -color:rgb(212, 212, 212); -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -background: #100A44; -border-radius: 4px; -} -QPushButton:hover { -background: #211966; -} - - - Save and restart VPN - - - - - - 30 - 500 - 321 - 40 - - - - QProgressBar{ -color:rgb(212, 212, 212); -border-radius: 4px; - -font-family: Lato; -font-style: normal; -font-weight: normal; -font-size: 16px; -line-height: 21px; - -background: #100A44; -border-radius: 4px; -} - -QProgressBar::chunk { -background: rgba(255, 255, 255, 0.15); -border-radius: 4px 0px 0px 4px; - -} - - - - 24 - - - Qt::AlignCenter - - - true - - - Configuring... - - - - - true - - - - 30 - 550 - 321 - 41 - - - - - - - Qt::AlignCenter - - - true - - - progressBar_proto_cloak_reset - lineEdit_proto_cloak_port - label_105 - label_44 - lineEdit_proto_cloak_site - label_102 - label_47 - comboBox_proto_cloak_cipher - pushButton_proto_cloak_save - label_proto_cloak_info - - - - - - - - - - SlidingStackedWidget - QStackedWidget -
ui/Controls/SlidingStackedWidget.h
- 1 -
-
- - -
diff --git a/client/ui/qml/BasicButtonType.qml b/client/ui/qml/BasicButtonType.qml index 6494f8d0..ce72509f 100644 --- a/client/ui/qml/BasicButtonType.qml +++ b/client/ui/qml/BasicButtonType.qml @@ -3,11 +3,12 @@ import QtQuick.Controls 2.12 Button { id: root - property alias containsMouse: mouseArea.containsMouse + hoverEnabled: true + property bool containsMouse: hovered MouseArea { id: mouseArea anchors.fill: parent - hoverEnabled: true + enabled: false cursorShape: Qt.PointingHandCursor } } diff --git a/client/ui/qml/PageGeneralSettings.qml b/client/ui/qml/PageGeneralSettings.qml index 2fbb645e..ee37a050 100644 --- a/client/ui/qml/PageGeneralSettings.qml +++ b/client/ui/qml/PageGeneralSettings.qml @@ -1,5 +1,6 @@ import QtQuick 2.12 import QtQuick.Controls 2.12 +import PageEnum 1.0 import "./" Item { @@ -87,6 +88,9 @@ Item { height: 30 icon.source: "qrc:/images/plus.png" text: qsTr("Add server") + onClicked: { + UiLogic.goToPage(PageEnum.Start) + } } SettingButtonType { x: 30 @@ -95,6 +99,9 @@ Item { height: 30 icon.source: "qrc:/images/settings.png" text: qsTr("App settings") + onClicked: { + UiLogic.goToPage(PageEnum.AppSettings) + } } SettingButtonType { x: 30 @@ -103,6 +110,9 @@ Item { height: 30 icon.source: "qrc:/images/settings.png" text: qsTr("Exit") + onClicked: { + Qt.quit() + } } SettingButtonType { x: 30 @@ -111,6 +121,9 @@ Item { height: 30 icon.source: "qrc:/images/settings.png" text: qsTr("Network settings") + onClicked: { + UiLogic.goToPage(PageEnum.NetworkSettings) + } } SettingButtonType { x: 30 @@ -119,6 +132,9 @@ Item { height: 30 icon.source: "qrc:/images/server_settings.png" text: qsTr("Server management") + onClicked: { + UiLogic.onPushButtonGeneralSettingsServerSettingsClicked() + } } SettingButtonType { x: 30 @@ -127,6 +143,9 @@ Item { height: 30 icon.source: "qrc:/images/server_settings.png" text: qsTr("Servers") + onClicked: { + UiLogic.goToPage(PageEnum.ServersList) + } } SettingButtonType { x: 30 @@ -136,5 +155,8 @@ Item { icon.source: "qrc:/images/share.png" text: qsTr("Share connection") enabled: UiLogic.pushButtonGeneralSettingsShareConnectionEnable + onClicked: { + UiLogic.onPushButtonGeneralSettingsShareConnectionClicked() + } } } diff --git a/client/ui/qml/PageNewServer.qml b/client/ui/qml/PageNewServer.qml index 9c18f077..e903fda1 100644 --- a/client/ui/qml/PageNewServer.qml +++ b/client/ui/qml/PageNewServer.qml @@ -1,6 +1,6 @@ import QtQuick 2.12 import QtQuick.Controls 2.12 -import Page 1.0 +import PageEnum 1.0 import "./" Item { @@ -47,7 +47,7 @@ Item { height: 40 anchors.horizontalCenter: parent.horizontalCenter onClicked: { - UiLogic.goToPage(Page.Wizard); + UiLogic.goToPage(PageEnum.Wizard); } } BlueButtonType { @@ -57,7 +57,7 @@ Item { height: 40 anchors.horizontalCenter: parent.horizontalCenter onClicked: { - UiLogic.goToPage(Page.NewServerProtocols); + UiLogic.goToPage(PageEnum.NewServerProtocols); } } diff --git a/client/ui/qml/PageNewServerConfiguring.qml b/client/ui/qml/PageNewServerConfiguring.qml index fedad670..bb35b7ba 100644 --- a/client/ui/qml/PageNewServerConfiguring.qml +++ b/client/ui/qml/PageNewServerConfiguring.qml @@ -6,6 +6,7 @@ Item { id: root width: GC.screenWidth height: GC.screenHeight + enabled: UiLogic.pageNewServerConfiguringEnabled Text { font.family: "Lato" font.styleName: "normal" @@ -31,7 +32,8 @@ Item { y: 560 width: 301 height: 41 - text: qsTr("Please wait, configuring process may take up to 5 minutes") + text: UiLogic.labelNewServerConfiguringWaitInfoText + visible: UiLogic.labelNewServerConfiguringWaitInfoVisible } ProgressBar { id: pr @@ -40,8 +42,9 @@ Item { width: 301 height: 40 from: 0 - to: 100 + to: UiLogic.progressBarNewServerConfiguringMaximium value: UiLogic.progressBarNewServerConfiguringValue + visible: UiLogic.progressBarNewServerConfiguringVisible background: Rectangle { implicitWidth: parent.width implicitHeight: parent.height @@ -62,12 +65,13 @@ Item { LabelType { anchors.fill: parent - text: qsTr("Configuring...") + text: UiLogic.progressBarNewServerConfiguringText horizontalAlignment: Text.AlignHCenter font.family: "Lato" font.styleName: "normal" font.pixelSize: 16 color: "#D4D4D4" + visible: UiLogic.progressBarNewServerConfiguringTextVisible } } } diff --git a/client/ui/qml/PageNewServerProtocol.qml b/client/ui/qml/PageNewServerProtocol.qml index fa765164..dff27153 100644 --- a/client/ui/qml/PageNewServerProtocol.qml +++ b/client/ui/qml/PageNewServerProtocol.qml @@ -102,6 +102,7 @@ Item { anchors.bottom: parent.bottom anchors.bottomMargin: 5 anchors.horizontalCenter: parent.horizontalCenter + visible: false radius: 2 Grid { anchors.fill: parent @@ -164,6 +165,11 @@ Item { checked: UiLogic.pushButtonNewServerSettingsCloakChecked onCheckedChanged: { 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.horizontalCenter: parent.horizontalCenter radius: 2 + visible: false Grid { anchors.fill: parent columns: 2 @@ -258,8 +265,14 @@ Item { anchors.verticalCenter: parent.verticalCenter icon.source: "qrc:/images/settings.png" checked: UiLogic.pushButtonNewServerSettingsSsChecked + checkable: true onCheckedChanged: { 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.horizontalCenter: parent.horizontalCenter radius: 2 + visible: false Grid { anchors.fill: parent columns: 2 @@ -351,8 +365,14 @@ Item { anchors.verticalCenter: parent.verticalCenter icon.source: "qrc:/images/settings.png" checked: UiLogic.pushButtonNewServerSettingsOpenvpnChecked + checkable: true onCheckedChanged: { 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.horizontalCenter: parent.horizontalCenter radius: 2 + visible: false Grid { anchors.fill: parent columns: 2 @@ -414,6 +435,14 @@ Item { height: 35 anchors.verticalCenter: parent.verticalCenter 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 + } + } } } } diff --git a/client/ui/qml/PageProtoCloak.qml b/client/ui/qml/PageProtoCloak.qml index d3abb24e..d7ac34cc 100644 --- a/client/ui/qml/PageProtoCloak.qml +++ b/client/ui/qml/PageProtoCloak.qml @@ -6,6 +6,7 @@ Item { id: root width: GC.screenWidth height: GC.screenHeight + enabled: UiLogic.pageProtoCloakEnabled ImageButtonType { id: back x: 10 @@ -22,6 +23,7 @@ Item { y: 40 width: 380 height: 600 + enabled: UiLogic.widgetProtoCloakEnabled ComboBoxType { x: 190 y: 60 @@ -86,6 +88,8 @@ Item { y: 550 width: 321 height: 41 + visible: UiLogic.labelProtoCloakInfoVisible + text: UiLogic.labelProtoCloakInfoText } TextFieldType { id: lineEdit_proto_cloak_port @@ -97,6 +101,7 @@ Item { onEditingFinished: { UiLogic.lineEditProtoCloakPortText = text } + enabled: UiLogic.lineEditProtoCloakPortEnabled } TextFieldType { id: lineEdit_proto_cloak_site @@ -116,8 +121,8 @@ Item { width: 321 height: 40 from: 0 - to: 100 - value: 0 + to: UiLogic.progressBarProtoCloakResetMaximium + value: UiLogic.progressBarProtoCloakResetValue background: Rectangle { implicitWidth: parent.width implicitHeight: parent.height @@ -135,6 +140,7 @@ Item { color: Qt.rgba(255, 255, 255, 0.15); } } + visible: UiLogic.progressBarProtoCloakResetVisible } BlueButtonType { anchors.horizontalCenter: parent.horizontalCenter @@ -142,6 +148,10 @@ Item { width: 321 height: 40 text: qsTr("Save and restart VPN") + visible: UiLogic.pushButtonProtoCloakSaveVisible + onClicked: { + UiLogic.pushButtonProtoCloakSaveClicked() + } } } } diff --git a/client/ui/qml/PageProtoOpenVPN.qml b/client/ui/qml/PageProtoOpenVPN.qml index c66b756f..f0537b82 100644 --- a/client/ui/qml/PageProtoOpenVPN.qml +++ b/client/ui/qml/PageProtoOpenVPN.qml @@ -6,6 +6,7 @@ Item { id: root width: GC.screenWidth height: GC.screenHeight + enabled: UiLogic.pageProtoOpenvpnEnabled ImageButtonType { id: back x: 10 @@ -22,6 +23,7 @@ Item { y: 40 width: 380 height: 600 + enabled: UiLogic.widgetProtoOpenvpnEnabled CheckBoxType { x: 30 y: 280 @@ -32,6 +34,9 @@ Item { onCheckedChanged: { UiLogic.checkBoxProtoOpenvpnAutoEncryptionChecked = checked } + onClicked: { + UiLogic.checkBoxProtoOpenvpnAutoEncryptionClicked() + } } CheckBoxType { x: 30 @@ -84,6 +89,7 @@ Item { onCurrentTextChanged: { UiLogic.comboBoxProtoOpenvpnCipherText = currentText } + enabled: UiLogic.comboBoxProtoOpenvpnCipherEnabled } ComboBoxType { x: 200 @@ -113,6 +119,7 @@ Item { onCurrentTextChanged: { UiLogic.comboBoxProtoOpenvpnHashText = currentText } + enabled: UiLogic.comboBoxProtoOpenvpnHashEnabled } Rectangle { x: 30 @@ -128,6 +135,11 @@ Item { width: 171 height: 19 text: qsTr("TCP") + enabled: UiLogic.radioButtonProtoOpenvpnTcpEnabled + checked: UiLogic.radioButtonProtoOpenvpnTcpChecked + onCheckedChanged: { + UiLogic.radioButtonProtoOpenvpnTcpChecked = checked + } } RadioButtonType { x: 10 @@ -139,6 +151,7 @@ Item { onCheckedChanged: { UiLogic.radioButtonProtoOpenvpnUdpChecked = checked } + enabled: UiLogic.radioButtonProtoOpenvpnUdpEnabled } } LabelType { @@ -195,6 +208,8 @@ Item { y: 550 width: 321 height: 41 + visible: UiLogic.labelProtoOpenvpnInfoVisible + text: UiLogic.labelProtoOpenvpnInfoText } TextFieldType { id: lineEdit_proto_openvpn_port @@ -206,6 +221,7 @@ Item { onEditingFinished: { UiLogic.lineEditProtoOpenvpnPortText = text } + enabled: UiLogic.lineEditProtoOpenvpnPortEnabled } TextFieldType { id: lineEdit_proto_openvpn_subnet @@ -225,8 +241,9 @@ Item { width: 321 height: 40 from: 0 - to: 100 - value: 0 + to: UiLogic.progressBarProtoOpenvpnResetMaximium + value: UiLogic.progressBarProtoOpenvpnResetValue + visible: UiLogic.progressBarProtoOpenvpnResetVisible background: Rectangle { implicitWidth: parent.width implicitHeight: parent.height @@ -251,6 +268,10 @@ Item { width: 321 height: 40 text: qsTr("Save and restart VPN") + visible: UiLogic.pushButtonProtoOpenvpnSaveVisible + onClicked: { + UiLogic.pushButtonProtoOpenvpnSaveClicked() + } } } } diff --git a/client/ui/qml/PageProtoShadowSock.qml b/client/ui/qml/PageProtoShadowSock.qml index 87a658c3..33ffeed7 100644 --- a/client/ui/qml/PageProtoShadowSock.qml +++ b/client/ui/qml/PageProtoShadowSock.qml @@ -6,6 +6,7 @@ Item { id: root width: GC.screenWidth height: GC.screenHeight + enabled: UiLogic.pageProtoShadowsocksEnabled ImageButtonType { id: back x: 10 @@ -22,6 +23,7 @@ Item { y: 40 width: 380 height: 600 + enabled: UiLogic.widgetProtoSsEnabled ComboBoxType { x: 190 y: 60 @@ -77,6 +79,8 @@ Item { y: 550 width: 321 height: 41 + visible: UiLogic.labelProtoShadowsocksInfoVisible + text: UiLogic.labelProtoShadowsocksInfoText } TextFieldType { id: lineEdit_proto_shadowsocks_port @@ -88,6 +92,7 @@ Item { onEditingFinished: { UiLogic.lineEditProtoShadowsocksPortText = text } + enabled: UiLogic.lineEditProtoShadowsocksPortEnabled } ProgressBar { id: progressBar_proto_shadowsocks_reset @@ -96,8 +101,9 @@ Item { width: 321 height: 40 from: 0 - to: 100 - value: 0 + to: UiLogic.progressBarProtoShadowsocksResetMaximium + value: UiLogic.progressBarProtoShadowsocksResetValue + visible: UiLogic.progressBarProtoShadowsocksResetVisible background: Rectangle { implicitWidth: parent.width implicitHeight: parent.height @@ -122,6 +128,10 @@ Item { width: 321 height: 40 text: qsTr("Save and restart VPN") + visible: UiLogic.pushButtonProtoShadowsocksSaveVisible + onClicked: { + UiLogic.pushButtonProtoShadowsocksSaveClicked() + } } } } diff --git a/client/ui/qml/PageServer.qml b/client/ui/qml/PageServer.qml index 8e9c2437..818317c1 100644 --- a/client/ui/qml/PageServer.qml +++ b/client/ui/qml/PageServer.qml @@ -2,6 +2,7 @@ import QtQuick 2.12 import QtQuick.Controls 2.12 import "./" import QtGraphicalEffects 1.12 +import PageEnum 1.0 Item { id: root @@ -37,34 +38,38 @@ Item { width: 24 height: 24 icon.source: "qrc:/images/plus.png" - } - ListModel { - id: md - ListElement { - description: "Bill Smith" - address: "555 3264" - } - ListElement { - description: "John Brown" - address: "555 8426" - } - ListElement { - description: "Sam Wise" - address: "555 0473" + onClicked: { + UiLogic.goToPage(PageEnum.Start); } } - ListView { id: listWidget_servers x: 20 y: 90 width: 340 height: 501 - model: md + model: UiLogic.serverListModel spacing: 5 delegate: Item { height: 60 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 { visible: !ms.containsMouse anchors.fill: parent @@ -106,7 +111,7 @@ Item { horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter wrapMode: Text.Wrap - text: description + text: desc } ImageButtonType { x: 212 @@ -117,6 +122,7 @@ Item { iconMargin: 0 icon.source: checked ? "qrc:/images/connect_button_connected.png" : "qrc:/images/connect_button_disconnected.png" + visible: false } ImageButtonType { x: 300 @@ -126,21 +132,39 @@ Item { checkable: true icon.source: checked ? "qrc:/images/check.png" : "qrc:/images/uncheck.png" + onClicked: { + UiLogic.onServerListPushbuttonDefaultClicked(index) + } + checked: is_default + enabled: !is_default } ImageButtonType { + id: pushButtonSetting x: 260 y: 25 width: 24 height: 24 icon.source: "qrc:/images/settings.png" - } - MouseArea { - id: ms - anchors.fill: parent - hoverEnabled: true onClicked: { - listWidget_servers.currentIndex = index - mouse.accepted = false + UiLogic.onServerListPushbuttonSettingsClicked(index) + } + 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 } } } diff --git a/client/ui/qml/PageServerProtocols.qml b/client/ui/qml/PageServerProtocols.qml index 9b3c8a57..bbb96f33 100644 --- a/client/ui/qml/PageServerProtocols.qml +++ b/client/ui/qml/PageServerProtocols.qml @@ -6,6 +6,7 @@ Item { id: root width: GC.screenWidth height: GC.screenHeight + enabled: UiLogic.pageServerProtocolsEnabled ImageButtonType { id: back x: 10 @@ -37,8 +38,9 @@ Item { width: 301 height: 40 from: 0 - to: 100 - value: 0 + to: UiLogic.progressBarProtocolsContainerReinstallMaximium + value: UiLogic.progressBarProtocolsContainerReinstallValue + visible: UiLogic.progressBarProtocolsContainerReinstallVisible background: Rectangle { implicitWidth: parent.width implicitHeight: parent.height @@ -83,6 +85,7 @@ Item { border.width: 1 border.color: "lightgray" radius: 2 + visible: UiLogic.frameOpenvpnSsCloakSettingsVisible Item { x: 5 y: 5 @@ -102,6 +105,15 @@ Item { icon.source: checked ? "qrc:/images/check.png" : "qrc:/images/uncheck.png" width: 24 height: 24 + checked: UiLogic.pushButtonProtoCloakOpenvpnContDefaultChecked + onCheckedChanged: { + UiLogic.pushButtonProtoCloakOpenvpnContDefaultChecked = checked + } + onClicked: { + UiLogic.pushButtonProtoCloakOpenvpnContDefaultClicked(checked) + } + + visible: UiLogic.pushButtonProtoCloakOpenvpnContDefaultVisible } ImageButtonType { @@ -111,6 +123,10 @@ Item { icon.source: "qrc:/images/share.png" width: 24 height: 24 + visible: UiLogic.pushButtonProtoCloakOpenvpnContShareVisible + onClicked: { + UiLogic.pushButtonProtoCloakOpenvpnContShareClicked(false) + } } ImageButtonType { id: cn1 @@ -120,6 +136,14 @@ Item { : "qrc:/images/connect_button_disconnected.png" width: 36 height: 24 + checked: UiLogic.pushButtonProtoCloakOpenvpnContInstallChecked + onCheckedChanged: { + UiLogic.pushButtonProtoCloakOpenvpnContInstallChecked = checked + } + onClicked: { + UiLogic.pushButtonProtoCloakOpenvpnContInstallClicked(checked) + } + enabled: UiLogic.pushButtonProtoCloakOpenvpnContInstallEnabled } } Rectangle { @@ -137,6 +161,9 @@ Item { height: 24 text: qsTr("OpenVPN settings") icon.source: "qrc:/images/settings.png" + onClicked: { + UiLogic.pushButtonProtoCloakOpenvpnContOpenvpnConfigClicked() + } } SettingButtonType { x: 10 @@ -145,6 +172,9 @@ Item { height: 24 text: qsTr("ShadowSocks settings") icon.source: "qrc:/images/settings.png" + onClicked: { + UiLogic.pushButtonProtoCloakOpenvpnContSsConfigClicked() + } } SettingButtonType { x: 10 @@ -153,6 +183,9 @@ Item { height: 24 text: qsTr("Cloak settings") icon.source: "qrc:/images/settings.png" + onClicked: { + UiLogic.pushButtonProtoCloakOpenvpnContCloakConfigClicked() + } } } } @@ -164,6 +197,7 @@ Item { border.width: 1 border.color: "lightgray" radius: 2 + visible: UiLogic.frameOpenvpnSsSettingsVisible Item { x: 5 y: 5 @@ -183,6 +217,15 @@ Item { icon.source: checked ? "qrc:/images/check.png" : "qrc:/images/uncheck.png" width: 24 height: 24 + checked: UiLogic.pushButtonProtoSsOpenvpnContDefaultChecked + onCheckedChanged: { + UiLogic.pushButtonProtoSsOpenvpnContDefaultChecked = checked + } + onClicked: { + UiLogic.pushButtonProtoSsOpenvpnContDefaultClicked(checked) + } + + visible: UiLogic.pushButtonProtoSsOpenvpnContDefaultVisible } ImageButtonType { @@ -192,6 +235,10 @@ Item { icon.source: "qrc:/images/share.png" width: 24 height: 24 + visible: UiLogic.pushButtonProtoSsOpenvpnContShareVisible + onClicked: { + UiLogic.pushButtonProtoSsOpenvpnContShareClicked(false) + } } ImageButtonType { id: cn2 @@ -201,6 +248,14 @@ Item { : "qrc:/images/connect_button_disconnected.png" width: 36 height: 24 + checked: UiLogic.pushButtonProtoSsOpenvpnContInstallChecked + onCheckedChanged: { + UiLogic.pushButtonProtoSsOpenvpnContInstallChecked = checked + } + onClicked: { + UiLogic.pushButtonProtoSsOpenvpnContInstallClicked(checked) + } + enabled: UiLogic.pushButtonProtoSsOpenvpnContInstallEnabled } } Rectangle { @@ -218,6 +273,9 @@ Item { height: 24 text: qsTr("OpenVPN settings") icon.source: "qrc:/images/settings.png" + onClicked: { + UiLogic.pushButtonProtoSsOpenvpnContOpenvpnConfigClicked() + } } SettingButtonType { x: 10 @@ -226,6 +284,9 @@ Item { height: 24 text: qsTr("ShadowSocks settings") icon.source: "qrc:/images/settings.png" + onClicked: { + UiLogic.pushButtonProtoSsOpenvpnContSsConfigClicked() + } } } } @@ -237,6 +298,7 @@ Item { border.width: 1 border.color: "lightgray" radius: 2 + visible: UiLogic.frameOpenvpnSettingsVisible Item { x: 5 y: 5 @@ -256,6 +318,15 @@ Item { icon.source: checked ? "qrc:/images/check.png" : "qrc:/images/uncheck.png" width: 24 height: 24 + checked: UiLogic.pushButtonProtoOpenvpnContDefaultChecked + onCheckedChanged: { + UiLogic.pushButtonProtoOpenvpnContDefaultChecked = checked + } + onClicked: { + UiLogic.pushButtonProtoOpenvpnContDefaultClicked(checked) + } + + visible: UiLogic.pushButtonProtoOpenvpnContDefaultVisible } ImageButtonType { @@ -265,6 +336,10 @@ Item { icon.source: "qrc:/images/share.png" width: 24 height: 24 + visible: UiLogic.pushButtonProtoOpenvpnContShareVisible + onClicked: { + UiLogic.pushButtonProtoOpenvpnContShareClicked(false) + } } ImageButtonType { id: cn3 @@ -274,6 +349,14 @@ Item { : "qrc:/images/connect_button_disconnected.png" width: 36 height: 24 + checked: UiLogic.pushButtonProtoOpenvpnContInstallChecked + onCheckedChanged: { + UiLogic.pushButtonProtoOpenvpnContInstallChecked = checked + } + onClicked: { + UiLogic.pushButtonProtoOpenvpnContInstallClicked(checked) + } + enabled: UiLogic.pushButtonProtoOpenvpnContInstallEnabled } } Rectangle { @@ -291,6 +374,9 @@ Item { height: 24 text: qsTr("OpenVPN settings") 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" width: 24 height: 24 + checked: UiLogic.pushButtonProtoWireguardContDefaultChecked + onCheckedChanged: { + UiLogic.pushButtonProtoWireguardContDefaultChecked = checked + } + onClicked: { + UiLogic.pushButtonProtoWireguardContDefaultClicked(checked) + } + + visible: UiLogic.pushButtonProtoWireguardContDefaultVisible } ImageButtonType { @@ -331,6 +426,10 @@ Item { icon.source: "qrc:/images/share.png" width: 24 height: 24 + visible: UiLogic.pushButtonProtoWireguardContShareVisible + onClicked: { + UiLogic.pushButtonProtoWireguardContShareClicked(false) + } } ImageButtonType { id: cn4 @@ -340,6 +439,14 @@ Item { : "qrc:/images/connect_button_disconnected.png" width: 36 height: 24 + checked: UiLogic.pushButtonProtoWireguardContInstallChecked + onCheckedChanged: { + UiLogic.pushButtonProtoWireguardContInstallChecked = checked + } + onClicked: { + UiLogic.pushButtonProtoWireguardContInstallClicked(checked) + } + enabled: UiLogic.pushButtonProtoWireguardContInstallEnabled } } Rectangle { diff --git a/client/ui/qml/PageServerSetting.qml b/client/ui/qml/PageServerSetting.qml index 591d3ac1..6a09fcc3 100644 --- a/client/ui/qml/PageServerSetting.qml +++ b/client/ui/qml/PageServerSetting.qml @@ -1,11 +1,14 @@ import QtQuick 2.12 import QtQuick.Controls 2.12 import "./" +import PageEnum 1.0 Item { id: root width: GC.screenWidth height: GC.screenHeight + enabled: UiLogic.pageServerSettingsEnabled + ImageButtonType { id: back x: 10 @@ -72,6 +75,7 @@ Item { text: UiLogic.lineEditServerSettingsDescriptionText onEditingFinished: { UiLogic.lineEditServerSettingsDescriptionText = text + UiLogic.onLineEditServerSettingsDescriptionEditingFinished() } } BlueButtonType { @@ -79,16 +83,22 @@ Item { y: 410 width: 300 height: 40 - text: qsTr("Clear server from Amnezia software") + text: UiLogic.pushButtonServerSettingsClearText visible: UiLogic.pushButtonServerSettingsClearVisible + onClicked: { + UiLogic.onPushButtonClearServer() + } } BlueButtonType { anchors.horizontalCenter: parent.horizontalCenter y: 350 width: 300 height: 40 - text: qsTr("Clear client cached profile") + text: UiLogic.pushButtonServerSettingsClearClientCacheText visible: UiLogic.pushButtonServerSettingsClearClientCacheVisible + onClicked: { + UiLogic.onPushButtonServerSettingsClearClientCacheClicked() + } } BlueButtonType { anchors.horizontalCenter: parent.horizontalCenter @@ -96,6 +106,9 @@ Item { width: 300 height: 40 text: qsTr("Forget this server") + onClicked: { + UiLogic.onPushButtonForgetServer() + } } BlueButtonType { anchors.horizontalCenter: parent.horizontalCenter @@ -103,6 +116,9 @@ Item { width: 300 height: 40 text: qsTr("VPN protocols") + onClicked: { + UiLogic.goToPage(PageEnum.ServerVpnProtocols) + } } BlueButtonType { anchors.horizontalCenter: parent.horizontalCenter @@ -111,5 +127,8 @@ Item { height: 40 text: qsTr("Share Server (FULL ACCESS)") visible: UiLogic.pushButtonServerSettingsShareFullVisible + onClicked: { + UiLogic.onPushButtonServerSettingsShareFullClicked() + } } } diff --git a/client/ui/qml/PageSetupWizard.qml b/client/ui/qml/PageSetupWizard.qml index ab7c91ac..ea35a812 100644 --- a/client/ui/qml/PageSetupWizard.qml +++ b/client/ui/qml/PageSetupWizard.qml @@ -1,6 +1,6 @@ import QtQuick 2.12 import QtQuick.Controls 2.12 -import Page 1.0 +import PageEnum 1.0 import "./" Item { @@ -74,11 +74,11 @@ Item { text: qsTr("Next") onClicked: { if (radioButton_setup_wizard_high.checked) { - UiLogic.goToPage(Page.WizardHigh); + UiLogic.goToPage(PageEnum.WizardHigh); } else if (radioButton_setup_wizard_medium.checked) { - UiLogic.goToPage(Page.WizardMedium); + UiLogic.goToPage(PageEnum.WizardMedium); } else if (radioButton_setup_wizard_low.checked) { - UiLogic.goToPage(Page.WizardLow); + UiLogic.goToPage(PageEnum.WizardLow); } } } diff --git a/client/ui/qml/PageSetupWizardHighLevel.qml b/client/ui/qml/PageSetupWizardHighLevel.qml index 4242fa0c..511918d5 100644 --- a/client/ui/qml/PageSetupWizardHighLevel.qml +++ b/client/ui/qml/PageSetupWizardHighLevel.qml @@ -1,6 +1,6 @@ import QtQuick 2.12 import QtQuick.Controls 2.12 -import Page 1.0 +import PageEnum 1.0 import "./" Item { @@ -90,7 +90,7 @@ Item { if (!domain || !domain.includes(".")) { return } - UiLogic.goToPage(Page.WizardVpnMode) + UiLogic.goToPage(PageEnum.WizardVpnMode) } } } diff --git a/client/ui/qml/PageSetupWizardMediumLevel.qml b/client/ui/qml/PageSetupWizardMediumLevel.qml index c15b964c..263e40dc 100644 --- a/client/ui/qml/PageSetupWizardMediumLevel.qml +++ b/client/ui/qml/PageSetupWizardMediumLevel.qml @@ -1,6 +1,6 @@ import QtQuick 2.12 import QtQuick.Controls 2.12 -import Page 1.0 +import PageEnum 1.0 import "./" Item { @@ -60,7 +60,7 @@ Item { height: 40 text: qsTr("Next") onClicked: { - UiLogic.goToPage(Page.WizardVpnMode) + UiLogic.goToPage(PageEnum.WizardVpnMode) } } } diff --git a/client/ui/qml/PageShareConnection.qml b/client/ui/qml/PageShareConnection.qml index 13384570..a06c6da7 100644 --- a/client/ui/qml/PageShareConnection.qml +++ b/client/ui/qml/PageShareConnection.qml @@ -34,10 +34,23 @@ Item { share_shadowshock, 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() { for (let i = 0; i < contentList.length; ++i) { contentList[i].active = false } + currentIndex = -1; } Column { spacing: 5 @@ -45,6 +58,7 @@ Item { id: full_access x: 0 text: qsTr("Full access") + visible: UiLogic.pageShareFullAccessVisible content: Component { Item { width: 360 @@ -68,7 +82,10 @@ Item { y: 130 width: 341 height: 40 - text: qsTr("Copy") + text: UiLogic.pushButtonShareFullCopyText + onClicked: { + UiLogic.onPushButtonShareFullCopyClicked() + } } ShareConnectionButtonType { x: 10 @@ -76,6 +93,9 @@ Item { width: 341 height: 40 text: qsTr("Save file") + onClicked: { + UiLogic.onPushButtonShareFullSaveClicked() + } } TextFieldType { x: 10 @@ -83,15 +103,19 @@ Item { width: 341 height: 100 verticalAlignment: Text.AlignTop + text: UiLogic.textEditShareFullCodeText + onEditingFinished: { + UiLogic.textEditShareFullCodeText = text + } } } } onClicked: { if (active) { - active = false + ct.currentIndex = -1 } else { ct.clearActive() - active = true + ct.currentIndex = 0 } } } @@ -99,6 +123,7 @@ Item { id: share_amezia x: 0 text: qsTr("Share for Amnezia client") + visible: UiLogic.pageShareAmneziaVisible content: Component { Item { width: 360 @@ -122,14 +147,22 @@ Item { y: 180 width: 341 height: 40 - text: qsTr("Copy") + text: UiLogic.pushButtonShareAmneziaCopyText + onClicked: { + UiLogic.onPushButtonShareAmneziaCopyClicked() + } + enabled: UiLogic.pushButtonShareAmneziaCopyEnabled } ShareConnectionButtonType { x: 10 y: 130 width: 341 height: 40 - text: qsTr("Generate config") + text: UiLogic.pushButtonShareAmneziaGenerateText + enabled: UiLogic.pushButtonShareAmneziaGenerateEnabled + onClicked: { + UiLogic.onPushButtonShareAmneziaGenerateClicked() + } } ShareConnectionButtonType { x: 10 @@ -137,6 +170,9 @@ Item { width: 341 height: 40 text: qsTr("Save file") + onClicked: { + UiLogic.onPushButtonShareAmneziaSaveClicked() + } } TextFieldType { x: 10 @@ -144,15 +180,19 @@ Item { width: 341 height: 100 verticalAlignment: Text.AlignTop + text: UiLogic.textEditShareAmneziaCodeText + onEditingFinished: { + UiLogic.textEditShareAmneziaCodeText = text + } } } } onClicked: { if (active) { - active = false + ct.currentIndex = -1 } else { ct.clearActive() - active = true + ct.currentIndex = 1 } } } @@ -160,6 +200,7 @@ Item { id: share_openvpn x: 0 text: qsTr("Share for OpenVPN client") + visible: UiLogic.pageShareOpenvpnVisible content: Component { Item { width: 360 @@ -169,14 +210,22 @@ Item { y: 180 width: 341 height: 40 - text: qsTr("Copy") + text: UiLogic.pushButtonShareOpenvpnCopyText + enabled: UiLogic.pushButtonShareOpenvpnCopyEnabled + onClicked: { + UiLogic.onPushButtonShareOpenvpnCopyClicked() + } } ShareConnectionButtonType { x: 10 y: 130 width: 341 height: 40 - text: qsTr("Generate config") + text: UiLogic.pushButtonShareOpenvpnGenerateText + onClicked: { + UiLogic.onPushButtonShareOpenvpnGenerateClicked() + } + enabled: UiLogic.pushButtonShareOpenvpnGenerateEnabled } ShareConnectionButtonType { x: 10 @@ -184,6 +233,10 @@ Item { width: 341 height: 40 text: qsTr("Save file") + enabled: UiLogic.pushButtonShareOpenvpnSaveEnabled + onClicked: { + UiLogic.onPushButtonShareOpenvpnSaveClicked() + } } TextFieldType { x: 10 @@ -191,15 +244,19 @@ Item { width: 341 height: 100 verticalAlignment: Text.AlignTop + text: UiLogic.textEditShareOpenvpnCodeText + onEditingFinished: { + UiLogic.textEditShareOpenvpnCodeText = text + } } } } onClicked: { if (active) { - active = false + ct.currentIndex = -1 } else { ct.clearActive() - active = true + ct.currentIndex = 2 } } } @@ -207,6 +264,7 @@ Item { id: share_shadowshock x: 0 text: qsTr("Share for ShadowSocks client") + visible: UiLogic.pageShareShadowsocksVisible content: Component { Item { width: 360 @@ -251,28 +309,28 @@ Item { y: 70 width: 100 height: 20 - text: qsTr("Password") + text: UiLogic.labelShareSsPasswordText } LabelType { x: 130 y: 10 width: 100 height: 20 - text: qsTr("Server:") + text: UiLogic.labelShareSsServerText } LabelType { x: 130 y: 50 width: 100 height: 20 - text: qsTr("Encryption:") + text: UiLogic.labelShareSsMethodText } LabelType { x: 130 y: 30 width: 100 height: 20 - text: qsTr("Port:") + text: UiLogic.labelShareSsPortText } Image { id: label_share_ss_qr_code @@ -280,15 +338,18 @@ Item { y: 235 width: 200 height: 200 - - // source: "file" + source: UiLogic.labelShareSsQrCodeText == "" ? "" : "data:image/png;base64," + UiLogic.labelShareSsQrCodeText } ShareConnectionButtonType { x: 10 y: 180 width: 331 height: 40 - text: qsTr("Copy") + text: UiLogic.pushButtonShareSsCopyText + enabled: UiLogic.pushButtonShareSsCopyEnabled + onClicked: { + UiLogic.onPushButtonShareSsCopyClicked() + } } TextFieldType { x: 10 @@ -296,15 +357,19 @@ Item { width: 331 height: 100 horizontalAlignment: Text.AlignHCenter + text: UiLogic.lineEditShareSsStringText + onEditingFinished: { + UiLogic.lineEditShareSsStringText = text + } } } } onClicked: { if (active) { - active = false + ct.currentIndex = -1 } else { ct.clearActive() - active = true + ct.currentIndex = 3 } } } @@ -312,6 +377,7 @@ Item { id: share_cloak x: 0 text: qsTr("Share for Cloak client") + visible: UiLogic.pageShareCloakVisible content: Component { Item { width: 360 @@ -321,22 +387,30 @@ Item { y: 290 width: 331 height: 40 - text: qsTr("Copy") + text: UiLogic.pushButtonShareCloakCopyText + enabled: UiLogic.pushButtonShareCloakCopyEnabled + onClicked: { + UiLogic.onPushButtonShareCloakCopyClicked() + } } TextInput { x: 10 y: 30 width: 331 height: 100 + text: UiLogic.plainTextEditShareCloakText + onEditingFinished: { + UiLogic.plainTextEditShareCloakText = text + } } } } onClicked: { if (active) { - active = false + ct.currentIndex = -1 } else { ct.clearActive() - active = true + ct.currentIndex = 4 } } } diff --git a/client/ui/qml/PageSites.qml b/client/ui/qml/PageSites.qml index 2800007c..55769f62 100644 --- a/client/ui/qml/PageSites.qml +++ b/client/ui/qml/PageSites.qml @@ -1,7 +1,9 @@ import QtQuick 2.12 import QtQuick.Controls 2.12 import "./" -import Qt.labs.qmlmodels 1.0 +import Qt.labs.platform 1.0 +import QtQuick.Dialogs 1.0 + Item { id: root width: GC.screenWidth @@ -26,7 +28,7 @@ Item { color: "#100A44" horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignTop - text: qsTr("These sites will be opened using VPN") + text: UiLogic.labelSitesAddCustomText x: 20 y: 40 width: 340 @@ -38,6 +40,13 @@ Item { width: 231 height: 31 placeholderText: qsTr("yousite.com or IP address") + text: UiLogic.lineEditSitesAddCustomText + onEditingFinished: { + UiLogic.lineEditSitesAddCustomText = text + } + onAccepted: { + UiLogic.onPushButtonAddCustomSitesClicked() + } } ImageButtonType { id: back @@ -58,6 +67,9 @@ Item { height: 31 font.pixelSize: 24 text: "+" + onClicked: { + UiLogic.onPushButtonAddCustomSitesClicked() + } } BlueButtonType { id: sites_delete @@ -67,6 +79,9 @@ Item { height: 31 font.pixelSize: 16 text: qsTr("Delete selected") + onClicked: { + UiLogic.onPushButtonSitesDeleteClicked(tb.currentRow) + } } BasicButtonType { @@ -92,6 +107,18 @@ Item { } } 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 { id: tb @@ -103,25 +130,7 @@ Item { clip: true property int currentRow: -1 columnSpacing: 0 - model: TableModel { - TableModelColumn { display: "name" } - TableModelColumn { display: "color" } - - rows: [ - { - "name": "cat", - "color": "black" - }, - { - "name": "dog", - "color": "brown" - }, - { - "name": "bird", - "color": "white" - } - ] - } + model: UiLogic.tableViewSitesModel delegate: Item { implicitWidth: 170 diff --git a/client/ui/qml/PageStart.qml b/client/ui/qml/PageStart.qml index c4b8c079..a598f582 100644 --- a/client/ui/qml/PageStart.qml +++ b/client/ui/qml/PageStart.qml @@ -25,15 +25,16 @@ Item { checked: false checkable: true onCheckedChanged: { -// if (checked){ -// ui->stackedWidget_start->setCurrentWidget(ui->page_start_new_server); -// ui->pushButton_start_switch_page->setText(tr("Import connection")); -// } -// else { -// ui->stackedWidget_start->setCurrentWidget(ui->page_start_import); -// ui->pushButton_start_switch_page->setText(tr("Set up your own server")); -// } - + if (checked) { + page_start_new_server.visible = true + page_start_import.visible = false + text = qsTr("Import connection"); + } + else { + page_start_new_server.visible = false + page_start_import.visible = true + text = qsTr("Set up your own server"); + } } 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 { + id: page_start_import width: 380 height: 481 + x: 0 + y: 35 + visible: true Text { x: 0 y: 20 @@ -120,13 +115,15 @@ Item { } } } - } - Component { - id: page_start_new_server + Item { + id: page_start_new_server width: 380 height: 481 + x: 0 + y: 35 + visible: false Label { x:10 y:0 @@ -157,6 +154,7 @@ Item { text: qsTr("Login to connect via SSH") } LabelType { + id: label_new_server_password x: 40 y: 230 width: 171 @@ -212,11 +210,12 @@ Item { y: 350 width: 301 height: 40 - text: qsTr("Connect") + text: UiLogic.pushButtonNewServerConnectText visible: UiLogic.pushButtonNewServerConnectVisible onClicked: { UiLogic.onPushButtonNewServerConnect() } + enabled: UiLogic.pushButtonNewServerConnectEnabled } BasicButtonType { id: new_sever_connect_key @@ -244,6 +243,10 @@ Item { checked: UiLogic.pushButtonNewServerConnectKeyChecked onCheckedChanged: { 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 { @@ -287,9 +290,10 @@ Item { onEditingFinished: { UiLogic.textEditNewServerSshKeyText = text } + visible: false } } - } + ImageButtonType { id: back_from_start diff --git a/client/ui/qml/PageVPN.qml b/client/ui/qml/PageVPN.qml index a58e0f86..72f1ea87 100644 --- a/client/ui/qml/PageVPN.qml +++ b/client/ui/qml/PageVPN.qml @@ -1,6 +1,6 @@ import QtQuick 2.12 import QtQuick.Controls 2.12 -import Page 1.0 +import PageEnum 1.0 import "./" Item { @@ -37,7 +37,7 @@ Item { horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter wrapMode: Text.Wrap - text: qsTr("Error text") + text: UiLogic.labelErrorText } Text { x: 0 @@ -51,7 +51,7 @@ Item { horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter wrapMode: Text.Wrap - text: qsTr("Connected") + text: UiLogic.labelStateText } Image { x: 0 @@ -79,6 +79,7 @@ Item { } contentItem: Item {} antialiasing: true + enabled: UiLogic.pushButtonConnectEnabled } ImageButtonType { @@ -87,6 +88,9 @@ Item { width: 31 height: 31 icon.source: "qrc:/images/settings_grey.png" + onClicked: { + UiLogic.goToPage(PageEnum.GeneralSettings) + } } BasicButtonType { id: button_add_site @@ -122,7 +126,7 @@ Item { } antialiasing: true onClicked: { - UiLogic.goToPage(Page.Sites) + UiLogic.goToPage(PageEnum.Sites) } } Item { @@ -156,7 +160,7 @@ Item { horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter wrapMode: Text.Wrap - text: qsTr("0 Mbps") + text: UiLogic.labelSpeedReceivedText } Text { x: 260 @@ -170,7 +174,7 @@ Item { horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter wrapMode: Text.Wrap - text: qsTr("0 Mbps") + text: UiLogic.labelSpeedSentText } } Item { @@ -178,6 +182,7 @@ Item { y: 470 width: 351 height: 91 + enabled: UiLogic.widgetVpnModeEnabled RadioButtonType { x: 0 y: 0 @@ -215,6 +220,5 @@ Item { UiLogic.onRadioButtonVpnModeForwardSitesToggled(checked) } } - } } diff --git a/client/ui/qml/main.qml b/client/ui/qml/main.qml index ef5a6486..4ce7690b 100644 --- a/client/ui/qml/main.qml +++ b/client/ui/qml/main.qml @@ -1,7 +1,7 @@ import QtQuick 2.14 import QtQuick.Window 2.14 import QtQuick.Controls 2.12 -import Page 1.0 +import PageEnum 1.0 import Qt.labs.platform 1.1 import QtQuick.Dialogs 1.1 import "./" @@ -11,51 +11,55 @@ Window { visible: true width: GC.screenWidth height: GC.isDesktop() ? GC.screenHeight + titleBar.height : GC.screenHeight + onClosing: { + UiLogic.onCloseWindow() + } + // flags: Qt.FramelessWindowHint title: "AmneziaVPN" function getPageComponent(page) { switch (page) { - case Page.Start: + case PageEnum.Start: return page_start; - case Page.NewServer: + case PageEnum.NewServer: return page_new_server - case Page.NewServerProtocols: + case PageEnum.NewServerProtocols: return page_new_server_protocols - case Page.Wizard: + case PageEnum.Wizard: return page_setup_wizard - case Page.WizardHigh: + case PageEnum.WizardHigh: return page_setup_wizard_high_level - case Page.WizardLow: + case PageEnum.WizardLow: return page_setup_wizard_low_level - case Page.WizardMedium: + case PageEnum.WizardMedium: return page_setup_wizard_medium_level - case Page.WizardVpnMode: + case PageEnum.WizardVpnMode: return page_setup_wizard_vpn_mode - case Page.ServerConfiguring: + case PageEnum.ServerConfiguring: return page_new_server_configuring - case Page.Vpn: + case PageEnum.Vpn: return page_vpn - case Page.GeneralSettings: + case PageEnum.GeneralSettings: return page_general_settings - case Page.AppSettings: + case PageEnum.AppSettings: return page_app_settings - case Page.NetworkSettings: + case PageEnum.NetworkSettings: return page_network_settings - case Page.ServerSettings: + case PageEnum.ServerSettings: return page_server_settings - case Page.ServerVpnProtocols: + case PageEnum.ServerVpnProtocols: return page_server_protocols - case Page.ServersList: + case PageEnum.ServersList: return page_servers - case Page.ShareConnection: + case PageEnum.ShareConnection: return page_share_connection - case Page.Sites: + case PageEnum.Sites: return page_sites - case Page.OpenVpnSettings: + case PageEnum.OpenVpnSettings: return page_proto_openvpn - case Page.ShadowSocksSettings: + case PageEnum.ShadowSocksSettings: return page_proto_shadowsocks - case Page.CloakSettings: + case PageEnum.CloakSettings: return page_proto_cloak } return undefined; @@ -63,113 +67,114 @@ Window { function getPageEnum(item) { if (item instanceof PageStart) { - return Page.Start + return PageEnum.Start } if (item instanceof PageNewServer) { - return Page.NewServer + return PageEnum.NewServer } if (item instanceof PageNewServerProtocol) { - return Page.NewServerProtocols + return PageEnum.NewServerProtocols } if (item instanceof PageSetupWizard) { - return Page.Wizard + return PageEnum.Wizard } if (item instanceof PageSetupWizardHighLevel) { - return Page.WizardHigh + return PageEnum.WizardHigh } if (item instanceof PageSetupWizardLowLevel) { - return Page.WizardLow + return PageEnum.WizardLow } if (item instanceof PageSetupWizardMediumLevel) { - return Page.WizardMedium + return PageEnum.WizardMedium } if (item instanceof PageSetupWizardVPNMode) { - return Page.WizardVpnMode + return PageEnum.WizardVpnMode } if (item instanceof PageNewServerConfiguring) { - return Page.ServerConfiguring + return PageEnum.ServerConfiguring } if (item instanceof PageVPN) { - return Page.Vpn + return PageEnum.Vpn } if (item instanceof PageGeneralSettings) { - return Page.GeneralSettings + return PageEnum.GeneralSettings } if (item instanceof PageAppSetting) { - return Page.AppSettings + return PageEnum.AppSettings } if (item instanceof PageNetworkSetting) { - return Page.NetworkSettings + return PageEnum.NetworkSettings } if (item instanceof PageServerSetting) { - return Page.ServerSettings + return PageEnum.ServerSettings } if (item instanceof PageServerProtocols) { - return Page.ServerVpnProtocols + return PageEnum.ServerVpnProtocols } if (item instanceof PageServer) { - return Page.ServersList + return PageEnum.ServersList } if (item instanceof PageShareConnection) { - return Page.ShareConnection + return PageEnum.ShareConnection } if (item instanceof PageSites) { - return Page.Sites + return PageEnum.Sites } if (item instanceof PageProtoOpenVPN) { - return Page.OpenVpnSettings + return PageEnum.OpenVpnSettings } if (item instanceof PageProtoShadowSock) { - return Page.ShadowSocksSettings + return PageEnum.ShadowSocksSettings } if (item instanceof PageProtoCloak) { - return Page.CloakSettings + return PageEnum.CloakSettings } - return Page.Start + return PageEnum.Start } function gotoPage(page, reset, slide) { let pageComponent = getPageComponent(page) + console.debug(pageComponent) if (reset) { - if (page === Page.ServerSettings) { + if (page === PageEnum.ServerSettings) { UiLogic.updateServerPage(); } - if (page === Page.ShareConnection) {} - if (page === Page.Wizard) { + if (page === PageEnum.ShareConnection) {} + if (page === PageEnum.Wizard) { UiLogic.radioButtonSetupWizardMediumChecked = true } - if (page === Page.WizardHigh) { + if (page === PageEnum.WizardHigh) { UiLogic.updateWizardHighPage(); } - if (page === Page.ServerConfiguring) { + if (page === PageEnum.ServerConfiguring) { UiLogic.progressBarNewServerConfiguringValue = 0; } - if (page === Page.GeneralSettings) { + if (page === PageEnum.GeneralSettings) { UiLogic.updateGeneralSettingPage(); } - if (page === Page.ServersList) { + if (page === PageEnum.ServersList) { UiLogic.updateServersListPage(); } - if (page === Page.Start) { + if (page === PageEnum.Start) { UiLogic.pushButtonBackFromStartVisible = !pageLoader.empty UiLogic.updateStartPage(); } - if (page === Page.NewServerProtocols) { + if (page === PageEnum.NewServerProtocols) { UiLogic.updateNewServerProtocolsPage() } - if (page === Page.ServerVpnProtocols) { + if (page === PageEnum.ServerVpnProtocols) { UiLogic.updateProtocolsPage() } - if (page === Page.AppSettings) { + if (page === PageEnum.AppSettings) { UiLogic.updateAppSettingsPage() } - if (page === Page.NetworkSettings) { + if (page === PageEnum.NetworkSettings) { UiLogic.updateAppSettingsPage() } - if (page === Page.Sites) { + if (page === PageEnum.Sites) { UiLogic.updateSitesPage() } - if (page === Page.Vpn) { + if (page === PageEnum.Vpn) { UiLogic.updateVpnPage() } UiLogic.pushButtonNewServerConnectKeyChecked = false @@ -196,7 +201,7 @@ Window { } else { pageLoader.push(pageComponent, {}, StackView.Immediate) } - if (page === Page.Start) { + if (page === PageEnum.Start) { UiLogic.pushButtonBackFromStartVisible = !pageLoader.empty UiLogic.updateStartPage(); } @@ -216,8 +221,8 @@ Window { target: null } onCloseButtonClicked: { - if (UiLogic.currentPageValue === Page.Start || - UiLogic.currentPageValue === Page.NewServer) { + if (UiLogic.currentPageValue === PageEnum.Start || + UiLogic.currentPageValue === PageEnum.NewServer) { Qt.quit() } else { root.hide() @@ -237,10 +242,9 @@ Window { y: GC.isDesktop() ? titleBar.height : 0 width: GC.screenWidth height: GC.screenHeight - initialItem: page_vpn +// initialItem: page_servers onCurrentItemChanged: { let pageEnum = root.getPageEnum(currentItem) - console.debug(pageEnum) UiLogic.currentPageValue = pageEnum } } @@ -345,6 +349,18 @@ Window { onSetStartPage: { root.set_start_page(page, slide) } + onShowPublicKeyWarning: { + publicKeyWarning.visible = true + } + onShowConnectErrorDialog: { + connectErrorDialog.visible = true + } + onShow: { + root.show() + } + onHide: { + root.hide() + } } MessageDialog { 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 + } + } diff --git a/client/ui/server_widget.cpp b/client/ui/server_widget.cpp deleted file mode 100644 index 9b61aa8e..00000000 --- a/client/ui/server_widget.cpp +++ /dev/null @@ -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(); -} - diff --git a/client/ui/server_widget.h b/client/ui/server_widget.h deleted file mode 100644 index 5b7c68b3..00000000 --- a/client/ui/server_widget.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef SERVER_WIDGET_H -#define SERVER_WIDGET_H - -#include -#include - -#include -#include - -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 diff --git a/client/ui/serversmodel.cpp b/client/ui/serversmodel.cpp new file mode 100644 index 00000000..ed5b29b3 --- /dev/null +++ b/client/ui/serversmodel.cpp @@ -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 &data) +{ + beginResetModel(); + content = data; + endResetModel(); +} + +int ServersModel::rowCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return static_cast(content.size()); +} + +QHash ServersModel::roleNames() const { + QHash 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(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(); +} + + diff --git a/client/ui/serversmodel.h b/client/ui/serversmodel.h new file mode 100644 index 00000000..7f2e3ad1 --- /dev/null +++ b/client/ui/serversmodel.h @@ -0,0 +1,39 @@ +#ifndef SERVERSMODEL_H +#define SERVERSMODEL_H + +#include +#include +#include + +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& data); + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + +protected: + QHash roleNames() const override; + +private: + std::vector content; +}; + +#endif // SERVERSMODEL_H diff --git a/client/ui/sites_model.cpp b/client/ui/sites_model.cpp index 8cddf734..9fc5452d 100644 --- a/client/ui/sites_model.cpp +++ b/client/ui/sites_model.cpp @@ -1,8 +1,8 @@ #include "sites_model.h" SitesModel::SitesModel(Settings::RouteMode mode, QObject *parent) - : m_mode(mode), - QAbstractTableModel(parent) + : QAbstractListModel(parent), + m_mode(mode) { } @@ -14,22 +14,13 @@ void SitesModel::resetCache() endResetModel(); } -QVariant SitesModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - // FIXME: Implement me! - return QVariant(); -} - int SitesModel::rowCount(const QModelIndex &parent) const { + Q_UNUSED(parent) if (!m_cacheReady) genCache(); return m_ipsCache.size(); } -int SitesModel::columnCount(const QModelIndex &parent) const -{ - return 2; -} 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 (role == Qt::DisplayRole){ + if (role == SitesModel::UrlRole || role == SitesModel::IpRole) { if (m_ipsCache.isEmpty()) return QVariant(); - if (index.column() == 0) { + if (role == SitesModel::UrlRole) { return m_ipsCache.at(index.row()).first; } - if (index.column() == 1) { + if (role == SitesModel::IpRole) { return m_ipsCache.at(index.row()).second; } } -// if (role == Qt::TextAlignmentRole && index.column() == 1) { -// return Qt::AlignRight; -// } + // if (role == Qt::TextAlignmentRole && index.column() == 1) { + // return Qt::AlignRight; + // } 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 { qDebug() << "SitesModel::genCache"; @@ -70,3 +77,10 @@ void SitesModel::genCache() const m_cacheReady= true; } + +QHash SitesModel::roleNames() const { + QHash roles; + roles[UrlRole] = "url_path"; + roles[IpRole] = "ip"; + return roles; +} diff --git a/client/ui/sites_model.h b/client/ui/sites_model.h index b6921fe4..5e4feb0f 100644 --- a/client/ui/sites_model.h +++ b/client/ui/sites_model.h @@ -1,26 +1,31 @@ #ifndef SITESMODEL_H #define SITESMODEL_H -#include +#include #include "settings.h" -class SitesModel : public QAbstractTableModel +class SitesModel : public QAbstractListModel { Q_OBJECT public: + enum SiteRoles { + UrlRole = Qt::UserRole + 1, + IpRole + }; + explicit SitesModel(Settings::RouteMode mode, QObject *parent = nullptr); void resetCache(); - // Header: - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; - // Basic functionality: 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(int row, int column); + +protected: + QHash roleNames() const override; private: void genCache() const; diff --git a/client/ui/uilogic.cpp b/client/ui/uilogic.cpp index e289d7e5..ce023930 100644 --- a/client/ui/uilogic.cpp +++ b/client/ui/uilogic.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include "configurators/cloak_configurator.h" #include "configurators/vpn_configurator.h" @@ -37,14 +38,14 @@ #include "uilogic.h" #include "utils.h" #include "vpnconnection.h" -#include "ui/server_widget.h" -#include "ui_server_widget.h" +#include #if defined Q_OS_MAC || defined Q_OS_LINUX #include "ui/macos_util.h" #endif using namespace amnezia; +using namespace PageEnumNS; UiLogic::UiLogic(QObject *parent) : QObject(parent), @@ -60,9 +61,9 @@ UiLogic::UiLogic(QObject *parent) : m_lineEditNewServerCloakPortText{}, m_lineEditNewServerCloakSiteText{}, m_lineEditNewServerSsPortText{}, - m_comboBoxNewServerSsCipherText{}, + m_comboBoxNewServerSsCipherText{"chacha20-ietf-poly1305"}, m_lineEditNewServerOpenvpnPortText{}, - m_comboBoxNewServerOpenvpnProtoText{}, + m_comboBoxNewServerOpenvpnProtoText{"udp"}, m_pushButtonNewServerConnectKeyChecked{false}, m_lineEditStartExistingCodeText{}, m_textEditNewServerSshKeyText{}, @@ -119,12 +120,124 @@ UiLogic::UiLogic(QObject *parent) : m_checkBoxSetupWizardVpnModeChecked{false}, m_ipAddressValidatorRegex{Utils::ipAddressRegExp().pattern()}, m_pushButtonConnectChecked{false}, + m_labelSitesAddCustomText{}, + m_tableViewSitesModel{nullptr}, + m_lineEditSitesAddCustomText{}, + m_widgetProtoCloakEnabled{false}, + m_pushButtonProtoCloakSaveVisible{false}, + m_progressBarProtoCloakResetVisible{false}, + m_lineEditProtoCloakPortEnabled{false}, + m_widgetProtoSsEnabled{false}, + m_pushButtonProtoShadowsocksSaveVisible{false}, + m_progressBarProtoShadowsocksResetVisible{false}, + m_lineEditProtoShadowsocksPortEnabled{false}, + m_widgetProtoOpenvpnEnabled{false}, + m_pushButtonProtoOpenvpnSaveVisible{false}, + m_progressBarProtoOpenvpnResetVisible{false}, + m_radioButtonProtoOpenvpnUdpEnabled{false}, + m_radioButtonProtoOpenvpnTcpEnabled{false}, + m_radioButtonProtoOpenvpnTcpChecked{false}, + m_lineEditProtoOpenvpnPortEnabled{false}, + m_pushButtonProtoOpenvpnContInstallChecked{false}, + m_pushButtonProtoSsOpenvpnContInstallChecked{false}, + m_pushButtonProtoCloakOpenvpnContInstallChecked{false}, + m_pushButtonProtoWireguardContInstallChecked{false}, + m_pushButtonProtoOpenvpnContInstallEnabled{false}, + m_pushButtonProtoSsOpenvpnContInstallEnabled{false}, + m_pushButtonProtoCloakOpenvpnContInstallEnabled{false}, + m_pushButtonProtoWireguardContInstallEnabled{false}, + m_pushButtonProtoOpenvpnContDefaultChecked{false}, + m_pushButtonProtoSsOpenvpnContDefaultChecked{false}, + m_pushButtonProtoCloakOpenvpnContDefaultChecked{false}, + m_pushButtonProtoWireguardContDefaultChecked{false}, + m_pushButtonProtoOpenvpnContDefaultVisible{true}, + m_pushButtonProtoSsOpenvpnContDefaultVisible{false}, + m_pushButtonProtoCloakOpenvpnContDefaultVisible{false}, + m_pushButtonProtoWireguardContDefaultVisible{false}, + m_pushButtonProtoOpenvpnContShareVisible{false}, + m_pushButtonProtoSsOpenvpnContShareVisible{false}, + m_pushButtonProtoCloakOpenvpnContShareVisible{false}, + m_pushButtonProtoWireguardContShareVisible{false}, + m_frameOpenvpnSettingsVisible{true}, + m_frameOpenvpnSsSettingsVisible{true}, + m_frameOpenvpnSsCloakSettingsVisible{true}, + m_progressBarProtocolsContainerReinstallVisible{false}, + m_labelSpeedReceivedText{tr("0 Mbps")}, + m_labelSpeedSentText{tr("0 Mbps")}, + m_labelStateText{}, + m_pushButtonConnectEnabled{false}, + m_widgetVpnModeEnabled{false}, + m_labelErrorText{tr("Error text")}, + m_pushButtonNewServerConnectEnabled{}, + m_pushButtonNewServerConnectText{tr("Connect")}, + m_dialogConnectErrorText{}, + m_pageServerSettingsEnabled{false}, + m_pushButtonServerSettingsClearText{tr("Clear server from Amnezia software")}, + m_pageShareAmneziaVisible{true}, + m_pageShareOpenvpnVisible{true}, + m_pageShareShadowsocksVisible{true}, + m_pageShareCloakVisible{true}, + m_pageShareFullAccessVisible{true}, + m_textEditShareOpenvpnCodeText{}, + m_pushButtonShareOpenvpnCopyEnabled{false}, + m_pushButtonShareOpenvpnSaveEnabled{false}, + m_toolBoxShareConnectionCurrentIndex{-1}, + m_pushButtonShareSsCopyEnabled{false}, + m_lineEditShareSsStringText{}, + m_labelShareSsQrCodeText{}, + m_labelShareSsServerText{}, + m_labelShareSsPortText{}, + m_labelShareSsMethodText{}, + m_labelShareSsPasswordText{}, + m_plainTextEditShareCloakText{}, + m_pushButtonShareCloakCopyEnabled{false}, + m_textEditShareFullCodeText{}, + m_textEditShareAmneziaCodeText{}, + m_pushButtonShareFullCopyText{tr("Copy")}, + m_pushButtonShareAmneziaCopyText{tr("Copy")}, + m_pushButtonShareOpenvpnCopyText{tr("Copy")}, + m_pushButtonShareSsCopyText{tr("Copy")}, + m_pushButtonShareCloakCopyText{tr("Copy")}, + m_pushButtonShareAmneziaGenerateEnabled{true}, + m_pushButtonShareAmneziaCopyEnabled{true}, + m_pushButtonShareAmneziaGenerateText{tr("Generate config")}, + m_pushButtonShareOpenvpnGenerateEnabled{true}, + m_pushButtonShareOpenvpnGenerateText{tr("Generate config")}, + m_pageNewServerConfiguringEnabled{true}, + m_labelNewServerConfiguringWaitInfoVisible{true}, + m_labelNewServerConfiguringWaitInfoText{tr("Please wait, configuring process may take up to 5 minutes")}, + m_progressBarNewServerConfiguringVisible{true}, + m_progressBarNewServerConfiguringMaximium{100}, + m_progressBarNewServerConfiguringTextVisible{true}, + m_progressBarNewServerConfiguringText{tr("Configuring...")}, + m_pageServerProtocolsEnabled{true}, + m_progressBarProtocolsContainerReinstallValue{0}, + m_progressBarProtocolsContainerReinstallMaximium{100}, + m_comboBoxProtoOpenvpnCipherEnabled{true}, + m_comboBoxProtoOpenvpnHashEnabled{true}, + m_pageProtoOpenvpnEnabled{true}, + m_labelProtoOpenvpnInfoVisible{true}, + m_labelProtoOpenvpnInfoText{}, + m_progressBarProtoOpenvpnResetValue{0}, + m_progressBarProtoOpenvpnResetMaximium{100}, + m_pageProtoShadowsocksEnabled{true}, + m_labelProtoShadowsocksInfoVisible{true}, + m_labelProtoShadowsocksInfoText{}, + m_progressBarProtoShadowsocksResetValue{0}, + m_progressBarProtoShadowsocksResetMaximium{100}, + m_pageProtoCloakEnabled{true}, + m_labelProtoCloakInfoVisible{true}, + m_labelProtoCloakInfoText{}, + m_progressBarProtoCloakResetValue{0}, + m_progressBarProtoCloakResetMaximium{100}, + m_serverListModel{nullptr}, + m_pushButtonServerSettingsClearClientCacheText{tr("Clear client cached profile")}, m_vpnConnection(nullptr) { m_vpnConnection = new VpnConnection(this); - // connect(m_vpnConnection, SIGNAL(bytesChanged(quint64, quint64)), this, SLOT(onBytesChanged(quint64, quint64))); - // connect(m_vpnConnection, SIGNAL(connectionStateChanged(VpnProtocol::ConnectionState)), this, SLOT(onConnectionStateChanged(VpnProtocol::ConnectionState))); - // connect(m_vpnConnection, SIGNAL(vpnProtocolError(amnezia::ErrorCode)), this, SLOT(onVpnProtocolError(amnezia::ErrorCode))); + connect(m_vpnConnection, SIGNAL(bytesChanged(quint64, quint64)), this, SLOT(onBytesChanged(quint64, quint64))); + connect(m_vpnConnection, SIGNAL(connectionStateChanged(VpnProtocol::ConnectionState)), this, SLOT(onConnectionStateChanged(VpnProtocol::ConnectionState))); + connect(m_vpnConnection, SIGNAL(vpnProtocolError(amnezia::ErrorCode)), this, SLOT(onVpnProtocolError(amnezia::ErrorCode))); } void UiLogic::initalizeUiLogic() @@ -135,24 +248,10 @@ void UiLogic::initalizeUiLogic() setupTray(); setupNewServerConnections(); - // setupSitesPageConnections(); - // setupGeneralSettingsConnections(); - // setupProtocolsPageConnections(); - setupNewServerPageConnections(); - // setupSharePageConnections(); - // setupServerSettingsPageConnections(); + setupProtocolsPageConnections(); - // ui->label_error_text->clear(); - // installEventFilter(this); - // ui->widget_tittlebar->installEventFilter(this); + setLabelErrorText(""); - // ui->stackedWidget_main->setSpeed(200); - // ui->stackedWidget_main->setAnimation(QEasingCurve::Linear); - - - // ui->tableView_sites->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); - // // ui->tableView_sites->setColumnWidth(0, 450); - // // ui->tableView_sites->setColumnWidth(1, 120); // if (QOperatingSystemVersion::current() <= QOperatingSystemVersion::Windows7) { // needToHideCustomTitlebar = true; @@ -169,31 +268,30 @@ void UiLogic::initalizeUiLogic() // ui->stackedWidget_main->move(0,0); // } - // // Post initialization - // goToPage(Page::Start, true, false); + // Post initialization + goToPage(Page::Start, true, false); - // if (m_settings.defaultServerIndex() >= 0 && m_settings.serversCount() > 0) { - // goToPage(Page::Vpn, true, false); - // } + if (m_settings.defaultServerIndex() >= 0 && m_settings.serversCount() > 0) { + goToPage(Page::Vpn, true, false); + } // //ui->pushButton_general_settings_exit->hide(); - // updateSharingPage(selectedServerIndex, m_settings.serverCredentials(selectedServerIndex), selectedDockerContainer); + updateSharingPage(selectedServerIndex, m_settings.serverCredentials(selectedServerIndex), selectedDockerContainer); - // setFixedSize(width(),height()); - // qInfo().noquote() << QString("Started %1 version %2").arg(APPLICATION_NAME).arg(APP_VERSION); - // qInfo().noquote() << QString("%1 (%2)").arg(QSysInfo::prettyProductName()).arg(QSysInfo::currentCpuArchitecture()); + qInfo().noquote() << QString("Started %1 version %2").arg(APPLICATION_NAME).arg(APP_VERSION); + qInfo().noquote() << QString("%1 (%2)").arg(QSysInfo::prettyProductName()).arg(QSysInfo::currentCpuArchitecture()); - // onConnectionStateChanged(VpnProtocol::Disconnected); + onConnectionStateChanged(VpnProtocol::Disconnected); - // if (m_settings.isAutoConnect() && m_settings.defaultServerIndex() >= 0) { - // QTimer::singleShot(1000, this, [this](){ - // ui->pushButton_connect->setEnabled(false); - // onConnect(); - // }); - // } + if (m_settings.isAutoConnect() && m_settings.defaultServerIndex() >= 0) { + QTimer::singleShot(1000, this, [this](){ + setPushButtonConnectEnabled(false); + onConnect(); + }); + } // m_ipAddressValidator.setRegExp(Utils::ipAddressRegExp()); // m_ipAddressPortValidator.setRegExp(Utils::ipAddressPortRegExp()); @@ -210,12 +308,11 @@ void UiLogic::initalizeUiLogic() // ui->lineEdit_proto_shadowsocks_port->setValidator(&m_ipPortValidator); // ui->lineEdit_proto_cloak_port->setValidator(&m_ipPortValidator); - // //ui->toolBox_share_connection->removeItem(ui->toolBox_share_connection->indexOf(ui->page_share_shadowsocks)); - // //ui->page_share_shadowsocks->setVisible(false); - // sitesModels.insert(Settings::VpnOnlyForwardSites, new SitesModel(Settings::VpnOnlyForwardSites)); - // sitesModels.insert(Settings::VpnAllExceptSites, new SitesModel(Settings::VpnAllExceptSites)); + sitesModels.insert(Settings::VpnOnlyForwardSites, new SitesModel(Settings::VpnOnlyForwardSites)); + sitesModels.insert(Settings::VpnAllExceptSites, new SitesModel(Settings::VpnAllExceptSites)); + m_serverListModel = new ServersModel(this); } bool UiLogic::getFrameWireguardSettingsVisible() const @@ -1150,64 +1247,1476 @@ void UiLogic::setPushButtonConnectChecked(bool pushButtonConnectChecked) } } -//UiLogic::~UiLogic() -//{ -// hide(); +QString UiLogic::getLabelSitesAddCustomText() const +{ + return m_labelSitesAddCustomText; +} -// m_vpnConnection->disconnectFromVpn(); -// for (int i = 0; i < 50; i++) { -// qApp->processEvents(QEventLoop::ExcludeUserInputEvents); -// QThread::msleep(100); -// if (m_vpnConnection->isDisconnected()) { -// break; -// } -// } +void UiLogic::setLabelSitesAddCustomText(const QString &labelSitesAddCustomText) +{ + if (m_labelSitesAddCustomText != labelSitesAddCustomText) { + m_labelSitesAddCustomText = labelSitesAddCustomText; + emit labelSitesAddCustomTextChanged(); + } +} -// delete m_vpnConnection; -// delete ui; +QObject* UiLogic::getTableViewSitesModel() const +{ + return m_tableViewSitesModel; +} -// qDebug() << "Application closed"; -//} +void UiLogic::setTableViewSitesModel(QObject* tableViewSitesModel) +{ + if (m_tableViewSitesModel != tableViewSitesModel) { + m_tableViewSitesModel = tableViewSitesModel; + emit tableViewSitesModelChanged(); + } +} -//void UiLogic::showOnStartup() -//{ -// if (! m_settings.isStartMinimized()) show(); -// else { -//#if defined Q_OS_MACX -// setDockIconVisible(false); -//#endif -// } -//} +QString UiLogic::getLineEditSitesAddCustomText() const +{ + return m_lineEditSitesAddCustomText; +} -//bool UiLogic::eventFilter(QObject *obj, QEvent *event) -//{ -// if (obj == ui->widget_tittlebar) { -// QMouseEvent *mouseEvent = static_cast(event); +void UiLogic::setLineEditSitesAddCustomText(const QString &lineEditSitesAddCustomText) +{ + if (m_lineEditSitesAddCustomText != lineEditSitesAddCustomText) { + m_lineEditSitesAddCustomText = lineEditSitesAddCustomText; + emit lineEditSitesAddCustomTextChanged(); + } +} -// if (!mouseEvent) -// return false; +bool UiLogic::getWidgetProtoCloakEnabled() const +{ + return m_widgetProtoCloakEnabled; +} -// if(event->type() == QEvent::MouseButtonPress) { -// offset = mouseEvent->pos(); -// canMove = true; -// } +void UiLogic::setWidgetProtoCloakEnabled(bool widgetProtoCloakEnabled) +{ + if (m_widgetProtoCloakEnabled != widgetProtoCloakEnabled) { + m_widgetProtoCloakEnabled = widgetProtoCloakEnabled; + emit widgetProtoCloakEnabledChanged(); + } +} -// if(event->type() == QEvent::MouseButtonRelease) { -// canMove = false; -// } +bool UiLogic::getPushButtonProtoCloakSaveVisible() const +{ + return m_pushButtonProtoCloakSaveVisible; +} -// if (event->type() == QEvent::MouseMove) { -// if(canMove && (mouseEvent->buttons() & Qt::LeftButton)) { -// move(mapToParent(mouseEvent->pos() - offset)); -// } +void UiLogic::setPushButtonProtoCloakSaveVisible(bool pushButtonProtoCloakSaveVisible) +{ + if (m_pushButtonProtoCloakSaveVisible != pushButtonProtoCloakSaveVisible) { + m_pushButtonProtoCloakSaveVisible = pushButtonProtoCloakSaveVisible; + emit pushButtonProtoCloakSaveVisibleChanged(); + } +} -// event->ignore(); -// return false; -// } -// } +bool UiLogic::getProgressBarProtoCloakResetVisible() const +{ + return m_progressBarProtoCloakResetVisible; +} + +void UiLogic::setProgressBarProtoCloakResetVisible(bool progressBarProtoCloakResetVisible) +{ + if (m_progressBarProtoCloakResetVisible != progressBarProtoCloakResetVisible) { + m_progressBarProtoCloakResetVisible = progressBarProtoCloakResetVisible; + emit progressBarProtoCloakResetVisibleChanged(); + } +} + +bool UiLogic::getLineEditProtoCloakPortEnabled() const +{ + return m_lineEditProtoCloakPortEnabled; +} + +void UiLogic::setLineEditProtoCloakPortEnabled(bool lineEditProtoCloakPortEnabled) +{ + if (m_lineEditProtoCloakPortEnabled != lineEditProtoCloakPortEnabled) { + m_lineEditProtoCloakPortEnabled = lineEditProtoCloakPortEnabled; + emit lineEditProtoCloakPortEnabledChanged(); + } +} +bool UiLogic::getWidgetProtoSsEnabled() const +{ + return m_widgetProtoSsEnabled; +} + +void UiLogic::setWidgetProtoSsEnabled(bool widgetProtoSsEnabled) +{ + if (m_widgetProtoSsEnabled != widgetProtoSsEnabled) { + m_widgetProtoSsEnabled = widgetProtoSsEnabled; + emit widgetProtoSsEnabledChanged(); + } +} + +bool UiLogic::getPushButtonProtoShadowsocksSaveVisible() const +{ + return m_pushButtonProtoShadowsocksSaveVisible; +} + +void UiLogic::setPushButtonProtoShadowsocksSaveVisible(bool pushButtonProtoShadowsocksSaveVisible) +{ + if (m_pushButtonProtoShadowsocksSaveVisible != pushButtonProtoShadowsocksSaveVisible) { + m_pushButtonProtoShadowsocksSaveVisible = pushButtonProtoShadowsocksSaveVisible; + emit pushButtonProtoShadowsocksSaveVisibleChanged(); + } +} + +bool UiLogic::getProgressBarProtoShadowsocksResetVisible() const +{ + return m_progressBarProtoShadowsocksResetVisible; +} + +void UiLogic::setProgressBarProtoShadowsocksResetVisible(bool progressBarProtoShadowsocksResetVisible) +{ + if (m_progressBarProtoShadowsocksResetVisible != progressBarProtoShadowsocksResetVisible) { + m_progressBarProtoShadowsocksResetVisible = progressBarProtoShadowsocksResetVisible; + emit progressBarProtoShadowsocksResetVisibleChanged(); + } +} + +bool UiLogic::getLineEditProtoShadowsocksPortEnabled() const +{ + return m_lineEditProtoShadowsocksPortEnabled; +} + +void UiLogic::setLineEditProtoShadowsocksPortEnabled(bool lineEditProtoShadowsocksPortEnabled) +{ + if (m_lineEditProtoShadowsocksPortEnabled != lineEditProtoShadowsocksPortEnabled) { + m_lineEditProtoShadowsocksPortEnabled = lineEditProtoShadowsocksPortEnabled; + emit lineEditProtoShadowsocksPortEnabledChanged(); + } +} + +bool UiLogic::getWidgetProtoOpenvpnEnabled() const +{ + return m_widgetProtoOpenvpnEnabled; +} + +void UiLogic::setWidgetProtoOpenvpnEnabled(bool widgetProtoOpenvpnEnabled) +{ + if (m_widgetProtoOpenvpnEnabled != widgetProtoOpenvpnEnabled) { + m_widgetProtoOpenvpnEnabled = widgetProtoOpenvpnEnabled; + emit widgetProtoOpenvpnEnabledChanged(); + } +} + +bool UiLogic::getPushButtonProtoOpenvpnSaveVisible() const +{ + return m_pushButtonProtoOpenvpnSaveVisible; +} + +void UiLogic::setPushButtonProtoOpenvpnSaveVisible(bool pushButtonProtoOpenvpnSaveVisible) +{ + if (m_pushButtonProtoOpenvpnSaveVisible != pushButtonProtoOpenvpnSaveVisible) { + m_pushButtonProtoOpenvpnSaveVisible = pushButtonProtoOpenvpnSaveVisible; + emit pushButtonProtoOpenvpnSaveVisibleChanged(); + } +} + +bool UiLogic::getProgressBarProtoOpenvpnResetVisible() const +{ + return m_progressBarProtoOpenvpnResetVisible; +} + +void UiLogic::setProgressBarProtoOpenvpnResetVisible(bool progressBarProtoOpenvpnResetVisible) +{ + if (m_progressBarProtoOpenvpnResetVisible != progressBarProtoOpenvpnResetVisible) { + m_progressBarProtoOpenvpnResetVisible = progressBarProtoOpenvpnResetVisible; + emit progressBarProtoOpenvpnResetVisibleChanged(); + } +} + +bool UiLogic::getRadioButtonProtoOpenvpnUdpEnabled() const +{ + return m_radioButtonProtoOpenvpnUdpEnabled; +} + +void UiLogic::setRadioButtonProtoOpenvpnUdpEnabled(bool radioButtonProtoOpenvpnUdpEnabled) +{ + if (m_radioButtonProtoOpenvpnUdpEnabled != radioButtonProtoOpenvpnUdpEnabled) { + m_radioButtonProtoOpenvpnUdpEnabled = radioButtonProtoOpenvpnUdpEnabled; + emit radioButtonProtoOpenvpnUdpEnabledChanged(); + } +} + +bool UiLogic::getRadioButtonProtoOpenvpnTcpEnabled() const +{ + return m_radioButtonProtoOpenvpnTcpEnabled; +} + +void UiLogic::setRadioButtonProtoOpenvpnTcpEnabled(bool radioButtonProtoOpenvpnTcpEnabled) +{ + if (m_radioButtonProtoOpenvpnTcpEnabled != radioButtonProtoOpenvpnTcpEnabled) { + m_radioButtonProtoOpenvpnTcpEnabled = radioButtonProtoOpenvpnTcpEnabled; + emit radioButtonProtoOpenvpnTcpEnabledChanged(); + } +} + +bool UiLogic::getRadioButtonProtoOpenvpnTcpChecked() const +{ + return m_radioButtonProtoOpenvpnTcpChecked; +} + +void UiLogic::setRadioButtonProtoOpenvpnTcpChecked(bool radioButtonProtoOpenvpnTcpChecked) +{ + if (m_radioButtonProtoOpenvpnTcpChecked != radioButtonProtoOpenvpnTcpChecked) { + m_radioButtonProtoOpenvpnTcpChecked = radioButtonProtoOpenvpnTcpChecked; + emit radioButtonProtoOpenvpnTcpCheckedChanged(); + } +} + +bool UiLogic::getLineEditProtoOpenvpnPortEnabled() const +{ + return m_lineEditProtoOpenvpnPortEnabled; +} + +void UiLogic::setLineEditProtoOpenvpnPortEnabled(bool lineEditProtoOpenvpnPortEnabled) +{ + if (m_lineEditProtoOpenvpnPortEnabled != lineEditProtoOpenvpnPortEnabled) { + m_lineEditProtoOpenvpnPortEnabled = lineEditProtoOpenvpnPortEnabled; + emit lineEditProtoOpenvpnPortEnabledChanged(); + } +} + +bool UiLogic::getPushButtonProtoOpenvpnContInstallChecked() const +{ + return m_pushButtonProtoOpenvpnContInstallChecked; +} + +void UiLogic::setPushButtonProtoOpenvpnContInstallChecked(bool pushButtonProtoOpenvpnContInstallChecked) +{ + if (m_pushButtonProtoOpenvpnContInstallChecked != pushButtonProtoOpenvpnContInstallChecked) { + m_pushButtonProtoOpenvpnContInstallChecked = pushButtonProtoOpenvpnContInstallChecked; + emit pushButtonProtoOpenvpnContInstallCheckedChanged(); + } +} + +bool UiLogic::getPushButtonProtoSsOpenvpnContInstallChecked() const +{ + return m_pushButtonProtoSsOpenvpnContInstallChecked; +} + +void UiLogic::setPushButtonProtoSsOpenvpnContInstallChecked(bool pushButtonProtoSsOpenvpnContInstallChecked) +{ + if (m_pushButtonProtoSsOpenvpnContInstallChecked != pushButtonProtoSsOpenvpnContInstallChecked) { + m_pushButtonProtoSsOpenvpnContInstallChecked = pushButtonProtoSsOpenvpnContInstallChecked; + emit pushButtonProtoSsOpenvpnContInstallCheckedChanged(); + } +} + +bool UiLogic::getPushButtonProtoCloakOpenvpnContInstallChecked() const +{ + return m_pushButtonProtoCloakOpenvpnContInstallChecked; +} + +void UiLogic::setPushButtonProtoCloakOpenvpnContInstallChecked(bool pushButtonProtoCloakOpenvpnContInstallChecked) +{ + if (m_pushButtonProtoCloakOpenvpnContInstallChecked != pushButtonProtoCloakOpenvpnContInstallChecked) { + m_pushButtonProtoCloakOpenvpnContInstallChecked = pushButtonProtoCloakOpenvpnContInstallChecked; + emit pushButtonProtoCloakOpenvpnContInstallCheckedChanged(); + } +} + +bool UiLogic::getPushButtonProtoWireguardContInstallChecked() const +{ + return m_pushButtonProtoWireguardContInstallChecked; +} + +void UiLogic::setPushButtonProtoWireguardContInstallChecked(bool pushButtonProtoWireguardContInstallChecked) +{ + if (m_pushButtonProtoWireguardContInstallChecked != pushButtonProtoWireguardContInstallChecked) { + m_pushButtonProtoWireguardContInstallChecked = pushButtonProtoWireguardContInstallChecked; + emit pushButtonProtoWireguardContInstallCheckedChanged(); + } +} + +bool UiLogic::getPushButtonProtoOpenvpnContInstallEnabled() const +{ + return m_pushButtonProtoOpenvpnContInstallEnabled; +} + +void UiLogic::setPushButtonProtoOpenvpnContInstallEnabled(bool pushButtonProtoOpenvpnContInstallEnabled) +{ + if (m_pushButtonProtoOpenvpnContInstallEnabled != pushButtonProtoOpenvpnContInstallEnabled) { + m_pushButtonProtoOpenvpnContInstallEnabled = pushButtonProtoOpenvpnContInstallEnabled; + emit pushButtonProtoOpenvpnContInstallEnabledChanged(); + } +} + +bool UiLogic::getPushButtonProtoSsOpenvpnContInstallEnabled() const +{ + return m_pushButtonProtoSsOpenvpnContInstallEnabled; +} + +void UiLogic::setPushButtonProtoSsOpenvpnContInstallEnabled(bool pushButtonProtoSsOpenvpnContInstallEnabled) +{ + if (m_pushButtonProtoSsOpenvpnContInstallEnabled != pushButtonProtoSsOpenvpnContInstallEnabled) { + m_pushButtonProtoSsOpenvpnContInstallEnabled = pushButtonProtoSsOpenvpnContInstallEnabled; + emit pushButtonProtoSsOpenvpnContInstallEnabledChanged(); + } +} + +bool UiLogic::getPushButtonProtoCloakOpenvpnContInstallEnabled() const +{ + return m_pushButtonProtoCloakOpenvpnContInstallEnabled; +} + +void UiLogic::setPushButtonProtoCloakOpenvpnContInstallEnabled(bool pushButtonProtoCloakOpenvpnContInstallEnabled) +{ + if (m_pushButtonProtoCloakOpenvpnContInstallEnabled != pushButtonProtoCloakOpenvpnContInstallEnabled) { + m_pushButtonProtoCloakOpenvpnContInstallEnabled = pushButtonProtoCloakOpenvpnContInstallEnabled; + emit pushButtonProtoCloakOpenvpnContInstallEnabledChanged(); + } +} + +bool UiLogic::getPushButtonProtoWireguardContInstallEnabled() const +{ + return m_pushButtonProtoWireguardContInstallEnabled; +} + +void UiLogic::setPushButtonProtoWireguardContInstallEnabled(bool pushButtonProtoWireguardContInstallEnabled) +{ + if (m_pushButtonProtoWireguardContInstallEnabled != pushButtonProtoWireguardContInstallEnabled) { + m_pushButtonProtoWireguardContInstallEnabled = pushButtonProtoWireguardContInstallEnabled; + emit pushButtonProtoWireguardContInstallEnabledChanged(); + } +} + +bool UiLogic::getPushButtonProtoOpenvpnContDefaultChecked() const +{ + return m_pushButtonProtoOpenvpnContDefaultChecked; +} + +void UiLogic::setPushButtonProtoOpenvpnContDefaultChecked(bool pushButtonProtoOpenvpnContDefaultChecked) +{ + if (m_pushButtonProtoOpenvpnContDefaultChecked != pushButtonProtoOpenvpnContDefaultChecked) { + m_pushButtonProtoOpenvpnContDefaultChecked = pushButtonProtoOpenvpnContDefaultChecked; + emit pushButtonProtoOpenvpnContDefaultCheckedChanged(); + } +} + +bool UiLogic::getPushButtonProtoSsOpenvpnContDefaultChecked() const +{ + return m_pushButtonProtoSsOpenvpnContDefaultChecked; +} + +void UiLogic::setPushButtonProtoSsOpenvpnContDefaultChecked(bool pushButtonProtoSsOpenvpnContDefaultChecked) +{ + if (m_pushButtonProtoSsOpenvpnContDefaultChecked != pushButtonProtoSsOpenvpnContDefaultChecked) { + m_pushButtonProtoSsOpenvpnContDefaultChecked = pushButtonProtoSsOpenvpnContDefaultChecked; + emit pushButtonProtoSsOpenvpnContDefaultCheckedChanged(); + } +} + +bool UiLogic::getPushButtonProtoCloakOpenvpnContDefaultChecked() const +{ + return m_pushButtonProtoCloakOpenvpnContDefaultChecked; +} + +void UiLogic::setPushButtonProtoCloakOpenvpnContDefaultChecked(bool pushButtonProtoCloakOpenvpnContDefaultChecked) +{ + if (m_pushButtonProtoCloakOpenvpnContDefaultChecked != pushButtonProtoCloakOpenvpnContDefaultChecked) { + m_pushButtonProtoCloakOpenvpnContDefaultChecked = pushButtonProtoCloakOpenvpnContDefaultChecked; + emit pushButtonProtoCloakOpenvpnContDefaultCheckedChanged(); + } +} + +bool UiLogic::getPushButtonProtoWireguardContDefaultChecked() const +{ + return m_pushButtonProtoWireguardContDefaultChecked; +} + +void UiLogic::setPushButtonProtoWireguardContDefaultChecked(bool pushButtonProtoWireguardContDefaultChecked) +{ + if (m_pushButtonProtoWireguardContDefaultChecked != pushButtonProtoWireguardContDefaultChecked) { + m_pushButtonProtoWireguardContDefaultChecked = pushButtonProtoWireguardContDefaultChecked; + emit pushButtonProtoWireguardContDefaultCheckedChanged(); + } +} + +bool UiLogic::getPushButtonProtoOpenvpnContDefaultVisible() const +{ + return m_pushButtonProtoOpenvpnContDefaultVisible; +} + +void UiLogic::setPushButtonProtoOpenvpnContDefaultVisible(bool pushButtonProtoOpenvpnContDefaultVisible) +{ + if (m_pushButtonProtoOpenvpnContDefaultVisible != pushButtonProtoOpenvpnContDefaultVisible) { + m_pushButtonProtoOpenvpnContDefaultVisible = pushButtonProtoOpenvpnContDefaultVisible; + emit pushButtonProtoOpenvpnContDefaultVisibleChanged(); + } +} + +bool UiLogic::getPushButtonProtoSsOpenvpnContDefaultVisible() const +{ + return m_pushButtonProtoSsOpenvpnContDefaultVisible; +} + +void UiLogic::setPushButtonProtoSsOpenvpnContDefaultVisible(bool pushButtonProtoSsOpenvpnContDefaultVisible) +{ + if (m_pushButtonProtoSsOpenvpnContDefaultVisible != pushButtonProtoSsOpenvpnContDefaultVisible) { + m_pushButtonProtoSsOpenvpnContDefaultVisible = pushButtonProtoSsOpenvpnContDefaultVisible; + emit pushButtonProtoSsOpenvpnContDefaultVisibleChanged(); + } +} + +bool UiLogic::getPushButtonProtoCloakOpenvpnContDefaultVisible() const +{ + return m_pushButtonProtoCloakOpenvpnContDefaultVisible; +} + +void UiLogic::setPushButtonProtoCloakOpenvpnContDefaultVisible(bool pushButtonProtoCloakOpenvpnContDefaultVisible) +{ + if (m_pushButtonProtoCloakOpenvpnContDefaultVisible != pushButtonProtoCloakOpenvpnContDefaultVisible) { + m_pushButtonProtoCloakOpenvpnContDefaultVisible = pushButtonProtoCloakOpenvpnContDefaultVisible; + emit pushButtonProtoCloakOpenvpnContDefaultVisibleChanged(); + } +} + +bool UiLogic::getPushButtonProtoWireguardContDefaultVisible() const +{ + return m_pushButtonProtoWireguardContDefaultVisible; +} + +void UiLogic::setPushButtonProtoWireguardContDefaultVisible(bool pushButtonProtoWireguardContDefaultVisible) +{ + if (m_pushButtonProtoWireguardContDefaultVisible != pushButtonProtoWireguardContDefaultVisible) { + m_pushButtonProtoWireguardContDefaultVisible = pushButtonProtoWireguardContDefaultVisible; + emit pushButtonProtoWireguardContDefaultVisibleChanged(); + } +} + +bool UiLogic::getPushButtonProtoOpenvpnContShareVisible() const +{ + return m_pushButtonProtoOpenvpnContShareVisible; +} + +void UiLogic::setPushButtonProtoOpenvpnContShareVisible(bool pushButtonProtoOpenvpnContShareVisible) +{ + if (m_pushButtonProtoOpenvpnContShareVisible != pushButtonProtoOpenvpnContShareVisible) { + m_pushButtonProtoOpenvpnContShareVisible = pushButtonProtoOpenvpnContShareVisible; + emit pushButtonProtoOpenvpnContShareVisibleChanged(); + } +} + +bool UiLogic::getPushButtonProtoSsOpenvpnContShareVisible() const +{ + return m_pushButtonProtoSsOpenvpnContShareVisible; +} + +void UiLogic::setPushButtonProtoSsOpenvpnContShareVisible(bool pushButtonProtoSsOpenvpnContShareVisible) +{ + if (m_pushButtonProtoSsOpenvpnContShareVisible != pushButtonProtoSsOpenvpnContShareVisible) { + m_pushButtonProtoSsOpenvpnContShareVisible = pushButtonProtoSsOpenvpnContShareVisible; + emit pushButtonProtoSsOpenvpnContShareVisibleChanged(); + } +} + +bool UiLogic::getPushButtonProtoCloakOpenvpnContShareVisible() const +{ + return m_pushButtonProtoCloakOpenvpnContShareVisible; +} + +void UiLogic::setPushButtonProtoCloakOpenvpnContShareVisible(bool pushButtonProtoCloakOpenvpnContShareVisible) +{ + if (m_pushButtonProtoCloakOpenvpnContShareVisible != pushButtonProtoCloakOpenvpnContShareVisible) { + m_pushButtonProtoCloakOpenvpnContShareVisible = pushButtonProtoCloakOpenvpnContShareVisible; + emit pushButtonProtoCloakOpenvpnContShareVisibleChanged(); + } +} + +bool UiLogic::getPushButtonProtoWireguardContShareVisible() const +{ + return m_pushButtonProtoWireguardContShareVisible; +} + +void UiLogic::setPushButtonProtoWireguardContShareVisible(bool pushButtonProtoWireguardContShareVisible) +{ + if (m_pushButtonProtoWireguardContShareVisible != pushButtonProtoWireguardContShareVisible) { + m_pushButtonProtoWireguardContShareVisible = pushButtonProtoWireguardContShareVisible; + emit pushButtonProtoWireguardContShareVisibleChanged(); + } +} + +bool UiLogic::getFrameOpenvpnSettingsVisible() const +{ + return m_frameOpenvpnSettingsVisible; +} + +void UiLogic::setFrameOpenvpnSettingsVisible(bool frameOpenvpnSettingsVisible) +{ + if (m_frameOpenvpnSettingsVisible != frameOpenvpnSettingsVisible) { + m_frameOpenvpnSettingsVisible = frameOpenvpnSettingsVisible; + emit frameOpenvpnSettingsVisibleChanged(); + } +} + +bool UiLogic::getFrameOpenvpnSsSettingsVisible() const +{ + return m_frameOpenvpnSsSettingsVisible; +} + +void UiLogic::setFrameOpenvpnSsSettingsVisible(bool frameOpenvpnSsSettingsVisible) +{ + if (m_frameOpenvpnSsSettingsVisible != frameOpenvpnSsSettingsVisible) { + m_frameOpenvpnSsSettingsVisible = frameOpenvpnSsSettingsVisible; + emit frameOpenvpnSsSettingsVisibleChanged(); + } +} + +bool UiLogic::getFrameOpenvpnSsCloakSettingsVisible() const +{ + return m_frameOpenvpnSsCloakSettingsVisible; +} + +void UiLogic::setFrameOpenvpnSsCloakSettingsVisible(bool frameOpenvpnSsCloakSettingsVisible) +{ + if (m_frameOpenvpnSsCloakSettingsVisible != frameOpenvpnSsCloakSettingsVisible) { + m_frameOpenvpnSsCloakSettingsVisible = frameOpenvpnSsCloakSettingsVisible; + emit frameOpenvpnSsCloakSettingsVisibleChanged(); + } +} + +bool UiLogic::getProgressBarProtocolsContainerReinstallVisible() const +{ + return m_progressBarProtocolsContainerReinstallVisible; +} + +void UiLogic::setProgressBarProtocolsContainerReinstallVisible(bool progressBarProtocolsContainerReinstallVisible) +{ + if (m_progressBarProtocolsContainerReinstallVisible != progressBarProtocolsContainerReinstallVisible) { + m_progressBarProtocolsContainerReinstallVisible = progressBarProtocolsContainerReinstallVisible; + emit progressBarProtocolsContainerReinstallVisibleChanged(); + } +} + +QString UiLogic::getLabelSpeedReceivedText() const +{ + return m_labelSpeedReceivedText; +} + +void UiLogic::setLabelSpeedReceivedText(const QString &labelSpeedReceivedText) +{ + if (m_labelSpeedReceivedText != labelSpeedReceivedText) { + m_labelSpeedReceivedText = labelSpeedReceivedText; + emit labelSpeedReceivedTextChanged(); + } +} + +QString UiLogic::getLabelSpeedSentText() const +{ + return m_labelSpeedSentText; +} + +void UiLogic::setLabelSpeedSentText(const QString &labelSpeedSentText) +{ + if (m_labelSpeedSentText != labelSpeedSentText) { + m_labelSpeedSentText = labelSpeedSentText; + emit labelSpeedSentTextChanged(); + } +} + +QString UiLogic::getLabelStateText() const +{ + return m_labelStateText; +} + +void UiLogic::setLabelStateText(const QString &labelStateText) +{ + if (m_labelStateText != labelStateText) { + m_labelStateText = labelStateText; + emit labelStateTextChanged(); + } +} + +bool UiLogic::getPushButtonConnectEnabled() const +{ + return m_pushButtonConnectEnabled; +} + +void UiLogic::setPushButtonConnectEnabled(bool pushButtonConnectEnabled) +{ + if (m_pushButtonConnectEnabled != pushButtonConnectEnabled) { + m_pushButtonConnectEnabled = pushButtonConnectEnabled; + emit pushButtonConnectEnabledChanged(); + } +} + +bool UiLogic::getWidgetVpnModeEnabled() const +{ + return m_widgetVpnModeEnabled; +} + +void UiLogic::setWidgetVpnModeEnabled(bool widgetVpnModeEnabled) +{ + if (m_widgetVpnModeEnabled != widgetVpnModeEnabled) { + m_widgetVpnModeEnabled = widgetVpnModeEnabled; + emit widgetVpnModeEnabledChanged(); + } +} + +QString UiLogic::getLabelErrorText() const +{ + return m_labelErrorText; +} + +void UiLogic::setLabelErrorText(const QString &labelErrorText) +{ + if (m_labelErrorText != labelErrorText) { + m_labelErrorText = labelErrorText; + emit labelErrorTextChanged(); + } +} + +bool UiLogic::getPushButtonNewServerConnectEnabled() const +{ + return m_pushButtonNewServerConnectEnabled; +} + +void UiLogic::setPushButtonNewServerConnectEnabled(bool pushButtonNewServerConnectEnabled) +{ + if (m_pushButtonNewServerConnectEnabled != pushButtonNewServerConnectEnabled) { + m_pushButtonNewServerConnectEnabled = pushButtonNewServerConnectEnabled; + emit pushButtonNewServerConnectEnabledChanged(); + } +} + +QString UiLogic::getPushButtonNewServerConnectText() const +{ + return m_pushButtonNewServerConnectText; +} + +void UiLogic::setPushButtonNewServerConnectText(const QString &pushButtonNewServerConnectText) +{ + if (m_pushButtonNewServerConnectText != pushButtonNewServerConnectText) { + m_pushButtonNewServerConnectText = pushButtonNewServerConnectText; + emit pushButtonNewServerConnectTextChanged(); + } +} +QString UiLogic::getDialogConnectErrorText() const +{ + return m_dialogConnectErrorText; +} + +void UiLogic::setDialogConnectErrorText(const QString &dialogConnectErrorText) +{ + if (m_dialogConnectErrorText != dialogConnectErrorText) { + m_dialogConnectErrorText = dialogConnectErrorText; + emit dialogConnectErrorTextChanged(); + } +} + +bool UiLogic::getPageServerSettingsEnabled() const +{ + return m_pageServerSettingsEnabled; +} + +void UiLogic::setPageServerSettingsEnabled(bool pageServerSettingsEnabled) +{ + if (m_pageServerSettingsEnabled != pageServerSettingsEnabled) { + m_pageServerSettingsEnabled = pageServerSettingsEnabled; + emit pageServerSettingsEnabledChanged(); + } +} + +QString UiLogic::getPushButtonServerSettingsClearText() const +{ + return m_pushButtonServerSettingsClearText; +} + +void UiLogic::setPushButtonServerSettingsClearText(const QString &pushButtonServerSettingsClearText) +{ + if (m_pushButtonServerSettingsClearText != pushButtonServerSettingsClearText) { + m_pushButtonServerSettingsClearText = pushButtonServerSettingsClearText; + emit pushButtonServerSettingsClearTextChanged(); + } +} + +bool UiLogic::getPageShareAmneziaVisible() const +{ + return m_pageShareAmneziaVisible; +} + +void UiLogic::setPageShareAmneziaVisible(bool pageShareAmneziaVisible) +{ + if (m_pageShareAmneziaVisible != pageShareAmneziaVisible) { + m_pageShareAmneziaVisible = pageShareAmneziaVisible; + emit pageShareAmneziaVisibleChanged(); + } +} + +bool UiLogic::getPageShareOpenvpnVisible() const +{ + return m_pageShareOpenvpnVisible; +} + +void UiLogic::setPageShareOpenvpnVisible(bool pageShareOpenvpnVisible) +{ + if (m_pageShareOpenvpnVisible != pageShareOpenvpnVisible) { + m_pageShareOpenvpnVisible = pageShareOpenvpnVisible; + emit pageShareOpenvpnVisibleChanged(); + } +} + +bool UiLogic::getPageShareShadowsocksVisible() const +{ + return m_pageShareShadowsocksVisible; +} + +void UiLogic::setPageShareShadowsocksVisible(bool pageShareShadowsocksVisible) +{ + if (m_pageShareShadowsocksVisible != pageShareShadowsocksVisible) { + m_pageShareShadowsocksVisible = pageShareShadowsocksVisible; + emit pageShareShadowsocksVisibleChanged(); + } +} + +bool UiLogic::getPageShareCloakVisible() const +{ + return m_pageShareCloakVisible; +} + +void UiLogic::setPageShareCloakVisible(bool pageShareCloakVisible) +{ + if (m_pageShareCloakVisible != pageShareCloakVisible) { + m_pageShareCloakVisible = pageShareCloakVisible; + emit pageShareCloakVisibleChanged(); + } +} + +bool UiLogic::getPageShareFullAccessVisible() const +{ + return m_pageShareFullAccessVisible; +} + +void UiLogic::setPageShareFullAccessVisible(bool pageShareFullAccessVisible) +{ + if (m_pageShareFullAccessVisible != pageShareFullAccessVisible) { + m_pageShareFullAccessVisible = pageShareFullAccessVisible; + emit pageShareFullAccessVisibleChanged(); + } +} + +QString UiLogic::getTextEditShareOpenvpnCodeText() const +{ + return m_textEditShareOpenvpnCodeText; +} + +void UiLogic::setTextEditShareOpenvpnCodeText(const QString &textEditShareOpenvpnCodeText) +{ + if (m_textEditShareOpenvpnCodeText != textEditShareOpenvpnCodeText) { + m_textEditShareOpenvpnCodeText = textEditShareOpenvpnCodeText; + emit textEditShareOpenvpnCodeTextChanged(); + } +} + +bool UiLogic::getPushButtonShareOpenvpnCopyEnabled() const +{ + return m_pushButtonShareOpenvpnCopyEnabled; +} + +void UiLogic::setPushButtonShareOpenvpnCopyEnabled(bool pushButtonShareOpenvpnCopyEnabled) +{ + if (m_pushButtonShareOpenvpnCopyEnabled != pushButtonShareOpenvpnCopyEnabled) { + m_pushButtonShareOpenvpnCopyEnabled = pushButtonShareOpenvpnCopyEnabled; + emit pushButtonShareOpenvpnCopyEnabledChanged(); + } +} + +bool UiLogic::getPushButtonShareOpenvpnSaveEnabled() const +{ + return m_pushButtonShareOpenvpnSaveEnabled; +} + +void UiLogic::setPushButtonShareOpenvpnSaveEnabled(bool pushButtonShareOpenvpnSaveEnabled) +{ + if (m_pushButtonShareOpenvpnSaveEnabled != pushButtonShareOpenvpnSaveEnabled) { + m_pushButtonShareOpenvpnSaveEnabled = pushButtonShareOpenvpnSaveEnabled; + emit pushButtonShareOpenvpnSaveEnabledChanged(); + } +} + +int UiLogic::getToolBoxShareConnectionCurrentIndex() const +{ + return m_toolBoxShareConnectionCurrentIndex; +} + +void UiLogic::setToolBoxShareConnectionCurrentIndex(int toolBoxShareConnectionCurrentIndex) +{ + if (m_toolBoxShareConnectionCurrentIndex != toolBoxShareConnectionCurrentIndex) { + m_toolBoxShareConnectionCurrentIndex = toolBoxShareConnectionCurrentIndex; + emit toolBoxShareConnectionCurrentIndexChanged(); + } +} + +bool UiLogic::getPushButtonShareSsCopyEnabled() const +{ + return m_pushButtonShareSsCopyEnabled; +} + +void UiLogic::setPushButtonShareSsCopyEnabled(bool pushButtonShareSsCopyEnabled) +{ + if (m_pushButtonShareSsCopyEnabled != pushButtonShareSsCopyEnabled) { + m_pushButtonShareSsCopyEnabled = pushButtonShareSsCopyEnabled; + emit pushButtonShareSsCopyEnabledChanged(); + } +} + +QString UiLogic::getLineEditShareSsStringText() const +{ + return m_lineEditShareSsStringText; +} + +void UiLogic::setLineEditShareSsStringText(const QString &lineEditShareSsStringText) +{ + if (m_lineEditShareSsStringText != lineEditShareSsStringText) { + m_lineEditShareSsStringText = lineEditShareSsStringText; + emit lineEditShareSsStringTextChanged(); + } +} + +QString UiLogic::getLabelShareSsQrCodeText() const +{ + return m_labelShareSsQrCodeText; +} + +void UiLogic::setLabelShareSsQrCodeText(const QString &labelShareSsQrCodeText) +{ + if (m_labelShareSsQrCodeText != labelShareSsQrCodeText) { + m_labelShareSsQrCodeText = labelShareSsQrCodeText; + emit labelShareSsQrCodeTextChanged(); + } +} + +QString UiLogic::getLabelShareSsServerText() const +{ + return m_labelShareSsServerText; +} + +void UiLogic::setLabelShareSsServerText(const QString &labelShareSsServerText) +{ + if (m_labelShareSsServerText != labelShareSsServerText) { + m_labelShareSsServerText = labelShareSsServerText; + emit labelShareSsServerTextChanged(); + } +} + +QString UiLogic::getLabelShareSsPortText() const +{ + return m_labelShareSsPortText; +} + +void UiLogic::setLabelShareSsPortText(const QString &labelShareSsPortText) +{ + if (m_labelShareSsPortText != labelShareSsPortText) { + m_labelShareSsPortText = labelShareSsPortText; + emit labelShareSsPortTextChanged(); + } +} + +QString UiLogic::getLabelShareSsMethodText() const +{ + return m_labelShareSsMethodText; +} + +void UiLogic::setLabelShareSsMethodText(const QString &labelShareSsMethodText) +{ + if (m_labelShareSsMethodText != labelShareSsMethodText) { + m_labelShareSsMethodText = labelShareSsMethodText; + emit labelShareSsMethodTextChanged(); + } +} + +QString UiLogic::getLabelShareSsPasswordText() const +{ + return m_labelShareSsPasswordText; +} + +void UiLogic::setLabelShareSsPasswordText(const QString &labelShareSsPasswordText) +{ + if (m_labelShareSsPasswordText != labelShareSsPasswordText) { + m_labelShareSsPasswordText = labelShareSsPasswordText; + emit labelShareSsPasswordTextChanged(); + } +} + +QString UiLogic::getPlainTextEditShareCloakText() const +{ + return m_plainTextEditShareCloakText; +} + +void UiLogic::setPlainTextEditShareCloakText(const QString &plainTextEditShareCloakText) +{ + if (m_plainTextEditShareCloakText != plainTextEditShareCloakText) { + m_plainTextEditShareCloakText = plainTextEditShareCloakText; + emit plainTextEditShareCloakTextChanged(); + } +} + +bool UiLogic::getPushButtonShareCloakCopyEnabled() const +{ + return m_pushButtonShareCloakCopyEnabled; +} + +void UiLogic::setPushButtonShareCloakCopyEnabled(bool pushButtonShareCloakCopyEnabled) +{ + if (m_pushButtonShareCloakCopyEnabled != pushButtonShareCloakCopyEnabled) { + m_pushButtonShareCloakCopyEnabled = pushButtonShareCloakCopyEnabled; + emit pushButtonShareCloakCopyEnabledChanged(); + } +} + +QString UiLogic::getTextEditShareFullCodeText() const +{ + return m_textEditShareFullCodeText; +} + +void UiLogic::setTextEditShareFullCodeText(const QString &textEditShareFullCodeText) +{ + if (m_textEditShareFullCodeText != textEditShareFullCodeText) { + m_textEditShareFullCodeText = textEditShareFullCodeText; + emit textEditShareFullCodeTextChanged(); + } +} + +QString UiLogic::getTextEditShareAmneziaCodeText() const +{ + return m_textEditShareAmneziaCodeText; +} + +void UiLogic::setTextEditShareAmneziaCodeText(const QString &textEditShareAmneziaCodeText) +{ + if (m_textEditShareAmneziaCodeText != textEditShareAmneziaCodeText) { + m_textEditShareAmneziaCodeText = textEditShareAmneziaCodeText; + emit textEditShareAmneziaCodeTextChanged(); + } +} + +QString UiLogic::getPushButtonShareFullCopyText() const +{ + return m_pushButtonShareFullCopyText; +} + +void UiLogic::setPushButtonShareFullCopyText(const QString &pushButtonShareFullCopyText) +{ + if (m_pushButtonShareFullCopyText != pushButtonShareFullCopyText) { + m_pushButtonShareFullCopyText = pushButtonShareFullCopyText; + emit pushButtonShareFullCopyTextChanged(); + } +} +QString UiLogic::getPushButtonShareAmneziaCopyText() const +{ + return m_pushButtonShareAmneziaCopyText; +} + +void UiLogic::setPushButtonShareAmneziaCopyText(const QString &pushButtonShareAmneziaCopyText) +{ + if (m_pushButtonShareAmneziaCopyText != pushButtonShareAmneziaCopyText) { + m_pushButtonShareAmneziaCopyText = pushButtonShareAmneziaCopyText; + emit pushButtonShareAmneziaCopyTextChanged(); + } +} + +QString UiLogic::getPushButtonShareOpenvpnCopyText() const +{ + return m_pushButtonShareOpenvpnCopyText; +} + +void UiLogic::setPushButtonShareOpenvpnCopyText(const QString &pushButtonShareOpenvpnCopyText) +{ + if (m_pushButtonShareOpenvpnCopyText != pushButtonShareOpenvpnCopyText) { + m_pushButtonShareOpenvpnCopyText = pushButtonShareOpenvpnCopyText; + emit pushButtonShareOpenvpnCopyTextChanged(); + } +} + +QString UiLogic::getPushButtonShareSsCopyText() const +{ + return m_pushButtonShareSsCopyText; +} + +void UiLogic::setPushButtonShareSsCopyText(const QString &pushButtonShareSsCopyText) +{ + if (m_pushButtonShareSsCopyText != pushButtonShareSsCopyText) { + m_pushButtonShareSsCopyText = pushButtonShareSsCopyText; + emit pushButtonShareSsCopyTextChanged(); + } +} + +QString UiLogic::getPushButtonShareCloakCopyText() const +{ + return m_pushButtonShareCloakCopyText; +} + +void UiLogic::setPushButtonShareCloakCopyText(const QString &pushButtonShareCloakCopyText) +{ + if (m_pushButtonShareCloakCopyText != pushButtonShareCloakCopyText) { + m_pushButtonShareCloakCopyText = pushButtonShareCloakCopyText; + emit pushButtonShareCloakCopyTextChanged(); + } +} + +bool UiLogic::getPushButtonShareAmneziaGenerateEnabled() const +{ + return m_pushButtonShareAmneziaGenerateEnabled; +} + +void UiLogic::setPushButtonShareAmneziaGenerateEnabled(bool pushButtonShareAmneziaGenerateEnabled) +{ + if (m_pushButtonShareAmneziaGenerateEnabled != pushButtonShareAmneziaGenerateEnabled) { + m_pushButtonShareAmneziaGenerateEnabled = pushButtonShareAmneziaGenerateEnabled; + emit pushButtonShareAmneziaGenerateEnabledChanged(); + } +} + +bool UiLogic::getPushButtonShareAmneziaCopyEnabled() const +{ + return m_pushButtonShareAmneziaCopyEnabled; +} + +void UiLogic::setPushButtonShareAmneziaCopyEnabled(bool pushButtonShareAmneziaCopyEnabled) +{ + if (m_pushButtonShareAmneziaCopyEnabled != pushButtonShareAmneziaCopyEnabled) { + m_pushButtonShareAmneziaCopyEnabled = pushButtonShareAmneziaCopyEnabled; + emit pushButtonShareAmneziaCopyEnabledChanged(); + } +} + +QString UiLogic::getPushButtonShareAmneziaGenerateText() const +{ + return m_pushButtonShareAmneziaGenerateText; +} + +void UiLogic::setPushButtonShareAmneziaGenerateText(const QString &pushButtonShareAmneziaGenerateText) +{ + if (m_pushButtonShareAmneziaGenerateText != pushButtonShareAmneziaGenerateText) { + m_pushButtonShareAmneziaGenerateText = pushButtonShareAmneziaGenerateText; + emit pushButtonShareAmneziaGenerateTextChanged(); + } +} + +bool UiLogic::getPushButtonShareOpenvpnGenerateEnabled() const +{ + return m_pushButtonShareOpenvpnGenerateEnabled; +} + +void UiLogic::setPushButtonShareOpenvpnGenerateEnabled(bool pushButtonShareOpenvpnGenerateEnabled) +{ + if (m_pushButtonShareOpenvpnGenerateEnabled != pushButtonShareOpenvpnGenerateEnabled) { + m_pushButtonShareOpenvpnGenerateEnabled = pushButtonShareOpenvpnGenerateEnabled; + emit pushButtonShareOpenvpnGenerateEnabledChanged(); + } +} + +QString UiLogic::getPushButtonShareOpenvpnGenerateText() const +{ + return m_pushButtonShareOpenvpnGenerateText; +} + +void UiLogic::setPushButtonShareOpenvpnGenerateText(const QString &pushButtonShareOpenvpnGenerateText) +{ + if (m_pushButtonShareOpenvpnGenerateText != pushButtonShareOpenvpnGenerateText) { + m_pushButtonShareOpenvpnGenerateText = pushButtonShareOpenvpnGenerateText; + emit pushButtonShareOpenvpnGenerateTextChanged(); + } +} + +bool UiLogic::getPageNewServerConfiguringEnabled() const +{ + return m_pageNewServerConfiguringEnabled; +} + +void UiLogic::setPageNewServerConfiguringEnabled(bool pageNewServerConfiguringEnabled) +{ + if (m_pageNewServerConfiguringEnabled != pageNewServerConfiguringEnabled) { + m_pageNewServerConfiguringEnabled = pageNewServerConfiguringEnabled; + emit pageNewServerConfiguringEnabledChanged(); + } +} + +bool UiLogic::getLabelNewServerConfiguringWaitInfoVisible() const +{ + return m_labelNewServerConfiguringWaitInfoVisible; +} + +void UiLogic::setLabelNewServerConfiguringWaitInfoVisible(bool labelNewServerConfiguringWaitInfoVisible) +{ + if (m_labelNewServerConfiguringWaitInfoVisible != labelNewServerConfiguringWaitInfoVisible) { + m_labelNewServerConfiguringWaitInfoVisible = labelNewServerConfiguringWaitInfoVisible; + emit labelNewServerConfiguringWaitInfoVisibleChanged(); + } +} + +QString UiLogic::getLabelNewServerConfiguringWaitInfoText() const +{ + return m_labelNewServerConfiguringWaitInfoText; +} + +void UiLogic::setLabelNewServerConfiguringWaitInfoText(const QString &labelNewServerConfiguringWaitInfoText) +{ + if (m_labelNewServerConfiguringWaitInfoText != labelNewServerConfiguringWaitInfoText) { + m_labelNewServerConfiguringWaitInfoText = labelNewServerConfiguringWaitInfoText; + emit labelNewServerConfiguringWaitInfoTextChanged(); + } +} + +bool UiLogic::getProgressBarNewServerConfiguringVisible() const +{ + return m_progressBarNewServerConfiguringVisible; +} + +void UiLogic::setProgressBarNewServerConfiguringVisible(bool progressBarNewServerConfiguringVisible) +{ + if (m_progressBarNewServerConfiguringVisible != progressBarNewServerConfiguringVisible) { + m_progressBarNewServerConfiguringVisible = progressBarNewServerConfiguringVisible; + emit progressBarNewServerConfiguringVisibleChanged(); + } +} + +int UiLogic::getProgressBarNewServerConfiguringMaximium() const +{ + return m_progressBarNewServerConfiguringMaximium; +} + +void UiLogic::setProgressBarNewServerConfiguringMaximium(int progressBarNewServerConfiguringMaximium) +{ + if (m_progressBarNewServerConfiguringMaximium != progressBarNewServerConfiguringMaximium) { + m_progressBarNewServerConfiguringMaximium = progressBarNewServerConfiguringMaximium; + emit progressBarNewServerConfiguringMaximiumChanged(); + } +} + +bool UiLogic::getProgressBarNewServerConfiguringTextVisible() const +{ + return m_progressBarNewServerConfiguringTextVisible; +} + +void UiLogic::setProgressBarNewServerConfiguringTextVisible(bool progressBarNewServerConfiguringTextVisible) +{ + if (m_progressBarNewServerConfiguringTextVisible != progressBarNewServerConfiguringTextVisible) { + m_progressBarNewServerConfiguringTextVisible = progressBarNewServerConfiguringTextVisible; + emit progressBarNewServerConfiguringTextVisibleChanged(); + } +} + +QString UiLogic::getProgressBarNewServerConfiguringText() const +{ + return m_progressBarNewServerConfiguringText; +} + +void UiLogic::setProgressBarNewServerConfiguringText(const QString &progressBarNewServerConfiguringText) +{ + if (m_progressBarNewServerConfiguringText != progressBarNewServerConfiguringText) { + m_progressBarNewServerConfiguringText = progressBarNewServerConfiguringText; + emit progressBarNewServerConfiguringTextChanged(); + } +} + +bool UiLogic::getPageServerProtocolsEnabled() const +{ + return m_pageServerProtocolsEnabled; +} + +void UiLogic::setPageServerProtocolsEnabled(bool pageServerProtocolsEnabled) +{ + if (m_pageServerProtocolsEnabled != pageServerProtocolsEnabled) { + m_pageServerProtocolsEnabled = pageServerProtocolsEnabled; + emit pageServerProtocolsEnabledChanged(); + } +} + +int UiLogic::getProgressBarProtocolsContainerReinstallValue() const +{ + return m_progressBarProtocolsContainerReinstallValue; +} + +void UiLogic::setProgressBarProtocolsContainerReinstallValue(int progressBarProtocolsContainerReinstallValue) +{ + if (m_progressBarProtocolsContainerReinstallValue != progressBarProtocolsContainerReinstallValue) { + m_progressBarProtocolsContainerReinstallValue = progressBarProtocolsContainerReinstallValue; + emit progressBarProtocolsContainerReinstallValueChanged(); + } +} + +int UiLogic::getProgressBarProtocolsContainerReinstallMaximium() const +{ + return m_progressBarProtocolsContainerReinstallMaximium; +} + +void UiLogic::setProgressBarProtocolsContainerReinstallMaximium(int progressBarProtocolsContainerReinstallMaximium) +{ + if (m_progressBarProtocolsContainerReinstallMaximium != progressBarProtocolsContainerReinstallMaximium) { + m_progressBarProtocolsContainerReinstallMaximium = progressBarProtocolsContainerReinstallMaximium; + emit progressBarProtocolsContainerReinstallMaximiumChanged(); + } +} + +bool UiLogic::getComboBoxProtoOpenvpnCipherEnabled() const +{ + return m_comboBoxProtoOpenvpnCipherEnabled; +} + +void UiLogic::setComboBoxProtoOpenvpnCipherEnabled(bool comboBoxProtoOpenvpnCipherEnabled) +{ + if (m_comboBoxProtoOpenvpnCipherEnabled != comboBoxProtoOpenvpnCipherEnabled) { + m_comboBoxProtoOpenvpnCipherEnabled = comboBoxProtoOpenvpnCipherEnabled; + emit comboBoxProtoOpenvpnCipherEnabledChanged(); + } +} + +bool UiLogic::getComboBoxProtoOpenvpnHashEnabled() const +{ + return m_comboBoxProtoOpenvpnHashEnabled; +} + +void UiLogic::setComboBoxProtoOpenvpnHashEnabled(bool comboBoxProtoOpenvpnHashEnabled) +{ + if (m_comboBoxProtoOpenvpnHashEnabled != comboBoxProtoOpenvpnHashEnabled) { + m_comboBoxProtoOpenvpnHashEnabled = comboBoxProtoOpenvpnHashEnabled; + emit comboBoxProtoOpenvpnHashEnabledChanged(); + } +} +bool UiLogic::getPageProtoOpenvpnEnabled() const +{ + return m_pageProtoOpenvpnEnabled; +} + +void UiLogic::setPageProtoOpenvpnEnabled(bool pageProtoOpenvpnEnabled) +{ + if (m_pageProtoOpenvpnEnabled != pageProtoOpenvpnEnabled) { + m_pageProtoOpenvpnEnabled = pageProtoOpenvpnEnabled; + emit pageProtoOpenvpnEnabledChanged(); + } +} + +bool UiLogic::getLabelProtoOpenvpnInfoVisible() const +{ + return m_labelProtoOpenvpnInfoVisible; +} + +void UiLogic::setLabelProtoOpenvpnInfoVisible(bool labelProtoOpenvpnInfoVisible) +{ + if (m_labelProtoOpenvpnInfoVisible != labelProtoOpenvpnInfoVisible) { + m_labelProtoOpenvpnInfoVisible = labelProtoOpenvpnInfoVisible; + emit labelProtoOpenvpnInfoVisibleChanged(); + } +} + +QString UiLogic::getLabelProtoOpenvpnInfoText() const +{ + return m_labelProtoOpenvpnInfoText; +} + +void UiLogic::setLabelProtoOpenvpnInfoText(const QString &labelProtoOpenvpnInfoText) +{ + if (m_labelProtoOpenvpnInfoText != labelProtoOpenvpnInfoText) { + m_labelProtoOpenvpnInfoText = labelProtoOpenvpnInfoText; + emit labelProtoOpenvpnInfoTextChanged(); + } +} + +int UiLogic::getProgressBarProtoOpenvpnResetValue() const +{ + return m_progressBarProtoOpenvpnResetValue; +} + +void UiLogic::setProgressBarProtoOpenvpnResetValue(int progressBarProtoOpenvpnResetValue) +{ + if (m_progressBarProtoOpenvpnResetValue != progressBarProtoOpenvpnResetValue) { + m_progressBarProtoOpenvpnResetValue = progressBarProtoOpenvpnResetValue; + emit progressBarProtoOpenvpnResetValueChanged(); + } +} + +int UiLogic::getProgressBarProtoOpenvpnResetMaximium() const +{ + return m_progressBarProtoOpenvpnResetMaximium; +} + +void UiLogic::setProgressBarProtoOpenvpnResetMaximium(int progressBarProtoOpenvpnResetMaximium) +{ + if (m_progressBarProtoOpenvpnResetMaximium != progressBarProtoOpenvpnResetMaximium) { + m_progressBarProtoOpenvpnResetMaximium = progressBarProtoOpenvpnResetMaximium; + emit progressBarProtoOpenvpnResetMaximiumChanged(); + } +} +bool UiLogic::getPageProtoShadowsocksEnabled() const +{ + return m_pageProtoShadowsocksEnabled; +} + +void UiLogic::setPageProtoShadowsocksEnabled(bool pageProtoShadowsocksEnabled) +{ + if (m_pageProtoShadowsocksEnabled != pageProtoShadowsocksEnabled) { + m_pageProtoShadowsocksEnabled = pageProtoShadowsocksEnabled; + emit pageProtoShadowsocksEnabledChanged(); + } +} + +bool UiLogic::getLabelProtoShadowsocksInfoVisible() const +{ + return m_labelProtoShadowsocksInfoVisible; +} + +void UiLogic::setLabelProtoShadowsocksInfoVisible(bool labelProtoShadowsocksInfoVisible) +{ + if (m_labelProtoShadowsocksInfoVisible != labelProtoShadowsocksInfoVisible) { + m_labelProtoShadowsocksInfoVisible = labelProtoShadowsocksInfoVisible; + emit labelProtoShadowsocksInfoVisibleChanged(); + } +} + +QString UiLogic::getLabelProtoShadowsocksInfoText() const +{ + return m_labelProtoShadowsocksInfoText; +} + +void UiLogic::setLabelProtoShadowsocksInfoText(const QString &labelProtoShadowsocksInfoText) +{ + if (m_labelProtoShadowsocksInfoText != labelProtoShadowsocksInfoText) { + m_labelProtoShadowsocksInfoText = labelProtoShadowsocksInfoText; + emit labelProtoShadowsocksInfoTextChanged(); + } +} + +int UiLogic::getProgressBarProtoShadowsocksResetValue() const +{ + return m_progressBarProtoShadowsocksResetValue; +} + +void UiLogic::setProgressBarProtoShadowsocksResetValue(int progressBarProtoShadowsocksResetValue) +{ + if (m_progressBarProtoShadowsocksResetValue != progressBarProtoShadowsocksResetValue) { + m_progressBarProtoShadowsocksResetValue = progressBarProtoShadowsocksResetValue; + emit progressBarProtoShadowsocksResetValueChanged(); + } +} + +int UiLogic::getProgressBarProtoShadowsocksResetMaximium() const +{ + return m_progressBarProtoShadowsocksResetMaximium; +} + +void UiLogic::setProgressBarProtoShadowsocksResetMaximium(int progressBarProtoShadowsocksResetMaximium) +{ + if (m_progressBarProtoShadowsocksResetMaximium != progressBarProtoShadowsocksResetMaximium) { + m_progressBarProtoShadowsocksResetMaximium = progressBarProtoShadowsocksResetMaximium; + emit progressBarProtoShadowsocksResetMaximiumChanged(); + } +} +bool UiLogic::getPageProtoCloakEnabled() const +{ + return m_pageProtoCloakEnabled; +} + +void UiLogic::setPageProtoCloakEnabled(bool pageProtoCloakEnabled) +{ + if (m_pageProtoCloakEnabled != pageProtoCloakEnabled) { + m_pageProtoCloakEnabled = pageProtoCloakEnabled; + emit pageProtoCloakEnabledChanged(); + } +} + +bool UiLogic::getLabelProtoCloakInfoVisible() const +{ + return m_labelProtoCloakInfoVisible; +} + +void UiLogic::setLabelProtoCloakInfoVisible(bool labelProtoCloakInfoVisible) +{ + if (m_labelProtoCloakInfoVisible != labelProtoCloakInfoVisible) { + m_labelProtoCloakInfoVisible = labelProtoCloakInfoVisible; + emit labelProtoCloakInfoVisibleChanged(); + } +} + +QString UiLogic::getLabelProtoCloakInfoText() const +{ + return m_labelProtoCloakInfoText; +} + +void UiLogic::setLabelProtoCloakInfoText(const QString &labelProtoCloakInfoText) +{ + if (m_labelProtoCloakInfoText != labelProtoCloakInfoText) { + m_labelProtoCloakInfoText = labelProtoCloakInfoText; + emit labelProtoCloakInfoTextChanged(); + } +} + +int UiLogic::getProgressBarProtoCloakResetValue() const +{ + return m_progressBarProtoCloakResetValue; +} + +void UiLogic::setProgressBarProtoCloakResetValue(int progressBarProtoCloakResetValue) +{ + if (m_progressBarProtoCloakResetValue != progressBarProtoCloakResetValue) { + m_progressBarProtoCloakResetValue = progressBarProtoCloakResetValue; + emit progressBarProtoCloakResetValueChanged(); + } +} + +int UiLogic::getProgressBarProtoCloakResetMaximium() const +{ + return m_progressBarProtoCloakResetMaximium; +} + +void UiLogic::setProgressBarProtoCloakResetMaximium(int progressBarProtoCloakResetMaximium) +{ + if (m_progressBarProtoCloakResetMaximium != progressBarProtoCloakResetMaximium) { + m_progressBarProtoCloakResetMaximium = progressBarProtoCloakResetMaximium; + emit progressBarProtoCloakResetMaximiumChanged(); + } +} + +QString UiLogic::getPushButtonServerSettingsClearClientCacheText() const +{ + return m_pushButtonServerSettingsClearClientCacheText; +} + +void UiLogic::setPushButtonServerSettingsClearClientCacheText(const QString &pushButtonServerSettingsClearClientCacheText) +{ + if (m_pushButtonServerSettingsClearClientCacheText != pushButtonServerSettingsClearClientCacheText) { + m_pushButtonServerSettingsClearClientCacheText = pushButtonServerSettingsClearClientCacheText; + emit pushButtonServerSettingsClearClientCacheTextChanged(); + } +} + +QObject* UiLogic::getServerListModel() const +{ + return m_serverListModel; +} + +UiLogic::~UiLogic() +{ + hide(); + m_vpnConnection->disconnectFromVpn(); + for (int i = 0; i < 50; i++) { + qApp->processEvents(QEventLoop::ExcludeUserInputEvents); + QThread::msleep(100); + if (m_vpnConnection->isDisconnected()) { + break; + } + } + + delete m_vpnConnection; + + qDebug() << "Application closed"; +} + +void UiLogic::showOnStartup() +{ + if (! m_settings.isStartMinimized()) { + show(); + } else { +#if defined Q_OS_MACX + setDockIconVisible(false); +#endif + } +} -// return QUiLogic::eventFilter(obj, event); -//} //void UiLogic::keyPressEvent(QKeyEvent *event) //{ @@ -1270,14 +2779,31 @@ void UiLogic::setPushButtonConnectChecked(bool pushButtonConnectChecked) // } //} -//void UiLogic::closeEvent(QCloseEvent *event) -//{ -// if (m_settings.serversCount() == 0) qApp->quit(); -// else { -// hide(); -// event->ignore(); -// } -//} +void UiLogic::onCloseWindow() +{ + if (m_settings.serversCount() == 0) qApp->quit(); + else { + hide(); + } +} + +void UiLogic::onServerListPushbuttonDefaultClicked(int index) +{ + m_settings.setDefaultServer(index); + updateServersListPage(); +} + +void UiLogic::onServerListPushbuttonSettingsClicked(int index) +{ + selectedServerIndex = index; + goToPage(Page::ServerSettings); +} + +void UiLogic::onPushButtonServerSettingsShareFullClicked() +{ + updateSharingPage(selectedServerIndex, m_settings.serverCredentials(selectedServerIndex), DockerContainer::None); + goToPage(Page::ShareConnection); +} //void UiLogic::showEvent(QShowEvent *event) //{ @@ -1304,85 +2830,78 @@ void UiLogic::setPushButtonConnectChecked(bool pushButtonConnectChecked) void UiLogic::onPushButtonNewServerConnect() { -// if (ui->pushButton_new_server_connect_key->isChecked()){ -// if (ui->lineEdit_new_server_ip->text().isEmpty() || -// ui->lineEdit_new_server_login->text().isEmpty() || -// ui->textEdit_new_server_ssh_key->toPlainText().isEmpty() ) { + if (getPushButtonNewServerConnectKeyChecked()){ + if (getLineEditNewServerIpText().isEmpty() || + getLineEditNewServerLoginText().isEmpty() || + getTextEditNewServerSshKeyText().isEmpty() ) { + setLabelNewServerWaitInfoText(tr("Please fill in all fields")); + return; + } + } + else { + if (getLineEditNewServerIpText().isEmpty() || + getLineEditNewServerLoginText().isEmpty() || + getLineEditNewServerPasswordText().isEmpty() ) { + setLabelNewServerWaitInfoText(tr("Please fill in all fields")); + return; + } + } + qDebug() << "UiLogic::onPushButtonNewServerConnect checking new server"; -// ui->label_new_server_wait_info->setText(tr("Please fill in all fields")); -// return; -// } -// } -// else { -// if (ui->lineEdit_new_server_ip->text().isEmpty() || -// ui->lineEdit_new_server_login->text().isEmpty() || -// ui->lineEdit_new_server_password->text().isEmpty() ) { + ServerCredentials serverCredentials; + serverCredentials.hostName = getLineEditNewServerIpText(); + if (serverCredentials.hostName.contains(":")) { + serverCredentials.port = serverCredentials.hostName.split(":").at(1).toInt(); + serverCredentials.hostName = serverCredentials.hostName.split(":").at(0); + } + serverCredentials.userName = getLineEditNewServerLoginText(); + if (getPushButtonNewServerConnectKeyChecked()){ + QString key = getTextEditNewServerSshKeyText(); + if (key.startsWith("ssh-rsa")) { + emit showPublicKeyWarning(); + return; + } -// ui->label_new_server_wait_info->setText(tr("Please fill in all fields")); -// return; -// } -// } + if (key.contains("OPENSSH") && key.contains("BEGIN") && key.contains("PRIVATE KEY")) { + key = SshConfigurator::convertOpenSShKey(key); + } + serverCredentials.password = key; + } + else { + serverCredentials.password = getLineEditNewServerPasswordText(); + } -// qDebug() << "UiLogic::onPushButtonNewServerConnect checking new server"; + setPushButtonNewServerConnectEnabled(false); + setPushButtonNewServerConnectText(tr("Connecting...")); + ErrorCode e = ErrorCode::NoError; +#ifdef Q_DEBUG + //QString output = ServerController::checkSshConnection(serverCredentials, &e); +#else + QString output; +#endif -// ServerCredentials serverCredentials; -// serverCredentials.hostName = ui->lineEdit_new_server_ip->text(); -// if (serverCredentials.hostName.contains(":")) { -// serverCredentials.port = serverCredentials.hostName.split(":").at(1).toInt(); -// serverCredentials.hostName = serverCredentials.hostName.split(":").at(0); -// } -// serverCredentials.userName = ui->lineEdit_new_server_login->text(); -// if (ui->pushButton_new_server_connect_key->isChecked()){ -// QString key = ui->textEdit_new_server_ssh_key->toPlainText(); -// if (key.startsWith("ssh-rsa")) { -// QMessageBox::warning(this, APPLICATION_NAME, -// tr("It's public key. Private key required")); + bool ok = true; + if (e) { + setLabelNewServerWaitInfoVisible(true); + setLabelNewServerWaitInfoText(errorString(e)); + ok = false; + } + else { + if (output.contains("Please login as the user")) { + output.replace("\n", ""); + setLabelNewServerWaitInfoVisible(true); + setLabelNewServerWaitInfoText(output); + ok = false; + } + } -// return; -// } + setPushButtonNewServerConnectEnabled(true); + setPushButtonNewServerConnectText(tr("Connect")); -// if (key.contains("OPENSSH") && key.contains("BEGIN") && key.contains("PRIVATE KEY")) { -// key = SshConfigurator::convertOpenSShKey(key); -// } - -// serverCredentials.password = key; -// } -// else { -// serverCredentials.password = ui->lineEdit_new_server_password->text(); -// } - -// ui->pushButton_new_server_connect->setEnabled(false); -// ui->pushButton_new_server_connect->setText(tr("Connecting...")); - -// ErrorCode e = ErrorCode::NoError; -//#ifdef Q_DEBUG -// //QString output = ServerController::checkSshConnection(serverCredentials, &e); -//#else -// QString output; -//#endif - -// bool ok = true; -// if (e) { -// ui->label_new_server_wait_info->show(); -// ui->label_new_server_wait_info->setText(errorString(e)); -// ok = false; -// } -// else { -// if (output.contains("Please login as the user")) { -// output.replace("\n", ""); -// ui->label_new_server_wait_info->show(); -// ui->label_new_server_wait_info->setText(output); -// ok = false; -// } -// } - -// ui->pushButton_new_server_connect->setEnabled(true); -// ui->pushButton_new_server_connect->setText(tr("Connect")); - -// installCredentials = serverCredentials; -// if (ok) goToPage(Page::NewServer); + installCredentials = serverCredentials; + if (ok) goToPage(Page::NewServer); } QMap UiLogic::getInstallConfigsFromProtocolsPage() const @@ -1460,358 +2979,454 @@ QMap UiLogic::getInstallConfigsFromWizardPage() co void UiLogic::installServer(const QMap &containers) { - // if (containers.isEmpty()) return; + if (containers.isEmpty()) return; - // goToPage(Page::ServerConfiguring); - // QEventLoop loop; - // QTimer::singleShot(500, &loop, SLOT(quit())); - // loop.exec(); - // qApp->processEvents(); + goToPage(Page::ServerConfiguring); + QEventLoop loop; + QTimer::singleShot(500, &loop, SLOT(quit())); + loop.exec(); + qApp->processEvents(); - // bool ok = installContainers(installCredentials, containers, - // ui->page_new_server_configuring, - // ui->progressBar_new_server_configuring, - // nullptr, - // ui->label_new_server_configuring_wait_info); + PageFunc page_new_server_configuring; + page_new_server_configuring.setEnabledFunc = [this] (bool enabled) -> void { + setPageNewServerConfiguringEnabled(enabled); + }; + ButtonFunc no_button; + LabelFunc label_new_server_configuring_wait_info; + label_new_server_configuring_wait_info.setTextFunc = [this] (const QString& text) -> void { + setLabelNewServerConfiguringWaitInfoText(text); + }; + label_new_server_configuring_wait_info.setVisibleFunc = [this] (bool visible) ->void { + setLabelNewServerConfiguringWaitInfoVisible(visible); + }; + ProgressFunc progressBar_new_server_configuring; + progressBar_new_server_configuring.setVisibleFunc = [this] (bool visible) ->void { + setProgressBarNewServerConfiguringVisible(visible); + }; + progressBar_new_server_configuring.setValueFunc = [this] (int value) ->void { + setProgressBarNewServerConfiguringValue(value); + }; + progressBar_new_server_configuring.getValueFunc = [this] (void) -> int { + return getProgressBarNewServerConfiguringValue(); + }; + progressBar_new_server_configuring.getMaximiumFunc = [this] (void) -> int { + return getProgressBarNewServerConfiguringMaximium(); + }; + progressBar_new_server_configuring.setTextVisibleFunc = [this] (bool visible) ->void { + setProgressBarNewServerConfiguringTextVisible(visible); + }; + progressBar_new_server_configuring.setTextFunc = [this] (const QString& text) ->void { + setProgressBarNewServerConfiguringText(text); + }; + bool ok = installContainers(installCredentials, containers, + page_new_server_configuring, + progressBar_new_server_configuring, + no_button, + label_new_server_configuring_wait_info); - // if (ok) { - // QJsonObject server; - // server.insert(config_key::hostName, installCredentials.hostName); - // server.insert(config_key::userName, installCredentials.userName); - // server.insert(config_key::password, installCredentials.password); - // server.insert(config_key::port, installCredentials.port); - // server.insert(config_key::description, m_settings.nextAvailableServerName()); + if (ok) { + QJsonObject server; + server.insert(config_key::hostName, installCredentials.hostName); + server.insert(config_key::userName, installCredentials.userName); + server.insert(config_key::password, installCredentials.password); + server.insert(config_key::port, installCredentials.port); + server.insert(config_key::description, m_settings.nextAvailableServerName()); - // QJsonArray containerConfigs; - // for (const QJsonObject &cfg : containers) { - // containerConfigs.append(cfg); - // } - // server.insert(config_key::containers, containerConfigs); - // server.insert(config_key::defaultContainer, containerToString(containers.firstKey())); + QJsonArray containerConfigs; + for (const QJsonObject &cfg : containers) { + containerConfigs.append(cfg); + } + server.insert(config_key::containers, containerConfigs); + server.insert(config_key::defaultContainer, containerToString(containers.firstKey())); - // m_settings.addServer(server); - // m_settings.setDefaultServer(m_settings.serversCount() - 1); + m_settings.addServer(server); + m_settings.setDefaultServer(m_settings.serversCount() - 1); - // setStartPage(Page::Vpn); - // qApp->processEvents(); - // } - // else { - // closePage(); - // } + setStartPage(Page::Vpn); + qApp->processEvents(); + } + else { + closePage(); + } } void UiLogic::onPushButtonNewServerImport() { -// QString s = ui->lineEdit_start_existing_code->text(); -// s.replace("vpn://", ""); -// QJsonObject o = QJsonDocument::fromJson(QByteArray::fromBase64(s.toUtf8(), QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals)).object(); + QString s = getLineEditStartExistingCodeText(); + s.replace("vpn://", ""); + QJsonObject o = QJsonDocument::fromJson(QByteArray::fromBase64(s.toUtf8(), QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals)).object(); -// ServerCredentials credentials; -// credentials.hostName = o.value("h").toString(); -// if (credentials.hostName.isEmpty()) credentials.hostName = o.value(config_key::hostName).toString(); + ServerCredentials credentials; + credentials.hostName = o.value("h").toString(); + if (credentials.hostName.isEmpty()) credentials.hostName = o.value(config_key::hostName).toString(); -// credentials.port = o.value("p").toInt(); -// if (credentials.port == 0) credentials.port = o.value(config_key::port).toInt(); + credentials.port = o.value("p").toInt(); + if (credentials.port == 0) credentials.port = o.value(config_key::port).toInt(); -// credentials.userName = o.value("u").toString(); -// if (credentials.userName.isEmpty()) credentials.userName = o.value(config_key::userName).toString(); + credentials.userName = o.value("u").toString(); + if (credentials.userName.isEmpty()) credentials.userName = o.value(config_key::userName).toString(); -// credentials.password = o.value("w").toString(); -// if (credentials.password.isEmpty()) credentials.password = o.value(config_key::password).toString(); + credentials.password = o.value("w").toString(); + if (credentials.password.isEmpty()) credentials.password = o.value(config_key::password).toString(); -// if (credentials.isValid()) { -// o.insert(config_key::hostName, credentials.hostName); -// o.insert(config_key::port, credentials.port); -// o.insert(config_key::userName, credentials.userName); -// o.insert(config_key::password, credentials.password); + if (credentials.isValid()) { + o.insert(config_key::hostName, credentials.hostName); + o.insert(config_key::port, credentials.port); + o.insert(config_key::userName, credentials.userName); + o.insert(config_key::password, credentials.password); -// o.remove("h"); -// o.remove("p"); -// o.remove("u"); -// o.remove("w"); -// } -// qDebug() << QString("Added server %3@%1:%2"). -// arg(credentials.hostName). -// arg(credentials.port). -// arg(credentials.userName); + o.remove("h"); + o.remove("p"); + o.remove("u"); + o.remove("w"); + } + qDebug() << QString("Added server %3@%1:%2"). + arg(credentials.hostName). + arg(credentials.port). + arg(credentials.userName); -// //qDebug() << QString("Password") << credentials.password; + //qDebug() << QString("Password") << credentials.password; -// if (credentials.isValid() || o.contains(config_key::containers)) { -// m_settings.addServer(o); -// m_settings.setDefaultServer(m_settings.serversCount() - 1); + if (credentials.isValid() || o.contains(config_key::containers)) { + m_settings.addServer(o); + m_settings.setDefaultServer(m_settings.serversCount() - 1); -// setStartPage(Page::Vpn); -// } -// else { -// qDebug() << "Failed to import profile"; -// qDebug().noquote() << QJsonDocument(o).toJson(); -// return; -// } + setStartPage(Page::Vpn); + } + else { + qDebug() << "Failed to import profile"; + qDebug().noquote() << QJsonDocument(o).toJson(); + return; + } -// if (!o.contains(config_key::containers)) { -// selectedServerIndex = m_settings.defaultServerIndex(); -// selectedDockerContainer = m_settings.defaultContainer(selectedServerIndex); -// goToPage(Page::ServerVpnProtocols); -// } + if (!o.contains(config_key::containers)) { + selectedServerIndex = m_settings.defaultServerIndex(); + selectedDockerContainer = m_settings.defaultContainer(selectedServerIndex); + goToPage(Page::ServerVpnProtocols); + } } -//bool UiLogic::installContainers(ServerCredentials credentials, -// const QMap &containers, -// QWidget *page, QProgressBar *progress, QPushButton *button, QLabel *info) -//{ -// if (!progress) return false; +bool UiLogic::installContainers(ServerCredentials credentials, + const QMap &containers, + const PageFunc &page, + const ProgressFunc &progress, + const ButtonFunc &button, + const LabelFunc &info) +{ + if (!progress.setValueFunc) return false; -// if (page) page->setEnabled(false); -// if (button) button->setVisible(false); + if (page.setEnabledFunc) { + page.setEnabledFunc(false); + } + if (button.setVisibleFunc) { + button.setVisibleFunc(false); + } -// if (info) info->setVisible(true); -// if (info) info->setText(tr("Please wait, configuring process may take up to 5 minutes")); + if (info.setVisibleFunc) { + info.setVisibleFunc(true); + } + if (info.setTextFunc) { + info.setTextFunc(tr("Please wait, configuring process may take up to 5 minutes")); + } + + int cnt = 0; + for (QMap::const_iterator i = containers.constBegin(); i != containers.constEnd(); i++, cnt++) { + QTimer timer; + connect(&timer, &QTimer::timeout, [progress](){ + progress.setValueFunc(progress.getValueFunc() + 1); + }); + + progress.setValueFunc(0); + timer.start(1000); + + progress.setTextVisibleFunc(true); + progress.setTextFunc(QString("Installing %1 %2 %3").arg(cnt+1).arg(tr("of")).arg(containers.size())); + + ErrorCode e = ServerController::setupContainer(credentials, i.key(), i.value()); + qDebug() << "Setup server finished with code" << e; + ServerController::disconnectFromHost(credentials); + + if (e) { + if (page.setEnabledFunc) { + page.setEnabledFunc(true); + } + if (button.setVisibleFunc) { + button.setVisibleFunc(true); + } + if (info.setVisibleFunc) { + info.setVisibleFunc(false); + } + + QMessageBox::warning(nullptr, APPLICATION_NAME, + tr("Error occurred while configuring server.") + "\n" + + errorString(e)); + + return false; + } + + // just ui progressbar tweak + timer.stop(); + + int remaining_val = progress.getMaximiumFunc() - progress.getValueFunc(); + + if (remaining_val > 0) { + QTimer timer1; + QEventLoop loop1; + + connect(&timer1, &QTimer::timeout, [&](){ + progress.setValueFunc(progress.getValueFunc() + 1); + if (progress.getValueFunc() >= progress.getMaximiumFunc()) { + loop1.quit(); + } + }); + + timer1.start(5); + loop1.exec(); + } + } -// int cnt = 0; -// for (QMap::const_iterator i = containers.constBegin(); i != containers.constEnd(); i++, cnt++) { -// QTimer timer; -// connect(&timer, &QTimer::timeout, [progress](){ -// progress->setValue(progress->value() + 1); -// }); + if (button.setVisibleFunc) { + button.setVisibleFunc(true); + } + if (page.setEnabledFunc) { + page.setEnabledFunc(true); + } + if (info.setTextFunc) { + info.setTextFunc(tr("Amnezia server installed")); + } -// progress->setValue(0); -// timer.start(1000); + return true; +} -// progress->setTextVisible(true); -// progress->setFormat(QString("Installing %1 %2 %3").arg(cnt+1).arg(tr("of")).arg(containers.size())); +ErrorCode UiLogic::doInstallAction(const std::function &action, + const PageFunc &page, + const ProgressFunc &progress, + const ButtonFunc &button, + const LabelFunc &info) +{ + progress.setVisibleFunc(true); + if (page.setEnabledFunc) { + page.setEnabledFunc(false); + } + if (button.setVisibleFunc) { + button.setVisibleFunc(false); + } + if (info.setVisibleFunc) { + info.setVisibleFunc(true); + } + if (info.setTextFunc) { + info.setTextFunc(tr("Please wait, configuring process may take up to 5 minutes")); + } -// ErrorCode e = ServerController::setupContainer(credentials, i.key(), i.value()); -// qDebug() << "Setup server finished with code" << e; -// ServerController::disconnectFromHost(credentials); + QTimer timer; + connect(&timer, &QTimer::timeout, [progress](){ + progress.setValueFunc(progress.getValueFunc() + 1); + }); -// if (e) { -// if (page) page->setEnabled(true); -// if (button) button->setVisible(true); -// if (info) info->setVisible(false); + progress.setValueFunc(0); + timer.start(1000); -// QMessageBox::warning(this, APPLICATION_NAME, -// tr("Error occurred while configuring server.") + "\n" + -// errorString(e)); + ErrorCode e = action(); + qDebug() << "doInstallAction finished with code" << e; -// return false; -// } + if (e) { + if (page.setEnabledFunc) { + page.setEnabledFunc(true); + } + if (button.setVisibleFunc) { + button.setVisibleFunc(true); + } + if (info.setVisibleFunc) { + info.setVisibleFunc(false); + } + QMessageBox::warning(nullptr, APPLICATION_NAME, + tr("Error occurred while configuring server.") + "\n" + + errorString(e)); -// // just ui progressbar tweak -// timer.stop(); + progress.setVisibleFunc(false); + return e; + } -// int remaining_val = progress->maximum() - progress->value(); + // just ui progressbar tweak + timer.stop(); -// if (remaining_val > 0) { -// QTimer timer1; -// QEventLoop loop1; + int remaining_val = progress.getMaximiumFunc() - progress.getValueFunc(); -// connect(&timer1, &QTimer::timeout, [&](){ -// progress->setValue(progress->value() + 1); -// if (progress->value() >= progress->maximum()) { -// loop1.quit(); -// } -// }); + if (remaining_val > 0) { + QTimer timer1; + QEventLoop loop1; -// timer1.start(5); -// loop1.exec(); -// } -// } + connect(&timer1, &QTimer::timeout, [&](){ + progress.setValueFunc(progress.getValueFunc() + 1); + if (progress.getValueFunc() >= progress.getMaximiumFunc()) { + loop1.quit(); + } + }); + + timer1.start(5); + loop1.exec(); + } -// if (button) button->show(); -// if (page) page->setEnabled(true); -// if (info) info->setText(tr("Amnezia server installed")); + progress.setVisibleFunc(false); + if (button.setVisibleFunc) { + button.setVisibleFunc(true); + } + if (page.setEnabledFunc) { + page.setEnabledFunc(true); + } + if (info.setTextFunc) { + info.setTextFunc(tr("Operation finished")); + } + return ErrorCode::NoError; +} -// return true; -//} +void UiLogic::onPushButtonClearServer() +{ + setPageServerSettingsEnabled(false); + setPushButtonServerSettingsClearText(tr("Uninstalling Amnezia software...")); -//ErrorCode UiLogic::doInstallAction(const std::function &action, QWidget *page, QProgressBar *progress, QPushButton *button, QLabel *info) -//{ -// progress->show(); -// if (page) page->setEnabled(false); -// if (button) button->setVisible(false); + if (m_settings.defaultServerIndex() == selectedServerIndex) { + onDisconnect(); + } -// if (info) info->setVisible(true); -// if (info) info->setText(tr("Please wait, configuring process may take up to 5 minutes")); + ErrorCode e = ServerController::removeAllContainers(m_settings.serverCredentials(selectedServerIndex)); + ServerController::disconnectFromHost(m_settings.serverCredentials(selectedServerIndex)); + if (e) { + setDialogConnectErrorText( + tr("Error occurred while configuring server.") + "\n" + + errorString(e) + "\n" + + tr("See logs for details.")); + emit showConnectErrorDialog(); + } + else { + setLabelServerSettingsWaitInfoVisible(true); + setLabelServerSettingsWaitInfoText(tr("Amnezia server successfully uninstalled")); + } + + m_settings.setContainers(selectedServerIndex, {}); + m_settings.setDefaultContainer(selectedServerIndex, DockerContainer::None); + + setPageServerSettingsEnabled(true); + setPushButtonServerSettingsClearText(tr("Clear server from Amnezia software")); +} + +void UiLogic::onPushButtonForgetServer() +{ + if (m_settings.defaultServerIndex() == selectedServerIndex && m_vpnConnection->isConnected()) { + onDisconnect(); + } + m_settings.removeServer(selectedServerIndex); + + if (m_settings.defaultServerIndex() == selectedServerIndex) { + m_settings.setDefaultServer(0); + } + else if (m_settings.defaultServerIndex() > selectedServerIndex) { + m_settings.setDefaultServer(m_settings.defaultServerIndex() - 1); + } + + if (m_settings.serversCount() == 0) { + m_settings.setDefaultServer(-1); + } -// QTimer timer; -// connect(&timer, &QTimer::timeout, [progress](){ -// progress->setValue(progress->value() + 1); -// }); + selectedServerIndex = -1; -// progress->setValue(0); -// timer.start(1000); + updateServersListPage(); -// ErrorCode e = action(); -// qDebug() << "doInstallAction finished with code" << e; + if (m_settings.serversCount() == 0) { + setStartPage(Page::Start); + } + else { + closePage(); + } +} -// if (e) { -// if (page) page->setEnabled(true); -// if (button) button->setVisible(true); -// if (info) info->setVisible(false); +void UiLogic::onPushButtonServerSettingsClearClientCacheClicked() +{ + setPushButtonServerSettingsClearClientCacheText(tr("Cache cleared")); -// QMessageBox::warning(this, APPLICATION_NAME, -// tr("Error occurred while configuring server.") + "\n" + -// errorString(e)); + const auto &containers = m_settings.containers(selectedServerIndex); + for (DockerContainer container: containers.keys()) { + m_settings.clearLastConnectionConfig(selectedServerIndex, container); + } -// progress->hide(); -// return e; -// } + QTimer::singleShot(3000, this, [this]() { + setPushButtonServerSettingsClearClientCacheText(tr("Clear client cached profile")); + }); +} -// // just ui progressbar tweak -// timer.stop(); +void UiLogic::onLineEditServerSettingsDescriptionEditingFinished() +{ + const QString &newText = getLineEditServerSettingsDescriptionText(); + QJsonObject server = m_settings.server(selectedServerIndex); + server.insert(config_key::description, newText); + m_settings.editServer(selectedServerIndex, server); + updateServersListPage(); +} -// int remaining_val = progress->maximum() - progress->value(); +void UiLogic::onBytesChanged(quint64 receivedData, quint64 sentData) +{ + setLabelSpeedReceivedText(VpnConnection::bytesPerSecToText(receivedData)); + setLabelSpeedSentText(VpnConnection::bytesPerSecToText(sentData)); +} -// if (remaining_val > 0) { -// QTimer timer1; -// QEventLoop loop1; +void UiLogic::onConnectionStateChanged(VpnProtocol::ConnectionState state) +{ + qDebug() << "UiLogic::onConnectionStateChanged" << VpnProtocol::textConnectionState(state); -// connect(&timer1, &QTimer::timeout, [&](){ -// progress->setValue(progress->value() + 1); -// if (progress->value() >= progress->maximum()) { -// loop1.quit(); -// } -// }); + bool pushButtonConnectEnabled = false; + bool radioButtonsModeEnabled = false; + setLabelStateText(VpnProtocol::textConnectionState(state)); -// timer1.start(5); -// loop1.exec(); -// } + setTrayState(state); + switch (state) { + case VpnProtocol::Disconnected: + onBytesChanged(0,0); + setPushButtonConnectChecked(false); + pushButtonConnectEnabled = true; + radioButtonsModeEnabled = true; + break; + case VpnProtocol::Preparing: + pushButtonConnectEnabled = false; + radioButtonsModeEnabled = false; + break; + case VpnProtocol::Connecting: + pushButtonConnectEnabled = false; + radioButtonsModeEnabled = false; + break; + case VpnProtocol::Connected: + pushButtonConnectEnabled = true; + radioButtonsModeEnabled = false; + break; + case VpnProtocol::Disconnecting: + pushButtonConnectEnabled = false; + radioButtonsModeEnabled = false; + break; + case VpnProtocol::Reconnecting: + pushButtonConnectEnabled = true; + radioButtonsModeEnabled = false; + break; + case VpnProtocol::Error: + setPushButtonConnectEnabled(false); + pushButtonConnectEnabled = true; + radioButtonsModeEnabled = true; + break; + case VpnProtocol::Unknown: + pushButtonConnectEnabled = true; + radioButtonsModeEnabled = true; + } -// progress->hide(); -// if (button) button->show(); -// if (page) page->setEnabled(true); -// if (info) info->setText(tr("Operation finished")); + setPushButtonConnectEnabled(pushButtonConnectEnabled); + setWidgetVpnModeEnabled(radioButtonsModeEnabled); +} -// return ErrorCode::NoError; -//} - -//void UiLogic::onPushButtonClearServer(bool) -//{ -// ui->page_server_settings->setEnabled(false); -// ui->pushButton_server_settings_clear->setText(tr("Uninstalling Amnezia software...")); - -// if (m_settings.defaultServerIndex() == selectedServerIndex) { -// onDisconnect(); -// } - -// ErrorCode e = ServerController::removeAllContainers(m_settings.serverCredentials(selectedServerIndex)); -// ServerController::disconnectFromHost(m_settings.serverCredentials(selectedServerIndex)); -// if (e) { -// QMessageBox::warning(this, APPLICATION_NAME, -// tr("Error occurred while configuring server.") + "\n" + -// errorString(e) + "\n" + -// tr("See logs for details.")); - -// } -// else { -// ui->label_server_settings_wait_info->show(); -// ui->label_server_settings_wait_info->setText(tr("Amnezia server successfully uninstalled")); -// } - -// m_settings.setContainers(selectedServerIndex, {}); -// m_settings.setDefaultContainer(selectedServerIndex, DockerContainer::None); - -// ui->page_server_settings->setEnabled(true); -// ui->pushButton_server_settings_clear->setText(tr("Clear server from Amnezia software")); -//} - -//void UiLogic::onPushButtonForgetServer(bool) -//{ -// if (m_settings.defaultServerIndex() == selectedServerIndex && m_vpnConnection->isConnected()) { -// onDisconnect(); -// } -// m_settings.removeServer(selectedServerIndex); - -// if (m_settings.defaultServerIndex() == selectedServerIndex) { -// m_settings.setDefaultServer(0); -// } -// else if (m_settings.defaultServerIndex() > selectedServerIndex) { -// m_settings.setDefaultServer(m_settings.defaultServerIndex() - 1); -// } - -// if (m_settings.serversCount() == 0) { -// m_settings.setDefaultServer(-1); -// } - - -// selectedServerIndex = -1; - -// updateServersListPage(); - -// if (m_settings.serversCount() == 0) { -// setStartPage(Page::Start); -// } -// else { -// closePage(); -// } -//} - -//void UiLogic::onBytesChanged(quint64 receivedData, quint64 sentData) -//{ -// ui->label_speed_received->setText(VpnConnection::bytesPerSecToText(receivedData)); -// ui->label_speed_sent->setText(VpnConnection::bytesPerSecToText(sentData)); -//} - -//void UiLogic::onConnectionStateChanged(VpnProtocol::ConnectionState state) -//{ -// qDebug() << "UiLogic::onConnectionStateChanged" << VpnProtocol::textConnectionState(state); - -// bool pushButtonConnectEnabled = false; -// bool radioButtonsModeEnabled = false; -// ui->label_state->setText(VpnProtocol::textConnectionState(state)); - -// setTrayState(state); - -// switch (state) { -// case VpnProtocol::Disconnected: -// onBytesChanged(0,0); -// ui->pushButton_connect->setChecked(false); -// pushButtonConnectEnabled = true; -// radioButtonsModeEnabled = true; -// break; -// case VpnProtocol::Preparing: -// pushButtonConnectEnabled = false; -// radioButtonsModeEnabled = false; -// break; -// case VpnProtocol::Connecting: -// pushButtonConnectEnabled = false; -// radioButtonsModeEnabled = false; -// break; -// case VpnProtocol::Connected: -// pushButtonConnectEnabled = true; -// radioButtonsModeEnabled = false; -// break; -// case VpnProtocol::Disconnecting: -// pushButtonConnectEnabled = false; -// radioButtonsModeEnabled = false; -// break; -// case VpnProtocol::Reconnecting: -// pushButtonConnectEnabled = true; -// radioButtonsModeEnabled = false; -// break; -// case VpnProtocol::Error: -// ui->pushButton_connect->setChecked(false); -// pushButtonConnectEnabled = true; -// radioButtonsModeEnabled = true; -// break; -// case VpnProtocol::Unknown: -// pushButtonConnectEnabled = true; -// radioButtonsModeEnabled = true; -// } - -// ui->pushButton_connect->setEnabled(pushButtonConnectEnabled); -// ui->widget_vpn_mode->setEnabled(radioButtonsModeEnabled); -//} - -//void UiLogic::onVpnProtocolError(ErrorCode errorCode) -//{ -// ui->label_error_text->setText(errorString(errorCode)); -//} +void UiLogic::onVpnProtocolError(ErrorCode errorCode) +{ + setLabelErrorText(errorString(errorCode)); +} void UiLogic::onPushButtonConnectClicked(bool checked) { @@ -1832,9 +3447,9 @@ void UiLogic::setTrayIcon(const QString &iconPath) setTrayIconUrl(iconPath); } -UiLogic::Page UiLogic::currentPage() +PageEnumNS::Page UiLogic::currentPage() { - return static_cast(getCurrentPageValue()); + return static_cast(getCurrentPageValue()); } void UiLogic::setupNewServerConnections() @@ -1844,544 +3459,132 @@ void UiLogic::setupNewServerConnections() }); } - -//void UiLogic::setupSitesPageConnections() -//{ -// connect(ui->pushButton_sites_add_custom, &QPushButton::clicked, this, [this](){ onPushButtonAddCustomSitesClicked(); }); - -// connect(ui->lineEdit_sites_add_custom, &QLineEdit::returnPressed, [&](){ -// ui->pushButton_sites_add_custom->click(); -// }); - -// connect(ui->pushButton_sites_delete, &QPushButton::clicked, this, [this](){ -// Settings::RouteMode mode = m_settings.routeMode(); - -// QItemSelectionModel* selection = ui->tableView_sites->selectionModel(); -// if (!selection) return; - -// { -// QModelIndexList indexesSites = selection->selectedRows(0); - -// QStringList sites; -// for (const QModelIndex &index : indexesSites) { -// sites.append(index.data().toString()); -// } - -// m_settings.removeVpnSites(mode, sites); -// } - -// if (m_vpnConnection->connectionState() == VpnProtocol::Connected) { -// QModelIndexList indexesIps = selection->selectedRows(1); - -// QStringList ips; -// for (const QModelIndex &index : indexesIps) { -// if (index.data().toString().isEmpty()) { -// ips.append(index.sibling(index.row(), 0).data().toString()); -// } -// else { -// ips.append(index.data().toString()); -// } -// } - -// m_vpnConnection->deleteRoutes(ips); -// m_vpnConnection->flushDns(); -// } - -// updateSitesPage(); -// }); - -// connect(ui->pushButton_sites_import, &QPushButton::clicked, this, [this](){ -// QString fileName = QFileDialog::getOpenFileName(this, tr("Import IP addresses"), -// QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)); - -// QFile file(fileName); -// if (!file.open(QIODevice::ReadOnly)) return; - -// Settings::RouteMode mode = m_settings.routeMode(); - -// QStringList ips; -// while (!file.atEnd()) { -// QString line = file.readLine(); - -// int pos = 0; -// QRegExp rx = Utils::ipAddressWithSubnetRegExp(); -// while ((pos = rx.indexIn(line, pos)) != -1) { -// ips << rx.cap(0); -// pos += rx.matchedLength(); -// } -// } - -// m_settings.addVpnIps(mode, ips); - -// m_vpnConnection->addRoutes(QStringList() << ips); -// m_vpnConnection->flushDns(); - -// updateSitesPage(); -// }); -//} - - -//void UiLogic::setupGeneralSettingsConnections() -//{ -// connect(ui->pushButton_general_settings_exit, &QPushButton::clicked, this, [&](){ qApp->quit(); }); - -// connect(ui->pushButton_settings, &QPushButton::clicked, this, [this](){ goToPage(Page::GeneralSettings); }); -// connect(ui->pushButton_general_settings_app_settings, &QPushButton::clicked, this, [this](){ goToPage(Page::AppSettings); }); -// connect(ui->pushButton_general_settings_network_settings, &QPushButton::clicked, this, [this](){ goToPage(Page::NetworkSettings); }); -// connect(ui->pushButton_general_settings_server_settings, &QPushButton::clicked, this, [this](){ -// selectedServerIndex = m_settings.defaultServerIndex(); -// goToPage(Page::ServerSettings); -// }); -// connect(ui->pushButton_general_settings_servers_list, &QPushButton::clicked, this, [this](){ goToPage(Page::ServersList); }); -// connect(ui->pushButton_general_settings_share_connection, &QPushButton::clicked, this, [this](){ -// selectedServerIndex = m_settings.defaultServerIndex(); -// selectedDockerContainer = m_settings.defaultContainer(selectedServerIndex); - -// updateSharingPage(selectedServerIndex, m_settings.serverCredentials(selectedServerIndex), selectedDockerContainer); -// goToPage(Page::ShareConnection); -// }); - -// connect(ui->pushButton_general_settings_add_server, &QPushButton::clicked, this, [this](){ goToPage(Page::Start); }); - -//} - - -//void UiLogic::setupProtocolsPageConnections() -//{ -// QJsonObject openvpnConfig; - -// // all containers -// QList containers { -// DockerContainer::OpenVpn, -// DockerContainer::OpenVpnOverShadowSocks, -// DockerContainer::OpenVpnOverCloak, -// DockerContainer::WireGuard -// }; - -// // default buttons -// QList defaultButtons { -// ui->pushButton_proto_openvpn_cont_default, -// ui->pushButton_proto_ss_openvpn_cont_default, -// ui->pushButton_proto_cloak_openvpn_cont_default, -// ui->pushButton_proto_wireguard_cont_default -// }; - -// for (int i = 0; i < containers.size(); ++i) { -// connect(defaultButtons.at(i), &QPushButton::clicked, this, [this, containers, i](){ -// m_settings.setDefaultContainer(selectedServerIndex, containers.at(i)); -// updateProtocolsPage(); -// }); -// } - -// // install buttons -// QList installButtons { -// ui->pushButton_proto_openvpn_cont_install, -// ui->pushButton_proto_ss_openvpn_cont_install, -// ui->pushButton_proto_cloak_openvpn_cont_install, -// ui->pushButton_proto_wireguard_cont_install -// }; - -// for (int i = 0; i < containers.size(); ++i) { -// QPushButton *button = installButtons.at(i); -// DockerContainer container = containers.at(i); - -// connect(button, &QPushButton::clicked, this, [this, container, button](bool checked){ -// if (checked) { -// ErrorCode e = doInstallAction([this, container](){ -// return ServerController::setupContainer(m_settings.serverCredentials(selectedServerIndex), container); -// }, -// ui->page_server_protocols, ui->progressBar_protocols_container_reinstall, -// nullptr, nullptr); - -// if (!e) { -// m_settings.setContainerConfig(selectedServerIndex, container, QJsonObject()); -// m_settings.setDefaultContainer(selectedServerIndex, container); -// } -// } -// else { -// button->setEnabled(false); -// ErrorCode e = ServerController::removeContainer(m_settings.serverCredentials(selectedServerIndex), container); -// m_settings.removeContainerConfig(selectedServerIndex, container); -// button->setEnabled(true); - -// if (m_settings.defaultContainer(selectedServerIndex) == container) { -// const auto &c = m_settings.containers(selectedServerIndex); -// if (c.isEmpty()) m_settings.setDefaultContainer(selectedServerIndex, DockerContainer::None); -// else m_settings.setDefaultContainer(selectedServerIndex, c.keys().first()); -// } -// } - -// updateProtocolsPage(); -// }); -// } - -// // share buttons -// QList shareButtons { -// ui->pushButton_proto_openvpn_cont_share, -// ui->pushButton_proto_ss_openvpn_cont_share, -// ui->pushButton_proto_cloak_openvpn_cont_share, -// ui->pushButton_proto_wireguard_cont_share -// }; - -// for (int i = 0; i < containers.size(); ++i) { -// QPushButton *button = shareButtons.at(i); -// DockerContainer container = containers.at(i); - -// connect(button, &QPushButton::clicked, this, [this, button, container](){ -// updateSharingPage(selectedServerIndex, m_settings.serverCredentials(selectedServerIndex), container); -// goToPage(Page::ShareConnection); -// }); -// } - -// // settings buttons - -// // settings openvpn container -// connect(ui->pushButton_proto_openvpn_cont_openvpn_config, &QPushButton::clicked, this, [this](){ -// selectedDockerContainer = DockerContainer::OpenVpn; -// updateOpenVpnPage(m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, Protocol::OpenVpn), -// selectedDockerContainer, m_settings.haveAuthData(selectedServerIndex)); -// goToPage(Page::OpenVpnSettings); -// }); - -// // settings shadowsocks container -// connect(ui->pushButton_proto_ss_openvpn_cont_openvpn_config, &QPushButton::clicked, this, [this](){ -// selectedDockerContainer = DockerContainer::OpenVpnOverShadowSocks; -// updateOpenVpnPage(m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, Protocol::OpenVpn), -// selectedDockerContainer, m_settings.haveAuthData(selectedServerIndex)); -// goToPage(Page::OpenVpnSettings); -// }); -// connect(ui->pushButton_proto_ss_openvpn_cont_ss_config, &QPushButton::clicked, this, [this](){ -// selectedDockerContainer = DockerContainer::OpenVpnOverShadowSocks; -// updateShadowSocksPage(m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, Protocol::ShadowSocks), -// selectedDockerContainer, m_settings.haveAuthData(selectedServerIndex)); -// goToPage(Page::ShadowSocksSettings); -// }); - -// // settings cloak container -// connect(ui->pushButton_proto_cloak_openvpn_cont_openvpn_config, &QPushButton::clicked, this, [this](){ -// selectedDockerContainer = DockerContainer::OpenVpnOverCloak; -// updateOpenVpnPage(m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, Protocol::OpenVpn), -// selectedDockerContainer, m_settings.haveAuthData(selectedServerIndex)); -// goToPage(Page::OpenVpnSettings); -// }); -// connect(ui->pushButton_proto_cloak_openvpn_cont_ss_config, &QPushButton::clicked, this, [this](){ -// selectedDockerContainer = DockerContainer::OpenVpnOverCloak; -// updateShadowSocksPage(m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, Protocol::ShadowSocks), -// selectedDockerContainer, m_settings.haveAuthData(selectedServerIndex)); -// goToPage(Page::ShadowSocksSettings); -// }); -// connect(ui->pushButton_proto_cloak_openvpn_cont_cloak_config, &QPushButton::clicked, this, [this](){ -// selectedDockerContainer = DockerContainer::OpenVpnOverCloak; -// updateCloakPage(m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, Protocol::Cloak), -// selectedDockerContainer, m_settings.haveAuthData(selectedServerIndex)); -// goToPage(Page::CloakSettings); -// }); - -// /// -// // Protocols pages -// connect(ui->checkBox_proto_openvpn_auto_encryption, &QCheckBox::stateChanged, this, [this](){ -// ui->comboBox_proto_openvpn_cipher->setDisabled(ui->checkBox_proto_openvpn_auto_encryption->isChecked()); -// ui->comboBox_proto_openvpn_hash->setDisabled(ui->checkBox_proto_openvpn_auto_encryption->isChecked()); -// }); - -// connect(ui->pushButton_proto_openvpn_save, &QPushButton::clicked, this, [this](){ -// QJsonObject protocolConfig = m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, Protocol::OpenVpn); -// protocolConfig = getOpenVpnConfigFromPage(protocolConfig); - -// QJsonObject containerConfig = m_settings.containerConfig(selectedServerIndex, selectedDockerContainer); -// QJsonObject newContainerConfig = containerConfig; -// newContainerConfig.insert(config_key::openvpn, protocolConfig); - -// ErrorCode e = doInstallAction([this, containerConfig, newContainerConfig](){ -// return ServerController::updateContainer(m_settings.serverCredentials(selectedServerIndex), selectedDockerContainer, containerConfig, newContainerConfig); -// }, -// ui->page_proto_openvpn, ui->progressBar_proto_openvpn_reset, -// ui->pushButton_proto_openvpn_save, ui->label_proto_openvpn_info); - -// if (!e) { -// m_settings.setContainerConfig(selectedServerIndex, selectedDockerContainer, newContainerConfig); -// m_settings.clearLastConnectionConfig(selectedServerIndex, selectedDockerContainer); -// } -// qDebug() << "Protocol saved with code:" << e << "for" << selectedServerIndex << selectedDockerContainer; -// }); - -// connect(ui->pushButton_proto_shadowsocks_save, &QPushButton::clicked, this, [this](){ -// QJsonObject protocolConfig = m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, Protocol::ShadowSocks); -// protocolConfig = getShadowSocksConfigFromPage(protocolConfig); - -// QJsonObject containerConfig = m_settings.containerConfig(selectedServerIndex, selectedDockerContainer); -// QJsonObject newContainerConfig = containerConfig; -// newContainerConfig.insert(config_key::shadowsocks, protocolConfig); - -// ErrorCode e = doInstallAction([this, containerConfig, newContainerConfig](){ -// return ServerController::updateContainer(m_settings.serverCredentials(selectedServerIndex), selectedDockerContainer, containerConfig, newContainerConfig); -// }, -// ui->page_proto_shadowsocks, ui->progressBar_proto_shadowsocks_reset, -// ui->pushButton_proto_shadowsocks_save, ui->label_proto_shadowsocks_info); - -// if (!e) { -// m_settings.setContainerConfig(selectedServerIndex, selectedDockerContainer, newContainerConfig); -// m_settings.clearLastConnectionConfig(selectedServerIndex, selectedDockerContainer); -// } -// qDebug() << "Protocol saved with code:" << e << "for" << selectedServerIndex << selectedDockerContainer; -// }); - -// connect(ui->pushButton_proto_cloak_save, &QPushButton::clicked, this, [this](){ -// QJsonObject protocolConfig = m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, Protocol::Cloak); -// protocolConfig = getCloakConfigFromPage(protocolConfig); - -// QJsonObject containerConfig = m_settings.containerConfig(selectedServerIndex, selectedDockerContainer); -// QJsonObject newContainerConfig = containerConfig; -// newContainerConfig.insert(config_key::cloak, protocolConfig); - -// ErrorCode e = doInstallAction([this, containerConfig, newContainerConfig](){ -// return ServerController::updateContainer(m_settings.serverCredentials(selectedServerIndex), selectedDockerContainer, containerConfig, newContainerConfig); -// }, -// ui->page_proto_cloak, ui->progressBar_proto_cloak_reset, -// ui->pushButton_proto_cloak_save, ui->label_proto_cloak_info); - -// if (!e) { -// m_settings.setContainerConfig(selectedServerIndex, selectedDockerContainer, newContainerConfig); -// m_settings.clearLastConnectionConfig(selectedServerIndex, selectedDockerContainer); -// } - -// qDebug() << "Protocol saved with code:" << e << "for" << selectedServerIndex << selectedDockerContainer; -// }); -//} - -void UiLogic::setupNewServerPageConnections() +void UiLogic::setupProtocolsPageConnections() { - // connect(ui->pushButton_connect, SIGNAL(clicked(bool)), this, SLOT(onPushButtonConnectClicked(bool))); - // connect(ui->pushButton_start_switch_page, &QPushButton::toggled, this, [this](bool toggled){ - // if (toggled){ - // ui->stackedWidget_start->setCurrentWidget(ui->page_start_new_server); - // ui->pushButton_start_switch_page->setText(tr("Import connection")); - // } - // else { - // ui->stackedWidget_start->setCurrentWidget(ui->page_start_import); - // ui->pushButton_start_switch_page->setText(tr("Set up your own server")); - // } - // //goToPage(Page::NewServer); - // }); + QJsonObject openvpnConfig; - // connect(ui->pushButton_new_server_connect_key, &QPushButton::toggled, this, [this](bool checked){ - // ui->label_new_server_password->setText(checked ? tr("Private key") : tr("Password")); - // ui->pushButton_new_server_connect_key->setText(checked ? tr("Connect using SSH password") : tr("Connect using SSH key")); - // ui->lineEdit_new_server_password->setVisible(!checked); - // ui->textEdit_new_server_ssh_key->setVisible(checked); - // }); + // all containers + QList containers { + DockerContainer::OpenVpn, + DockerContainer::OpenVpnOverShadowSocks, + DockerContainer::OpenVpnOverCloak, + DockerContainer::WireGuard + }; + using ButtonClickedFunc = void (UiLogic::*)(bool); + using ButtonSetEnabledFunc = std::function; - // connect(ui->pushButton_new_server_settings_cloak, &QPushButton::toggled, this, [this](bool toggle){ - // ui->frame_new_server_settings_cloak->setMaximumHeight(toggle * 200); - // if (toggle) - // ui->frame_new_server_settings_parent_cloak->layout()->addWidget(ui->frame_new_server_settings_cloak); - // else - // ui->frame_new_server_settings_parent_cloak->layout()->removeWidget(ui->frame_new_server_settings_cloak); - // }); - // connect(ui->pushButton_new_server_settings_ss, &QPushButton::toggled, this, [this](bool toggle){ - // ui->frame_new_server_settings_ss->setMaximumHeight(toggle * 200); - // if (toggle) - // ui->frame_new_server_settings_parent_ss->layout()->addWidget(ui->frame_new_server_settings_ss); - // else - // ui->frame_new_server_settings_parent_ss->layout()->removeWidget(ui->frame_new_server_settings_ss); - // }); - // connect(ui->pushButton_new_server_settings_openvpn, &QPushButton::toggled, this, [this](bool toggle){ - // ui->frame_new_server_settings_openvpn->setMaximumHeight(toggle * 200); - // if (toggle) - // ui->frame_new_server_settings_parent_openvpn->layout()->addWidget(ui->frame_new_server_settings_openvpn); - // else - // ui->frame_new_server_settings_parent_openvpn->layout()->removeWidget(ui->frame_new_server_settings_ss); - // }); + // default buttons + QList defaultButtonClickedSig { + &UiLogic::pushButtonProtoOpenvpnContDefaultClicked, + &UiLogic::pushButtonProtoSsOpenvpnContDefaultClicked, + &UiLogic::pushButtonProtoCloakOpenvpnContDefaultClicked, + &UiLogic::pushButtonProtoWireguardContDefaultClicked + }; + + for (int i = 0; i < containers.size(); ++i) { + connect(this, defaultButtonClickedSig.at(i), [this, containers, i](bool){ + qDebug() << "clmm" << i; + m_settings.setDefaultContainer(selectedServerIndex, containers.at(i)); + updateProtocolsPage(); + }); + } + + // install buttons + QList installButtonsClickedSig { + &UiLogic::pushButtonProtoOpenvpnContInstallClicked, + &UiLogic::pushButtonProtoSsOpenvpnContInstallClicked, + &UiLogic::pushButtonProtoCloakOpenvpnContInstallClicked, + &UiLogic::pushButtonProtoWireguardContInstallClicked, + }; + QList installButtonsSetEnabledFunc { + [this] (bool enabled) -> void { + setPushButtonProtoOpenvpnContInstallEnabled(enabled); + }, + [this] (bool enabled) -> void { + setPushButtonProtoSsOpenvpnContInstallEnabled(enabled); + }, + [this] (bool enabled) -> void { + setPushButtonProtoCloakOpenvpnContInstallEnabled(enabled); + }, + [this] (bool enabled) -> void { + setPushButtonProtoWireguardContInstallEnabled(enabled); + }, + }; + + for (int i = 0; i < containers.size(); ++i) { + ButtonClickedFunc buttonClickedFunc = installButtonsClickedSig.at(i); + ButtonSetEnabledFunc buttonSetEnabledFunc = installButtonsSetEnabledFunc.at(i); + DockerContainer container = containers.at(i); + + connect(this, buttonClickedFunc, [this, container, buttonSetEnabledFunc](bool checked){ + if (checked) { + PageFunc page_server_protocols; + page_server_protocols.setEnabledFunc = [this] (bool enabled) -> void { + setPageServerProtocolsEnabled(enabled); + }; + ButtonFunc no_button; + LabelFunc no_label; + ProgressFunc progressBar_protocols_container_reinstall; + progressBar_protocols_container_reinstall.setVisibleFunc = [this] (bool visible) ->void { + setProgressBarProtocolsContainerReinstallVisible(visible); + }; + progressBar_protocols_container_reinstall.setValueFunc = [this] (int value) ->void { + setProgressBarProtocolsContainerReinstallValue(value); + }; + progressBar_protocols_container_reinstall.getValueFunc = [this] (void) -> int { + return getProgressBarProtocolsContainerReinstallValue(); + }; + progressBar_protocols_container_reinstall.getMaximiumFunc = [this] (void) -> int { + return getProgressBarProtocolsContainerReinstallMaximium(); + }; + + ErrorCode e = doInstallAction([this, container](){ + return ServerController::setupContainer(m_settings.serverCredentials(selectedServerIndex), container); + }, + page_server_protocols, progressBar_protocols_container_reinstall, + no_button, no_label); + + if (!e) { + m_settings.setContainerConfig(selectedServerIndex, container, QJsonObject()); + m_settings.setDefaultContainer(selectedServerIndex, container); + } + } + else { + buttonSetEnabledFunc(false); + ErrorCode e = ServerController::removeContainer(m_settings.serverCredentials(selectedServerIndex), container); + m_settings.removeContainerConfig(selectedServerIndex, container); + buttonSetEnabledFunc(true); + + if (m_settings.defaultContainer(selectedServerIndex) == container) { + const auto &c = m_settings.containers(selectedServerIndex); + if (c.isEmpty()) m_settings.setDefaultContainer(selectedServerIndex, DockerContainer::None); + else m_settings.setDefaultContainer(selectedServerIndex, c.keys().first()); + } + } + + updateProtocolsPage(); + }); + } + + // share buttons + QList shareButtonsClickedSig { + &UiLogic::pushButtonProtoOpenvpnContShareClicked, + &UiLogic::pushButtonProtoSsOpenvpnContShareClicked, + &UiLogic::pushButtonProtoCloakOpenvpnContShareClicked, + &UiLogic::pushButtonProtoWireguardContShareClicked, + }; + + for (int i = 0; i < containers.size(); ++i) { + ButtonClickedFunc buttonClickedFunc = shareButtonsClickedSig.at(i); + DockerContainer container = containers.at(i); + + connect(this, buttonClickedFunc, [this, container](bool){ + updateSharingPage(selectedServerIndex, m_settings.serverCredentials(selectedServerIndex), container); + goToPage(Page::ShareConnection); + }); + } } -//void UiLogic::setupServerSettingsPageConnections() -//{ -// connect(ui->pushButton_servers_add_new, &QPushButton::clicked, this, [this](){ goToPage(Page::Start); }); - -// connect(ui->pushButton_server_settings_protocols, &QPushButton::clicked, this, [this](){ goToPage(Page::ServerVpnProtocols); }); -// connect(ui->pushButton_server_settings_share_full, &QPushButton::clicked, this, [this](){ -// updateSharingPage(selectedServerIndex, m_settings.serverCredentials(selectedServerIndex), DockerContainer::None); -// goToPage(Page::ShareConnection); -// }); - -// connect(ui->pushButton_server_settings_clear, SIGNAL(clicked(bool)), this, SLOT(onPushButtonClearServer(bool))); -// connect(ui->pushButton_server_settings_forget, SIGNAL(clicked(bool)), this, SLOT(onPushButtonForgetServer(bool))); - -// connect(ui->pushButton_server_settings_clear_client_cache, &QPushButton::clicked, this, [this](){ -// ui->pushButton_server_settings_clear_client_cache->setText(tr("Cache cleared")); - -// const auto &containers = m_settings.containers(selectedServerIndex); -// for (DockerContainer container: containers.keys()) { -// m_settings.clearLastConnectionConfig(selectedServerIndex, container); -// } - -// QTimer::singleShot(3000, this, [this]() { -// ui->pushButton_server_settings_clear_client_cache->setText(tr("Clear client cached profile")); -// }); -// }); - -// connect(ui->lineEdit_server_settings_description, &QLineEdit::editingFinished, this, [this](){ -// const QString &newText = ui->lineEdit_server_settings_description->text(); -// QJsonObject server = m_settings.server(selectedServerIndex); -// server.insert(config_key::description, newText); -// m_settings.editServer(selectedServerIndex, server); -// updateServersListPage(); -// }); - -// connect(ui->lineEdit_server_settings_description, &QLineEdit::returnPressed, this, [this](){ -// ui->lineEdit_server_settings_description->clearFocus(); -// }); -//} - -//void UiLogic::setupSharePageConnections() -//{ -// connect(ui->pushButton_share_full_copy, &QPushButton::clicked, this, [this](){ -// QGuiApplication::clipboard()->setText(ui->textEdit_share_full_code->toPlainText()); -// ui->pushButton_share_full_copy->setText(tr("Copied")); - -// QTimer::singleShot(3000, this, [this]() { -// ui->pushButton_share_full_copy->setText(tr("Copy")); -// }); -// }); - -// connect(ui->pushButton_share_full_save, &QPushButton::clicked, this, [this](){ -// if (ui->textEdit_share_full_code->toPlainText().isEmpty()) return; - -// QString fileName = QFileDialog::getSaveFileName(this, tr("Save AmneziaVPN config"), -// QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.amnezia"); -// QSaveFile save(fileName); -// save.open(QIODevice::WriteOnly); -// save.write(ui->textEdit_share_full_code->toPlainText().toUtf8()); -// save.commit(); -// }); - -// connect(ui->pushButton_share_amnezia_copy, &QPushButton::clicked, this, [this](){ -// if (ui->textEdit_share_amnezia_code->toPlainText().isEmpty()) return; - -// QGuiApplication::clipboard()->setText(ui->textEdit_share_amnezia_code->toPlainText()); -// ui->pushButton_share_amnezia_copy->setText(tr("Copied")); - -// QTimer::singleShot(3000, this, [this]() { -// ui->pushButton_share_amnezia_copy->setText(tr("Copy")); -// }); -// }); - -// connect(ui->pushButton_share_amnezia_save, &QPushButton::clicked, this, [this](){ -// if (ui->textEdit_share_amnezia_code->toPlainText().isEmpty()) return; - -// QString fileName = QFileDialog::getSaveFileName(this, tr("Save AmneziaVPN config"), -// QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.amnezia"); -// QSaveFile save(fileName); -// save.open(QIODevice::WriteOnly); -// save.write(ui->textEdit_share_amnezia_code->toPlainText().toUtf8()); -// save.commit(); -// }); - -// connect(ui->pushButton_share_openvpn_copy, &QPushButton::clicked, this, [this](){ -// QGuiApplication::clipboard()->setText(ui->textEdit_share_openvpn_code->toPlainText()); -// ui->pushButton_share_openvpn_copy->setText(tr("Copied")); - -// QTimer::singleShot(3000, this, [this]() { -// ui->pushButton_share_openvpn_copy->setText(tr("Copy")); -// }); -// }); - -// connect(ui->pushButton_share_ss_copy, &QPushButton::clicked, this, [this](){ -// QGuiApplication::clipboard()->setText(ui->lineEdit_share_ss_string->text()); -// ui->pushButton_share_ss_copy->setText(tr("Copied")); - -// QTimer::singleShot(3000, this, [this]() { -// ui->pushButton_share_ss_copy->setText(tr("Copy")); -// }); -// }); - -// connect(ui->pushButton_share_cloak_copy, &QPushButton::clicked, this, [this](){ -// QGuiApplication::clipboard()->setText(ui->plainTextEdit_share_cloak->toPlainText()); -// ui->pushButton_share_cloak_copy->setText(tr("Copied")); - -// QTimer::singleShot(3000, this, [this]() { -// ui->pushButton_share_cloak_copy->setText(tr("Copy")); -// }); -// }); - -// connect(ui->pushButton_share_amnezia_generate, &QPushButton::clicked, this, [this](){ -// ui->pushButton_share_amnezia_generate->setEnabled(false); -// ui->pushButton_share_amnezia_copy->setEnabled(false); -// ui->pushButton_share_amnezia_generate->setText(tr("Generating...")); -// qApp->processEvents(); - -// ServerCredentials credentials = m_settings.serverCredentials(selectedServerIndex); -// QJsonObject containerConfig = m_settings.containerConfig(selectedServerIndex, selectedDockerContainer); -// containerConfig.insert(config_key::container, containerToString(selectedDockerContainer)); - -// ErrorCode e = ErrorCode::NoError; -// for (Protocol p: amnezia::protocolsForContainer(selectedDockerContainer)) { -// QJsonObject protoConfig = m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, p); - -// QString cfg = VpnConfigurator::genVpnProtocolConfig(credentials, selectedDockerContainer, containerConfig, p, &e); -// if (e) { -// cfg = "Error generating config"; -// break; -// } -// protoConfig.insert(config_key::last_config, cfg); - -// containerConfig.insert(protoToString(p), protoConfig); -// } - -// QByteArray ba; -// if (!e) { -// QJsonObject serverConfig = m_settings.server(selectedServerIndex); -// serverConfig.remove(config_key::userName); -// serverConfig.remove(config_key::password); -// serverConfig.remove(config_key::port); -// serverConfig.insert(config_key::containers, QJsonArray {containerConfig}); -// serverConfig.insert(config_key::defaultContainer, containerToString(selectedDockerContainer)); - - -// ba = QJsonDocument(serverConfig).toJson().toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals); -// ui->textEdit_share_amnezia_code->setPlainText(QString("vpn://%1").arg(QString(ba))); -// } -// else { -// ui->textEdit_share_amnezia_code->setPlainText(tr("Error while generating connection profile")); -// } - -// ui->pushButton_share_amnezia_generate->setEnabled(true); -// ui->pushButton_share_amnezia_copy->setEnabled(true); -// ui->pushButton_share_amnezia_generate->setText(tr("Generate config")); -// }); - -// connect(ui->pushButton_share_openvpn_generate, &QPushButton::clicked, this, [this](){ -// ui->pushButton_share_openvpn_generate->setEnabled(false); -// ui->pushButton_share_openvpn_copy->setEnabled(false); -// ui->pushButton_share_openvpn_save->setEnabled(false); -// ui->pushButton_share_openvpn_generate->setText(tr("Generating...")); - -// ServerCredentials credentials = m_settings.serverCredentials(selectedServerIndex); -// const QJsonObject &containerConfig = m_settings.containerConfig(selectedServerIndex, selectedDockerContainer); - -// ErrorCode e = ErrorCode::NoError; -// QString cfg = OpenVpnConfigurator::genOpenVpnConfig(credentials, selectedDockerContainer, containerConfig, &e); -// cfg = OpenVpnConfigurator::processConfigWithExportSettings(cfg); - -// ui->textEdit_share_openvpn_code->setPlainText(cfg); - -// ui->pushButton_share_openvpn_generate->setEnabled(true); -// ui->pushButton_share_openvpn_copy->setEnabled(true); -// ui->pushButton_share_openvpn_save->setEnabled(true); -// ui->pushButton_share_openvpn_generate->setText(tr("Generate config")); -// }); - -// connect(ui->pushButton_share_openvpn_save, &QPushButton::clicked, this, [this](){ -// QString fileName = QFileDialog::getSaveFileName(this, tr("Save OpenVPN config"), -// QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.ovpn"); - -// QSaveFile save(fileName); -// save.open(QIODevice::WriteOnly); -// save.write(ui->textEdit_share_openvpn_code->toPlainText().toUtf8()); -// save.commit(); -// }); -//} - void UiLogic::setTrayState(VpnProtocol::ConnectionState state) { QString resourcesPath = "qrc:/images/tray/%1"; @@ -2426,48 +3629,48 @@ void UiLogic::setTrayState(VpnProtocol::ConnectionState state) } - void UiLogic::onConnect() { - // int serverIndex = m_settings.defaultServerIndex(); - // ServerCredentials credentials = m_settings.serverCredentials(serverIndex); - // DockerContainer container = m_settings.defaultContainer(serverIndex); + int serverIndex = m_settings.defaultServerIndex(); + ServerCredentials credentials = m_settings.serverCredentials(serverIndex); + DockerContainer container = m_settings.defaultContainer(serverIndex); - // if (m_settings.containers(serverIndex).isEmpty()) { - // ui->label_error_text->setText(tr("VPN Protocols is not installed.\n Please install VPN container at first")); - // ui->pushButton_connect->setChecked(false); - // return; - // } + if (m_settings.containers(serverIndex).isEmpty()) { + setLabelErrorText(tr("VPN Protocols is not installed.\n Please install VPN container at first")); + setPushButtonConnectChecked(false); + return; + } - // if (container == DockerContainer::None) { - // ui->label_error_text->setText(tr("VPN Protocol not choosen")); - // ui->pushButton_connect->setChecked(false); - // return; - // } + if (container == DockerContainer::None) { + setLabelErrorText(tr("VPN Protocol not choosen")); + setPushButtonConnectChecked(false); + return; + } - // const QJsonObject &containerConfig = m_settings.containerConfig(serverIndex, container); - // onConnectWorker(serverIndex, credentials, container, containerConfig); + const QJsonObject &containerConfig = m_settings.containerConfig(serverIndex, container); + onConnectWorker(serverIndex, credentials, container, containerConfig); } -//void UiLogic::onConnectWorker(int serverIndex, const ServerCredentials &credentials, DockerContainer container, const QJsonObject &containerConfig) -//{ -// ui->label_error_text->clear(); -// ui->pushButton_connect->setChecked(true); -// qApp->processEvents(); +void UiLogic::onConnectWorker(int serverIndex, const ServerCredentials &credentials, DockerContainer container, const QJsonObject &containerConfig) +{ + setLabelErrorText(""); + setPushButtonConnectChecked(true); + qApp->processEvents(); -// ErrorCode errorCode = m_vpnConnection->connectToVpn( -// serverIndex, credentials, container, containerConfig -// ); + ErrorCode errorCode = m_vpnConnection->connectToVpn( + serverIndex, credentials, container, containerConfig + ); -// if (errorCode) { -// //ui->pushButton_connect->setChecked(false); -// QMessageBox::critical(this, APPLICATION_NAME, errorString(errorCode)); -// return; -// } + if (errorCode) { + //ui->pushButton_connect->setChecked(false); + setDialogConnectErrorText(errorString(errorCode)); + emit showConnectErrorDialog(); + return; + } -// ui->pushButton_connect->setEnabled(false); -//} + setPushButtonConnectEnabled(false); +} void UiLogic::onDisconnect() { @@ -2476,63 +3679,501 @@ void UiLogic::onDisconnect() } -//void UiLogic::onPushButtonAddCustomSitesClicked() -//{ -// if (ui->radioButton_vpn_mode_all_sites->isChecked()) return; -// Settings::RouteMode mode = m_settings.routeMode(); +void UiLogic::onPushButtonAddCustomSitesClicked() +{ + if (getRadioButtonVpnModeAllSitesChecked()) { + return; + } + Settings::RouteMode mode = m_settings.routeMode(); -// QString newSite = ui->lineEdit_sites_add_custom->text(); + QString newSite = getLineEditSitesAddCustomText(); -// if (newSite.isEmpty()) return; -// if (!newSite.contains(".")) return; + if (newSite.isEmpty()) return; + if (!newSite.contains(".")) return; -// if (!Utils::ipAddressWithSubnetRegExp().exactMatch(newSite)) { -// // get domain name if it present -// newSite.replace("https://", ""); -// newSite.replace("http://", ""); -// newSite.replace("ftp://", ""); + if (!Utils::ipAddressWithSubnetRegExp().exactMatch(newSite)) { + // get domain name if it present + newSite.replace("https://", ""); + newSite.replace("http://", ""); + newSite.replace("ftp://", ""); -// newSite = newSite.split("/", QString::SkipEmptyParts).first(); -// } + newSite = newSite.split("/", QString::SkipEmptyParts).first(); + } -// const auto &cbProcess = [this, mode](const QString &newSite, const QString &ip) { -// m_settings.addVpnSite(mode, newSite, ip); + const auto &cbProcess = [this, mode](const QString &newSite, const QString &ip) { + m_settings.addVpnSite(mode, newSite, ip); -// if (!ip.isEmpty()) { -// m_vpnConnection->addRoutes(QStringList() << ip); -// m_vpnConnection->flushDns(); -// } -// else if (Utils::ipAddressWithSubnetRegExp().exactMatch(newSite)) { -// m_vpnConnection->addRoutes(QStringList() << newSite); -// m_vpnConnection->flushDns(); -// } + if (!ip.isEmpty()) { + m_vpnConnection->addRoutes(QStringList() << ip); + m_vpnConnection->flushDns(); + } + else if (Utils::ipAddressWithSubnetRegExp().exactMatch(newSite)) { + m_vpnConnection->addRoutes(QStringList() << newSite); + m_vpnConnection->flushDns(); + } -// updateSitesPage(); -// }; + updateSitesPage(); + }; -// const auto &cbResolv = [this, cbProcess](const QHostInfo &hostInfo){ -// const QList &addresses = hostInfo.addresses(); -// QString ipv4Addr; -// for (const QHostAddress &addr: hostInfo.addresses()) { -// if (addr.protocol() == QAbstractSocket::NetworkLayerProtocol::IPv4Protocol) { -// cbProcess(hostInfo.hostName(), addr.toString()); -// break; -// } -// } -// }; + const auto &cbResolv = [this, cbProcess](const QHostInfo &hostInfo){ + const QList &addresses = hostInfo.addresses(); + QString ipv4Addr; + for (const QHostAddress &addr: hostInfo.addresses()) { + if (addr.protocol() == QAbstractSocket::NetworkLayerProtocol::IPv4Protocol) { + cbProcess(hostInfo.hostName(), addr.toString()); + break; + } + } + }; -// ui->lineEdit_sites_add_custom->clear(); + setLineEditSitesAddCustomText(""); -// if (Utils::ipAddressWithSubnetRegExp().exactMatch(newSite)) { -// cbProcess(newSite, ""); -// return; -// } -// else { -// cbProcess(newSite, ""); -// updateSitesPage(); -// QHostInfo::lookupHost(newSite, this, cbResolv); -// } -//} + if (Utils::ipAddressWithSubnetRegExp().exactMatch(newSite)) { + cbProcess(newSite, ""); + return; + } + else { + cbProcess(newSite, ""); + updateSitesPage(); + QHostInfo::lookupHost(newSite, this, cbResolv); + } +} + +void UiLogic::onPushButtonSitesDeleteClicked(int row) +{ + Settings::RouteMode mode = m_settings.routeMode(); + + auto siteModel = qobject_cast (getTableViewSitesModel()); + if (!siteModel) { + return; + } + if (row < 0 || row >= siteModel->rowCount()) { + return; + } + + { + QStringList sites; + sites.append(siteModel->data(row, 0).toString()); + m_settings.removeVpnSites(mode, sites); + } + + if (m_vpnConnection->connectionState() == VpnProtocol::Connected) { + QStringList ips; + ips.append(siteModel->data(row, 1).toString()); + m_vpnConnection->deleteRoutes(ips); + m_vpnConnection->flushDns(); + } + + updateSitesPage(); +} + +void UiLogic::onPushButtonSitesImportClicked(const QString& fileName) +{ + QFile file(QUrl{fileName}.toLocalFile()); + if (!file.open(QIODevice::ReadOnly)) { + qDebug() << "Can't open file " << QUrl{fileName}.toLocalFile(); + return; + } + + Settings::RouteMode mode = m_settings.routeMode(); + + QStringList ips; + while (!file.atEnd()) { + QString line = file.readLine(); + + int pos = 0; + QRegExp rx = Utils::ipAddressWithSubnetRegExp(); + while ((pos = rx.indexIn(line, pos)) != -1) { + ips << rx.cap(0); + pos += rx.matchedLength(); + } + } + + m_settings.addVpnIps(mode, ips); + + m_vpnConnection->addRoutes(QStringList() << ips); + m_vpnConnection->flushDns(); + + updateSitesPage(); +} + +void UiLogic::onPushButtonShareFullCopyClicked() +{ + QGuiApplication::clipboard()->setText(getTextEditShareFullCodeText()); + setPushButtonShareFullCopyText(tr("Copied")); + + QTimer::singleShot(3000, this, [this]() { + setPushButtonShareFullCopyText(tr("Copy")); + }); +} + +void UiLogic::onPushButtonShareFullSaveClicked() +{ + if (getTextEditShareFullCodeText().isEmpty()) return; + + QString fileName = QFileDialog::getSaveFileName(nullptr, tr("Save AmneziaVPN config"), + QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.amnezia"); + QSaveFile save(fileName); + save.open(QIODevice::WriteOnly); + save.write(getTextEditShareFullCodeText().toUtf8()); + save.commit(); +} + +void UiLogic::onPushButtonShareAmneziaCopyClicked() +{ + if (getTextEditShareAmneziaCodeText().isEmpty()) return; + + QGuiApplication::clipboard()->setText(getTextEditShareAmneziaCodeText()); + setPushButtonShareAmneziaCopyText(tr("Copied")); + + QTimer::singleShot(3000, this, [this]() { + setPushButtonShareAmneziaCopyText(tr("Copy")); + }); +} + +void UiLogic::onPushButtonShareAmneziaSaveClicked() +{ + if (getTextEditShareAmneziaCodeText().isEmpty()) return; + + QString fileName = QFileDialog::getSaveFileName(nullptr, tr("Save AmneziaVPN config"), + QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.amnezia"); + QSaveFile save(fileName); + save.open(QIODevice::WriteOnly); + save.write(getTextEditShareAmneziaCodeText().toUtf8()); + save.commit(); +} + +void UiLogic::onPushButtonShareOpenvpnCopyClicked() +{ + QGuiApplication::clipboard()->setText(getTextEditShareOpenvpnCodeText()); + setPushButtonShareOpenvpnCopyText(tr("Copied")); + + QTimer::singleShot(3000, this, [this]() { + setPushButtonShareOpenvpnCopyText(tr("Copy")); + }); +} + +void UiLogic::onPushButtonShareSsCopyClicked() +{ + QGuiApplication::clipboard()->setText(getLineEditShareSsStringText()); + setPushButtonShareSsCopyText(tr("Copied")); + + QTimer::singleShot(3000, this, [this]() { + setPushButtonShareSsCopyText(tr("Copy")); + }); +} + +void UiLogic::onPushButtonShareCloakCopyClicked() +{ + QGuiApplication::clipboard()->setText(getPlainTextEditShareCloakText()); + setPushButtonShareCloakCopyText(tr("Copied")); + + QTimer::singleShot(3000, this, [this]() { + setPushButtonShareCloakCopyText(tr("Copy")); + }); +} + +void UiLogic::onPushButtonShareAmneziaGenerateClicked() +{ + setPushButtonShareAmneziaGenerateEnabled(false); + setPushButtonShareAmneziaCopyEnabled(false); + setPushButtonShareAmneziaGenerateText(tr("Generating...")); + qApp->processEvents(); + + ServerCredentials credentials = m_settings.serverCredentials(selectedServerIndex); + QJsonObject containerConfig = m_settings.containerConfig(selectedServerIndex, selectedDockerContainer); + containerConfig.insert(config_key::container, containerToString(selectedDockerContainer)); + + ErrorCode e = ErrorCode::NoError; + for (Protocol p: amnezia::protocolsForContainer(selectedDockerContainer)) { + QJsonObject protoConfig = m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, p); + + QString cfg = VpnConfigurator::genVpnProtocolConfig(credentials, selectedDockerContainer, containerConfig, p, &e); + if (e) { + cfg = "Error generating config"; + break; + } + protoConfig.insert(config_key::last_config, cfg); + + containerConfig.insert(protoToString(p), protoConfig); + } + + QByteArray ba; + if (!e) { + QJsonObject serverConfig = m_settings.server(selectedServerIndex); + serverConfig.remove(config_key::userName); + serverConfig.remove(config_key::password); + serverConfig.remove(config_key::port); + serverConfig.insert(config_key::containers, QJsonArray {containerConfig}); + serverConfig.insert(config_key::defaultContainer, containerToString(selectedDockerContainer)); + + + ba = QJsonDocument(serverConfig).toJson().toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals); + setTextEditShareAmneziaCodeText(QString("vpn://%1").arg(QString(ba))); + } + else { + setTextEditShareAmneziaCodeText(tr("Error while generating connection profile")); + } + + setPushButtonShareAmneziaGenerateEnabled(true); + setPushButtonShareAmneziaCopyEnabled(true); + setPushButtonShareAmneziaGenerateText(tr("Generate config")); +} + +void UiLogic::onPushButtonShareOpenvpnGenerateClicked() +{ + setPushButtonShareOpenvpnGenerateEnabled(false); + setPushButtonShareOpenvpnCopyEnabled(false); + setPushButtonShareOpenvpnSaveEnabled(false); + setPushButtonShareOpenvpnGenerateText(tr("Generating...")); + + ServerCredentials credentials = m_settings.serverCredentials(selectedServerIndex); + const QJsonObject &containerConfig = m_settings.containerConfig(selectedServerIndex, selectedDockerContainer); + + ErrorCode e = ErrorCode::NoError; + QString cfg = OpenVpnConfigurator::genOpenVpnConfig(credentials, selectedDockerContainer, containerConfig, &e); + cfg = OpenVpnConfigurator::processConfigWithExportSettings(cfg); + + setTextEditShareOpenvpnCodeText(cfg); + + setPushButtonShareOpenvpnGenerateEnabled(true); + setPushButtonShareOpenvpnCopyEnabled(true); + setPushButtonShareOpenvpnSaveEnabled(true); + setPushButtonShareOpenvpnGenerateText(tr("Generate config")); +} + +void UiLogic::onPushButtonShareOpenvpnSaveClicked() +{ + QString fileName = QFileDialog::getSaveFileName(nullptr, tr("Save OpenVPN config"), + QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.ovpn"); + + QSaveFile save(fileName); + save.open(QIODevice::WriteOnly); + save.write(getTextEditShareOpenvpnCodeText().toUtf8()); + save.commit(); +} + +void UiLogic::onPushButtonGeneralSettingsServerSettingsClicked() +{ + selectedServerIndex = m_settings.defaultServerIndex(); + goToPage(Page::ServerSettings); +} + +void UiLogic::onPushButtonGeneralSettingsShareConnectionClicked() +{ + selectedServerIndex = m_settings.defaultServerIndex(); + selectedDockerContainer = m_settings.defaultContainer(selectedServerIndex); + + updateSharingPage(selectedServerIndex, m_settings.serverCredentials(selectedServerIndex), selectedDockerContainer); + goToPage(Page::ShareConnection); +} + +void UiLogic::onPushButtonProtoOpenvpnContOpenvpnConfigClicked() +{ + selectedDockerContainer = DockerContainer::OpenVpn; + updateOpenVpnPage(m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, Protocol::OpenVpn), + selectedDockerContainer, m_settings.haveAuthData(selectedServerIndex)); + goToPage(Page::OpenVpnSettings); +} + +void UiLogic::onPushButtonProtoSsOpenvpnContOpenvpnConfigClicked() +{ + selectedDockerContainer = DockerContainer::OpenVpnOverShadowSocks; + updateOpenVpnPage(m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, Protocol::OpenVpn), + selectedDockerContainer, m_settings.haveAuthData(selectedServerIndex)); + goToPage(Page::OpenVpnSettings); +} + +void UiLogic::onPushButtonProtoSsOpenvpnContSsConfigClicked() +{ + selectedDockerContainer = DockerContainer::OpenVpnOverShadowSocks; + updateShadowSocksPage(m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, Protocol::ShadowSocks), + selectedDockerContainer, m_settings.haveAuthData(selectedServerIndex)); + goToPage(Page::ShadowSocksSettings); +} + +void UiLogic::onPushButtonProtoCloakOpenvpnContOpenvpnConfigClicked() +{ + selectedDockerContainer = DockerContainer::OpenVpnOverCloak; + updateOpenVpnPage(m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, Protocol::OpenVpn), + selectedDockerContainer, m_settings.haveAuthData(selectedServerIndex)); + goToPage(Page::OpenVpnSettings); +} + +void UiLogic::onPushButtonProtoCloakOpenvpnContSsConfigClicked() +{ + selectedDockerContainer = DockerContainer::OpenVpnOverCloak; + updateShadowSocksPage(m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, Protocol::ShadowSocks), + selectedDockerContainer, m_settings.haveAuthData(selectedServerIndex)); + goToPage(Page::ShadowSocksSettings); +} + +void UiLogic::onPushButtonProtoCloakOpenvpnContCloakConfigClicked() +{ + selectedDockerContainer = DockerContainer::OpenVpnOverCloak; + updateCloakPage(m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, Protocol::Cloak), + selectedDockerContainer, m_settings.haveAuthData(selectedServerIndex)); + goToPage(Page::CloakSettings); +} + +void UiLogic::onCheckBoxProtoOpenvpnAutoEncryptionClicked() +{ + setComboBoxProtoOpenvpnCipherEnabled(!getCheckBoxProtoOpenvpnAutoEncryptionChecked()); + setComboBoxProtoOpenvpnHashEnabled(!getCheckBoxProtoOpenvpnAutoEncryptionChecked()); +} + +void UiLogic::onPushButtonProtoOpenvpnSaveClicked() +{ + QJsonObject protocolConfig = m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, Protocol::OpenVpn); + protocolConfig = getOpenVpnConfigFromPage(protocolConfig); + + QJsonObject containerConfig = m_settings.containerConfig(selectedServerIndex, selectedDockerContainer); + QJsonObject newContainerConfig = containerConfig; + newContainerConfig.insert(config_key::openvpn, protocolConfig); + + PageFunc page_proto_openvpn; + page_proto_openvpn.setEnabledFunc = [this] (bool enabled) -> void { + setPageProtoOpenvpnEnabled(enabled); + }; + ButtonFunc pushButton_proto_openvpn_save; + pushButton_proto_openvpn_save.setVisibleFunc = [this] (bool visible) ->void { + setPushButtonProtoOpenvpnSaveVisible(visible); + }; + LabelFunc label_proto_openvpn_info; + label_proto_openvpn_info.setVisibleFunc = [this] (bool visible) ->void { + setLabelProtoOpenvpnInfoVisible(visible); + }; + label_proto_openvpn_info.setTextFunc = [this] (const QString& text) ->void { + setLabelProtoOpenvpnInfoText(text); + }; + ProgressFunc progressBar_proto_openvpn_reset; + progressBar_proto_openvpn_reset.setVisibleFunc = [this] (bool visible) ->void { + setProgressBarProtoOpenvpnResetVisible(visible); + }; + progressBar_proto_openvpn_reset.setValueFunc = [this] (int value) ->void { + setProgressBarProtoOpenvpnResetValue(value); + }; + progressBar_proto_openvpn_reset.getValueFunc = [this] (void) -> int { + return getProgressBarProtoOpenvpnResetValue(); + }; + progressBar_proto_openvpn_reset.getMaximiumFunc = [this] (void) -> int { + return getProgressBarProtoOpenvpnResetMaximium(); + }; + + ErrorCode e = doInstallAction([this, containerConfig, newContainerConfig](){ + return ServerController::updateContainer(m_settings.serverCredentials(selectedServerIndex), selectedDockerContainer, containerConfig, newContainerConfig); + }, + page_proto_openvpn, progressBar_proto_openvpn_reset, + pushButton_proto_openvpn_save, label_proto_openvpn_info); + + if (!e) { + m_settings.setContainerConfig(selectedServerIndex, selectedDockerContainer, newContainerConfig); + m_settings.clearLastConnectionConfig(selectedServerIndex, selectedDockerContainer); + } + qDebug() << "Protocol saved with code:" << e << "for" << selectedServerIndex << selectedDockerContainer; +} + +void UiLogic::onPushButtonProtoShadowsocksSaveClicked() +{ + QJsonObject protocolConfig = m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, Protocol::ShadowSocks); + protocolConfig = getShadowSocksConfigFromPage(protocolConfig); + + QJsonObject containerConfig = m_settings.containerConfig(selectedServerIndex, selectedDockerContainer); + QJsonObject newContainerConfig = containerConfig; + newContainerConfig.insert(config_key::shadowsocks, protocolConfig); + PageFunc page_proto_shadowsocks; + page_proto_shadowsocks.setEnabledFunc = [this] (bool enabled) -> void { + setPageProtoShadowsocksEnabled(enabled); + }; + ButtonFunc pushButton_proto_shadowsocks_save; + pushButton_proto_shadowsocks_save.setVisibleFunc = [this] (bool visible) ->void { + setPushButtonProtoShadowsocksSaveVisible(visible); + }; + LabelFunc label_proto_shadowsocks_info; + label_proto_shadowsocks_info.setVisibleFunc = [this] (bool visible) ->void { + setLabelProtoShadowsocksInfoVisible(visible); + }; + label_proto_shadowsocks_info.setTextFunc = [this] (const QString& text) ->void { + setLabelProtoShadowsocksInfoText(text); + }; + ProgressFunc progressBar_proto_shadowsocks_reset; + progressBar_proto_shadowsocks_reset.setVisibleFunc = [this] (bool visible) ->void { + setProgressBarProtoOpenvpnResetVisible(visible); + }; + progressBar_proto_shadowsocks_reset.setValueFunc = [this] (int value) ->void { + setProgressBarProtoShadowsocksResetValue(value); + }; + progressBar_proto_shadowsocks_reset.getValueFunc = [this] (void) -> int { + return getProgressBarProtoShadowsocksResetValue(); + }; + progressBar_proto_shadowsocks_reset.getMaximiumFunc = [this] (void) -> int { + return getProgressBarProtoShadowsocksResetMaximium(); + }; + + ErrorCode e = doInstallAction([this, containerConfig, newContainerConfig](){ + return ServerController::updateContainer(m_settings.serverCredentials(selectedServerIndex), selectedDockerContainer, containerConfig, newContainerConfig); + }, + page_proto_shadowsocks, progressBar_proto_shadowsocks_reset, + pushButton_proto_shadowsocks_save, label_proto_shadowsocks_info); + + if (!e) { + m_settings.setContainerConfig(selectedServerIndex, selectedDockerContainer, newContainerConfig); + m_settings.clearLastConnectionConfig(selectedServerIndex, selectedDockerContainer); + } + qDebug() << "Protocol saved with code:" << e << "for" << selectedServerIndex << selectedDockerContainer; +} + +void UiLogic::onPushButtonProtoCloakSaveClicked() +{ + QJsonObject protocolConfig = m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, Protocol::Cloak); + protocolConfig = getCloakConfigFromPage(protocolConfig); + + QJsonObject containerConfig = m_settings.containerConfig(selectedServerIndex, selectedDockerContainer); + QJsonObject newContainerConfig = containerConfig; + newContainerConfig.insert(config_key::cloak, protocolConfig); + + PageFunc page_proto_cloak; + page_proto_cloak.setEnabledFunc = [this] (bool enabled) -> void { + setPageProtoCloakEnabled(enabled); + }; + ButtonFunc pushButton_proto_cloak_save; + pushButton_proto_cloak_save.setVisibleFunc = [this] (bool visible) ->void { + setPushButtonProtoCloakSaveVisible(visible); + }; + LabelFunc label_proto_cloak_info; + label_proto_cloak_info.setVisibleFunc = [this] (bool visible) ->void { + setLabelProtoCloakInfoVisible(visible); + }; + label_proto_cloak_info.setTextFunc = [this] (const QString& text) ->void { + setLabelProtoCloakInfoText(text); + }; + ProgressFunc progressBar_proto_cloak_reset; + progressBar_proto_cloak_reset.setVisibleFunc = [this] (bool visible) ->void { + setProgressBarProtoCloakResetVisible(visible); + }; + progressBar_proto_cloak_reset.setValueFunc = [this] (int value) ->void { + setProgressBarProtoCloakResetValue(value); + }; + progressBar_proto_cloak_reset.getValueFunc = [this] (void) -> int { + return getProgressBarProtoCloakResetValue(); + }; + progressBar_proto_cloak_reset.getMaximiumFunc = [this] (void) -> int { + return getProgressBarProtoCloakResetMaximium(); + }; + + ErrorCode e = doInstallAction([this, containerConfig, newContainerConfig](){ + return ServerController::updateContainer(m_settings.serverCredentials(selectedServerIndex), selectedDockerContainer, containerConfig, newContainerConfig); + }, + page_proto_cloak, progressBar_proto_cloak_reset, + pushButton_proto_cloak_save, label_proto_cloak_info); + + if (!e) { + m_settings.setContainerConfig(selectedServerIndex, selectedDockerContainer, newContainerConfig); + m_settings.clearLastConnectionConfig(selectedServerIndex, selectedDockerContainer); + } + + qDebug() << "Protocol saved with code:" << e << "for" << selectedServerIndex << selectedDockerContainer; +} void UiLogic::updateStartPage() { @@ -2550,17 +4191,21 @@ void UiLogic::updateStartPage() setPushButtonNewServerConnectVisible(true); } -//void UiLogic::updateSitesPage() -//{ -// Settings::RouteMode m = m_settings.routeMode(); -// if (m == Settings::VpnAllSites) return; +void UiLogic::updateSitesPage() +{ + Settings::RouteMode m = m_settings.routeMode(); + if (m == Settings::VpnAllSites) return; -// if (m == Settings::VpnOnlyForwardSites) ui->label_sites_add_custom->setText(tr("These sites will be opened using VPN")); -// if (m == Settings::VpnAllExceptSites) ui->label_sites_add_custom->setText(tr("These sites will be excepted from VPN")); + if (m == Settings::VpnOnlyForwardSites) { + setLabelSitesAddCustomText(tr("These sites will be opened using VPN")); + } + if (m == Settings::VpnAllExceptSites) { + setLabelSitesAddCustomText(tr("These sites will be excepted from VPN")); + } -// ui->tableView_sites->setModel(sitesModels.value(m)); -// sitesModels.value(m)->resetCache(); -//} + setTableViewSitesModel(sitesModels.value(m)); + sitesModels.value(m)->resetCache(); +} void UiLogic::updateVpnPage() { @@ -2699,332 +4344,326 @@ void UiLogic::onPushButtonNetworkSettingsResetdns2Clicked() updateAppSettingsPage(); } -//void UiLogic::updateServersListPage() -//{ -// ui->listWidget_servers->clear(); -// const QJsonArray &servers = m_settings.serversArray(); -// int defaultServer = m_settings.defaultServerIndex(); - -// ui->listWidget_servers->setUpdatesEnabled(false); -// for(int i = 0; i < servers.size(); i++) { -// makeServersListItem(ui->listWidget_servers, servers.at(i).toObject(), i == defaultServer, i); -// } -// ui->listWidget_servers->setUpdatesEnabled(true); -//} - -//void UiLogic::updateProtocolsPage() -//{ -// ui->progressBar_protocols_container_reinstall->hide(); - -// auto containers = m_settings.containers(selectedServerIndex); -// DockerContainer defaultContainer = m_settings.defaultContainer(selectedServerIndex); -// bool haveAuthData = m_settings.haveAuthData(selectedServerIndex); - -// // all containers -// QList allContainers { -// DockerContainer::OpenVpn, -// DockerContainer::OpenVpnOverShadowSocks, -// DockerContainer::OpenVpnOverCloak, -// DockerContainer::WireGuard -// }; - -// // install buttons -// QList installButtons { -// ui->pushButton_proto_openvpn_cont_install, -// ui->pushButton_proto_ss_openvpn_cont_install, -// ui->pushButton_proto_cloak_openvpn_cont_install, -// ui->pushButton_proto_wireguard_cont_install -// }; - -// // default buttons -// QList defaultButtons { -// ui->pushButton_proto_openvpn_cont_default, -// ui->pushButton_proto_ss_openvpn_cont_default, -// ui->pushButton_proto_cloak_openvpn_cont_default, -// ui->pushButton_proto_wireguard_cont_default -// }; - -// // share buttons -// QList shareButtons { -// ui->pushButton_proto_openvpn_cont_share, -// ui->pushButton_proto_ss_openvpn_cont_share, -// ui->pushButton_proto_cloak_openvpn_cont_share, -// ui->pushButton_proto_wireguard_cont_share -// }; - -// // frames -// QList frames { -// ui->frame_openvpn_settings, -// ui->frame_openvpn_ss_settings, -// ui->frame_openvpn_ss_cloak_settings, -// ui->frame_wireguard_settings -// }; - -// for (int i = 0; i < allContainers.size(); ++i) { -// defaultButtons.at(i)->setChecked(defaultContainer == allContainers.at(i)); -// defaultButtons.at(i)->setVisible(haveAuthData && containers.contains(allContainers.at(i))); -// shareButtons.at(i)->setVisible(haveAuthData && containers.contains(allContainers.at(i))); -// installButtons.at(i)->setChecked(containers.contains(allContainers.at(i))); -// installButtons.at(i)->setEnabled(haveAuthData); -// frames.at(i)->setVisible(containers.contains(allContainers.at(i))); - -// } -//} - -//void UiLogic::updateOpenVpnPage(const QJsonObject &openvpnConfig, DockerContainer container, bool haveAuthData) -//{ -// ui->widget_proto_openvpn->setEnabled(haveAuthData); -// ui->pushButton_proto_openvpn_save->setVisible(haveAuthData); -// ui->progressBar_proto_openvpn_reset->setVisible(haveAuthData); - -// ui->radioButton_proto_openvpn_udp->setEnabled(true); -// ui->radioButton_proto_openvpn_tcp->setEnabled(true); - -// ui->lineEdit_proto_openvpn_subnet->setText(openvpnConfig.value(config_key::subnet_address). -// toString(protocols::openvpn::defaultSubnetAddress)); - -// QString trasnsport = openvpnConfig.value(config_key::transport_proto). -// toString(protocols::openvpn::defaultTransportProto); - -// ui->radioButton_proto_openvpn_udp->setChecked(trasnsport == protocols::openvpn::defaultTransportProto); -// ui->radioButton_proto_openvpn_tcp->setChecked(trasnsport != protocols::openvpn::defaultTransportProto); - -// ui->comboBox_proto_openvpn_cipher->setCurrentText(openvpnConfig.value(config_key::cipher). -// toString(protocols::openvpn::defaultCipher)); - -// ui->comboBox_proto_openvpn_hash->setCurrentText(openvpnConfig.value(config_key::hash). -// toString(protocols::openvpn::defaultHash)); - -// bool blockOutsideDns = openvpnConfig.value(config_key::block_outside_dns).toBool(protocols::openvpn::defaultBlockOutsideDns); -// ui->checkBox_proto_openvpn_block_dns->setChecked(blockOutsideDns); - -// bool isNcpDisabled = openvpnConfig.value(config_key::ncp_disable).toBool(protocols::openvpn::defaultNcpDisable); -// ui->checkBox_proto_openvpn_auto_encryption->setChecked(!isNcpDisabled); - -// bool isTlsAuth = openvpnConfig.value(config_key::tls_auth).toBool(protocols::openvpn::defaultTlsAuth); -// ui->checkBox_proto_openvpn_tls_auth->setChecked(isTlsAuth); - -// if (container == DockerContainer::OpenVpnOverShadowSocks) { -// ui->radioButton_proto_openvpn_udp->setEnabled(false); -// ui->radioButton_proto_openvpn_tcp->setEnabled(false); -// ui->radioButton_proto_openvpn_tcp->setChecked(true); -// } - -// ui->lineEdit_proto_openvpn_port->setText(openvpnConfig.value(config_key::port). -// toString(protocols::openvpn::defaultPort)); - -// ui->lineEdit_proto_openvpn_port->setEnabled(container == DockerContainer::OpenVpn); -//} - -//void UiLogic::updateShadowSocksPage(const QJsonObject &ssConfig, DockerContainer container, bool haveAuthData) -//{ -// ui->widget_proto_ss->setEnabled(haveAuthData); -// ui->pushButton_proto_shadowsocks_save->setVisible(haveAuthData); -// ui->progressBar_proto_shadowsocks_reset->setVisible(haveAuthData); - -// ui->comboBox_proto_shadowsocks_cipher->setCurrentText(ssConfig.value(config_key::cipher). -// toString(protocols::shadowsocks::defaultCipher)); - -// ui->lineEdit_proto_shadowsocks_port->setText(ssConfig.value(config_key::port). -// toString(protocols::shadowsocks::defaultPort)); - -// ui->lineEdit_proto_shadowsocks_port->setEnabled(container == DockerContainer::OpenVpnOverShadowSocks); -//} - -//void UiLogic::updateCloakPage(const QJsonObject &ckConfig, DockerContainer container, bool haveAuthData) -//{ -// ui->widget_proto_cloak->setEnabled(haveAuthData); -// ui->pushButton_proto_cloak_save->setVisible(haveAuthData); -// ui->progressBar_proto_cloak_reset->setVisible(haveAuthData); - -// ui->comboBox_proto_cloak_cipher->setCurrentText(ckConfig.value(config_key::cipher). -// toString(protocols::cloak::defaultCipher)); - -// ui->lineEdit_proto_cloak_site->setText(ckConfig.value(config_key::site). -// toString(protocols::cloak::defaultRedirSite)); +void UiLogic::updateServersListPage() +{ + const QJsonArray &servers = m_settings.serversArray(); + int defaultServer = m_settings.defaultServerIndex(); + std::vector serverListContent; + for(int i = 0; i < servers.size(); i++) { + ServerModelContent c; + auto server = servers.at(i).toObject(); + c.desc = server.value(config_key::description).toString(); + c.address = server.value(config_key::hostName).toString(); + if (c.desc.isEmpty()) { + c.desc = c.address; + } + c.isDefault = (i == defaultServer); + serverListContent.push_back(c); + } + m_serverListModel->setContent(serverListContent); +} + +void UiLogic::updateProtocolsPage() +{ + setProgressBarProtocolsContainerReinstallVisible(false); + + auto containers = m_settings.containers(selectedServerIndex); + DockerContainer defaultContainer = m_settings.defaultContainer(selectedServerIndex); + bool haveAuthData = m_settings.haveAuthData(selectedServerIndex); + + // all containers + QList allContainers { + DockerContainer::OpenVpn, + DockerContainer::OpenVpnOverShadowSocks, + DockerContainer::OpenVpnOverCloak, + DockerContainer::WireGuard + }; + + using SetVisibleFunc = std::function; + using SetCheckedFunc = std::function; + using SetEnabledFunc = std::function; + QList installButtonsCheckedFunc { + [this](bool checked) ->void {setPushButtonProtoOpenvpnContInstallChecked(checked);}, + [this](bool checked) ->void {setPushButtonProtoSsOpenvpnContInstallChecked(checked);}, + [this](bool checked) ->void {setPushButtonProtoCloakOpenvpnContInstallChecked(checked);}, + [this](bool checked) ->void {setPushButtonProtoWireguardContInstallChecked(checked);}, + }; + QList installButtonsEnabledFunc { + [this](bool enabled) ->void {setPushButtonProtoOpenvpnContInstallEnabled(enabled);}, + [this](bool enabled) ->void {setPushButtonProtoSsOpenvpnContInstallEnabled(enabled);}, + [this](bool enabled) ->void {setPushButtonProtoCloakOpenvpnContInstallEnabled(enabled);}, + [this](bool enabled) ->void {setPushButtonProtoWireguardContInstallEnabled(enabled);}, + }; + + QList defaultButtonsCheckedFunc { + [this](bool checked) ->void {setPushButtonProtoOpenvpnContDefaultChecked(checked);}, + [this](bool checked) ->void {setPushButtonProtoSsOpenvpnContDefaultChecked(checked);}, + [this](bool checked) ->void {setPushButtonProtoCloakOpenvpnContDefaultChecked(checked);}, + [this](bool checked) ->void {setPushButtonProtoWireguardContDefaultChecked(checked);}, + }; + QList defaultButtonsVisibleFunc { + [this](bool visible) ->void {setPushButtonProtoOpenvpnContDefaultVisible(visible);}, + [this](bool visible) ->void {setPushButtonProtoSsOpenvpnContDefaultVisible(visible);}, + [this](bool visible) ->void {setPushButtonProtoCloakOpenvpnContDefaultVisible(visible);}, + [this](bool visible) ->void {setPushButtonProtoWireguardContDefaultVisible(visible);}, + }; + + QList shareButtonsVisibleFunc { + [this](bool visible) ->void {setPushButtonProtoOpenvpnContShareVisible(visible);}, + [this](bool visible) ->void {setPushButtonProtoSsOpenvpnContShareVisible(visible);}, + [this](bool visible) ->void {setPushButtonProtoCloakOpenvpnContShareVisible(visible);}, + [this](bool visible) ->void {setPushButtonProtoWireguardContShareVisible(visible);}, + }; + + QList framesVisibleFunc { + [this](bool visible) ->void {setFrameOpenvpnSettingsVisible(visible);}, + [this](bool visible) ->void {setFrameOpenvpnSsSettingsVisible(visible);}, + [this](bool visible) ->void {setFrameOpenvpnSsCloakSettingsVisible(visible);}, + [this](bool visible) ->void {setFrameWireguardSettingsVisible(visible);}, + }; + + for (int i = 0; i < allContainers.size(); ++i) { + defaultButtonsCheckedFunc.at(i)(defaultContainer == allContainers.at(i)); + defaultButtonsVisibleFunc.at(i)(haveAuthData && containers.contains(allContainers.at(i))); + shareButtonsVisibleFunc.at(i)(haveAuthData && containers.contains(allContainers.at(i))); + installButtonsCheckedFunc.at(i)(containers.contains(allContainers.at(i))); + installButtonsEnabledFunc.at(i)(haveAuthData); + framesVisibleFunc.at(i)(containers.contains(allContainers.at(i))); + } +} + +void UiLogic::updateOpenVpnPage(const QJsonObject &openvpnConfig, DockerContainer container, bool haveAuthData) +{ + setWidgetProtoOpenvpnEnabled(haveAuthData); + setPushButtonProtoOpenvpnSaveVisible(haveAuthData); + setProgressBarProtoOpenvpnResetVisible(haveAuthData); + + setRadioButtonProtoOpenvpnUdpEnabled(true); + setRadioButtonProtoOpenvpnTcpEnabled(true); + + setLineEditProtoOpenvpnSubnetText(openvpnConfig.value(config_key::subnet_address). + toString(protocols::openvpn::defaultSubnetAddress)); + + QString trasnsport = openvpnConfig.value(config_key::transport_proto). + toString(protocols::openvpn::defaultTransportProto); + + setRadioButtonProtoOpenvpnUdpChecked(trasnsport == protocols::openvpn::defaultTransportProto); + setRadioButtonProtoOpenvpnTcpChecked(trasnsport != protocols::openvpn::defaultTransportProto); + + setComboBoxProtoOpenvpnCipherText(openvpnConfig.value(config_key::cipher). + toString(protocols::openvpn::defaultCipher)); + + setComboBoxProtoOpenvpnHashText(openvpnConfig.value(config_key::hash). + toString(protocols::openvpn::defaultHash)); + + bool blockOutsideDns = openvpnConfig.value(config_key::block_outside_dns).toBool(protocols::openvpn::defaultBlockOutsideDns); + setCheckBoxProtoOpenvpnBlockDnsChecked(blockOutsideDns); + + bool isNcpDisabled = openvpnConfig.value(config_key::ncp_disable).toBool(protocols::openvpn::defaultNcpDisable); + setCheckBoxProtoOpenvpnAutoEncryptionChecked(!isNcpDisabled); + + bool isTlsAuth = openvpnConfig.value(config_key::tls_auth).toBool(protocols::openvpn::defaultTlsAuth); + setCheckBoxProtoOpenvpnTlsAuthChecked(isTlsAuth); + + if (container == DockerContainer::OpenVpnOverShadowSocks) { + setRadioButtonProtoOpenvpnUdpEnabled(false); + setRadioButtonProtoOpenvpnTcpEnabled(false); + setRadioButtonProtoOpenvpnTcpChecked(true); + } + + setLineEditProtoOpenvpnPortText(openvpnConfig.value(config_key::port). + toString(protocols::openvpn::defaultPort)); + + setLineEditProtoOpenvpnPortEnabled(container == DockerContainer::OpenVpn); +} + +void UiLogic::updateShadowSocksPage(const QJsonObject &ssConfig, DockerContainer container, bool haveAuthData) +{ + setWidgetProtoSsEnabled(haveAuthData); + setPushButtonProtoShadowsocksSaveVisible(haveAuthData); + setProgressBarProtoShadowsocksResetVisible(haveAuthData); + + setComboBoxProtoShadowsocksCipherText(ssConfig.value(config_key::cipher). + toString(protocols::shadowsocks::defaultCipher)); + + setLineEditProtoShadowsocksPortText(ssConfig.value(config_key::port). + toString(protocols::shadowsocks::defaultPort)); + + setLineEditProtoShadowsocksPortEnabled(container == DockerContainer::OpenVpnOverShadowSocks); +} + +void UiLogic::updateCloakPage(const QJsonObject &ckConfig, DockerContainer container, bool haveAuthData) +{ + setWidgetProtoCloakEnabled(haveAuthData); + setPushButtonProtoCloakSaveVisible(haveAuthData); + setProgressBarProtoCloakResetVisible(haveAuthData); + + setComboBoxProtoCloakCipherText(ckConfig.value(config_key::cipher). + toString(protocols::cloak::defaultCipher)); + + setLineEditProtoCloakSiteText(ckConfig.value(config_key::site). + toString(protocols::cloak::defaultRedirSite)); + + setLineEditProtoCloakPortText(ckConfig.value(config_key::port). + toString(protocols::cloak::defaultPort)); -// ui->lineEdit_proto_cloak_port->setText(ckConfig.value(config_key::port). -// toString(protocols::cloak::defaultPort)); + setLineEditProtoCloakPortEnabled(container == DockerContainer::OpenVpnOverCloak); +} + +void UiLogic::updateSharingPage(int serverIndex, const ServerCredentials &credentials, + DockerContainer container) +{ + selectedDockerContainer = container; + selectedServerIndex = serverIndex; -// ui->lineEdit_proto_cloak_port->setEnabled(container == DockerContainer::OpenVpnOverCloak); -//} + //const QJsonObject &containerConfig = m_settings.containerConfig(serverIndex, container); -//void UiLogic::updateSharingPage(int serverIndex, const ServerCredentials &credentials, -// DockerContainer container) -//{ -// selectedDockerContainer = container; -// selectedServerIndex = serverIndex; + setPageShareAmneziaVisible(false); + setPageShareOpenvpnVisible(false); + setPageShareShadowsocksVisible(false); + setPageShareCloakVisible(false); + setPageShareFullAccessVisible(false); -// //const QJsonObject &containerConfig = m_settings.containerConfig(serverIndex, container); + enum currentWidget { + full_access = 0, + share_amezia, + share_openvpn, + share_shadowshock, + share_cloak + }; -// for (QWidget *page : { -// ui->page_share_amnezia, -// ui->page_share_openvpn, -// ui->page_share_shadowsocks, -// ui->page_share_cloak, -// ui->page_share_full_access }) { + if (container == DockerContainer::OpenVpn) { + setPageShareAmneziaVisible(true); + setPageShareOpenvpnVisible(true); -// ui->toolBox_share_connection->removeItem(ui->toolBox_share_connection->indexOf(page)); -// page->hide(); -// } + QString cfg = tr("Press Generate config"); + setTextEditShareOpenvpnCodeText(cfg); + setPushButtonShareOpenvpnCopyEnabled(false); + setPushButtonShareOpenvpnSaveEnabled(false); -// if (container == DockerContainer::OpenVpn) { -// ui->toolBox_share_connection->addItem(ui->page_share_amnezia, tr(" Share for Amnezia client")); -// ui->toolBox_share_connection->addItem(ui->page_share_openvpn, tr(" Share for OpenVPN client")); + setToolBoxShareConnectionCurrentIndex(share_openvpn); + } -// QString cfg = tr("Press Generate config"); -// ui->textEdit_share_openvpn_code->setPlainText(cfg); -// ui->pushButton_share_openvpn_copy->setEnabled(false); -// ui->pushButton_share_openvpn_save->setEnabled(false); + if (container == DockerContainer::OpenVpnOverShadowSocks || + container == DockerContainer::OpenVpnOverCloak) { + setPageShareAmneziaVisible(true); + setPageShareShadowsocksVisible(true); -// ui->toolBox_share_connection->setCurrentWidget(ui->page_share_openvpn); -// } + QJsonObject protoConfig = m_settings.protocolConfig(serverIndex, container, Protocol::ShadowSocks); + QString cfg = protoConfig.value(config_key::last_config).toString(); -// if (container == DockerContainer::OpenVpnOverShadowSocks || -// container == DockerContainer::OpenVpnOverCloak) { -// ui->toolBox_share_connection->addItem(ui->page_share_amnezia, tr(" Share for Amnezia client")); -// ui->toolBox_share_connection->addItem(ui->page_share_shadowsocks, tr(" Share for ShadowSocks client")); + if (cfg.isEmpty()) { + const QJsonObject &containerConfig = m_settings.containerConfig(serverIndex, container); -// QJsonObject protoConfig = m_settings.protocolConfig(serverIndex, container, Protocol::ShadowSocks); -// QString cfg = protoConfig.value(config_key::last_config).toString(); + ErrorCode e = ErrorCode::NoError; + cfg = ShadowSocksConfigurator::genShadowSocksConfig(credentials, container, containerConfig, &e); -// if (cfg.isEmpty()) { -// const QJsonObject &containerConfig = m_settings.containerConfig(serverIndex, container); + setPushButtonShareSsCopyEnabled(true); + } -// ErrorCode e = ErrorCode::NoError; -// cfg = ShadowSocksConfigurator::genShadowSocksConfig(credentials, container, containerConfig, &e); + QJsonObject ssConfig = QJsonDocument::fromJson(cfg.toUtf8()).object(); -// ui->pushButton_share_ss_copy->setEnabled(true); -// } + QString ssString = QString("%1:%2@%3:%4") + .arg(ssConfig.value("method").toString()) + .arg(ssConfig.value("password").toString()) + .arg(ssConfig.value("server").toString()) + .arg(ssConfig.value("server_port").toString()); -// QJsonObject ssConfig = QJsonDocument::fromJson(cfg.toUtf8()).object(); + ssString = "ss://" + ssString.toUtf8().toBase64(); + setLineEditShareSsStringText(ssString); + updateQRCodeImage(ssString, [this](const QString& labelText) ->void { + setLabelShareSsQrCodeText(labelText); + }); -// QString ssString = QString("%1:%2@%3:%4") -// .arg(ssConfig.value("method").toString()) -// .arg(ssConfig.value("password").toString()) -// .arg(ssConfig.value("server").toString()) -// .arg(ssConfig.value("server_port").toString()); + setLabelShareSsServerText(ssConfig.value("server").toString()); + setLabelShareSsPortText(ssConfig.value("server_port").toString()); + setLabelShareSsMethodText(ssConfig.value("method").toString()); + setLabelShareSsPasswordText(ssConfig.value("password").toString()); -// ssString = "ss://" + ssString.toUtf8().toBase64(); -// ui->lineEdit_share_ss_string->setText(ssString); -// updateQRCodeImage(ssString, ui->label_share_ss_qr_code); + setToolBoxShareConnectionCurrentIndex(share_shadowshock); + } -// ui->label_share_ss_server->setText(ssConfig.value("server").toString()); -// ui->label_share_ss_port->setText(ssConfig.value("server_port").toString()); -// ui->label_share_ss_method->setText(ssConfig.value("method").toString()); -// ui->label_share_ss_password->setText(ssConfig.value("password").toString()); + if (container == DockerContainer::OpenVpnOverCloak) { + //ui->toolBox_share_connection->addItem(ui->page_share_amnezia, tr(" Share for Amnezia client")); + setPageShareCloakVisible(true); + setPlainTextEditShareCloakText(QString("")); -// ui->toolBox_share_connection->setCurrentWidget(ui->page_share_shadowsocks); -// ui->page_share_shadowsocks->show(); -// ui->page_share_shadowsocks->raise(); -// qDebug() << ui->page_share_shadowsocks->size(); -// ui->toolBox_share_connection->layout()->update(); -// } + QJsonObject protoConfig = m_settings.protocolConfig(serverIndex, container, Protocol::Cloak); + QString cfg = protoConfig.value(config_key::last_config).toString(); -// if (container == DockerContainer::OpenVpnOverCloak) { -// //ui->toolBox_share_connection->addItem(ui->page_share_amnezia, tr(" Share for Amnezia client")); -// ui->toolBox_share_connection->addItem(ui->page_share_cloak, tr(" Share for Cloak client")); -// ui->plainTextEdit_share_cloak->setPlainText(QString("")); + if (cfg.isEmpty()) { + const QJsonObject &containerConfig = m_settings.containerConfig(serverIndex, container); -// QJsonObject protoConfig = m_settings.protocolConfig(serverIndex, container, Protocol::Cloak); -// QString cfg = protoConfig.value(config_key::last_config).toString(); + ErrorCode e = ErrorCode::NoError; + cfg = CloakConfigurator::genCloakConfig(credentials, container, containerConfig, &e); -// if (cfg.isEmpty()) { -// const QJsonObject &containerConfig = m_settings.containerConfig(serverIndex, container); + setPushButtonShareCloakCopyEnabled(true); + } -// ErrorCode e = ErrorCode::NoError; -// cfg = CloakConfigurator::genCloakConfig(credentials, container, containerConfig, &e); + QJsonObject cloakConfig = QJsonDocument::fromJson(cfg.toUtf8()).object(); + cloakConfig.remove(config_key::transport_proto); + cloakConfig.insert("ProxyMethod", "shadowsocks"); -// ui->pushButton_share_cloak_copy->setEnabled(true); -// } + setPlainTextEditShareCloakText(QJsonDocument(cloakConfig).toJson()); + } -// QJsonObject cloakConfig = QJsonDocument::fromJson(cfg.toUtf8()).object(); -// cloakConfig.remove(config_key::transport_proto); -// cloakConfig.insert("ProxyMethod", "shadowsocks"); + // Full access + if (container == DockerContainer::None) { + setPageShareFullAccessVisible(true); -// ui->plainTextEdit_share_cloak->setPlainText(QJsonDocument(cloakConfig).toJson()); -// } + const QJsonObject &server = m_settings.server(selectedServerIndex); -// // Full access -// if (container == DockerContainer::None) { -// ui->toolBox_share_connection->addItem(ui->page_share_full_access, tr(" Share server full access")); + QByteArray ba = QJsonDocument(server).toJson().toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals); -// const QJsonObject &server = m_settings.server(selectedServerIndex); + setTextEditShareFullCodeText(QString("vpn://%1").arg(QString(ba))); + setToolBoxShareConnectionCurrentIndex(full_access); + } -// QByteArray ba = QJsonDocument(server).toJson().toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals); + //ui->toolBox_share_connection->addItem(ui->page_share_amnezia, tr(" Share for Amnezia client")); -// ui->textEdit_share_full_code->setText(QString("vpn://%1").arg(QString(ba))); -// ui->toolBox_share_connection->setCurrentWidget(ui->page_share_full_access); -// } + // Amnezia sharing + // QJsonObject exportContainer; + // for (Protocol p: protocolsForContainer(container)) { + // QJsonObject protocolConfig = containerConfig.value(protoToString(p)).toObject(); + // protocolConfig.remove(config_key::last_config); + // exportContainer.insert(protoToString(p), protocolConfig); + // } + // exportContainer.insert(config_key::container, containerToString(container)); -// //ui->toolBox_share_connection->addItem(ui->page_share_amnezia, tr(" Share for Amnezia client")); + // ui->textEdit_share_amnezia_code->setPlainText(QJsonDocument(exportContainer).toJson()); -// // Amnezia sharing -// // QJsonObject exportContainer; -// // for (Protocol p: protocolsForContainer(container)) { -// // QJsonObject protocolConfig = containerConfig.value(protoToString(p)).toObject(); -// // protocolConfig.remove(config_key::last_config); -// // exportContainer.insert(protoToString(p), protocolConfig); -// // } -// // exportContainer.insert(config_key::container, containerToString(container)); + setTextEditShareAmneziaCodeText(tr("")); +} -// // ui->textEdit_share_amnezia_code->setPlainText(QJsonDocument(exportContainer).toJson()); -// ui->textEdit_share_amnezia_code->setPlainText(tr("")); -//} +void UiLogic::updateQRCodeImage(const QString &text, const std::function& setLabelFunc) +{ + int levelIndex = 1; + int versionIndex = 0; + bool bExtent = true; + int maskIndex = -1; -//void UiLogic::makeServersListItem(QListWidget *listWidget, const QJsonObject &server, bool isDefault, int index) -//{ -// QSize size(310, 70); -// ServerWidget* widget = new ServerWidget(server, isDefault); + m_qrEncode.EncodeData( levelIndex, versionIndex, bExtent, maskIndex, text.toUtf8().data() ); -// widget->resize(size); + int qrImageSize = m_qrEncode.m_nSymbleSize; -// connect(widget->ui->pushButton_default, &QPushButton::clicked, this, [this, index](){ -// m_settings.setDefaultServer(index); -// updateServersListPage(); -// }); + int encodeImageSize = qrImageSize + ( QR_MARGIN * 2 ); + QImage encodeImage( encodeImageSize, encodeImageSize, QImage::Format_Mono ); -// // connect(widget->ui->pushButton_share, &QPushButton::clicked, this, [this, index](){ -// // goToPage(Page::ShareConnection); -// // // update share page -// // }); + encodeImage.fill( 1 ); -// connect(widget->ui->pushButton_settings, &QPushButton::clicked, this, [this, index](){ -// selectedServerIndex = index; -// goToPage(Page::ServerSettings); -// }); + for ( int i = 0; i < qrImageSize; i++ ) + for ( int j = 0; j < qrImageSize; j++ ) + if ( m_qrEncode.m_byModuleData[i][j] ) + encodeImage.setPixel( i + QR_MARGIN, j + QR_MARGIN, 0 ); -// QListWidgetItem* item = new QListWidgetItem(listWidget); -// item->setSizeHint(size); -// listWidget->setItemWidget(item, widget); + QByteArray byteArray; + QBuffer buffer(&byteArray); + encodeImage.save(&buffer, "PNG"); // writes the image in PNG format inside the buffer + QString iconBase64 = QString::fromLatin1(byteArray.toBase64().data()); -// widget->setStyleSheet(styleSheet()); -//} - -//void UiLogic::updateQRCodeImage(const QString &text, QLabel *label) -//{ -// int levelIndex = 1; -// int versionIndex = 0; -// bool bExtent = true; -// int maskIndex = -1; - -// m_qrEncode.EncodeData( levelIndex, versionIndex, bExtent, maskIndex, text.toUtf8().data() ); - -// int qrImageSize = m_qrEncode.m_nSymbleSize; - -// int encodeImageSize = qrImageSize + ( QR_MARGIN * 2 ); -// QImage encodeImage( encodeImageSize, encodeImageSize, QImage::Format_Mono ); - -// encodeImage.fill( 1 ); - -// for ( int i = 0; i < qrImageSize; i++ ) -// for ( int j = 0; j < qrImageSize; j++ ) -// if ( m_qrEncode.m_byModuleData[i][j] ) -// encodeImage.setPixel( i + QR_MARGIN, j + QR_MARGIN, 0 ); - -// label->setPixmap(QPixmap::fromImage(encodeImage.scaledToWidth(label->width()))); -//} + setLabelFunc(iconBase64); +} QJsonObject UiLogic::getOpenVpnConfigFromPage(QJsonObject oldConfig) { diff --git a/client/ui/uilogic.h b/client/ui/uilogic.h index 9a3d0cf2..d3e4afa8 100644 --- a/client/ui/uilogic.h +++ b/client/ui/uilogic.h @@ -1,25 +1,30 @@ #ifndef UILOGIC_H #define UILOGIC_H -#include -#include -#include -#include #include -#include -#include -#include #include +#include #include "3rd/QRCodeGenerator/QRCodeGenerator.h" -#include "framelesswindow.h" #include "protocols/vpnprotocol.h" #include "settings.h" #include "sites_model.h" +#include "serversmodel.h" 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 { Q_OBJECT @@ -94,24 +99,134 @@ class UiLogic : public QObject Q_PROPERTY(bool checkBoxSetupWizardVpnModeChecked READ getCheckBoxSetupWizardVpnModeChecked WRITE setCheckBoxSetupWizardVpnModeChecked NOTIFY checkBoxSetupWizardVpnModeCheckedChanged) Q_PROPERTY(QString ipAddressValidatorRegex READ getIpAddressValidatorRegex CONSTANT) Q_PROPERTY(bool pushButtonConnectChecked READ getPushButtonConnectChecked WRITE setPushButtonConnectChecked NOTIFY pushButtonConnectCheckedChanged) + Q_PROPERTY(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: explicit UiLogic(QObject *parent = nullptr); - // ~UiLogic(); - - 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(); + ~UiLogic(); + void showOnStartup(); Q_INVOKABLE void initalizeUiLogic(); static void declareQML() { - qmlRegisterType("Page", 1, 0, "Style"); + qmlRegisterUncreatableMetaObject( + PageEnumNS::staticMetaObject, + "PageEnum", + 1, 0, + "PageEnum", + "Error: only enums" + ); } bool getFrameWireguardSettingsVisible() const; void setFrameWireguardSettingsVisible(bool frameWireguardSettingsVisible); @@ -254,6 +369,229 @@ public: QString getIpAddressValidatorRegex() const; bool getPushButtonConnectChecked() const; 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(); @@ -280,8 +618,39 @@ public: Q_INVOKABLE void onPushButtonNetworkSettingsResetdns1Clicked(); Q_INVOKABLE void onPushButtonNetworkSettingsResetdns2Clicked(); 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: void frameWireguardSettingsVisibleChanged(); @@ -354,11 +723,138 @@ signals: void radioButtonSetupWizardLowCheckedChanged(); void checkBoxSetupWizardVpnModeCheckedChanged(); 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 setStartPage(Page page, bool slide = true); + void setStartPage(int page, bool slide = true); 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: bool m_frameWireguardSettingsVisible; @@ -432,60 +928,182 @@ private: bool m_checkBoxSetupWizardVpnModeChecked; QString m_ipAddressValidatorRegex; 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: - // void onBytesChanged(quint64 receivedBytes, quint64 sentBytes); - // void onConnectionStateChanged(VpnProtocol::ConnectionState state); - // void onVpnProtocolError(amnezia::ErrorCode errorCode); +private slots: + void onBytesChanged(quint64 receivedBytes, quint64 sentBytes); + void onConnectionStateChanged(VpnProtocol::ConnectionState state); + void onVpnProtocolError(amnezia::ErrorCode errorCode); void installServer(const QMap &containers); - - // void onPushButtonClearServer(bool); - // void onPushButtonForgetServer(bool); - - // void onPushButtonAddCustomSitesClicked(); - void setTrayState(VpnProtocol::ConnectionState state); - - 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(); private: + PageEnumNS::Page currentPage(); + struct ProgressFunc { + std::function setVisibleFunc; + std::function setValueFunc; + std::function getValueFunc; + std::function getMaximiumFunc; + std::function setTextVisibleFunc; + std::function setTextFunc; + }; + struct PageFunc { + std::function setEnabledFunc; + }; + struct ButtonFunc { + std::function setVisibleFunc; + }; + struct LabelFunc { + std::function setVisibleFunc; + std::function setTextFunc; + }; - Page currentPage(); + bool installContainers(ServerCredentials credentials, + const QMap &containers, + const PageFunc& page, + const ProgressFunc& progress, + const ButtonFunc& button, + const LabelFunc& info); - // bool installContainers(ServerCredentials credentials, const QMap &containers, - // QWidget *page, QProgressBar *progress, QPushButton *button, QLabel *info); - - // ErrorCode doInstallAction(const std::function &action, QWidget *page, QProgressBar *progress, QPushButton *button, QLabel *info); + ErrorCode doInstallAction(const std::function &action, + const PageFunc& page, + const ProgressFunc& progress, + const ButtonFunc& button, + const LabelFunc& info); void setupTray(); void setTrayIcon(const QString &iconPath); void setupNewServerConnections(); - // void setupSitesPageConnections(); - // void setupGeneralSettingsConnections(); - // void setupProtocolsPageConnections(); - void setupNewServerPageConnections(); - // void setupServerSettingsPageConnections(); - // void setupSharePageConnections(); + void setupSitesPageConnections(); + void setupProtocolsPageConnections(); - // void updateSitesPage(); - // 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 updateSitesPage(); + 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); + void updateSharingPage(int serverIndex, const ServerCredentials &credentials, + DockerContainer container); + void updateQRCodeImage(const QString &text, const std::function& setLabelFunc); QJsonObject getOpenVpnConfigFromPage(QJsonObject oldConfig); QJsonObject getShadowSocksConfigFromPage(QJsonObject oldConfig); @@ -498,22 +1116,19 @@ private: VpnConnection* m_vpnConnection; Settings m_settings; - // QMap sitesModels; + QMap sitesModels; // QRegExpValidator m_ipAddressValidator; // QRegExpValidator m_ipAddressPortValidator; // QRegExpValidator m_ipNetwok24Validator; // QRegExpValidator m_ipPortValidator; - // CQR_Encode m_qrEncode; + 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;