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); }
void StatusBar::updateDHTNodesNumber(const BitTorrent::SessionStatus &sessionStatus) { if (BitTorrent::Session::instance()->isDHTEnabled()) { m_DHTLbl->setVisible(true); m_DHTLbl->setText(tr("DHT: %1 nodes").arg(QString::number(sessionStatus.dhtNodes()))); } else { m_DHTLbl->setVisible(false); } }
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); }
void StatusBar::updateConnectionStatus(const BitTorrent::SessionStatus &sessionStatus) { if (!BitTorrent::Session::instance()->isListening()) { m_connecStatusLblIcon->setIcon(QIcon(QLatin1String(":/icons/skin/disconnected.png"))); m_connecStatusLblIcon->setToolTip(QLatin1String("<b>") + tr("Connection Status:") + QLatin1String("</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 m_connecStatusLblIcon->setIcon(QIcon(QLatin1String(":/icons/skin/connected.png"))); m_connecStatusLblIcon->setToolTip(QLatin1String("<b>") + tr("Connection Status:") + QLatin1String("</b><br>") + tr("Online")); } else { m_connecStatusLblIcon->setIcon(QIcon(QLatin1String(":/icons/skin/firewalled.png"))); m_connecStatusLblIcon->setToolTip(QLatin1String("<b>") + tr("Connection status:") + QLatin1String("</b><br>") + QLatin1String("<i>") + tr("No direct connections. This may indicate network configuration problems.") + QLatin1String("</i>")); } } }
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; }