// SPDX-FileCopyrightText: 2017 Konstantinos Sideris // SPDX-FileCopyrightText: 2021 Nheko Contributors // SPDX-FileCopyrightText: 2022 Nheko Contributors // // SPDX-License-Identifier: GPL-3.0-or-later #pragma once #include #include #include #include #include "UserSettingsPage.h" #include "jdenticoninterface.h" class ChatPage; class RegisterPage; class WelcomePage; class TrayIcon; class UserSettings; class MxcImageProvider; namespace mtx { namespace requests { struct CreateRoom; } } namespace dialogs { class CreateRoom; class InviteUsers; class MemberList; class ReCaptcha; } class MainWindow : public QQuickView { Q_OBJECT Q_PROPERTY(QString activeRoom READ activeRoom WRITE updateActiveRoom NOTIFY activeRoomChanged) public: explicit MainWindow(QWindow *parent = nullptr); static MainWindow *instance() { return instance_; } void saveCurrentWindowSize(); void openJoinRoomDialog(std::function callback); MxcImageProvider *imageProvider() { return imgProvider; } //! Show the chat page and start communicating with the given access token. void showChatPage(); #ifdef NHEKO_DBUS_SYS bool dbusAvailable() const { return dbusAvailable_; } #endif QString activeRoom() const { return activeRoom_; } void updateActiveRoom(QString r) { if (activeRoom_ != r) { activeRoom_ = std::move(r); emit activeRoomChanged(); } } protected: void closeEvent(QCloseEvent *event); bool event(QEvent *event) override; private slots: //! Handle interaction with the tray icon. void iconActivated(QSystemTrayIcon::ActivationReason reason); virtual void setWindowTitle(int notificationCount); signals: void reload(); void secretsChanged(); void showNotification(QString msg); void switchToChatPage(); void switchToWelcomePage(); void switchToLoginPage(QString error); void activeRoomChanged(); private: void showDialog(QWidget *dialog); bool hasActiveUser(); void restoreWindowSize(); //! Check if the current page supports the "minimize to tray" functionality. bool pageSupportsTray() const; void registerQmlTypes(); static MainWindow *instance_; //! The initial welcome screen. WelcomePage *welcome_page_; //! The register page. RegisterPage *register_page_; //! The main chat area. ChatPage *chat_page_; QSharedPointer userSettings_; //! Tray icon that shows the unread message count. TrayIcon *trayIcon_; MxcImageProvider *imgProvider = nullptr; QString activeRoom_; #ifdef NHEKO_DBUS_SYS bool dbusAvailable_{false}; #endif };