qBittorrent/src/gui/mainwindow.h

255 lines
8.2 KiB
C
Raw Normal View History

/*
* Bittorrent Client using Qt and libtorrent.
2018-06-06 16:48:17 +03:00
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
*
* 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.
*
* 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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* 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.
*/
#pragma once
#include <QMainWindow>
2008-09-13 11:33:41 +04:00
#include <QPointer>
#include "base/bittorrent/torrent.h"
#include "base/logger.h"
#include "base/settingvalue.h"
#include "guiapplicationcomponent.h"
class QCloseEvent;
class QFileSystemWatcher;
class QSplitter;
class QTabWidget;
class QTimer;
2018-06-06 16:48:17 +03:00
class AboutDialog;
2018-06-14 14:46:50 +03:00
class DownloadFromURLDialog;
class ExecutionLogWidget;
class LineEdit;
class OptionsDialog;
2018-06-14 14:46:50 +03:00
class PowerManagement;
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;
class StatusBar;
class TorrentCreatorDialog;
2018-06-14 14:46:50 +03:00
class TransferListFiltersWidget;
class TransferListWidget;
namespace Net
{
struct DownloadResult;
}
namespace Ui
{
class MainWindow;
}
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)) && defined(QT_DBUS_LIB)
#define QBT_USES_CUSTOMDBUSNOTIFICATIONS
class DBusNotifier;
#endif
class MainWindow final : public QMainWindow, public GUIApplicationComponent
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(MainWindow)
2010-03-03 17:48:49 +03:00
public:
enum State
{
Normal,
Minimized
};
explicit MainWindow(IGUIApplication *app, State initialState = Normal);
~MainWindow() override;
QWidget *currentTabWidget() const;
TransferListWidget *transferListWidget() const;
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);
Log::MsgTypes executionLogMsgTypes() const;
void setExecutionLogMsgTypes(Log::MsgTypes value);
2016-03-14 15:39:13 +03:00
// Notifications properties
// Misc properties
bool isDownloadTrackerFavicon() const;
void setDownloadTrackerFavicon(bool value);
void activate();
void cleanup();
private slots:
2022-01-21 12:31:31 +03:00
void showFilterContextMenu();
void desktopNotificationClicked();
void writeSettings();
void writeSplitterSettings();
void readSettings();
void tabChanged(int newTab);
2018-11-21 16:40:31 +03:00
bool defineUILockPassword();
void clearUILockPassword();
bool unlockUI();
void notifyOfUpdate(const QString &);
void showConnectionSettings();
void minimizeWindow();
// Keyboard shortcuts
void createKeyboardShortcuts();
void displayTransferTab() const;
void displaySearchTab();
void displayRSSTab();
void displayExecutionLogTab();
void focusSearchFilter();
void reloadSessionStats();
void reloadTorrentStats(const QVector<BitTorrent::Torrent *> &torrents);
2021-12-13 10:56:20 +03:00
void loadPreferences();
void askRecursiveTorrentDownloadConfirmation(BitTorrent::Torrent *const torrent);
void optionsSaved();
2017-05-25 17:50:05 +03:00
void toggleAlternativeSpeeds();
2009-03-28 01:25:34 +03:00
#ifdef Q_OS_WIN
void pythonDownloadFinished(const Net::DownloadResult &result);
#endif
void addToolbarContextMenu();
2016-01-23 15:12:13 +03:00
void manageCookies();
2011-03-12 23:59:44 +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
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();
void on_actionShowFiltersSidebar_triggered(bool checked);
void on_actionDonateMoney_triggered();
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);
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_actionSetGlobalSpeedLimits_triggered();
void on_actionDocumentation_triggered() const;
void on_actionOpen_triggered();
void on_actionDownloadFromURL_triggered();
void on_actionExit_triggered();
void on_actionLock_triggered();
// Check for unpaused downloading or seeding torrents and prevent system suspend/sleep according to preferences
void updatePowerManagementState();
2022-01-21 12:31:31 +03:00
void toolbarMenuRequested();
void toolbarIconsOnly();
void toolbarTextOnly();
void toolbarTextBeside();
void toolbarTextUnder();
void toolbarFollowSystem();
#ifdef Q_OS_MACOS
void on_actionCloseWindow_triggered();
#else
void toggleVisibility();
#endif
private:
QMenu *createDesktopIntegrationMenu();
#ifdef Q_OS_WIN
void installPython();
#endif
void dropEvent(QDropEvent *event) override;
void dragEnterEvent(QDragEnterEvent *event) override;
void closeEvent(QCloseEvent *) override;
void showEvent(QShowEvent *) override;
void keyPressEvent(QKeyEvent *event) override;
bool event(QEvent *e) override;
void displayRSSTab(bool enable);
void displaySearchTab(bool enable);
void createTorrentTriggered(const Path &path);
2017-05-25 17:50:05 +03:00
void showStatusBar(bool show);
void showFiltersSidebar(bool show);
2022-06-23 07:28:00 +03:00
Ui::MainWindow *m_ui = nullptr;
2022-06-23 07:28:00 +03:00
QFileSystemWatcher *m_executableWatcher = nullptr;
// GUI related
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;
QPointer<OptionsDialog> m_options;
2018-06-06 16:48:17 +03:00
QPointer<AboutDialog> m_aboutDlg;
QPointer<StatsDialog> m_statsDlg;
QPointer<TorrentCreatorDialog> m_createTorrentDlg;
QPointer<DownloadFromURLDialog> m_downloadFromURLDialog;
2021-12-13 10:56:20 +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;
TransferListFiltersWidget *m_transferListFiltersWidget = nullptr;
2022-06-23 07:28:00 +03:00
PropertiesWidget *m_propertiesWidget = nullptr;
bool m_displaySpeedInTitle = false;
bool m_forceExit = false;
2022-06-23 07:28:00 +03:00
bool m_uiLocked = false;
bool m_unlockDlgShowing = false;
2022-06-23 07:28:00 +03:00
LineEdit *m_searchFilter = nullptr;
QAction *m_searchFilterAction = nullptr;
// Widgets
2022-06-23 07:28:00 +03:00
QAction *m_queueSeparator = nullptr;
QAction *m_queueSeparatorMenu = nullptr;
QSplitter *m_splitter = nullptr;
QPointer<SearchWidget> m_searchWidget;
2017-03-07 16:10:42 +03:00
QPointer<RSSWidget> m_rssWidget;
QPointer<ExecutionLogWidget> m_executionLog;
// Power Management
2022-06-23 07:28:00 +03:00
PowerManagement *m_pwr = nullptr;
QTimer *m_preventTimer = nullptr;
bool m_hasPython = false;
2022-06-23 07:28:00 +03:00
QMenu *m_toolbarMenu = nullptr;
SettingValue<bool> m_storeExecutionLogEnabled;
SettingValue<bool> m_storeDownloadTrackerFavicon;
CachedSettingValue<Log::MsgTypes> m_storeExecutionLogTypes;
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
void checkProgramUpdate(bool invokedByUser);
void handleUpdateCheckFinished(ProgramUpdater *updater, bool invokedByUser);
QTimer *m_programUpdateTimer = nullptr;
#endif
};