2006-09-30 20:02:39 +04:00
|
|
|
/*
|
2016-01-24 13:16:25 +03:00
|
|
|
* Bittorrent Client using Qt and libtorrent.
|
2007-07-14 18:31:59 +04:00
|
|
|
* Copyright (C) 2006 Christophe Dumez
|
2006-09-30 20:02:39 +04:00
|
|
|
*
|
2007-07-14 18:31:59 +04:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2006-09-30 20:02:39 +04:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2007-07-14 18:31:59 +04:00
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
2009-04-05 21:00:55 +04:00
|
|
|
* In addition, as a special exception, the copyright holders give permission to
|
|
|
|
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
|
|
|
* modified versions of it that use the same license as the "OpenSSL" library),
|
|
|
|
* and distribute the linked executables. You must obey the GNU General Public
|
|
|
|
* License in all respects for all of the code used other than "OpenSSL". If you
|
|
|
|
* modify file(s), you may extend this exception to your version of the file(s),
|
|
|
|
* but you are not obligated to do so. If you do not wish to do so, delete this
|
|
|
|
* exception statement from your version.
|
|
|
|
*
|
2007-07-14 18:31:59 +04:00
|
|
|
* Contact : chris@qbittorrent.org
|
2006-09-30 20:02:39 +04:00
|
|
|
*/
|
|
|
|
|
2016-01-24 13:16:25 +03:00
|
|
|
#ifndef MAINWINDOW_H
|
|
|
|
#define MAINWINDOW_H
|
2006-09-30 20:02:39 +04:00
|
|
|
|
2016-01-24 13:16:25 +03:00
|
|
|
#include <QMainWindow>
|
2008-09-13 11:33:41 +04:00
|
|
|
#include <QPointer>
|
2016-01-24 13:16:25 +03:00
|
|
|
|
2017-06-12 22:47:28 +03:00
|
|
|
#ifndef Q_OS_MAC
|
|
|
|
#include <QSystemTrayIcon>
|
|
|
|
#endif
|
|
|
|
|
2016-01-24 13:16:25 +03:00
|
|
|
class QCloseEvent;
|
|
|
|
class QFileSystemWatcher;
|
|
|
|
class QShortcut;
|
|
|
|
class QSplitter;
|
|
|
|
class QTabWidget;
|
|
|
|
class QTimer;
|
2007-02-19 19:34:23 +03:00
|
|
|
|
2006-09-30 20:02:39 +04:00
|
|
|
class downloadFromURL;
|
2015-08-26 20:05:57 +03:00
|
|
|
class SearchWidget;
|
2017-03-07 16:10:42 +03:00
|
|
|
class RSSWidget;
|
2007-07-23 16:46:36 +04:00
|
|
|
class about;
|
2016-04-25 10:54:38 +03:00
|
|
|
class OptionsDialog;
|
2009-11-07 22:55:33 +03:00
|
|
|
class TransferListWidget;
|
2009-11-08 15:05:35 +03:00
|
|
|
class TransferListFiltersWidget;
|
2009-11-08 17:20:58 +03:00
|
|
|
class PropertiesWidget;
|
2009-11-18 16:18:55 +03:00
|
|
|
class StatusBar;
|
2010-10-23 00:13:22 +04:00
|
|
|
class TorrentCreatorDlg;
|
2010-08-20 16:27:20 +04:00
|
|
|
class LineEdit;
|
2010-12-20 21:07:36 +03:00
|
|
|
class ExecutionLog;
|
2011-02-06 17:27:34 +03:00
|
|
|
class PowerManagement;
|
2016-01-24 13:16:25 +03:00
|
|
|
class StatsDialog;
|
2011-02-27 18:41:05 +03:00
|
|
|
|
2015-04-19 18:17:47 +03:00
|
|
|
namespace BitTorrent
|
|
|
|
{
|
|
|
|
class TorrentHandle;
|
|
|
|
}
|
|
|
|
|
2016-01-24 13:16:25 +03:00
|
|
|
namespace Ui
|
|
|
|
{
|
|
|
|
class MainWindow;
|
|
|
|
}
|
|
|
|
|
2017-01-08 03:46:01 +03:00
|
|
|
class MainWindow: public QMainWindow
|
2014-12-20 20:53:58 +03:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2006-09-30 20:02:39 +04:00
|
|
|
|
2010-03-03 17:48:49 +03:00
|
|
|
public:
|
2015-01-22 15:56:16 +03:00
|
|
|
explicit MainWindow(QWidget *parent = 0);
|
2016-01-24 13:16:25 +03:00
|
|
|
~MainWindow() override;
|
|
|
|
|
2017-01-08 03:46:01 +03:00
|
|
|
QWidget *currentTabWidget() const;
|
|
|
|
TransferListWidget *transferListWidget() const;
|
2016-01-24 13:16:25 +03:00
|
|
|
PropertiesWidget *propertiesWidget() const;
|
2017-01-08 03:46:01 +03:00
|
|
|
QMenu *trayIconMenu();
|
2010-03-03 17:48:49 +03:00
|
|
|
|
2016-03-14 15:39:13 +03:00
|
|
|
// ExecutionLog properties
|
|
|
|
bool isExecutionLogEnabled() const;
|
|
|
|
void setExecutionLogEnabled(bool value);
|
|
|
|
int executionLogMsgTypes() const;
|
|
|
|
void setExecutionLogMsgTypes(const int value);
|
|
|
|
|
2016-04-17 22:56:51 +03:00
|
|
|
// Notifications properties
|
|
|
|
bool isNotificationsEnabled() const;
|
|
|
|
void setNotificationsEnabled(bool value);
|
|
|
|
bool isTorrentAddedNotificationsEnabled() const;
|
|
|
|
void setTorrentAddedNotificationsEnabled(bool value);
|
|
|
|
|
2016-11-13 23:46:17 +03:00
|
|
|
// Misc properties
|
|
|
|
bool isDownloadTrackerFavicon() const;
|
|
|
|
void setDownloadTrackerFavicon(bool value);
|
|
|
|
|
2015-01-22 15:56:16 +03:00
|
|
|
void activate();
|
2015-04-16 00:47:59 +03:00
|
|
|
void cleanup();
|
2006-09-30 20:02:39 +04:00
|
|
|
|
2016-01-24 13:16:25 +03:00
|
|
|
void showNotificationBaloon(QString title, QString msg) const;
|
|
|
|
|
|
|
|
private slots:
|
2014-12-20 20:53:58 +03:00
|
|
|
void balloonClicked();
|
|
|
|
void writeSettings();
|
|
|
|
void readSettings();
|
2015-04-19 18:17:47 +03:00
|
|
|
void fullDiskError(BitTorrent::TorrentHandle *const torrent, QString msg) const;
|
2014-12-20 20:53:58 +03:00
|
|
|
void handleDownloadFromUrlFailure(QString, QString) const;
|
2016-01-24 13:16:25 +03:00
|
|
|
void tabChanged(int newTab);
|
2014-12-20 20:53:58 +03:00
|
|
|
void defineUILockPassword();
|
|
|
|
void clearUILockPassword();
|
|
|
|
bool unlockUI();
|
|
|
|
void notifyOfUpdate(QString);
|
|
|
|
void showConnectionSettings();
|
|
|
|
void minimizeWindow();
|
|
|
|
// Keyboard shortcuts
|
|
|
|
void createKeyboardShortcuts();
|
|
|
|
void displayTransferTab() const;
|
2017-01-26 22:01:19 +03:00
|
|
|
void displaySearchTab();
|
|
|
|
void displayRSSTab();
|
|
|
|
void displayExecutionLogTab();
|
2016-11-11 17:32:58 +03:00
|
|
|
void focusSearchFilter();
|
2014-12-20 20:53:58 +03:00
|
|
|
void updateGUI();
|
2016-01-24 13:16:25 +03:00
|
|
|
void loadPreferences(bool configureSession = true);
|
2017-01-08 03:46:01 +03:00
|
|
|
void addUnauthenticatedTracker(const QPair<BitTorrent::TorrentHandle *, QString> &tracker);
|
2015-04-19 18:17:47 +03:00
|
|
|
void addTorrentFailed(const QString &error) const;
|
2016-04-30 01:38:24 +03:00
|
|
|
void torrentNew(BitTorrent::TorrentHandle *const torrent) const;
|
2015-04-19 18:17:47 +03:00
|
|
|
void finishedTorrent(BitTorrent::TorrentHandle *const torrent) const;
|
|
|
|
void askRecursiveTorrentDownloadConfirmation(BitTorrent::TorrentHandle *const torrent);
|
2014-12-20 20:53:58 +03:00
|
|
|
void optionsSaved();
|
2013-09-21 11:59:58 +04:00
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
|
2016-01-24 13:16:25 +03:00
|
|
|
void handleUpdateCheckFinished(bool updateAvailable, QString newVersion, bool invokedByUser);
|
2010-10-24 01:46:05 +04:00
|
|
|
#endif
|
2017-05-25 17:50:05 +03:00
|
|
|
void toggleAlternativeSpeeds();
|
2009-03-28 01:25:34 +03:00
|
|
|
|
2016-01-24 10:46:57 +03:00
|
|
|
#ifdef Q_OS_WIN
|
2015-04-19 18:17:47 +03:00
|
|
|
void pythonDownloadSuccess(const QString &url, const QString &filePath);
|
|
|
|
void pythonDownloadFailure(const QString &url, const QString &error);
|
2014-09-14 15:30:22 +04:00
|
|
|
#endif
|
2014-10-18 18:18:58 +04:00
|
|
|
void addToolbarContextMenu();
|
2016-01-23 15:12:13 +03:00
|
|
|
void manageCookies();
|
2011-03-12 23:59:44 +03:00
|
|
|
|
2016-01-24 13:16:25 +03:00
|
|
|
void trackerAuthenticationRequired(BitTorrent::TorrentHandle *const torrent);
|
|
|
|
void downloadFromURLList(const QStringList &urlList);
|
|
|
|
void updateAltSpeedsBtn(bool alternative);
|
|
|
|
void updateNbTorrents();
|
2017-03-07 16:10:42 +03:00
|
|
|
void handleRSSUnreadCountUpdated(int count);
|
2010-06-21 22:32:01 +04:00
|
|
|
|
2016-01-24 13:16:25 +03:00
|
|
|
void on_actionSearchWidget_triggered();
|
|
|
|
void on_actionRSSReader_triggered();
|
|
|
|
void on_actionSpeedInTitleBar_triggered();
|
|
|
|
void on_actionTopToolBar_triggered();
|
2015-10-30 16:03:44 +03:00
|
|
|
void on_actionShowStatusbar_triggered();
|
2016-01-24 13:16:25 +03:00
|
|
|
void on_actionDonateMoney_triggered();
|
2016-01-24 22:38:45 +03:00
|
|
|
void on_actionExecutionLogs_triggered(bool checked);
|
|
|
|
void on_actionNormalMessages_triggered(bool checked);
|
|
|
|
void on_actionInformationMessages_triggered(bool checked);
|
|
|
|
void on_actionWarningMessages_triggered(bool checked);
|
|
|
|
void on_actionCriticalMessages_triggered(bool checked);
|
2016-01-24 13:16:25 +03:00
|
|
|
void on_actionAutoExit_toggled(bool);
|
|
|
|
void on_actionAutoSuspend_toggled(bool);
|
|
|
|
void on_actionAutoHibernate_toggled(bool);
|
|
|
|
void on_actionAutoShutdown_toggled(bool);
|
|
|
|
void on_actionAbout_triggered();
|
|
|
|
void on_actionStatistics_triggered();
|
|
|
|
void on_actionCreateTorrent_triggered();
|
|
|
|
void on_actionOptions_triggered();
|
|
|
|
void on_actionSetGlobalUploadLimit_triggered();
|
|
|
|
void on_actionSetGlobalDownloadLimit_triggered();
|
|
|
|
void on_actionDocumentation_triggered() const;
|
|
|
|
void on_actionOpen_triggered();
|
|
|
|
void on_actionDownloadFromURL_triggered();
|
|
|
|
void on_actionExit_triggered();
|
|
|
|
void on_actionLock_triggered();
|
2011-02-06 17:27:34 +03:00
|
|
|
// Check for active torrents and set preventing from suspend state
|
|
|
|
void checkForActiveTorrents();
|
2013-09-21 11:59:58 +04:00
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
|
2013-11-23 16:58:03 +04:00
|
|
|
void checkProgramUpdate();
|
|
|
|
#endif
|
2014-10-18 18:18:58 +04:00
|
|
|
void toolbarMenuRequested(QPoint);
|
|
|
|
void toolbarIconsOnly();
|
|
|
|
void toolbarTextOnly();
|
|
|
|
void toolbarTextBeside();
|
|
|
|
void toolbarTextUnder();
|
|
|
|
void toolbarFollowSystem();
|
2017-07-16 06:49:06 +03:00
|
|
|
#ifndef Q_OS_MAC
|
|
|
|
void toggleVisibility(const QSystemTrayIcon::ActivationReason reason = QSystemTrayIcon::Trigger);
|
|
|
|
void createSystrayDelayed();
|
|
|
|
void updateTrayIconMenu();
|
|
|
|
#endif
|
2006-09-30 20:02:39 +04:00
|
|
|
|
2016-01-24 13:16:25 +03:00
|
|
|
private:
|
2017-06-12 22:47:28 +03:00
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
void setupDockClickHandler();
|
|
|
|
#else
|
|
|
|
void createTrayIcon();
|
2016-01-24 13:16:25 +03:00
|
|
|
QIcon getSystrayIcon() const;
|
2017-06-12 22:47:28 +03:00
|
|
|
#endif
|
2016-01-24 13:16:25 +03:00
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
bool addPythonPathToEnv();
|
|
|
|
void installPython();
|
2006-09-30 20:02:39 +04:00
|
|
|
#endif
|
2016-01-24 13:16:25 +03:00
|
|
|
|
|
|
|
void dropEvent(QDropEvent *event) override;
|
|
|
|
void dragEnterEvent(QDragEnterEvent *event) override;
|
|
|
|
void closeEvent(QCloseEvent *) override;
|
|
|
|
void showEvent(QShowEvent *) override;
|
2017-05-09 08:55:24 +03:00
|
|
|
bool event(QEvent *e) override;
|
2016-01-24 13:16:25 +03:00
|
|
|
void displayRSSTab(bool enable);
|
|
|
|
void displaySearchTab(bool enable);
|
2016-04-28 14:06:02 +03:00
|
|
|
void createTorrentTriggered(const QString &path = QString());
|
2017-05-25 17:50:05 +03:00
|
|
|
void showStatusBar(bool show);
|
2016-01-24 13:16:25 +03:00
|
|
|
|
|
|
|
Ui::MainWindow *m_ui;
|
|
|
|
|
|
|
|
QFileSystemWatcher *m_executableWatcher;
|
|
|
|
// Bittorrent
|
2017-01-08 03:46:01 +03:00
|
|
|
QList<QPair<BitTorrent::TorrentHandle *, QString >> m_unauthenticatedTrackers; // Still needed?
|
2016-01-24 13:16:25 +03:00
|
|
|
// GUI related
|
|
|
|
bool m_posInitialized;
|
2017-03-07 16:10:42 +03:00
|
|
|
QPointer<QTabWidget> m_tabs;
|
2017-05-25 17:50:05 +03:00
|
|
|
QPointer<StatusBar> m_statusBar;
|
2016-04-25 10:54:38 +03:00
|
|
|
QPointer<OptionsDialog> m_options;
|
2016-01-24 13:16:25 +03:00
|
|
|
QPointer<about> m_aboutDlg;
|
|
|
|
QPointer<StatsDialog> m_statsDlg;
|
|
|
|
QPointer<TorrentCreatorDlg> m_createTorrentDlg;
|
|
|
|
QPointer<downloadFromURL> m_downloadFromURLDialog;
|
2017-06-12 22:47:28 +03:00
|
|
|
#ifndef Q_OS_MAC
|
2016-01-24 13:16:25 +03:00
|
|
|
QPointer<QSystemTrayIcon> m_systrayIcon;
|
|
|
|
QPointer<QTimer> m_systrayCreator;
|
2017-06-12 22:47:28 +03:00
|
|
|
#endif
|
2016-01-24 13:16:25 +03:00
|
|
|
QPointer<QMenu> m_trayIconMenu;
|
|
|
|
TransferListWidget *m_transferListWidget;
|
|
|
|
TransferListFiltersWidget *m_transferListFiltersWidget;
|
|
|
|
PropertiesWidget *m_propertiesWidget;
|
|
|
|
bool m_displaySpeedInTitle;
|
|
|
|
bool m_forceExit;
|
|
|
|
bool m_uiLocked;
|
|
|
|
bool m_unlockDlgShowing;
|
|
|
|
LineEdit *m_searchFilter;
|
|
|
|
QAction *m_searchFilterAction;
|
|
|
|
// Widgets
|
|
|
|
QAction *m_prioSeparator;
|
|
|
|
QAction *m_prioSeparatorMenu;
|
|
|
|
QSplitter *m_splitter;
|
|
|
|
QPointer<SearchWidget> m_searchWidget;
|
2017-03-07 16:10:42 +03:00
|
|
|
QPointer<RSSWidget> m_rssWidget;
|
2016-01-24 13:16:25 +03:00
|
|
|
QPointer<ExecutionLog> m_executionLog;
|
|
|
|
// Power Management
|
|
|
|
PowerManagement *m_pwr;
|
|
|
|
QTimer *m_preventTimer;
|
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
|
|
|
|
QTimer *m_programUpdateTimer;
|
|
|
|
bool m_wasUpdateCheckEnabled;
|
|
|
|
#endif
|
|
|
|
bool m_hasPython;
|
|
|
|
QMenu *m_toolbarMenu;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MAINWINDOW_H
|