Use cached SessionStatus and CacheStatus

This commit is contained in:
Vladimir Golovnev (Glassez) 2017-04-29 14:45:30 +03:00
parent cb678a254d
commit 8a6d8f3953
15 changed files with 171 additions and 360 deletions

View file

@ -1319,7 +1319,7 @@ void MainWindow::trackerAuthenticationRequired(BitTorrent::TorrentHandle *const
// Check connection status and display right icon
void MainWindow::updateGUI()
{
BitTorrent::SessionStatus status = BitTorrent::Session::instance()->status();
const BitTorrent::SessionStatus &status = BitTorrent::Session::instance()->status();
// update global informations
if (m_systrayIcon) {
@ -1328,24 +1328,24 @@ void MainWindow::updateGUI()
html += "qBittorrent";
html += "</div>";
html += "<div style='vertical-align: baseline; height: 18px;'>";
html += "<img src=':/icons/skin/download.png' height='14'/>&nbsp;" + tr("DL speed: %1", "e.g: Download speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate(), true));
html += "<img src=':/icons/skin/download.png' height='14'/>&nbsp;" + tr("DL speed: %1", "e.g: Download speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate, true));
html += "</div>";
html += "<div style='vertical-align: baseline; height: 18px;'>";
html += "<img src=':/icons/skin/seeding.png' height='14'/>&nbsp;" + tr("UP speed: %1", "e.g: Upload speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadUploadRate(), true));
html += "<img src=':/icons/skin/seeding.png' height='14'/>&nbsp;" + tr("UP speed: %1", "e.g: Upload speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadUploadRate, true));
html += "</div>";
#else
// OSes such as Windows do not support html here
QString html = tr("DL speed: %1", "e.g: Download speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate(), true));
QString html = tr("DL speed: %1", "e.g: Download speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate, true));
html += "\n";
html += tr("UP speed: %1", "e.g: Upload speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadUploadRate(), true));
html += tr("UP speed: %1", "e.g: Upload speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadUploadRate, true));
#endif
m_systrayIcon->setToolTip(html); // tray icon
}
if (m_displaySpeedInTitle) {
setWindowTitle(tr("[D: %1, U: %2] qBittorrent %3", "D = Download; U = Upload; %3 is qBittorrent version")
.arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate(), true))
.arg(Utils::Misc::friendlyUnit(status.payloadUploadRate(), true))
.arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate, true))
.arg(Utils::Misc::friendlyUnit(status.payloadUploadRate, true))
.arg(QBT_VERSION));
}
}