| 1 | // For license of this file, see <project-root-folder>/LICENSE.md. |
| 2 | |
| 3 | #ifndef FORMMAIN_H |
| 4 | #define FORMMAIN_H |
| 5 | |
| 6 | #include "ui_formmain.h" |
| 7 | |
| 8 | #include <QMainWindow> |
| 9 | |
| 10 | class StatusBar; |
| 11 | class QWidgetAction; |
| 12 | |
| 13 | class RSSGUARD_DLLSPEC FormMain : public QMainWindow { |
| 14 | Q_OBJECT |
| 15 | |
| 16 | friend class TabWidget; |
| 17 | friend class MessagesView; |
| 18 | friend class FeedsView; |
| 19 | |
| 20 | public: |
| 21 | explicit FormMain(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowType::Widget); |
| 22 | virtual ~FormMain(); |
| 23 | |
| 24 | // Returns menu for the tray icon. |
| 25 | QMenu* trayMenu() const; |
| 26 | |
| 27 | // Returns global tab widget. |
| 28 | TabWidget* tabWidget() const; |
| 29 | |
| 30 | // Access to statusbar. |
| 31 | StatusBar* statusBar() const; |
| 32 | |
| 33 | // Returns list of all globally available actions. |
| 34 | // NOTE: This is used for setting dynamic shortcuts |
| 35 | // for given actions. |
| 36 | QList<QAction*> allActions() const; |
| 37 | |
| 38 | // Loads/saves visual state of the application. |
| 39 | void loadSize(); |
| 40 | void saveSize(); |
| 41 | |
| 42 | public slots: |
| 43 | void display(); |
| 44 | void switchVisibility(bool force_hide = false); |
| 45 | void switchFullscreenMode(); |
| 46 | void showAddAccountDialog(); |
| 47 | |
| 48 | private slots: |
| 49 | void updateAddItemMenu(); |
| 50 | void updateRecycleBinMenu(); |
| 51 | void updateAccountsMenu(); |
| 52 | |
| 53 | void updateTabsButtonsAvailability(int index); |
| 54 | void updateMessageButtonsAvailability(); |
| 55 | void updateFeedButtonsAvailability(); |
| 56 | |
| 57 | void onFeedUpdatesStarted(); |
| 58 | void onFeedUpdatesProgress(const Feed* feed, int current, int total); |
| 59 | void onFeedUpdatesFinished(const FeedDownloadResults& results); |
| 60 | |
| 61 | // Displays various dialogs. |
| 62 | void backupDatabaseSettings(); |
| 63 | void restoreDatabaseSettings(); |
| 64 | void showDocs(); |
| 65 | void showDbCleanupAssistant(); |
| 66 | void reportABug(); |
| 67 | void donate(); |
| 68 | |
| 69 | protected: |
| 70 | virtual void resizeEvent(QResizeEvent* event); |
| 71 | virtual void changeEvent(QEvent* event); |
| 72 | virtual void closeEvent(QCloseEvent* event); |
| 73 | virtual void showEvent(QShowEvent* event); |
| 74 | virtual void hideEvent(QHideEvent* event); |
| 75 | |
| 76 | signals: |
| 77 | void windowResized(const QSize& new_size); |
| 78 | |
| 79 | private: |
| 80 | void prepareMenus(); |
| 81 | void createConnections(); |
| 82 | void setupIcons(); |
| 83 | |
| 84 | QScopedPointer<Ui::FormMain> m_ui; |
| 85 | QMenu* m_trayMenu; |
| 86 | QWidgetAction* m_actionToolbarMainMenu; |
| 87 | StatusBar* m_statusBar; |
| 88 | }; |
| 89 | |
| 90 | #endif // FORMMAIN_H |