示例#1
0
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);
    }
}
示例#2
0
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;
}
示例#3
0
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);
}