2023-05-15 13:38:17 +08:00
|
|
|
#ifndef PAGECONTROLLER_H
|
|
|
|
|
#define PAGECONTROLLER_H
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
#include <QQmlEngine>
|
|
|
|
|
|
2024-05-25 13:00:51 +03:00
|
|
|
#include "core/defs.h"
|
2023-05-15 13:38:17 +08:00
|
|
|
#include "ui/models/servers_model.h"
|
|
|
|
|
|
|
|
|
|
namespace PageLoader
|
|
|
|
|
{
|
|
|
|
|
Q_NAMESPACE
|
2023-06-07 18:28:32 +08:00
|
|
|
enum class PageEnum {
|
|
|
|
|
PageStart = 0,
|
|
|
|
|
PageHome,
|
|
|
|
|
PageShare,
|
|
|
|
|
PageDeinstalling,
|
2023-06-01 11:25:33 +08:00
|
|
|
|
2023-06-07 18:28:32 +08:00
|
|
|
PageSettingsServersList,
|
|
|
|
|
PageSettings,
|
|
|
|
|
PageSettingsServerData,
|
|
|
|
|
PageSettingsServerInfo,
|
|
|
|
|
PageSettingsServerProtocols,
|
|
|
|
|
PageSettingsServerServices,
|
|
|
|
|
PageSettingsServerProtocol,
|
2023-06-16 13:43:55 +09:00
|
|
|
PageSettingsConnection,
|
|
|
|
|
PageSettingsDns,
|
|
|
|
|
PageSettingsApplication,
|
|
|
|
|
PageSettingsBackup,
|
|
|
|
|
PageSettingsAbout,
|
2023-07-14 22:59:49 +09:00
|
|
|
PageSettingsLogging,
|
2023-08-08 19:10:14 +05:00
|
|
|
PageSettingsSplitTunneling,
|
2024-04-01 18:45:00 +07:00
|
|
|
PageSettingsAppSplitTunneling,
|
2023-05-15 13:38:17 +08:00
|
|
|
|
2023-07-18 11:15:04 +09:00
|
|
|
PageServiceSftpSettings,
|
|
|
|
|
PageServiceTorWebsiteSettings,
|
2023-09-18 16:39:26 +05:00
|
|
|
PageServiceDnsSettings,
|
2024-06-10 18:35:24 +07:00
|
|
|
PageServiceSocksProxySettings,
|
2023-07-18 11:15:04 +09:00
|
|
|
|
2023-06-07 18:28:32 +08:00
|
|
|
PageSetupWizardStart,
|
|
|
|
|
PageSetupWizardCredentials,
|
|
|
|
|
PageSetupWizardProtocols,
|
|
|
|
|
PageSetupWizardEasy,
|
|
|
|
|
PageSetupWizardProtocolSettings,
|
|
|
|
|
PageSetupWizardInstalling,
|
|
|
|
|
PageSetupWizardConfigSource,
|
|
|
|
|
PageSetupWizardTextKey,
|
2023-07-13 11:29:26 +09:00
|
|
|
PageSetupWizardViewConfig,
|
2023-07-24 16:31:04 +09:00
|
|
|
PageSetupWizardQrReader,
|
2024-08-20 16:54:05 +07:00
|
|
|
PageSetupWizardApiServicesList,
|
|
|
|
|
PageSetupWizardApiServiceInfo,
|
2023-07-13 11:29:26 +09:00
|
|
|
|
|
|
|
|
PageProtocolOpenVpnSettings,
|
|
|
|
|
PageProtocolShadowSocksSettings,
|
|
|
|
|
PageProtocolCloakSettings,
|
2024-03-27 11:02:34 +00:00
|
|
|
PageProtocolXraySettings,
|
2023-07-13 11:29:26 +09:00
|
|
|
PageProtocolWireGuardSettings,
|
2023-10-06 17:19:44 +05:00
|
|
|
PageProtocolAwgSettings,
|
2023-07-14 13:14:50 +09:00
|
|
|
PageProtocolIKev2Settings,
|
2023-11-23 00:03:43 +07:00
|
|
|
PageProtocolRaw,
|
|
|
|
|
|
2024-09-13 12:38:48 +04:00
|
|
|
PageProtocolWireGuardClientSettings,
|
|
|
|
|
PageProtocolAwgClientSettings,
|
|
|
|
|
|
2024-08-20 16:54:05 +07:00
|
|
|
PageShareFullAccess,
|
|
|
|
|
|
|
|
|
|
PageDevMenu
|
2023-05-15 13:38:17 +08:00
|
|
|
};
|
|
|
|
|
Q_ENUM_NS(PageEnum)
|
|
|
|
|
|
2023-06-21 20:56:00 +09:00
|
|
|
static void declareQmlPageEnum()
|
|
|
|
|
{
|
|
|
|
|
qmlRegisterUncreatableMetaObject(PageLoader::staticMetaObject, "PageEnum", 1, 0, "PageEnum", "Error: only enums");
|
2023-05-15 13:38:17 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class PageController : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2023-08-24 14:53:52 +05:00
|
|
|
explicit PageController(const QSharedPointer<ServersModel> &serversModel, const std::shared_ptr<Settings> &settings,
|
|
|
|
|
QObject *parent = nullptr);
|
2023-05-15 13:38:17 +08:00
|
|
|
|
|
|
|
|
public slots:
|
2024-08-20 16:54:05 +07:00
|
|
|
bool isStartPageVisible();
|
2023-05-15 13:38:17 +08:00
|
|
|
QString getPagePath(PageLoader::PageEnum page);
|
|
|
|
|
|
2023-07-24 16:31:04 +09:00
|
|
|
void closeWindow();
|
2024-03-31 14:14:12 +03:00
|
|
|
void hideWindow();
|
2023-07-24 16:31:04 +09:00
|
|
|
void keyPressEvent(Qt::Key key);
|
|
|
|
|
|
2023-07-25 16:56:10 +09:00
|
|
|
unsigned int getInitialPageNavigationBarColor();
|
|
|
|
|
void updateNavigationBarColor(const int color);
|
|
|
|
|
|
2023-08-24 14:53:52 +05:00
|
|
|
void showOnStartup();
|
|
|
|
|
|
2023-10-03 22:38:17 +05:00
|
|
|
bool isTriggeredByConnectButton();
|
2024-02-29 17:22:17 +07:00
|
|
|
void setTriggeredByConnectButton(bool trigger);
|
2023-10-01 12:11:13 +08:00
|
|
|
|
2023-10-09 19:16:06 +05:00
|
|
|
void closeApplication();
|
|
|
|
|
|
2024-02-28 19:39:28 +07:00
|
|
|
void setDrawerDepth(const int depth);
|
|
|
|
|
int getDrawerDepth();
|
|
|
|
|
|
2024-05-25 13:00:51 +03:00
|
|
|
private slots:
|
|
|
|
|
void onShowErrorMessage(amnezia::ErrorCode errorCode);
|
|
|
|
|
|
2023-05-15 13:38:17 +08:00
|
|
|
signals:
|
2023-09-06 13:37:37 +05:00
|
|
|
void goToPage(PageLoader::PageEnum page, bool slide = true);
|
|
|
|
|
void goToStartPage();
|
2023-05-25 15:40:17 +08:00
|
|
|
void goToPageHome();
|
2023-06-21 20:56:00 +09:00
|
|
|
void goToPageSettings();
|
2023-07-24 16:31:04 +09:00
|
|
|
void goToPageViewConfig();
|
2023-08-16 12:11:34 +05:00
|
|
|
void goToPageSettingsServerServices();
|
2023-09-13 16:11:08 +05:00
|
|
|
void goToPageSettingsBackup();
|
2023-08-16 12:11:34 +05:00
|
|
|
|
2023-07-24 16:31:04 +09:00
|
|
|
void closePage();
|
|
|
|
|
|
2023-06-01 11:25:33 +08:00
|
|
|
void restorePageHomeState(bool isContainerInstalled = false);
|
2023-07-24 16:31:04 +09:00
|
|
|
|
2024-05-25 13:00:51 +03:00
|
|
|
void showErrorMessage(amnezia::ErrorCode);
|
2023-08-08 19:10:14 +05:00
|
|
|
void showErrorMessage(const QString &errorMessage);
|
|
|
|
|
void showNotificationMessage(const QString &message);
|
2023-07-24 16:31:04 +09:00
|
|
|
|
2023-07-04 09:58:19 +09:00
|
|
|
void showBusyIndicator(bool visible);
|
2024-02-28 19:39:28 +07:00
|
|
|
void disableControls(bool disabled);
|
2024-03-31 12:40:42 +05:00
|
|
|
void disableTabBar(bool disabled);
|
2023-07-24 16:31:04 +09:00
|
|
|
|
|
|
|
|
void hideMainWindow();
|
|
|
|
|
void raiseMainWindow();
|
2023-05-15 13:38:17 +08:00
|
|
|
|
2023-08-02 20:37:43 +09:00
|
|
|
void showPassphraseRequestDrawer();
|
|
|
|
|
void passphraseRequestDrawerClosed(QString passphrase);
|
|
|
|
|
|
2024-02-28 19:39:28 +07:00
|
|
|
void escapePressed();
|
|
|
|
|
void closeTopDrawer();
|
|
|
|
|
|
2024-04-18 17:54:55 +04:00
|
|
|
void forceTabBarActiveFocus();
|
|
|
|
|
void forceStackActiveFocus();
|
|
|
|
|
|
2023-05-15 13:38:17 +08:00
|
|
|
private:
|
|
|
|
|
QSharedPointer<ServersModel> m_serversModel;
|
2023-08-24 14:53:52 +05:00
|
|
|
|
|
|
|
|
std::shared_ptr<Settings> m_settings;
|
2023-09-16 08:05:43 +08:00
|
|
|
|
2023-10-03 22:38:17 +05:00
|
|
|
bool m_isTriggeredByConnectButton;
|
2024-02-28 19:39:28 +07:00
|
|
|
|
2024-02-28 17:31:46 +03:00
|
|
|
int m_drawerDepth = 0;
|
2023-05-15 13:38:17 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // PAGECONTROLLER_H
|