diff options
| author | 2023-03-07 21:11:06 +0600 | |
|---|---|---|
| committer | 2023-03-07 21:11:06 +0600 | |
| commit | d830bfc8ce7c6763d074beafdde7cab1835d31f9 (patch) | |
| tree | 179f81f3b42779b1f6fb69deed6b69dab39f4f89 /src/mainwindow.h | |
| download | whatsie-d830bfc8ce7c6763d074beafdde7cab1835d31f9.tar.gz whatsie-d830bfc8ce7c6763d074beafdde7cab1835d31f9.zip | |
Import Upstream version 4.12.0upstream/4.12.0
Diffstat (limited to 'src/mainwindow.h')
| -rw-r--r-- | src/mainwindow.h | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/src/mainwindow.h b/src/mainwindow.h new file mode 100644 index 0000000..98dbf8b --- /dev/null +++ b/src/mainwindow.h @@ -0,0 +1,141 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include <QAction> +#include <QApplication> +#include <QFileDialog> +#include <QGraphicsOpacityEffect> +#include <QIcon> +#include <QMainWindow> +#include <QMenu> +#include <QMessageBox> +#include <QProgressBar> +#include <QRadioButton> +#include <QRegExp> +#include <QSettings> +#include <QStatusBar> +#include <QStyle> +#include <QStyleFactory> +#include <QSystemTrayIcon> +#include <QWebEngineContextMenuData> +#include <QWebEngineCookieStore> +#include <QWebEngineFullScreenRequest> +#include <QWebEngineProfile> +#include <QWebEngineSettings> +#include <QWebEngineView> + +#include "about.h" +#include "autolockeventfilter.h" +#include "dictionaries.h" +#include "downloadmanagerwidget.h" +#include "lock.h" +#include "notificationpopup.h" +#include "rateapp.h" +#include "requestinterceptor.h" +#include "settingswidget.h" +#include "webenginepage.h" +#include "webview.h" + +class MainWindow : public QMainWindow { + Q_OBJECT +public: + explicit MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + +public slots: + void updateWindowTheme(); + void updatePageTheme(); + void handleWebViewTitleChanged(QString title); + void handleLoadFinished(bool loaded); + void handleDownloadRequested(QWebEngineDownloadItem *download); + void loadSchemaUrl(const QString &arg); + void showSettings(bool isAskedByCLI = false); + void showAbout(); + void lockApp(); + void runMinimized(); + void alreadyRunning(bool notify = false); + void notify(QString title, QString message); + void toggleTheme(); + void doReload(bool byPassCache = false, bool isAskedByCLI = false, + bool byLoadingQuirk = false); + void newChat(); +protected slots: + void closeEvent(QCloseEvent *event) override; + void resizeEvent(QResizeEvent *event) override; + void changeEvent(QEvent *e) override; + +private: + const QIcon getTrayIcon(const int ¬ificationCount) const; + QPalette lightPalette, darkPalette; + void createActions(); + void createTrayIcon(); + void createWebEngine(); + + QSettings settings; + QRegExp notificationsTitleRegExp; + QIcon trayIconNormal; + QRegExp unreadMessageCountRegExp; + + QAction *reloadAction; + QAction *minimizeAction; + QAction *restoreAction; + QAction *aboutAction; + QAction *settingsAction; + QAction *toggleThemeAction; + QAction *quitAction; + QAction *lockAction; + QAction *fullscreenAction; + QAction *openUrlAction; + + QMenu *trayIconMenu; + QSystemTrayIcon *trayIcon; + QWebEngineView *webEngine; + SettingsWidget *settingsWidget = nullptr; + DownloadManagerWidget m_downloadManagerWidget; + QScopedPointer<QWebEngineProfile> m_otrProfile; + Lock *lockWidget = nullptr; + int correctlyLoaderRetries = 4; + QStringList m_dictionaries; + AutoLockEventFilter *autoLockEventFilter = nullptr; + +private slots: + + QString getPageTheme(); + void iconActivated(QSystemTrayIcon::ActivationReason reason); + void messageClicked(); + void handleCookieAdded(const QNetworkCookie &cookie); + void toggleMute(const bool &checked); + void doAppReload(); + void askToReloadPage(); + void updateSettingsUserAgentWidget(); + void fullScreenRequested(QWebEngineFullScreenRequest request); + void createWebPage(bool offTheRecord = false); + void initSettingWidget(); + void initGlobalWebProfile(); + void checkWindowState(); + void initLock(); + void tryLock(); + void checkLoadedCorrectly(); + void loadingQuirk(QString test); + void setNotificationPresenter(QWebEngineProfile *profile); + void quitApp(); + void initRateWidget(); + void initThemes(); + void handleZoomOnWindowStateChange(QWindowStateChangeEvent *ev); + void handleZoom(); + void changeLockPassword(); + void forceLogOut(); + void tryLogOut(); + bool isLoggedIn(); + void initAutoLock(); + void appAutoLockChanged(); + void injectNewChatJavaScript(); + void triggerNewChat(QString phone, QString text); + void restoreMainWindow(); + void injectFullWidthJavaScript(); + void injectMutationObserver(); + void injectClassChangeObserver(); + void injectPreventScrollWheelZoomHelper(); +}; + +#endif // MAINWINDOW_H |
