Files
amnezia-client/client/ui/controllers/qml/pageController.h
T

193 lines
5.4 KiB
C++
Raw Normal View History

2023-05-15 13:38:17 +08:00
#ifndef PAGECONTROLLER_H
#define PAGECONTROLLER_H
#include <QObject>
#include <QQmlEngine>
#include "core/utils/errorCodes.h"
#include "core/utils/routeModes.h"
#include "core/utils/commonStructs.h"
#include "core/controllers/settingsController.h"
#include "core/controllers/serversController.h"
2023-05-15 13:38:17 +08:00
namespace PageLoader
{
Q_NAMESPACE
enum class PageEnum {
PageStart = 0,
PageHome,
PageShare,
PageDeinstalling,
2023-06-01 11:25:33 +08:00
PageSettingsServersList,
PageSettings,
PageSettingsServerData,
PageSettingsServerInfo,
PageSettingsServerProtocols,
PageSettingsServerServices,
PageSettingsServerProtocol,
PageSettingsConnection,
PageSettingsDns,
PageSettingsApplication,
2025-10-06 08:06:36 +04:00
PageSettingsNewsNotifications,
PageSettingsNewsDetail,
PageSettingsBackup,
PageSettingsAbout,
PageSettingsLogging,
2023-08-08 19:10:14 +05:00
PageSettingsSplitTunneling,
2024-04-01 18:45:00 +07:00
PageSettingsAppSplitTunneling,
2025-05-02 23:54:36 -07:00
PageSettingsKillSwitch,
PageSettingsApiServerInfo,
PageSettingsApiAvailableCountries,
PageSettingsApiSupport,
PageSettingsApiInstructions,
PageSettingsApiNativeConfigs,
PageSettingsApiDevices,
PageSettingsApiSubscriptionKey,
2025-05-02 23:54:36 -07:00
PageSettingsKillSwitchExceptions,
PageServiceSftpSettings,
PageServiceTorWebsiteSettings,
2023-09-18 16:39:26 +05:00
PageServiceDnsSettings,
2024-06-10 18:35:24 +07:00
PageServiceSocksProxySettings,
2026-05-04 19:16:48 +03:00
PageServiceMtProxySettings,
PageSetupWizardStart,
PageSetupWizardCredentials,
PageSetupWizardProtocols,
PageSetupWizardEasy,
PageSetupWizardProtocolSettings,
PageSetupWizardInstalling,
PageSetupWizardConfigSource,
PageSetupWizardTextKey,
PageSetupWizardViewConfig,
PageSetupWizardQrReader,
PageSetupWizardApiServicesList,
2026-04-08 11:21:12 +07:00
PageSetupWizardApiFreeInfo,
PageProtocolOpenVpnSettings,
PageProtocolXraySettings,
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,
PageShareFullAccess,
PageShareConnection,
2026-04-08 11:21:12 +07:00
PageSetupWizardApiPremiumInfo,
PageSetupWizardApiTrialEmail,
PageDevMenu
2023-05-15 13:38:17 +08:00
};
Q_ENUM_NS(PageEnum)
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:
explicit PageController(ServersController* serversController, SettingsController* settingsController,
2023-08-24 14:53:52 +05:00
QObject *parent = nullptr);
2023-05-15 13:38:17 +08:00
Q_PROPERTY(int safeAreaTopMargin READ getSafeAreaTopMargin NOTIFY safeAreaTopMarginChanged)
Q_PROPERTY(int safeAreaBottomMargin READ getSafeAreaBottomMargin NOTIFY safeAreaBottomMarginChanged)
Q_PROPERTY(int imeHeight READ getImeHeight NOTIFY imeHeightChanged)
2023-05-15 13:38:17 +08:00
public slots:
bool isStartPageVisible();
2023-05-15 13:38:17 +08:00
QString getPagePath(PageLoader::PageEnum page);
void closeWindow();
void hideWindow();
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();
void setTriggeredByConnectButton(bool trigger);
void closeApplication();
2024-02-28 19:39:28 +07:00
void setDrawerDepth(const int depth);
2024-12-31 04:16:52 +01:00
int getDrawerDepth() const;
int incrementDrawerDepth();
int decrementDrawerDepth();
2024-02-28 19:39:28 +07:00
bool isEdgeToEdgeEnabled();
int getStatusBarHeight();
int getNavigationBarHeight();
int getSafeAreaTopMargin();
int getSafeAreaBottomMargin();
int getImeHeight();
private slots:
2024-05-25 13:00:51 +03:00
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();
void goToPageHome();
void goToPageSettings();
void goToPageViewConfig();
void goToPageSettingsServerServices();
void goToPageSettingsBackup();
void goToShareConnectionPage(QString headerText, QString configContentHeaderText, QString configCaption, QString configExtension,
QString configFileName);
void closePage();
2023-06-01 11:25:33 +08:00
void restorePageHomeState(bool isContainerInstalled = false);
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-04 09:58:19 +09:00
void showBusyIndicator(bool visible);
2024-02-28 19:39:28 +07:00
void disableControls(bool disabled);
void disableTabBar(bool disabled);
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);
void unsupportedConnectDrawerRequested();
2024-02-28 19:39:28 +07:00
void escapePressed();
void closeTopDrawer();
2026-05-04 07:37:19 +03:00
void showChangelogDrawer();
void imeHeightChanged(int height);
void safeAreaTopMarginChanged();
void safeAreaBottomMarginChanged();
2023-08-24 14:53:52 +05:00
private:
ServersController* m_serversController;
SettingsController* m_settingsController;
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;
mutable int m_cachedStatusBarHeight = -1;
mutable int m_cachedNavigationBarHeight = -1;
mutable bool m_cachedEdgeToEdgeEnabled = false;
mutable bool m_edgeToEdgeCached = false;
int m_imeHeight = 0;
2023-05-15 13:38:17 +08:00
};
#endif