diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 0c63979e6..b3e6bc217 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -4399,7 +4399,8 @@ void Session::handleStateUpdateAlert(const lt::state_update_alert *p) updatedTorrents.push_back(torrent); } - emit torrentsUpdated(updatedTorrents); + if (!updatedTorrents.isEmpty()) + emit torrentsUpdated(updatedTorrents); } namespace diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 83997352a..68bf54e35 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -335,7 +335,8 @@ MainWindow::MainWindow(QWidget *parent) // Configure BT session according to options loadPreferences(false); - connect(BitTorrent::Session::instance(), &BitTorrent::Session::torrentsUpdated, this, &MainWindow::updateGUI); + connect(BitTorrent::Session::instance(), &BitTorrent::Session::statsUpdated, this, &MainWindow::reloadSessionStats); + connect(BitTorrent::Session::instance(), &BitTorrent::Session::torrentsUpdated, this, &MainWindow::reloadTorrentStats); // Accept drag 'n drops setAcceptDrops(true); @@ -1509,19 +1510,23 @@ void MainWindow::loadPreferences(bool configureSession) qDebug("GUI settings loaded"); } -// Check connection status and display right icon -void MainWindow::updateGUI() +void MainWindow::reloadSessionStats() { - if (currentTabWidget() == m_transferListWidget) - m_propertiesWidget->loadDynamicData(); - const BitTorrent::SessionStatus &status = BitTorrent::Session::instance()->status(); // update global information -#ifndef Q_OS_MACOS +#ifdef Q_OS_MACOS + if (status.payloadDownloadRate > 0) { + QtMac::setBadgeLabelText(tr("%1/s", "s is a shorthand for seconds") + .arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate))); + } + else if (!QtMac::badgeLabelText().isEmpty()) { + QtMac::setBadgeLabelText(""); + } +#else if (m_systrayIcon) { #ifdef Q_OS_UNIX - const QString html = QString(QLatin1String( + const QString toolTip = QString(QLatin1String( "
" "qBittorrent" "
" @@ -1535,19 +1540,13 @@ void MainWindow::updateGUI() , tr("UP speed: %1", "e.g: Upload speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadUploadRate, true))); #else // OSes such as Windows do not support html here - const QString html = QString("%1\n%2").arg( + const QString toolTip = QString("%1\n%2").arg( tr("DL speed: %1", "e.g: Download speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate, true)) , tr("UP speed: %1", "e.g: Upload speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadUploadRate, true))); #endif // Q_OS_UNIX - m_systrayIcon->setToolTip(html); // tray icon + m_systrayIcon->setToolTip(toolTip); // tray icon } -#else - if (status.payloadDownloadRate > 0) - QtMac::setBadgeLabelText(tr("%1/s", "s is a shorthand for seconds") - .arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate))); - else if (!QtMac::badgeLabelText().isEmpty()) - QtMac::setBadgeLabelText(""); -#endif // Q_OS_MACOS +#endif // Q_OS_MACOS if (m_displaySpeedInTitle) { setWindowTitle(tr("[D: %1, U: %2] qBittorrent %3", "D = Download; U = Upload; %3 is qBittorrent version") @@ -1557,6 +1556,14 @@ void MainWindow::updateGUI() } } +void MainWindow::reloadTorrentStats(const QVector &torrents) +{ + if (currentTabWidget() == m_transferListWidget) { + if (torrents.contains(m_propertiesWidget->getCurrentTorrent())) + m_propertiesWidget->loadDynamicData(); + } +} + void MainWindow::showNotificationBaloon(const QString &title, const QString &msg) const { if (!isNotificationsEnabled()) return; @@ -1726,7 +1733,7 @@ void MainWindow::on_actionSpeedInTitleBar_triggered() m_displaySpeedInTitle = static_cast(sender())->isChecked(); Preferences::instance()->showSpeedInTitleBar(m_displaySpeedInTitle); if (m_displaySpeedInTitle) - updateGUI(); + reloadSessionStats(); else setWindowTitle("qBittorrent " QBT_VERSION); } diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index 4f4b4f3a0..37790dd00 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -127,7 +127,8 @@ private slots: void displayRSSTab(); void displayExecutionLogTab(); void focusSearchFilter(); - void updateGUI(); + void reloadSessionStats(); + void reloadTorrentStats(const QVector &torrents); void loadPreferences(bool configureSession = true); void addTorrentFailed(const QString &error) const; void torrentNew(BitTorrent::TorrentHandle *const torrent) const;