11/*
2- * Bittorrent Client using Qt4 and libtorrent.
2+ * Bittorrent Client using Qt and libtorrent.
33 * Copyright (C) 2006 Christophe Dumez
44 *
55 * This program is free software; you can redistribute it and/or
2828 * Contact : chris@qbittorrent.org
2929 */
3030
31- #ifndef GUI_H
32- #define GUI_H
31+ #ifndef MAINWINDOW_H
32+ #define MAINWINDOW_H
3333
34- #include < QProcess >
34+ #include < QMainWindow >
3535#include < QSystemTrayIcon>
3636#include < QPointer>
37- #include " ui_mainwindow.h"
38- #include " statsdialog.h"
37+
38+ class QCloseEvent ;
39+ class QFileSystemWatcher ;
40+ class QShortcut ;
41+ class QSplitter ;
42+ class QTabWidget ;
43+ class QTimer ;
3944
4045class downloadFromURL ;
4146class SearchWidget ;
@@ -52,67 +57,53 @@ class downloadFromURL;
5257class LineEdit ;
5358class ExecutionLog ;
5459class PowerManagement ;
55-
56- QT_BEGIN_NAMESPACE
57- class QCloseEvent ;
58- class QFileSystemWatcher ;
59- class QShortcut ;
60- class QSplitter ;
61- class QTabWidget ;
62- class QTimer ;
63- QT_END_NAMESPACE
60+ class StatsDialog ;
6461
6562namespace BitTorrent
6663{
6764 class TorrentHandle ;
6865}
6966
70- class MainWindow : public QMainWindow , private Ui ::MainWindow
67+ namespace Ui
68+ {
69+ class MainWindow ;
70+ }
71+
72+ class MainWindow : public QMainWindow
7173{
7274 Q_OBJECT
7375
7476public:
75- // Construct / Destruct
7677 explicit MainWindow (QWidget *parent = 0 );
77- ~MainWindow ();
78- // Methods
79- QWidget* getCurrentTabWidget () const ;
80- TransferListWidget* getTransferList () const { return transferList; }
81- QMenu* getTrayIconMenu () ;
82- PropertiesWidget * getProperties () const { return properties; }
78+ ~MainWindow () override ;
79+
80+ QWidget* currentTabWidget () const ;
81+ TransferListWidget* transferListWidget () const ;
82+ PropertiesWidget * propertiesWidget () const ;
83+ QMenu* trayIconMenu ();
8384
8485 // ExecutionLog properties
8586 bool isExecutionLogEnabled () const ;
8687 void setExecutionLogEnabled (bool value);
8788 int executionLogMsgTypes () const ;
8889 void setExecutionLogMsgTypes (const int value);
8990
90- public slots:
91- void trackerAuthenticationRequired (BitTorrent::TorrentHandle *const torrent);
92- void setTabText (int index, QString text) const ;
93- void showNotificationBaloon (QString title, QString msg) const ;
94- void downloadFromURLList (const QStringList& urls);
95- void updateAltSpeedsBtn (bool alternative);
96- void updateNbTorrents ();
9791 void activate ();
9892 void cleanup ();
9993
100- protected slots:
101- // GUI related slots
94+ void showNotificationBaloon (QString title, QString msg) const ;
95+
96+ private slots:
10297 void toggleVisibility (QSystemTrayIcon::ActivationReason e = QSystemTrayIcon::Trigger);
103- void on_actionAbout_triggered ();
104- void on_actionStatistics_triggered ();
105- void on_actionCreate_torrent_triggered ();
98+
10699 void balloonClicked ();
107100 void writeSettings ();
108101 void readSettings ();
109- void on_actionExit_triggered ();
110102 void createTrayIcon ();
111103 void fullDiskError (BitTorrent::TorrentHandle *const torrent, QString msg) const ;
112104 void handleDownloadFromUrlFailure (QString, QString) const ;
113105 void createSystrayDelayed ();
114- void tab_changed (int );
115- void on_actionLock_qBittorrent_triggered ();
106+ void tabChanged (int newTab);
116107 void defineUILockPassword ();
117108 void clearUILockPassword ();
118109 bool unlockUI ();
@@ -125,112 +116,56 @@ protected slots:
125116 void displayTransferTab () const ;
126117 void displaySearchTab () const ;
127118 void displayRSSTab () const ;
128- // Torrent actions
129- void on_actionSet_global_upload_limit_triggered ();
130- void on_actionSet_global_download_limit_triggered ();
131- void on_actionDocumentation_triggered () const ;
132- void on_actionOpen_triggered ();
133119 void updateGUI ();
134- void loadPreferences (bool configure_session = true );
120+ void loadPreferences (bool configureSession = true );
135121 void addUnauthenticatedTracker (const QPair<BitTorrent::TorrentHandle*, QString> &tracker);
136122 void addTorrentFailed (const QString &error) const ;
137123 void finishedTorrent (BitTorrent::TorrentHandle *const torrent) const ;
138124 void askRecursiveTorrentDownloadConfirmation (BitTorrent::TorrentHandle *const torrent);
139- // Options slots
140- void on_actionOptions_triggered ();
141125 void optionsSaved ();
142- // HTTP slots
143- void on_actionDownload_from_URL_triggered ();
144126#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
145- void handleUpdateCheckFinished (bool update_available , QString new_version , bool invokedByUser);
127+ void handleUpdateCheckFinished (bool updateAvailable , QString newVersion , bool invokedByUser);
146128#endif
147129 void updateRSSTabLabel (int count);
148130
149- protected:
150- void dropEvent (QDropEvent *event);
151- void dragEnterEvent (QDragEnterEvent *event);
152- void closeEvent (QCloseEvent *);
153- void showEvent (QShowEvent *);
154- bool event (QEvent * event);
155- void displayRSSTab (bool enable);
156- void displaySearchTab (bool enable);
157-
158- private slots:
159131#ifdef Q_OS_WIN
160132 void pythonDownloadSuccess (const QString &url, const QString &filePath);
161133 void pythonDownloadFailure (const QString &url, const QString &error);
162134#endif
163135 void addToolbarContextMenu ();
164136 void manageCookies ();
165137
166- private:
167- QIcon getSystrayIcon () const ;
168- #ifdef Q_OS_WIN
169- bool addPythonPathToEnv ();
170- void installPython ();
171- #endif
172-
173- QFileSystemWatcher *executable_watcher;
174- // Bittorrent
175- QList<QPair<BitTorrent::TorrentHandle*, QString>> unauthenticated_trackers; // Still needed?
176- // GUI related
177- bool m_posInitialized;
178- QTabWidget *tabs;
179- StatusBar *status_bar;
180- QPointer<options_imp> options;
181- QPointer<about> aboutDlg;
182- QPointer<StatsDialog> statsDlg;
183- QPointer<TorrentCreatorDlg> createTorrentDlg;
184- QPointer<downloadFromURL> downloadFromURLDialog;
185- QPointer<QSystemTrayIcon> systrayIcon;
186- QPointer<QTimer> systrayCreator;
187- QPointer<QMenu> myTrayIconMenu;
188- TransferListWidget *transferList;
189- TransferListFiltersWidget *transferListFilters;
190- PropertiesWidget *properties;
191- bool displaySpeedInTitle;
192- bool force_exit;
193- bool ui_locked;
194- bool unlockDlgShowing;
195- LineEdit *search_filter;
196- QAction *searchFilterAct;
197- // Widgets
198- QAction *prioSeparator;
199- QAction *prioSeparatorMenu;
200- QSplitter *hSplitter;
201- QSplitter *vSplitter;
202- // Search
203- QPointer<SearchWidget> searchEngine;
204- // RSS
205- QPointer<RSSImp> rssWidget;
206- // Execution Log
207- QPointer<ExecutionLog> m_executionLog;
208- // Power Management
209- PowerManagement *m_pwr;
210- QTimer *preventTimer;
211- #if defined(Q_OS_WIN) || defined(Q_OS_MAC)
212- QTimer programUpdateTimer;
213- bool m_wasUpdateCheckEnabled;
214- #endif
215- bool has_python;
216- QMenu* toolbarMenu;
138+ void trackerAuthenticationRequired (BitTorrent::TorrentHandle *const torrent);
139+ void downloadFromURLList (const QStringList &urlList);
140+ void updateAltSpeedsBtn (bool alternative);
141+ void updateNbTorrents ();
217142
218- private slots:
219- void on_actionSearch_engine_triggered ();
220- void on_actionRSS_Reader_triggered ();
221- void on_actionSpeed_in_title_bar_triggered ();
222- void on_actionTop_tool_bar_triggered ();
223- void on_action_Import_Torrent_triggered ();
224- void on_actionDonate_money_triggered ();
143+ void on_actionSearchWidget_triggered ();
144+ void on_actionRSSReader_triggered ();
145+ void on_actionSpeedInTitleBar_triggered ();
146+ void on_actionTopToolBar_triggered ();
147+ void on_actionImportTorrent_triggered ();
148+ void on_actionDonateMoney_triggered ();
225149 void on_actionExecutionLogs_triggered (bool checked);
226150 void on_actionNormalMessages_triggered (bool checked);
227151 void on_actionInformationMessages_triggered (bool checked);
228152 void on_actionWarningMessages_triggered (bool checked);
229153 void on_actionCriticalMessages_triggered (bool checked);
230- void on_actionAutoExit_qBittorrent_toggled (bool );
231- void on_actionAutoSuspend_system_toggled (bool );
232- void on_actionAutoHibernate_system_toggled (bool );
233- void on_actionAutoShutdown_system_toggled (bool );
154+ void on_actionAutoExit_toggled (bool );
155+ void on_actionAutoSuspend_toggled (bool );
156+ void on_actionAutoHibernate_toggled (bool );
157+ void on_actionAutoShutdown_toggled (bool );
158+ void on_actionAbout_triggered ();
159+ void on_actionStatistics_triggered ();
160+ void on_actionCreateTorrent_triggered ();
161+ void on_actionOptions_triggered ();
162+ void on_actionSetGlobalUploadLimit_triggered ();
163+ void on_actionSetGlobalDownloadLimit_triggered ();
164+ void on_actionDocumentation_triggered () const ;
165+ void on_actionOpen_triggered ();
166+ void on_actionDownloadFromURL_triggered ();
167+ void on_actionExit_triggered ();
168+ void on_actionLock_triggered ();
234169 // Check for active torrents and set preventing from suspend state
235170 void checkForActiveTorrents ();
236171#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
@@ -242,6 +177,64 @@ private slots:
242177 void toolbarTextBeside ();
243178 void toolbarTextUnder ();
244179 void toolbarFollowSystem ();
245- };
246180
181+ private:
182+ QIcon getSystrayIcon () const ;
183+ #ifdef Q_OS_WIN
184+ bool addPythonPathToEnv ();
185+ void installPython ();
247186#endif
187+
188+ void dropEvent (QDropEvent *event) override ;
189+ void dragEnterEvent (QDragEnterEvent *event) override ;
190+ void closeEvent (QCloseEvent *) override ;
191+ void showEvent (QShowEvent *) override ;
192+ bool event (QEvent * event) override ;
193+ void displayRSSTab (bool enable);
194+ void displaySearchTab (bool enable);
195+
196+ Ui::MainWindow *m_ui;
197+
198+ QFileSystemWatcher *m_executableWatcher;
199+ // Bittorrent
200+ QList<QPair<BitTorrent::TorrentHandle*, QString>> m_unauthenticatedTrackers; // Still needed?
201+ // GUI related
202+ bool m_posInitialized;
203+ QTabWidget *m_tabs;
204+ StatusBar *m_statusBar;
205+ QPointer<options_imp> m_options;
206+ QPointer<about> m_aboutDlg;
207+ QPointer<StatsDialog> m_statsDlg;
208+ QPointer<TorrentCreatorDlg> m_createTorrentDlg;
209+ QPointer<downloadFromURL> m_downloadFromURLDialog;
210+ QPointer<QSystemTrayIcon> m_systrayIcon;
211+ QPointer<QTimer> m_systrayCreator;
212+ QPointer<QMenu> m_trayIconMenu;
213+ TransferListWidget *m_transferListWidget;
214+ TransferListFiltersWidget *m_transferListFiltersWidget;
215+ PropertiesWidget *m_propertiesWidget;
216+ bool m_displaySpeedInTitle;
217+ bool m_forceExit;
218+ bool m_uiLocked;
219+ bool m_unlockDlgShowing;
220+ LineEdit *m_searchFilter;
221+ QAction *m_searchFilterAction;
222+ // Widgets
223+ QAction *m_prioSeparator;
224+ QAction *m_prioSeparatorMenu;
225+ QSplitter *m_splitter;
226+ QPointer<SearchWidget> m_searchWidget;
227+ QPointer<RSSImp> m_rssWidget;
228+ QPointer<ExecutionLog> m_executionLog;
229+ // Power Management
230+ PowerManagement *m_pwr;
231+ QTimer *m_preventTimer;
232+ #if defined(Q_OS_WIN) || defined(Q_OS_MAC)
233+ QTimer *m_programUpdateTimer;
234+ bool m_wasUpdateCheckEnabled;
235+ #endif
236+ bool m_hasPython;
237+ QMenu *m_toolbarMenu;
238+ };
239+
240+ #endif // MAINWINDOW_H
0 commit comments