void StatusBar::updateSpeedLabels(const BitTorrent::SessionStatus &sessionStatus) { QString speedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadDownloadRate(), true); int speedLimit = BitTorrent::Session::instance()->downloadSpeedLimit(); if (speedLimit) speedLbl += " [" + Utils::Misc::friendlyUnit(speedLimit, true) + "]"; speedLbl += " (" + Utils::Misc::friendlyUnit(sessionStatus.totalPayloadDownload()) + ")"; m_dlSpeedLbl->setText(speedLbl); speedLimit = BitTorrent::Session::instance()->uploadSpeedLimit(); speedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadUploadRate(), true); if (speedLimit) speedLbl += " [" + Utils::Misc::friendlyUnit(speedLimit, true) + "]"; speedLbl += " (" + Utils::Misc::friendlyUnit(sessionStatus.totalPayloadUpload()) + ")"; m_upSpeedLbl->setText(speedLbl); }
QVariantMap getTranserInfoMap() { QVariantMap map; BitTorrent::SessionStatus sessionStatus = BitTorrent::Session::instance()->status(); map[KEY_TRANSFER_DLSPEED] = sessionStatus.payloadDownloadRate(); map[KEY_TRANSFER_DLDATA] = sessionStatus.totalPayloadDownload(); map[KEY_TRANSFER_UPSPEED] = sessionStatus.payloadUploadRate(); map[KEY_TRANSFER_UPDATA] = sessionStatus.totalPayloadUpload(); map[KEY_TRANSFER_DLRATELIMIT] = BitTorrent::Session::instance()->downloadSpeedLimit(); map[KEY_TRANSFER_UPRATELIMIT] = BitTorrent::Session::instance()->uploadSpeedLimit(); map[KEY_TRANSFER_DHT_NODES] = sessionStatus.dhtNodes(); if (!BitTorrent::Session::instance()->isListening()) map[KEY_TRANSFER_CONNECTION_STATUS] = "disconnected"; else map[KEY_TRANSFER_CONNECTION_STATUS] = sessionStatus.hasIncomingConnections() ? "connected" : "firewalled"; return map; }
void StatusBar::refreshStatusBar() { // Update connection status const BitTorrent::SessionStatus sessionStatus = BitTorrent::Session::instance()->status(); if (!BitTorrent::Session::instance()->isListening()) { connecStatusLblIcon->setIcon(QIcon(QString::fromUtf8(":/icons/skin/disconnected.png"))); connecStatusLblIcon->setToolTip(QString::fromUtf8("<b>")+tr("Connection Status:")+QString::fromUtf8("</b><br>")+tr("Offline. This usually means that qBittorrent failed to listen on the selected port for incoming connections.")); } else { if (sessionStatus.hasIncomingConnections()) { // Connection OK connecStatusLblIcon->setIcon(QIcon(QString::fromUtf8(":/icons/skin/connected.png"))); connecStatusLblIcon->setToolTip(QString::fromUtf8("<b>")+tr("Connection Status:")+QString::fromUtf8("</b><br>")+tr("Online")); }else{ connecStatusLblIcon->setIcon(QIcon(QString::fromUtf8(":/icons/skin/firewalled.png"))); connecStatusLblIcon->setToolTip(QString::fromUtf8("<b>")+tr("Connection status:")+QString::fromUtf8("</b><br>")+QString::fromUtf8("<i>")+tr("No direct connections. This may indicate network configuration problems.")+QString::fromUtf8("</i>")); } } // Update Number of DHT nodes if (BitTorrent::Session::instance()->isDHTEnabled()) { DHTLbl->setVisible(true); //statusSep1->setVisible(true); DHTLbl->setText(tr("DHT: %1 nodes").arg(QString::number(sessionStatus.dhtNodes()))); } else { DHTLbl->setVisible(false); //statusSep1->setVisible(false); } // Update speed labels QString speedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadDownloadRate(), true)+" ("+Utils::Misc::friendlyUnit(sessionStatus.totalPayloadDownload())+")"; int speedLimit = BitTorrent::Session::instance()->downloadRateLimit(); if (speedLimit) speedLbl = "["+Utils::Misc::friendlyUnit(speedLimit, true)+"] " + speedLbl; dlSpeedLbl->setText(speedLbl); speedLimit = BitTorrent::Session::instance()->uploadRateLimit(); speedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadUploadRate(), true)+" ("+Utils::Misc::friendlyUnit(sessionStatus.totalPayloadUpload())+")"; if (speedLimit) speedLbl = "["+Utils::Misc::friendlyUnit(speedLimit, true)+"] " + speedLbl; upSpeedLbl->setText(speedLbl); }