File indexing completed on 2024-12-01 07:42:32

0001 /*
0002    SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "authenticationmanager.h"
0010 #include "channelgroupbasejob.h"
0011 #include "config-ruqola.h"
0012 #include "libruqolawidgets_export.h"
0013 #include <KXmlGuiWindow>
0014 #include <QPointer>
0015 class StatusCombobox;
0016 class RuqolaCentralWidget;
0017 class QAction;
0018 class QWidgetAction;
0019 class ServerMenu;
0020 class RocketChatAccount;
0021 class QLabel;
0022 class AccountsOverviewWidget;
0023 class Notification;
0024 class StatusModelFilterProxyModel;
0025 class QCommandLineParser;
0026 class SwitchChannelTreeViewManager;
0027 class KToggleAction;
0028 class KHamburgerMenu;
0029 class KToggleFullScreenAction;
0030 class QToolButton;
0031 class KActionMenu;
0032 class AccountManager;
0033 class LIBRUQOLAWIDGETS_EXPORT RuqolaMainWindow : public KXmlGuiWindow
0034 {
0035     Q_OBJECT
0036 public:
0037     explicit RuqolaMainWindow(QWidget *parent = nullptr);
0038     ~RuqolaMainWindow() override;
0039 
0040 #if !defined(Q_OS_WIN) && !defined(Q_OS_MACOS)
0041     void slotActivateRequested(const QStringList &arguments, const QString &workingDirectory);
0042 #endif
0043 
0044     void parseCommandLine(QCommandLineParser *parser);
0045 
0046 protected:
0047     [[nodiscard]] bool queryClose() override;
0048 
0049 private:
0050     [[nodiscard]] LIBRUQOLAWIDGETS_NO_EXPORT bool canCreateChannels() const;
0051     [[nodiscard]] LIBRUQOLAWIDGETS_NO_EXPORT bool canCreateDirectMessages() const;
0052     [[nodiscard]] LIBRUQOLAWIDGETS_NO_EXPORT bool canCreateTeams() const;
0053     LIBRUQOLAWIDGETS_NO_EXPORT void slotRegisterUserSuccessed();
0054     LIBRUQOLAWIDGETS_NO_EXPORT void setupActions();
0055     LIBRUQOLAWIDGETS_NO_EXPORT void readConfig();
0056     LIBRUQOLAWIDGETS_NO_EXPORT void setupStatusBar();
0057     LIBRUQOLAWIDGETS_NO_EXPORT void slotAddServer();
0058     LIBRUQOLAWIDGETS_NO_EXPORT void slotServerInfo();
0059     LIBRUQOLAWIDGETS_NO_EXPORT void slotConfigure();
0060     LIBRUQOLAWIDGETS_NO_EXPORT void slotLogout();
0061     LIBRUQOLAWIDGETS_NO_EXPORT void slotSelectNextUnreadChannel();
0062     LIBRUQOLAWIDGETS_NO_EXPORT void slotCreateNewChannel();
0063     LIBRUQOLAWIDGETS_NO_EXPORT void slotTypingNotificationChanged(const QString &roomId, const QString &notificationStr);
0064     LIBRUQOLAWIDGETS_NO_EXPORT void slotClearNotification();
0065     LIBRUQOLAWIDGETS_NO_EXPORT void slotAccountChanged();
0066     LIBRUQOLAWIDGETS_NO_EXPORT void slotUnreadOnTop(bool checked);
0067     LIBRUQOLAWIDGETS_NO_EXPORT void slotRoomListSortByLastMessage();
0068     LIBRUQOLAWIDGETS_NO_EXPORT void slotRoomListSortAlphabetically();
0069     LIBRUQOLAWIDGETS_NO_EXPORT void slotShowLog();
0070     LIBRUQOLAWIDGETS_NO_EXPORT void updateActions();
0071     LIBRUQOLAWIDGETS_NO_EXPORT void slotMissingChannelPassword(const RocketChatRestApi::ChannelGroupBaseJob::ChannelGroupInfo &channelInfo);
0072     LIBRUQOLAWIDGETS_NO_EXPORT void slotClearAccountAlerts();
0073     LIBRUQOLAWIDGETS_NO_EXPORT void slotLoginPageActivated(bool loginPageActivated);
0074     LIBRUQOLAWIDGETS_NO_EXPORT void slotConfigureNotifications();
0075     LIBRUQOLAWIDGETS_NO_EXPORT void slotRaiseWindow();
0076     LIBRUQOLAWIDGETS_NO_EXPORT void slotRegisterNewUser();
0077     LIBRUQOLAWIDGETS_NO_EXPORT void slotAdministrator();
0078     LIBRUQOLAWIDGETS_NO_EXPORT void slotConfigureMyAccount();
0079     LIBRUQOLAWIDGETS_NO_EXPORT void updateNotification(bool hasAlert, int nbUnread, const QString &accountName);
0080     LIBRUQOLAWIDGETS_NO_EXPORT void logout(const QString &accountName);
0081     LIBRUQOLAWIDGETS_NO_EXPORT void slotRoomNeedAttention();
0082     LIBRUQOLAWIDGETS_NO_EXPORT void slotCreateDirectMessages();
0083     LIBRUQOLAWIDGETS_NO_EXPORT void slotClose();
0084     LIBRUQOLAWIDGETS_NO_EXPORT void slotStatusChanged();
0085     LIBRUQOLAWIDGETS_NO_EXPORT void slotUpdateStatusMenu();
0086     LIBRUQOLAWIDGETS_NO_EXPORT void createSystemTray();
0087     LIBRUQOLAWIDGETS_NO_EXPORT void slotUpdateCustomUserStatus();
0088     LIBRUQOLAWIDGETS_NO_EXPORT void slotCreateDiscussion();
0089     LIBRUQOLAWIDGETS_NO_EXPORT void slotCreateTeam();
0090     LIBRUQOLAWIDGETS_NO_EXPORT void slotPermissionChanged();
0091     LIBRUQOLAWIDGETS_NO_EXPORT void slotDirectory();
0092     LIBRUQOLAWIDGETS_NO_EXPORT void showNextView();
0093     LIBRUQOLAWIDGETS_NO_EXPORT void showPreviousView();
0094     LIBRUQOLAWIDGETS_NO_EXPORT void slotMessageUrlNotFound(const QString &str);
0095     LIBRUQOLAWIDGETS_NO_EXPORT void slotHistorySwitchChannel(const QString &identifier);
0096     LIBRUQOLAWIDGETS_NO_EXPORT void undoSwitchChannel();
0097     LIBRUQOLAWIDGETS_NO_EXPORT void redoSwitchChannel();
0098     LIBRUQOLAWIDGETS_NO_EXPORT void slotToggleMenubar(bool dontShowWarning);
0099     LIBRUQOLAWIDGETS_NO_EXPORT void updateHamburgerMenu();
0100     LIBRUQOLAWIDGETS_NO_EXPORT void slotFullScreen(bool t);
0101     LIBRUQOLAWIDGETS_NO_EXPORT void slotOpenNotificationHistory();
0102     LIBRUQOLAWIDGETS_NO_EXPORT void slotNewNotification();
0103     LIBRUQOLAWIDGETS_NO_EXPORT void slotShowNotifyMessage(const QString &accountName, const QString &messageId, const QString &roomId);
0104     LIBRUQOLAWIDGETS_NO_EXPORT void slotAdministratorServerSettings();
0105     LIBRUQOLAWIDGETS_NO_EXPORT void slotRocketChatInformation();
0106     [[nodiscard]] LIBRUQOLAWIDGETS_NO_EXPORT bool hasBannerInfo() const;
0107     LIBRUQOLAWIDGETS_NO_EXPORT void slotShowRoomAvatar(bool checked);
0108     LIBRUQOLAWIDGETS_NO_EXPORT void slotPrivateSettingsChanged();
0109     LIBRUQOLAWIDGETS_NO_EXPORT void slotShowFavoriteRoom(bool checked);
0110     LIBRUQOLAWIDGETS_NO_EXPORT void slotShowServerInfo();
0111     LIBRUQOLAWIDGETS_NO_EXPORT void slotWhatsNew();
0112     LIBRUQOLAWIDGETS_NO_EXPORT void slotShowDatabaseMessages();
0113     LIBRUQOLAWIDGETS_NO_EXPORT void slotShowPermissions();
0114     LIBRUQOLAWIDGETS_NO_EXPORT void slotImportAccounts();
0115     LIBRUQOLAWIDGETS_NO_EXPORT void slotExportAccounts();
0116     LIBRUQOLAWIDGETS_NO_EXPORT void slotMessageStyleChanged();
0117     LIBRUQOLAWIDGETS_NO_EXPORT void slotAuthentication(AuthenticationManager::AuthMethodType type);
0118 
0119     bool mReallyClose{false};
0120 
0121     RuqolaCentralWidget *const mMainWidget;
0122     QAction *mServerInfo = nullptr;
0123     QAction *mLogout = nullptr;
0124     QAction *mNextUnreadChannel = nullptr;
0125     QAction *mCreateNewChannel = nullptr;
0126     QAction *mCreateDirectMessages = nullptr;
0127     QAction *mUnreadOnTop = nullptr;
0128     QAction *mRoomListSortByLastMessage = nullptr;
0129     QAction *mRoomListSortAlphabetically = nullptr;
0130     QAction *mShowLog = nullptr;
0131     QAction *mShowServerInfo = nullptr;
0132     QAction *mClearAlerts = nullptr;
0133     QAction *mRegisterNewUser = nullptr;
0134     QAction *mMyAccount = nullptr;
0135     QAction *mAdministrator = nullptr;
0136     QAction *mAdministratorServerSettings = nullptr;
0137     QAction *mCreateDiscussion = nullptr;
0138     QAction *mCreateTeam = nullptr;
0139     QAction *mDirectory = nullptr;
0140     QAction *mNextTab = nullptr;
0141     QAction *mPreviewTab = nullptr;
0142     QWidgetAction *mStatus = nullptr;
0143     ServerMenu *mServerMenu = nullptr;
0144     QPointer<RocketChatAccount> mCurrentRocketChatAccount;
0145     QLabel *mStatusBarTypingMessage = nullptr;
0146     AccountsOverviewWidget *mAccountOverviewWidget = nullptr;
0147     Notification *mNotification = nullptr;
0148     QMenu *mContextStatusMenu = nullptr;
0149     StatusCombobox *mStatusComboBox = nullptr;
0150     StatusModelFilterProxyModel *mStatusProxyModel = nullptr;
0151     SwitchChannelTreeViewManager *const mSwitchChannelTreeManager;
0152     KToggleAction *mShowMenuBarAction = nullptr;
0153     KHamburgerMenu *mHamburgerMenu = nullptr;
0154     KToggleFullScreenAction *mShowFullScreenAction = nullptr;
0155     QToolButton *mNotificationToolButton = nullptr;
0156     QAction *mShowNotifyHistory = nullptr;
0157     KActionMenu *mAdministratorMenu = nullptr;
0158     AccountManager *mAccountManager = nullptr;
0159     QAction *mShowRocketChatServerInfo = nullptr;
0160     QAction *mRoomAvatar = nullptr;
0161     QAction *mRoomFavorite = nullptr;
0162     QAction *mShowDatabaseMessages = nullptr;
0163     QAction *mMenuDebug = nullptr;
0164     QAction *mShowPermissions = nullptr;
0165 
0166     QAction *mImportAccountsAction = nullptr;
0167     QAction *mExportAccountsAction = nullptr;
0168 };