|
|
@ -43,11 +43,11 @@ |
|
|
|
#include <QtGlobal> |
|
|
|
#include <QtGlobal> |
|
|
|
#include <QTimer> |
|
|
|
#include <QTimer> |
|
|
|
|
|
|
|
|
|
|
|
#ifdef Q_OS_MAC |
|
|
|
#ifdef Q_OS_MACOS |
|
|
|
#include <QtMac> |
|
|
|
#include <QtMac> |
|
|
|
#include <QtMacExtras> |
|
|
|
#include <QtMacExtras> |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB) |
|
|
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)) && defined(QT_DBUS_LIB) |
|
|
|
#include <QDBusConnection> |
|
|
|
#include <QDBusConnection> |
|
|
|
#include "notifications.h" |
|
|
|
#include "notifications.h" |
|
|
|
#endif |
|
|
|
#endif |
|
|
@ -92,10 +92,10 @@ |
|
|
|
#include "uithememanager.h" |
|
|
|
#include "uithememanager.h" |
|
|
|
#include "utils.h" |
|
|
|
#include "utils.h" |
|
|
|
|
|
|
|
|
|
|
|
#ifdef Q_OS_MAC |
|
|
|
#ifdef Q_OS_MACOS |
|
|
|
#include "macutilities.h" |
|
|
|
#include "macutilities.h" |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_MAC) |
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS) |
|
|
|
#include "programupdater.h" |
|
|
|
#include "programupdater.h" |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
@ -132,7 +132,7 @@ MainWindow::MainWindow(QWidget *parent) |
|
|
|
, m_posInitialized(false) |
|
|
|
, m_posInitialized(false) |
|
|
|
, m_forceExit(false) |
|
|
|
, m_forceExit(false) |
|
|
|
, m_unlockDlgShowing(false) |
|
|
|
, m_unlockDlgShowing(false) |
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_MAC) |
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS) |
|
|
|
, m_wasUpdateCheckEnabled(false) |
|
|
|
, m_wasUpdateCheckEnabled(false) |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
, m_hasPython(false) |
|
|
|
, m_hasPython(false) |
|
|
@ -144,7 +144,7 @@ MainWindow::MainWindow(QWidget *parent) |
|
|
|
setWindowTitle("qBittorrent " QBT_VERSION); |
|
|
|
setWindowTitle("qBittorrent " QBT_VERSION); |
|
|
|
m_displaySpeedInTitle = pref->speedInTitleBar(); |
|
|
|
m_displaySpeedInTitle = pref->speedInTitleBar(); |
|
|
|
// Setting icons
|
|
|
|
// Setting icons
|
|
|
|
#ifndef Q_OS_MAC |
|
|
|
#ifndef Q_OS_MACOS |
|
|
|
#ifdef Q_OS_UNIX |
|
|
|
#ifdef Q_OS_UNIX |
|
|
|
const QIcon appLogo = Preferences::instance()->useSystemIconTheme() |
|
|
|
const QIcon appLogo = Preferences::instance()->useSystemIconTheme() |
|
|
|
? QIcon::fromTheme("qbittorrent", QIcon(":/icons/skin/qbittorrent-tray.svg")) |
|
|
|
? QIcon::fromTheme("qbittorrent", QIcon(":/icons/skin/qbittorrent-tray.svg")) |
|
|
@ -153,7 +153,7 @@ MainWindow::MainWindow(QWidget *parent) |
|
|
|
const QIcon appLogo(":/icons/skin/qbittorrent-tray.svg"); |
|
|
|
const QIcon appLogo(":/icons/skin/qbittorrent-tray.svg"); |
|
|
|
#endif // Q_OS_UNIX
|
|
|
|
#endif // Q_OS_UNIX
|
|
|
|
setWindowIcon(appLogo); |
|
|
|
setWindowIcon(appLogo); |
|
|
|
#endif // Q_OS_MAC
|
|
|
|
#endif // Q_OS_MACOS
|
|
|
|
|
|
|
|
|
|
|
|
#if (defined(Q_OS_UNIX)) |
|
|
|
#if (defined(Q_OS_UNIX)) |
|
|
|
m_ui->actionOptions->setText(tr("Preferences")); |
|
|
|
m_ui->actionOptions->setText(tr("Preferences")); |
|
|
@ -239,7 +239,7 @@ MainWindow::MainWindow(QWidget *parent) |
|
|
|
m_splitter->setCollapsible(0, true); |
|
|
|
m_splitter->setCollapsible(0, true); |
|
|
|
m_splitter->setCollapsible(1, false); |
|
|
|
m_splitter->setCollapsible(1, false); |
|
|
|
m_tabs->addTab(m_splitter, |
|
|
|
m_tabs->addTab(m_splitter, |
|
|
|
#ifndef Q_OS_MAC |
|
|
|
#ifndef Q_OS_MACOS |
|
|
|
UIThemeManager::instance()->getIcon("folder-remote"), |
|
|
|
UIThemeManager::instance()->getIcon("folder-remote"), |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
tr("Transfers")); |
|
|
|
tr("Transfers")); |
|
|
@ -259,7 +259,7 @@ MainWindow::MainWindow(QWidget *parent) |
|
|
|
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerWarning |
|
|
|
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerWarning |
|
|
|
, m_transferListFiltersWidget, qOverload<BitTorrent::TorrentHandle *const, const QString &>(&TransferListFiltersWidget::trackerWarning)); |
|
|
|
, m_transferListFiltersWidget, qOverload<BitTorrent::TorrentHandle *const, const QString &>(&TransferListFiltersWidget::trackerWarning)); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef Q_OS_MAC |
|
|
|
#ifdef Q_OS_MACOS |
|
|
|
// Increase top spacing to avoid tab overlapping
|
|
|
|
// Increase top spacing to avoid tab overlapping
|
|
|
|
m_ui->centralWidgetLayout->addSpacing(8); |
|
|
|
m_ui->centralWidgetLayout->addSpacing(8); |
|
|
|
#endif |
|
|
|
#endif |
|
|
@ -269,7 +269,7 @@ MainWindow::MainWindow(QWidget *parent) |
|
|
|
m_queueSeparator = m_ui->toolBar->insertSeparator(m_ui->actionTopQueuePos); |
|
|
|
m_queueSeparator = m_ui->toolBar->insertSeparator(m_ui->actionTopQueuePos); |
|
|
|
m_queueSeparatorMenu = m_ui->menuEdit->insertSeparator(m_ui->actionTopQueuePos); |
|
|
|
m_queueSeparatorMenu = m_ui->menuEdit->insertSeparator(m_ui->actionTopQueuePos); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef Q_OS_MAC |
|
|
|
#ifdef Q_OS_MACOS |
|
|
|
for (QAction *action : asConst(m_ui->toolBar->actions())) { |
|
|
|
for (QAction *action : asConst(m_ui->toolBar->actions())) { |
|
|
|
if (action->isSeparator()) { |
|
|
|
if (action->isSeparator()) { |
|
|
|
QWidget *spacer = new QWidget(this); |
|
|
|
QWidget *spacer = new QWidget(this); |
|
|
@ -291,7 +291,7 @@ MainWindow::MainWindow(QWidget *parent) |
|
|
|
spacer->setMinimumWidth(8); |
|
|
|
spacer->setMinimumWidth(8); |
|
|
|
m_ui->toolBar->addWidget(spacer); |
|
|
|
m_ui->toolBar->addWidget(spacer); |
|
|
|
} |
|
|
|
} |
|
|
|
#endif // Q_OS_MAC
|
|
|
|
#endif // Q_OS_MACOS
|
|
|
|
|
|
|
|
|
|
|
|
// Transfer list slots
|
|
|
|
// Transfer list slots
|
|
|
|
connect(m_ui->actionStart, &QAction::triggered, m_transferListWidget, &TransferListWidget::startSelectedTorrents); |
|
|
|
connect(m_ui->actionStart, &QAction::triggered, m_transferListWidget, &TransferListWidget::startSelectedTorrents); |
|
|
@ -303,13 +303,13 @@ MainWindow::MainWindow(QWidget *parent) |
|
|
|
connect(m_ui->actionIncreaseQueuePos, &QAction::triggered, m_transferListWidget, &TransferListWidget::increaseQueuePosSelectedTorrents); |
|
|
|
connect(m_ui->actionIncreaseQueuePos, &QAction::triggered, m_transferListWidget, &TransferListWidget::increaseQueuePosSelectedTorrents); |
|
|
|
connect(m_ui->actionDecreaseQueuePos, &QAction::triggered, m_transferListWidget, &TransferListWidget::decreaseQueuePosSelectedTorrents); |
|
|
|
connect(m_ui->actionDecreaseQueuePos, &QAction::triggered, m_transferListWidget, &TransferListWidget::decreaseQueuePosSelectedTorrents); |
|
|
|
connect(m_ui->actionBottomQueuePos, &QAction::triggered, m_transferListWidget, &TransferListWidget::bottomQueuePosSelectedTorrents); |
|
|
|
connect(m_ui->actionBottomQueuePos, &QAction::triggered, m_transferListWidget, &TransferListWidget::bottomQueuePosSelectedTorrents); |
|
|
|
#ifndef Q_OS_MAC |
|
|
|
#ifndef Q_OS_MACOS |
|
|
|
connect(m_ui->actionToggleVisibility, &QAction::triggered, this, [this]() { toggleVisibility(); }); |
|
|
|
connect(m_ui->actionToggleVisibility, &QAction::triggered, this, [this]() { toggleVisibility(); }); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
connect(m_ui->actionMinimize, &QAction::triggered, this, &MainWindow::minimizeWindow); |
|
|
|
connect(m_ui->actionMinimize, &QAction::triggered, this, &MainWindow::minimizeWindow); |
|
|
|
connect(m_ui->actionUseAlternativeSpeedLimits, &QAction::triggered, this, &MainWindow::toggleAlternativeSpeeds); |
|
|
|
connect(m_ui->actionUseAlternativeSpeedLimits, &QAction::triggered, this, &MainWindow::toggleAlternativeSpeeds); |
|
|
|
|
|
|
|
|
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_MAC) |
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS) |
|
|
|
m_programUpdateTimer = new QTimer(this); |
|
|
|
m_programUpdateTimer = new QTimer(this); |
|
|
|
m_programUpdateTimer->setInterval(60 * 60 * 1000); |
|
|
|
m_programUpdateTimer->setInterval(60 * 60 * 1000); |
|
|
|
m_programUpdateTimer->setSingleShot(true); |
|
|
|
m_programUpdateTimer->setSingleShot(true); |
|
|
@ -341,7 +341,7 @@ MainWindow::MainWindow(QWidget *parent) |
|
|
|
setAcceptDrops(true); |
|
|
|
setAcceptDrops(true); |
|
|
|
createKeyboardShortcuts(); |
|
|
|
createKeyboardShortcuts(); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef Q_OS_MAC |
|
|
|
#ifdef Q_OS_MACOS |
|
|
|
setUnifiedTitleAndToolBarOnMac(true); |
|
|
|
setUnifiedTitleAndToolBarOnMac(true); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
@ -376,7 +376,7 @@ MainWindow::MainWindow(QWidget *parent) |
|
|
|
autoShutdownGroup->addAction(m_ui->actionAutoShutdown); |
|
|
|
autoShutdownGroup->addAction(m_ui->actionAutoShutdown); |
|
|
|
autoShutdownGroup->addAction(m_ui->actionAutoSuspend); |
|
|
|
autoShutdownGroup->addAction(m_ui->actionAutoSuspend); |
|
|
|
autoShutdownGroup->addAction(m_ui->actionAutoHibernate); |
|
|
|
autoShutdownGroup->addAction(m_ui->actionAutoHibernate); |
|
|
|
#if (!defined(Q_OS_UNIX) || defined(Q_OS_MAC)) || defined(QT_DBUS_LIB) |
|
|
|
#if (!defined(Q_OS_UNIX) || defined(Q_OS_MACOS)) || defined(QT_DBUS_LIB) |
|
|
|
m_ui->actionAutoShutdown->setChecked(pref->shutdownWhenDownloadsComplete()); |
|
|
|
m_ui->actionAutoShutdown->setChecked(pref->shutdownWhenDownloadsComplete()); |
|
|
|
m_ui->actionAutoSuspend->setChecked(pref->suspendWhenDownloadsComplete()); |
|
|
|
m_ui->actionAutoSuspend->setChecked(pref->suspendWhenDownloadsComplete()); |
|
|
|
m_ui->actionAutoHibernate->setChecked(pref->hibernateWhenDownloadsComplete()); |
|
|
|
m_ui->actionAutoHibernate->setChecked(pref->hibernateWhenDownloadsComplete()); |
|
|
@ -393,7 +393,7 @@ MainWindow::MainWindow(QWidget *parent) |
|
|
|
// Load Window state and sizes
|
|
|
|
// Load Window state and sizes
|
|
|
|
readSettings(); |
|
|
|
readSettings(); |
|
|
|
|
|
|
|
|
|
|
|
#ifndef Q_OS_MAC |
|
|
|
#ifndef Q_OS_MACOS |
|
|
|
if (m_systrayIcon) { |
|
|
|
if (m_systrayIcon) { |
|
|
|
if (!(pref->startMinimized() || m_uiLocked)) { |
|
|
|
if (!(pref->startMinimized() || m_uiLocked)) { |
|
|
|
show(); |
|
|
|
show(); |
|
|
@ -422,7 +422,7 @@ MainWindow::MainWindow(QWidget *parent) |
|
|
|
activateWindow(); |
|
|
|
activateWindow(); |
|
|
|
raise(); |
|
|
|
raise(); |
|
|
|
} |
|
|
|
} |
|
|
|
#ifndef Q_OS_MAC |
|
|
|
#ifndef Q_OS_MACOS |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
@ -456,7 +456,7 @@ MainWindow::MainWindow(QWidget *parent) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#ifdef Q_OS_MAC |
|
|
|
#ifdef Q_OS_MACOS |
|
|
|
setupDockClickHandler(); |
|
|
|
setupDockClickHandler(); |
|
|
|
trayIconMenu()->setAsDockMenu(); |
|
|
|
trayIconMenu()->setAsDockMenu(); |
|
|
|
#endif |
|
|
|
#endif |
|
|
@ -669,7 +669,7 @@ void MainWindow::displayRSSTab(bool enable) |
|
|
|
if (!m_rssWidget) { |
|
|
|
if (!m_rssWidget) { |
|
|
|
m_rssWidget = new RSSWidget(m_tabs); |
|
|
|
m_rssWidget = new RSSWidget(m_tabs); |
|
|
|
connect(m_rssWidget.data(), &RSSWidget::unreadCountUpdated, this, &MainWindow::handleRSSUnreadCountUpdated); |
|
|
|
connect(m_rssWidget.data(), &RSSWidget::unreadCountUpdated, this, &MainWindow::handleRSSUnreadCountUpdated); |
|
|
|
#ifdef Q_OS_MAC |
|
|
|
#ifdef Q_OS_MACOS |
|
|
|
m_tabs->addTab(m_rssWidget, tr("RSS (%1)").arg(RSS::Session::instance()->rootFolder()->unreadCount())); |
|
|
|
m_tabs->addTab(m_rssWidget, tr("RSS (%1)").arg(RSS::Session::instance()->rootFolder()->unreadCount())); |
|
|
|
#else |
|
|
|
#else |
|
|
|
const int indexTab = m_tabs->addTab(m_rssWidget, tr("RSS (%1)").arg(RSS::Session::instance()->rootFolder()->unreadCount())); |
|
|
|
const int indexTab = m_tabs->addTab(m_rssWidget, tr("RSS (%1)").arg(RSS::Session::instance()->rootFolder()->unreadCount())); |
|
|
@ -707,7 +707,7 @@ void MainWindow::displaySearchTab(bool enable) |
|
|
|
if (!m_searchWidget) { |
|
|
|
if (!m_searchWidget) { |
|
|
|
m_searchWidget = new SearchWidget(this); |
|
|
|
m_searchWidget = new SearchWidget(this); |
|
|
|
m_tabs->insertTab(1, m_searchWidget, |
|
|
|
m_tabs->insertTab(1, m_searchWidget, |
|
|
|
#ifndef Q_OS_MAC |
|
|
|
#ifndef Q_OS_MACOS |
|
|
|
UIThemeManager::instance()->getIcon("edit-find"), |
|
|
|
UIThemeManager::instance()->getIcon("edit-find"), |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
tr("Search")); |
|
|
|
tr("Search")); |
|
|
@ -771,13 +771,13 @@ void MainWindow::cleanup() |
|
|
|
delete m_rssWidget; |
|
|
|
delete m_rssWidget; |
|
|
|
|
|
|
|
|
|
|
|
delete m_executableWatcher; |
|
|
|
delete m_executableWatcher; |
|
|
|
#ifndef Q_OS_MAC |
|
|
|
#ifndef Q_OS_MACOS |
|
|
|
if (m_systrayCreator) |
|
|
|
if (m_systrayCreator) |
|
|
|
m_systrayCreator->stop(); |
|
|
|
m_systrayCreator->stop(); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
if (m_preventTimer) |
|
|
|
if (m_preventTimer) |
|
|
|
m_preventTimer->stop(); |
|
|
|
m_preventTimer->stop(); |
|
|
|
#if (defined(Q_OS_WIN) || defined(Q_OS_MAC)) |
|
|
|
#if (defined(Q_OS_WIN) || defined(Q_OS_MACOS)) |
|
|
|
m_programUpdateTimer->stop(); |
|
|
|
m_programUpdateTimer->stop(); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
@ -851,7 +851,7 @@ void MainWindow::createKeyboardShortcuts() |
|
|
|
m_ui->actionDelete->setShortcutContext(Qt::WidgetShortcut); // nullify its effect: delete key event is handled by respective widgets, not here
|
|
|
|
m_ui->actionDelete->setShortcutContext(Qt::WidgetShortcut); // nullify its effect: delete key event is handled by respective widgets, not here
|
|
|
|
m_ui->actionDownloadFromURL->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_O); |
|
|
|
m_ui->actionDownloadFromURL->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_O); |
|
|
|
m_ui->actionExit->setShortcut(Qt::CTRL + Qt::Key_Q); |
|
|
|
m_ui->actionExit->setShortcut(Qt::CTRL + Qt::Key_Q); |
|
|
|
#ifdef Q_OS_MAC |
|
|
|
#ifdef Q_OS_MACOS |
|
|
|
m_ui->actionCloseWindow->setShortcut(QKeySequence::Close); |
|
|
|
m_ui->actionCloseWindow->setShortcut(QKeySequence::Close); |
|
|
|
#else |
|
|
|
#else |
|
|
|
m_ui->actionCloseWindow->setVisible(false); |
|
|
|
m_ui->actionCloseWindow->setVisible(false); |
|
|
@ -878,7 +878,7 @@ void MainWindow::createKeyboardShortcuts() |
|
|
|
m_ui->actionDecreaseQueuePos->setShortcut(Qt::CTRL + Qt::Key_Minus); |
|
|
|
m_ui->actionDecreaseQueuePos->setShortcut(Qt::CTRL + Qt::Key_Minus); |
|
|
|
m_ui->actionIncreaseQueuePos->setShortcut(Qt::CTRL + Qt::Key_Plus); |
|
|
|
m_ui->actionIncreaseQueuePos->setShortcut(Qt::CTRL + Qt::Key_Plus); |
|
|
|
m_ui->actionTopQueuePos->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_Plus); |
|
|
|
m_ui->actionTopQueuePos->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_Plus); |
|
|
|
#ifdef Q_OS_MAC |
|
|
|
#ifdef Q_OS_MACOS |
|
|
|
m_ui->actionMinimize->setShortcut(Qt::CTRL + Qt::Key_M); |
|
|
|
m_ui->actionMinimize->setShortcut(Qt::CTRL + Qt::Key_M); |
|
|
|
addAction(m_ui->actionMinimize); |
|
|
|
addAction(m_ui->actionMinimize); |
|
|
|
#endif |
|
|
|
#endif |
|
|
@ -998,7 +998,7 @@ void MainWindow::on_actionExit_triggered() |
|
|
|
close(); |
|
|
|
close(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#ifdef Q_OS_MAC |
|
|
|
#ifdef Q_OS_MACOS |
|
|
|
void MainWindow::on_actionCloseWindow_triggered() |
|
|
|
void MainWindow::on_actionCloseWindow_triggered() |
|
|
|
{ |
|
|
|
{ |
|
|
|
// On macOS window close is basically equivalent to window hide.
|
|
|
|
// On macOS window close is basically equivalent to window hide.
|
|
|
@ -1057,7 +1057,7 @@ void MainWindow::notifyOfUpdate(const QString &) |
|
|
|
m_executableWatcher = nullptr; |
|
|
|
m_executableWatcher = nullptr; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#ifndef Q_OS_MAC |
|
|
|
#ifndef Q_OS_MACOS |
|
|
|
// Toggle Main window visibility
|
|
|
|
// Toggle Main window visibility
|
|
|
|
void MainWindow::toggleVisibility(const QSystemTrayIcon::ActivationReason reason) |
|
|
|
void MainWindow::toggleVisibility(const QSystemTrayIcon::ActivationReason reason) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1084,7 +1084,7 @@ void MainWindow::toggleVisibility(const QSystemTrayIcon::ActivationReason reason |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#endif // Q_OS_MAC
|
|
|
|
#endif // Q_OS_MACOS
|
|
|
|
|
|
|
|
|
|
|
|
// Display About Dialog
|
|
|
|
// Display About Dialog
|
|
|
|
void MainWindow::on_actionAbout_triggered() |
|
|
|
void MainWindow::on_actionAbout_triggered() |
|
|
@ -1124,7 +1124,7 @@ void MainWindow::showEvent(QShowEvent *e) |
|
|
|
void MainWindow::closeEvent(QCloseEvent *e) |
|
|
|
void MainWindow::closeEvent(QCloseEvent *e) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Preferences *const pref = Preferences::instance(); |
|
|
|
Preferences *const pref = Preferences::instance(); |
|
|
|
#ifdef Q_OS_MAC |
|
|
|
#ifdef Q_OS_MACOS |
|
|
|
if (!m_forceExit) { |
|
|
|
if (!m_forceExit) { |
|
|
|
hide(); |
|
|
|
hide(); |
|
|
|
e->accept(); |
|
|
|
e->accept(); |
|
|
@ -1141,7 +1141,7 @@ void MainWindow::closeEvent(QCloseEvent *e) |
|
|
|
} |
|
|
|
} |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
#endif // Q_OS_MAC
|
|
|
|
#endif // Q_OS_MACOS
|
|
|
|
|
|
|
|
|
|
|
|
if (pref->confirmOnExit() && BitTorrent::Session::instance()->hasActiveTorrents()) { |
|
|
|
if (pref->confirmOnExit() && BitTorrent::Session::instance()->hasActiveTorrents()) { |
|
|
|
if (e->spontaneous() || m_forceExit) { |
|
|
|
if (e->spontaneous() || m_forceExit) { |
|
|
@ -1173,7 +1173,7 @@ void MainWindow::closeEvent(QCloseEvent *e) |
|
|
|
delete m_searchWidget; |
|
|
|
delete m_searchWidget; |
|
|
|
|
|
|
|
|
|
|
|
hide(); |
|
|
|
hide(); |
|
|
|
#ifndef Q_OS_MAC |
|
|
|
#ifndef Q_OS_MACOS |
|
|
|
// Hide tray icon
|
|
|
|
// Hide tray icon
|
|
|
|
if (m_systrayIcon) |
|
|
|
if (m_systrayIcon) |
|
|
|
m_systrayIcon->hide(); |
|
|
|
m_systrayIcon->hide(); |
|
|
@ -1201,7 +1201,7 @@ void MainWindow::createTorrentTriggered(const QString &path) |
|
|
|
|
|
|
|
|
|
|
|
bool MainWindow::event(QEvent *e) |
|
|
|
bool MainWindow::event(QEvent *e) |
|
|
|
{ |
|
|
|
{ |
|
|
|
#ifndef Q_OS_MAC |
|
|
|
#ifndef Q_OS_MACOS |
|
|
|
switch (e->type()) { |
|
|
|
switch (e->type()) { |
|
|
|
case QEvent::WindowStateChange: { |
|
|
|
case QEvent::WindowStateChange: { |
|
|
|
qDebug("Window change event"); |
|
|
|
qDebug("Window change event"); |
|
|
@ -1246,7 +1246,7 @@ bool MainWindow::event(QEvent *e) |
|
|
|
default: |
|
|
|
default: |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
#endif // Q_OS_MAC
|
|
|
|
#endif // Q_OS_MACOS
|
|
|
|
|
|
|
|
|
|
|
|
return QMainWindow::event(e); |
|
|
|
return QMainWindow::event(e); |
|
|
|
} |
|
|
|
} |
|
|
@ -1313,7 +1313,7 @@ void MainWindow::dragEnterEvent(QDragEnterEvent *event) |
|
|
|
event->acceptProposedAction(); |
|
|
|
event->acceptProposedAction(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#ifdef Q_OS_MAC |
|
|
|
#ifdef Q_OS_MACOS |
|
|
|
|
|
|
|
|
|
|
|
static MainWindow *dockMainWindowHandle; |
|
|
|
static MainWindow *dockMainWindowHandle; |
|
|
|
|
|
|
|
|
|
|
@ -1335,7 +1335,7 @@ void MainWindow::setupDockClickHandler() |
|
|
|
MacUtils::overrideDockClickHandler(dockClickHandler); |
|
|
|
MacUtils::overrideDockClickHandler(dockClickHandler); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endif // Q_OS_MAC
|
|
|
|
#endif // Q_OS_MACOS
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************
|
|
|
|
/*****************************************************
|
|
|
|
* * |
|
|
|
* * |
|
|
@ -1405,7 +1405,7 @@ void MainWindow::loadPreferences(bool configureSession) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Logger::instance()->addMessage(tr("Options were saved successfully.")); |
|
|
|
Logger::instance()->addMessage(tr("Options were saved successfully.")); |
|
|
|
const Preferences *const pref = Preferences::instance(); |
|
|
|
const Preferences *const pref = Preferences::instance(); |
|
|
|
#ifdef Q_OS_MAC |
|
|
|
#ifdef Q_OS_MACOS |
|
|
|
Q_UNUSED(configureSession); |
|
|
|
Q_UNUSED(configureSession); |
|
|
|
#else |
|
|
|
#else |
|
|
|
const bool newSystrayIntegration = pref->systrayIntegration(); |
|
|
|
const bool newSystrayIntegration = pref->systrayIntegration(); |
|
|
@ -1472,7 +1472,7 @@ void MainWindow::loadPreferences(bool configureSession) |
|
|
|
m_ui->actionIncreaseQueuePos->setVisible(true); |
|
|
|
m_ui->actionIncreaseQueuePos->setVisible(true); |
|
|
|
m_ui->actionTopQueuePos->setVisible(true); |
|
|
|
m_ui->actionTopQueuePos->setVisible(true); |
|
|
|
m_ui->actionBottomQueuePos->setVisible(true); |
|
|
|
m_ui->actionBottomQueuePos->setVisible(true); |
|
|
|
#ifndef Q_OS_MAC |
|
|
|
#ifndef Q_OS_MACOS |
|
|
|
m_queueSeparator->setVisible(true); |
|
|
|
m_queueSeparator->setVisible(true); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
m_queueSeparatorMenu->setVisible(true); |
|
|
|
m_queueSeparatorMenu->setVisible(true); |
|
|
@ -1485,7 +1485,7 @@ void MainWindow::loadPreferences(bool configureSession) |
|
|
|
m_ui->actionIncreaseQueuePos->setVisible(false); |
|
|
|
m_ui->actionIncreaseQueuePos->setVisible(false); |
|
|
|
m_ui->actionTopQueuePos->setVisible(false); |
|
|
|
m_ui->actionTopQueuePos->setVisible(false); |
|
|
|
m_ui->actionBottomQueuePos->setVisible(false); |
|
|
|
m_ui->actionBottomQueuePos->setVisible(false); |
|
|
|
#ifndef Q_OS_MAC |
|
|
|
#ifndef Q_OS_MACOS |
|
|
|
m_queueSeparator->setVisible(false); |
|
|
|
m_queueSeparator->setVisible(false); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
m_queueSeparatorMenu->setVisible(false); |
|
|
|
m_queueSeparatorMenu->setVisible(false); |
|
|
@ -1495,7 +1495,7 @@ void MainWindow::loadPreferences(bool configureSession) |
|
|
|
// Torrent properties
|
|
|
|
// Torrent properties
|
|
|
|
m_propertiesWidget->reloadPreferences(); |
|
|
|
m_propertiesWidget->reloadPreferences(); |
|
|
|
|
|
|
|
|
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_MAC) |
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS) |
|
|
|
if (pref->isUpdateCheckEnabled() && !m_wasUpdateCheckEnabled) { |
|
|
|
if (pref->isUpdateCheckEnabled() && !m_wasUpdateCheckEnabled) { |
|
|
|
m_wasUpdateCheckEnabled = true; |
|
|
|
m_wasUpdateCheckEnabled = true; |
|
|
|
checkProgramUpdate(); |
|
|
|
checkProgramUpdate(); |
|
|
@ -1518,7 +1518,7 @@ void MainWindow::updateGUI() |
|
|
|
const BitTorrent::SessionStatus &status = BitTorrent::Session::instance()->status(); |
|
|
|
const BitTorrent::SessionStatus &status = BitTorrent::Session::instance()->status(); |
|
|
|
|
|
|
|
|
|
|
|
// update global information
|
|
|
|
// update global information
|
|
|
|
#ifndef Q_OS_MAC |
|
|
|
#ifndef Q_OS_MACOS |
|
|
|
if (m_systrayIcon) { |
|
|
|
if (m_systrayIcon) { |
|
|
|
#ifdef Q_OS_UNIX |
|
|
|
#ifdef Q_OS_UNIX |
|
|
|
const QString html = QString(QLatin1String( |
|
|
|
const QString html = QString(QLatin1String( |
|
|
@ -1547,7 +1547,7 @@ void MainWindow::updateGUI() |
|
|
|
.arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate))); |
|
|
|
.arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate))); |
|
|
|
else if (!QtMac::badgeLabelText().isEmpty()) |
|
|
|
else if (!QtMac::badgeLabelText().isEmpty()) |
|
|
|
QtMac::setBadgeLabelText(""); |
|
|
|
QtMac::setBadgeLabelText(""); |
|
|
|
#endif // Q_OS_MAC
|
|
|
|
#endif // Q_OS_MACOS
|
|
|
|
|
|
|
|
|
|
|
|
if (m_displaySpeedInTitle) { |
|
|
|
if (m_displaySpeedInTitle) { |
|
|
|
setWindowTitle(tr("[D: %1, U: %2] qBittorrent %3", "D = Download; U = Upload; %3 is qBittorrent version") |
|
|
|
setWindowTitle(tr("[D: %1, U: %2] qBittorrent %3", "D = Download; U = Upload; %3 is qBittorrent version") |
|
|
@ -1560,7 +1560,7 @@ void MainWindow::updateGUI() |
|
|
|
void MainWindow::showNotificationBaloon(const QString &title, const QString &msg) const |
|
|
|
void MainWindow::showNotificationBaloon(const QString &title, const QString &msg) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!isNotificationsEnabled()) return; |
|
|
|
if (!isNotificationsEnabled()) return; |
|
|
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB) |
|
|
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)) && defined(QT_DBUS_LIB) |
|
|
|
org::freedesktop::Notifications notifications("org.freedesktop.Notifications", |
|
|
|
org::freedesktop::Notifications notifications("org.freedesktop.Notifications", |
|
|
|
"/org/freedesktop/Notifications", |
|
|
|
"/org/freedesktop/Notifications", |
|
|
|
QDBusConnection::sessionBus()); |
|
|
|
QDBusConnection::sessionBus()); |
|
|
@ -1580,7 +1580,7 @@ void MainWindow::showNotificationBaloon(const QString &title, const QString &msg |
|
|
|
reply.waitForFinished(); |
|
|
|
reply.waitForFinished(); |
|
|
|
if (!reply.isError()) |
|
|
|
if (!reply.isError()) |
|
|
|
return; |
|
|
|
return; |
|
|
|
#elif defined(Q_OS_MAC) |
|
|
|
#elif defined(Q_OS_MACOS) |
|
|
|
MacUtils::displayNotification(title, msg); |
|
|
|
MacUtils::displayNotification(title, msg); |
|
|
|
#else |
|
|
|
#else |
|
|
|
if (m_systrayIcon && QSystemTrayIcon::supportsMessages()) |
|
|
|
if (m_systrayIcon && QSystemTrayIcon::supportsMessages()) |
|
|
@ -1611,7 +1611,7 @@ void MainWindow::downloadFromURLList(const QStringList &urlList) |
|
|
|
* * |
|
|
|
* * |
|
|
|
*****************************************************/ |
|
|
|
*****************************************************/ |
|
|
|
|
|
|
|
|
|
|
|
#ifndef Q_OS_MAC |
|
|
|
#ifndef Q_OS_MACOS |
|
|
|
void MainWindow::createSystrayDelayed() |
|
|
|
void MainWindow::createSystrayDelayed() |
|
|
|
{ |
|
|
|
{ |
|
|
|
static int timeout = 20; |
|
|
|
static int timeout = 20; |
|
|
@ -1654,14 +1654,14 @@ void MainWindow::createTrayIcon() |
|
|
|
connect(m_systrayIcon.data(), &QSystemTrayIcon::activated, this, &MainWindow::toggleVisibility); |
|
|
|
connect(m_systrayIcon.data(), &QSystemTrayIcon::activated, this, &MainWindow::toggleVisibility); |
|
|
|
m_systrayIcon->show(); |
|
|
|
m_systrayIcon->show(); |
|
|
|
} |
|
|
|
} |
|
|
|
#endif // Q_OS_MAC
|
|
|
|
#endif // Q_OS_MACOS
|
|
|
|
|
|
|
|
|
|
|
|
QMenu *MainWindow::trayIconMenu() |
|
|
|
QMenu *MainWindow::trayIconMenu() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (m_trayIconMenu) return m_trayIconMenu; |
|
|
|
if (m_trayIconMenu) return m_trayIconMenu; |
|
|
|
|
|
|
|
|
|
|
|
m_trayIconMenu = new QMenu(this); |
|
|
|
m_trayIconMenu = new QMenu(this); |
|
|
|
#ifndef Q_OS_MAC |
|
|
|
#ifndef Q_OS_MACOS |
|
|
|
connect(m_trayIconMenu.data(), &QMenu::aboutToShow, this, &MainWindow::updateTrayIconMenu); |
|
|
|
connect(m_trayIconMenu.data(), &QMenu::aboutToShow, this, &MainWindow::updateTrayIconMenu); |
|
|
|
m_trayIconMenu->addAction(m_ui->actionToggleVisibility); |
|
|
|
m_trayIconMenu->addAction(m_ui->actionToggleVisibility); |
|
|
|
m_trayIconMenu->addSeparator(); |
|
|
|
m_trayIconMenu->addSeparator(); |
|
|
@ -1678,7 +1678,7 @@ QMenu *MainWindow::trayIconMenu() |
|
|
|
m_trayIconMenu->addSeparator(); |
|
|
|
m_trayIconMenu->addSeparator(); |
|
|
|
m_trayIconMenu->addAction(m_ui->actionStartAll); |
|
|
|
m_trayIconMenu->addAction(m_ui->actionStartAll); |
|
|
|
m_trayIconMenu->addAction(m_ui->actionPauseAll); |
|
|
|
m_trayIconMenu->addAction(m_ui->actionPauseAll); |
|
|
|
#ifndef Q_OS_MAC |
|
|
|
#ifndef Q_OS_MACOS |
|
|
|
m_trayIconMenu->addSeparator(); |
|
|
|
m_trayIconMenu->addSeparator(); |
|
|
|
m_trayIconMenu->addAction(m_ui->actionExit); |
|
|
|
m_trayIconMenu->addAction(m_ui->actionExit); |
|
|
|
#endif |
|
|
|
#endif |
|
|
@ -1803,7 +1803,7 @@ void MainWindow::on_actionDownloadFromURL_triggered() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_MAC) |
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS) |
|
|
|
void MainWindow::handleUpdateCheckFinished(bool updateAvailable, QString newVersion, bool invokedByUser) |
|
|
|
void MainWindow::handleUpdateCheckFinished(bool updateAvailable, QString newVersion, bool invokedByUser) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QMessageBox::StandardButton answer = QMessageBox::Yes; |
|
|
|
QMessageBox::StandardButton answer = QMessageBox::Yes; |
|
|
@ -1860,7 +1860,7 @@ void MainWindow::on_actionExecutionLogs_triggered(bool checked) |
|
|
|
if (checked) { |
|
|
|
if (checked) { |
|
|
|
Q_ASSERT(!m_executionLog); |
|
|
|
Q_ASSERT(!m_executionLog); |
|
|
|
m_executionLog = new ExecutionLogWidget(m_tabs, static_cast<Log::MsgType>(executionLogMsgTypes())); |
|
|
|
m_executionLog = new ExecutionLogWidget(m_tabs, static_cast<Log::MsgType>(executionLogMsgTypes())); |
|
|
|
#ifdef Q_OS_MAC |
|
|
|
#ifdef Q_OS_MACOS |
|
|
|
m_tabs->addTab(m_executionLog, tr("Execution Log")); |
|
|
|
m_tabs->addTab(m_executionLog, tr("Execution Log")); |
|
|
|
#else |
|
|
|
#else |
|
|
|
const int indexTab = m_tabs->addTab(m_executionLog, tr("Execution Log")); |
|
|
|
const int indexTab = m_tabs->addTab(m_executionLog, tr("Execution Log")); |
|
|
@ -1949,12 +1949,12 @@ void MainWindow::updatePowerManagementState() |
|
|
|
m_pwr->setActivityState(inhibitSuspend); |
|
|
|
m_pwr->setActivityState(inhibitSuspend); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#ifndef Q_OS_MAC |
|
|
|
#ifndef Q_OS_MACOS |
|
|
|
QIcon MainWindow::getSystrayIcon() const |
|
|
|
QIcon MainWindow::getSystrayIcon() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
const TrayIcon::Style style = Preferences::instance()->trayIconStyle(); |
|
|
|
const TrayIcon::Style style = Preferences::instance()->trayIconStyle(); |
|
|
|
// on Linux we use theme icons, and icons from resources everywhere else
|
|
|
|
// on Linux we use theme icons, and icons from resources everywhere else
|
|
|
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) |
|
|
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)) |
|
|
|
switch (style) { |
|
|
|
switch (style) { |
|
|
|
case TrayIcon::NORMAL: |
|
|
|
case TrayIcon::NORMAL: |
|
|
|
return QIcon::fromTheme(QLatin1String("qbittorrent-tray")); |
|
|
|
return QIcon::fromTheme(QLatin1String("qbittorrent-tray")); |
|
|
@ -1981,9 +1981,9 @@ QIcon MainWindow::getSystrayIcon() const |
|
|
|
// As a failsafe in case the enum is invalid
|
|
|
|
// As a failsafe in case the enum is invalid
|
|
|
|
return QIcon(QLatin1String(":/icons/skin/qbittorrent-tray.svg")); |
|
|
|
return QIcon(QLatin1String(":/icons/skin/qbittorrent-tray.svg")); |
|
|
|
} |
|
|
|
} |
|
|
|
#endif // Q_OS_MAC
|
|
|
|
#endif // Q_OS_MACOS
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_MAC) |
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS) |
|
|
|
void MainWindow::checkProgramUpdate() |
|
|
|
void MainWindow::checkProgramUpdate() |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_programUpdateTimer->stop(); // If the user had clicked the menu item
|
|
|
|
m_programUpdateTimer->stop(); // If the user had clicked the menu item
|
|
|
|