Extract desktop integration stuff into separate class

PR #17313.
This commit is contained in:
Vladimir Golovnev
2022-07-09 08:06:22 +03:00
committed by GitHub
parent 2ef059807a
commit 890630944d
12 changed files with 541 additions and 347 deletions

View File

@@ -31,10 +31,6 @@
#include <QMainWindow>
#include <QPointer>
#ifndef Q_OS_MACOS
#include <QSystemTrayIcon>
#endif
#include "base/bittorrent/torrent.h"
#include "base/logger.h"
#include "base/settingvalue.h"
@@ -97,14 +93,6 @@ public:
void setExecutionLogMsgTypes(Log::MsgTypes value);
// Notifications properties
bool isNotificationsEnabled() const;
void setNotificationsEnabled(bool value);
bool isTorrentAddedNotificationsEnabled() const;
void setTorrentAddedNotificationsEnabled(bool value);
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)) && defined(QT_DBUS_LIB)
int getNotificationTimeout() const;
void setNotificationTimeout(int value);
#endif
// Misc properties
bool isDownloadTrackerFavicon() const;
@@ -113,19 +101,12 @@ public:
void activate();
void cleanup();
void showNotificationBalloon(const QString &title, const QString &msg) const;
signals:
void systemTrayIconCreated();
private slots:
void showFilterContextMenu();
void balloonClicked();
void desktopNotificationClicked();
void writeSettings();
void writeSplitterSettings();
void readSettings();
void fullDiskError(BitTorrent::Torrent *const torrent, const QString &msg) const;
void handleDownloadFromUrlFailure(const QString &, const QString &) const;
void tabChanged(int newTab);
bool defineUILockPassword();
void clearUILockPassword();
@@ -143,9 +124,6 @@ private slots:
void reloadSessionStats();
void reloadTorrentStats(const QVector<BitTorrent::Torrent *> &torrents);
void loadPreferences();
void addTorrentFailed(const QString &error) const;
void torrentNew(BitTorrent::Torrent *const torrent) const;
void finishedTorrent(BitTorrent::Torrent *const torrent) const;
void askRecursiveTorrentDownloadConfirmation(BitTorrent::Torrent *const torrent);
void optionsSaved();
void toggleAlternativeSpeeds();
@@ -199,16 +177,11 @@ private slots:
#ifdef Q_OS_MACOS
void on_actionCloseWindow_triggered();
#else
void toggleVisibility(const QSystemTrayIcon::ActivationReason reason = QSystemTrayIcon::Trigger);
void toggleVisibility();
#endif
private:
void createTrayIconMenu();
#ifdef Q_OS_MACOS
void setupDockClickHandler();
#else
void createTrayIcon(int retries);
#endif
QMenu *createDesktopIntegrationMenu();
#ifdef Q_OS_WIN
void installPython();
#endif
@@ -238,9 +211,6 @@ private:
QPointer<TorrentCreatorDialog> m_createTorrentDlg;
QPointer<DownloadFromURLDialog> m_downloadFromURLDialog;
#ifndef Q_OS_MACOS
QPointer<QSystemTrayIcon> m_systrayIcon;
#endif
QPointer<QMenu> m_trayIconMenu;
TransferListWidget *m_transferListWidget = nullptr;
@@ -267,15 +237,8 @@ private:
SettingValue<bool> m_storeExecutionLogEnabled;
SettingValue<bool> m_storeDownloadTrackerFavicon;
SettingValue<bool> m_storeNotificationEnabled;
SettingValue<bool> m_storeNotificationTorrentAdded;
CachedSettingValue<Log::MsgTypes> m_storeExecutionLogTypes;
#ifdef QBT_USES_CUSTOMDBUSNOTIFICATIONS
SettingValue<int> m_storeNotificationTimeOut;
DBusNotifier *m_notifier = nullptr;
#endif
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
void checkProgramUpdate(bool invokedByUser);
void handleUpdateCheckFinished(ProgramUpdater *updater, bool invokedByUser);