2006-09-30 20:02:39 +04:00
|
|
|
/*
|
2016-01-24 13:16:25 +03:00
|
|
|
* Bittorrent Client using Qt and libtorrent.
|
2018-06-06 16:48:17 +03:00
|
|
|
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
|
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.
|
2006-09-30 20:02:39 +04:00
|
|
|
*/
|
|
|
|
|
2020-12-10 20:56:37 +03:00
|
|
|
#pragma once
|
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
|
|
|
|
2021-07-24 15:37:11 +03:00
|
|
|
#include "base/bittorrent/torrent.h"
|
2021-11-08 08:23:33 +03:00
|
|
|
#include "base/logger.h"
|
|
|
|
#include "base/settingvalue.h"
|
2022-06-25 15:46:55 +03:00
|
|
|
#include "guiapplicationcomponent.h"
|
2021-07-24 15:37:11 +03:00
|
|
|
|
2016-01-24 13:16:25 +03:00
|
|
|
class QCloseEvent;
|
|
|
|
class QFileSystemWatcher;
|
|
|
|
class QSplitter;
|
|
|
|
class QTabWidget;
|
|
|
|
class QTimer;
|
2007-02-19 19:34:23 +03:00
|
|
|
|
2018-06-06 16:48:17 +03:00
|
|
|
class AboutDialog;
|
2018-06-14 14:46:50 +03:00
|
|
|
class DownloadFromURLDialog;
|
|
|
|
class ExecutionLogWidget;
|
|
|
|
class LineEdit;
|
2016-04-25 10:54:38 +03:00
|
|
|
class OptionsDialog;
|
2018-06-14 14:46:50 +03:00
|
|
|
class PowerManagement;
|
2021-01-25 10:49:29 +03:00
|
|
|
class ProgramUpdater;
|
2009-11-08 17:20:58 +03:00
|
|
|
class PropertiesWidget;
|
2018-06-14 14:46:50 +03:00
|
|
|
class RSSWidget;
|
|
|
|
class SearchWidget;
|
|
|
|
class StatsDialog;
|
2009-11-18 16:18:55 +03:00
|
|
|
class StatusBar;
|
2018-06-14 12:54:23 +03:00
|
|
|
class TorrentCreatorDialog;
|
2018-06-14 14:46:50 +03:00
|
|
|
class TransferListFiltersWidget;
|
|
|
|
class TransferListWidget;
|
2011-02-27 18:41:05 +03:00
|
|
|
|
2019-03-01 10:38:16 +03:00
|
|
|
namespace Net
|
|
|
|
{
|
|
|
|
struct DownloadResult;
|
|
|
|
}
|
|
|
|
|
2016-01-24 13:16:25 +03:00
|
|
|
namespace Ui
|
|
|
|
{
|
|
|
|
class MainWindow;
|
|
|
|
}
|
|
|
|
|
2022-06-30 08:01:17 +03:00
|
|
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)) && defined(QT_DBUS_LIB)
|
|
|
|
#define QBT_USES_CUSTOMDBUSNOTIFICATIONS
|
|
|
|
class DBusNotifier;
|
|
|
|
#endif
|
|
|
|
|
2022-06-25 15:46:55 +03:00
|
|
|
class MainWindow final : public QMainWindow, public GUIApplicationComponent
|
2014-12-20 20:53:58 +03:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2022-05-18 08:43:04 +03:00
|
|
|
Q_DISABLE_COPY_MOVE(MainWindow)
|
2006-09-30 20:02:39 +04:00
|
|
|
|
2010-03-03 17:48:49 +03:00
|
|
|
public:
|
2022-08-03 07:14:26 +03:00
|
|
|
enum State
|
|
|
|
{
|
|
|
|
Normal,
|
|
|
|
Minimized
|
|
|
|
};
|
|
|
|
|
|
|
|
explicit MainWindow(IGUIApplication *app, State initialState = Normal);
|
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;
|
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);
|
2021-11-08 08:23:33 +03:00
|
|
|
Log::MsgTypes executionLogMsgTypes() const;
|
|
|
|
void setExecutionLogMsgTypes(Log::MsgTypes value);
|
2016-03-14 15:39:13 +03:00
|
|
|
|
2016-04-17 22:56:51 +03:00
|
|
|
// Notifications properties
|
|
|
|
|
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
|
|
|
private slots:
|
2022-01-21 12:31:31 +03:00
|
|
|
void showFilterContextMenu();
|
2022-07-09 08:06:22 +03:00
|
|
|
void desktopNotificationClicked();
|
2014-12-20 20:53:58 +03:00
|
|
|
void writeSettings();
|
2022-03-21 07:41:06 +03:00
|
|
|
void writeSplitterSettings();
|
2014-12-20 20:53:58 +03:00
|
|
|
void readSettings();
|
2016-01-24 13:16:25 +03:00
|
|
|
void tabChanged(int newTab);
|
2018-11-21 16:40:31 +03:00
|
|
|
bool defineUILockPassword();
|
2014-12-20 20:53:58 +03:00
|
|
|
void clearUILockPassword();
|
|
|
|
bool unlockUI();
|
2019-02-12 03:45:30 +03:00
|
|
|
void notifyOfUpdate(const QString &);
|
2014-12-20 20:53:58 +03:00
|
|
|
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();
|
2019-09-24 06:29:07 +03:00
|
|
|
void reloadSessionStats();
|
2021-01-06 15:12:40 +03:00
|
|
|
void reloadTorrentStats(const QVector<BitTorrent::Torrent *> &torrents);
|
2021-12-13 10:56:20 +03:00
|
|
|
void loadPreferences();
|
2021-01-06 15:12:40 +03:00
|
|
|
void askRecursiveTorrentDownloadConfirmation(BitTorrent::Torrent *const torrent);
|
2014-12-20 20:53:58 +03:00
|
|
|
void optionsSaved();
|
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
|
2019-03-01 10:38:16 +03:00
|
|
|
void pythonDownloadFinished(const Net::DownloadResult &result);
|
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 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();
|
2022-03-21 07:41:06 +03:00
|
|
|
void on_actionShowFiltersSidebar_triggered(bool checked);
|
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();
|
2019-08-25 21:19:05 +03:00
|
|
|
void on_actionSetGlobalSpeedLimits_triggered();
|
2016-01-24 13:16:25 +03:00
|
|
|
void on_actionDocumentation_triggered() const;
|
|
|
|
void on_actionOpen_triggered();
|
|
|
|
void on_actionDownloadFromURL_triggered();
|
|
|
|
void on_actionExit_triggered();
|
|
|
|
void on_actionLock_triggered();
|
2018-08-02 22:45:21 +03:00
|
|
|
// Check for unpaused downloading or seeding torrents and prevent system suspend/sleep according to preferences
|
|
|
|
void updatePowerManagementState();
|
2021-01-25 10:49:29 +03:00
|
|
|
|
2022-01-21 12:31:31 +03:00
|
|
|
void toolbarMenuRequested();
|
2014-10-18 18:18:58 +04:00
|
|
|
void toolbarIconsOnly();
|
|
|
|
void toolbarTextOnly();
|
|
|
|
void toolbarTextBeside();
|
|
|
|
void toolbarTextUnder();
|
|
|
|
void toolbarFollowSystem();
|
2019-09-05 15:11:33 +03:00
|
|
|
#ifdef Q_OS_MACOS
|
2017-12-12 18:01:55 +03:00
|
|
|
void on_actionCloseWindow_triggered();
|
|
|
|
#else
|
2022-07-09 08:06:22 +03:00
|
|
|
void toggleVisibility();
|
2017-07-16 06:49:06 +03:00
|
|
|
#endif
|
2006-09-30 20:02:39 +04:00
|
|
|
|
2016-01-24 13:16:25 +03:00
|
|
|
private:
|
2022-07-09 08:06:22 +03:00
|
|
|
QMenu *createDesktopIntegrationMenu();
|
2016-01-24 13:16:25 +03:00
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
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;
|
2020-10-30 20:49:15 +03:00
|
|
|
void keyPressEvent(QKeyEvent *event) 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);
|
2022-02-08 06:03:48 +03:00
|
|
|
void createTorrentTriggered(const Path &path);
|
2017-05-25 17:50:05 +03:00
|
|
|
void showStatusBar(bool show);
|
2022-03-21 07:41:06 +03:00
|
|
|
void showFiltersSidebar(bool show);
|
2016-01-24 13:16:25 +03:00
|
|
|
|
2022-06-23 07:28:00 +03:00
|
|
|
Ui::MainWindow *m_ui = nullptr;
|
2016-01-24 13:16:25 +03:00
|
|
|
|
2022-06-23 07:28:00 +03:00
|
|
|
QFileSystemWatcher *m_executableWatcher = nullptr;
|
2016-01-24 13:16:25 +03:00
|
|
|
// GUI related
|
2021-11-08 08:23:33 +03:00
|
|
|
bool m_posInitialized = false;
|
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;
|
2018-06-06 16:48:17 +03:00
|
|
|
QPointer<AboutDialog> m_aboutDlg;
|
2016-01-24 13:16:25 +03:00
|
|
|
QPointer<StatsDialog> m_statsDlg;
|
2018-06-14 12:54:23 +03:00
|
|
|
QPointer<TorrentCreatorDialog> m_createTorrentDlg;
|
2018-05-23 11:43:03 +03:00
|
|
|
QPointer<DownloadFromURLDialog> m_downloadFromURLDialog;
|
2021-12-13 10:56:20 +03:00
|
|
|
|
2016-01-24 13:16:25 +03:00
|
|
|
QPointer<QMenu> m_trayIconMenu;
|
2021-12-13 10:56:20 +03:00
|
|
|
|
2022-06-23 07:28:00 +03:00
|
|
|
TransferListWidget *m_transferListWidget = nullptr;
|
2022-03-21 07:41:06 +03:00
|
|
|
TransferListFiltersWidget *m_transferListFiltersWidget = nullptr;
|
2022-06-23 07:28:00 +03:00
|
|
|
PropertiesWidget *m_propertiesWidget = nullptr;
|
|
|
|
bool m_displaySpeedInTitle = false;
|
2021-11-08 08:23:33 +03:00
|
|
|
bool m_forceExit = false;
|
2022-06-23 07:28:00 +03:00
|
|
|
bool m_uiLocked = false;
|
2021-11-08 08:23:33 +03:00
|
|
|
bool m_unlockDlgShowing = false;
|
2022-06-23 07:28:00 +03:00
|
|
|
LineEdit *m_searchFilter = nullptr;
|
|
|
|
QAction *m_searchFilterAction = nullptr;
|
2016-01-24 13:16:25 +03:00
|
|
|
// Widgets
|
2022-06-23 07:28:00 +03:00
|
|
|
QAction *m_queueSeparator = nullptr;
|
|
|
|
QAction *m_queueSeparatorMenu = nullptr;
|
|
|
|
QSplitter *m_splitter = nullptr;
|
2016-01-24 13:16:25 +03:00
|
|
|
QPointer<SearchWidget> m_searchWidget;
|
2017-03-07 16:10:42 +03:00
|
|
|
QPointer<RSSWidget> m_rssWidget;
|
2018-06-14 12:54:23 +03:00
|
|
|
QPointer<ExecutionLogWidget> m_executionLog;
|
2016-01-24 13:16:25 +03:00
|
|
|
// Power Management
|
2022-06-23 07:28:00 +03:00
|
|
|
PowerManagement *m_pwr = nullptr;
|
|
|
|
QTimer *m_preventTimer = nullptr;
|
2021-11-08 08:23:33 +03:00
|
|
|
bool m_hasPython = false;
|
2022-06-23 07:28:00 +03:00
|
|
|
QMenu *m_toolbarMenu = nullptr;
|
2021-01-25 10:49:29 +03:00
|
|
|
|
2021-11-08 08:23:33 +03:00
|
|
|
SettingValue<bool> m_storeExecutionLogEnabled;
|
|
|
|
SettingValue<bool> m_storeDownloadTrackerFavicon;
|
|
|
|
CachedSettingValue<Log::MsgTypes> m_storeExecutionLogTypes;
|
|
|
|
|
2021-01-25 10:49:29 +03:00
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
|
|
|
|
void checkProgramUpdate(bool invokedByUser);
|
|
|
|
void handleUpdateCheckFinished(ProgramUpdater *updater, bool invokedByUser);
|
|
|
|
|
|
|
|
QTimer *m_programUpdateTimer = nullptr;
|
|
|
|
#endif
|
2016-01-24 13:16:25 +03:00
|
|
|
};
|