Exemplo n.º 1
0
void StatusBar::capUploadSpeed() {
  bool ok = false;
  int cur_limit = BitTorrent::Session::instance()->uploadRateLimit();
  long new_limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Global Upload Speed Limit"), cur_limit);
  if (ok) {
    Preferences* const pref = Preferences::instance();
    bool alt = pref->isAltBandwidthEnabled();
    if (new_limit <= 0) {
      qDebug("Setting global upload rate limit to Unlimited");
      BitTorrent::Session::instance()->setUploadRateLimit(-1);
      if (!alt)
        Preferences::instance()->setGlobalUploadLimit(-1);
      else
        Preferences::instance()->setAltGlobalUploadLimit(-1);
    } else {
      qDebug("Setting global upload rate limit to %.1fKb/s", new_limit/1024.);
      BitTorrent::Session::instance()->setUploadRateLimit(new_limit);
      if (!alt)
        Preferences::instance()->setGlobalUploadLimit(new_limit/1024.);
      else
        Preferences::instance()->setAltGlobalUploadLimit(new_limit/1024.);
    }
    refreshStatusBar();
  }
}
Exemplo n.º 2
0
CloudView::CloudView(QWidget *parent)
    : QWidget(parent),
      clone_task_dialog_(NULL)

{
    setupUi(this);

    // seahub_messages_monitor_ = new SeahubMessagesMonitor(this);
    // mSeahubMessagesBtn->setVisible(false);

    layout()->setContentsMargins(1, 0, 1, 0);

    // Setup widgets from top down
    setupHeader();

    createAccountView();

    createTabs();

    // tool bar have to be created after tabs, since some of the toolbar
    // actions are provided by the tabs
    createToolBar();

    setupDropArea();

    setupFooter();

    QVBoxLayout *vlayout = (QVBoxLayout *)layout();
    vlayout->insertWidget(kIndexOfAccountView, account_view_);
    vlayout->insertWidget(kIndexOfToolBar, tool_bar_);
    vlayout->insertWidget(kIndexOfTabWidget, tabs_);

    resizer_ = new QSizeGrip(this);
    resizer_->resize(resizer_->sizeHint());

    refresh_status_bar_timer_ = new QTimer(this);
    connect(refresh_status_bar_timer_, SIGNAL(timeout()), this, SLOT(refreshStatusBar()));

    AccountManager *account_mgr = seafApplet->accountManager();
    connect(account_mgr, SIGNAL(accountsChanged()),
            this, SLOT(onAccountChanged()));

#if defined(Q_OS_MAC)
    mHeader->setVisible(false);
#endif

    connect(ServerStatusService::instance(), SIGNAL(serverStatusChanged()),
            this, SLOT(refreshServerStatus()));
    connect(CustomizationService::instance(), SIGNAL(serverLogoFetched(const QUrl&)),
            this, SLOT(onServerLogoFetched(const QUrl&)));

    QTimer::singleShot(0, this, SLOT(onAccountChanged()));
}
Exemplo n.º 3
0
void StatusBar::capUploadSpeed()
{
    BitTorrent::Session *const session = BitTorrent::Session::instance();
    bool ok = false;
    const long newLimit = SpeedLimitDialog::askSpeedLimit(
                &ok, tr("Global Upload Speed Limit"), session->uploadSpeedLimit());
    if (ok) {
        qDebug("Setting global upload rate limit to %.1fKb/s", newLimit / 1024.);
        session->setUploadSpeedLimit(newLimit);
        refreshStatusBar();
    }
}
Exemplo n.º 4
0
void StatusBar::updateAltSpeedsBtn(bool alternative) {
  if (alternative) {
    altSpeedsBtn->setIcon(QIcon(":/icons/slow.png"));
    altSpeedsBtn->setToolTip(tr("Click to switch to regular speed limits"));
    altSpeedsBtn->setDown(true);
  } else {
    altSpeedsBtn->setIcon(QIcon(":/icons/slow_off.png"));
    altSpeedsBtn->setToolTip(tr("Click to switch to alternative speed limits"));
    altSpeedsBtn->setDown(false);
  }
  refreshStatusBar();
}
Exemplo n.º 5
0
void QueueMgrWindow::slotQueueContentsChanged()
{
    if (d->busy)
    {
        refreshStatusBar();
    }
    else
    {
        // refreshStatusBar() and actions in tools view
        slotAssignedToolsChanged(d->assignedList->assignedList());
    }
}
Exemplo n.º 6
0
CloudView::CloudView(QWidget *parent)
    : QWidget(parent),
      in_refresh_(false),
      list_repo_req_(NULL),
      clone_task_dialog_(NULL)

{
    setupUi(this);

    // seahub_messages_monitor_ = new SeahubMessagesMonitor(this);
    mSeahubMessagesBtn->setVisible(false);

    setupHeader();
    createRepoModelView();
    createLoadingView();
    createLoadingFailedView();
    mStack->insertWidget(INDEX_LOADING_VIEW, loading_view_);
    mStack->insertWidget(INDEX_LOADING_FAILED_VIEW, loading_failed_view_);
    mStack->insertWidget(INDEX_REPOS_VIEW, repos_tree_);

    createToolBar();
    updateAccountInfoDisplay();
    prepareAccountButtonMenu();

    setupDropArea();
    setupFooter();

    mDropArea->setVisible(false); //disk42

    resizer_ = new QSizeGrip(this);
    resizer_->resize(resizer_->sizeHint());

    refresh_status_bar_timer_ = new QTimer(this);
    connect(refresh_status_bar_timer_, SIGNAL(timeout()), this, SLOT(refreshStatusBar()));

    refresh_timer_ = new QTimer(this);
    connect(refresh_timer_, SIGNAL(timeout()), this, SLOT(refreshRepos()));

    connect(seafApplet->accountManager(), SIGNAL(accountAdded(const Account&)),
            this, SLOT(setCurrentAccount(const Account&)));

    connect(seafApplet->accountManager(), SIGNAL(accountAdded(const Account&)),
            this, SLOT(updateAccountMenu()));

    connect(seafApplet->accountManager(), SIGNAL(accountRemoved(const Account&)),
            this, SLOT(updateAccountMenu()));
#ifdef Q_WS_MAC
    mHeader->setVisible(false);
#endif
}
Exemplo n.º 7
0
StatusBar::StatusBar(QStatusBar *bar)
    : m_bar(bar)
{
    qApp->setStyleSheet("QStatusBar::item { border-width: 0; }");

    BitTorrent::Session *const session = BitTorrent::Session::instance();
    connect(session, SIGNAL(speedLimitModeChanged(bool)), this, SLOT(updateAltSpeedsBtn(bool)));
    m_container = new QWidget(bar);
    m_layout = new QHBoxLayout(m_container);
    m_layout->setContentsMargins(0,0,0,0);

    m_container->setLayout(m_layout);
    m_connecStatusLblIcon = new QPushButton(bar);
    m_connecStatusLblIcon->setFlat(true);
    m_connecStatusLblIcon->setFocusPolicy(Qt::NoFocus);
    m_connecStatusLblIcon->setCursor(Qt::PointingHandCursor);
    m_connecStatusLblIcon->setIcon(QIcon(":/icons/skin/firewalled.png"));
    m_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>"));

    m_dlSpeedLbl = new QPushButton(bar);
    m_dlSpeedLbl->setIcon(QIcon(":/icons/skin/download.png"));
    connect(m_dlSpeedLbl, SIGNAL(clicked()), this, SLOT(capDownloadSpeed()));
    m_dlSpeedLbl->setFlat(true);
    m_dlSpeedLbl->setFocusPolicy(Qt::NoFocus);
    m_dlSpeedLbl->setCursor(Qt::PointingHandCursor);
    m_dlSpeedLbl->setStyleSheet("text-align:left;");
    m_dlSpeedLbl->setMinimumWidth(200);

    m_upSpeedLbl = new QPushButton(bar);
    m_upSpeedLbl->setIcon(QIcon(":/icons/skin/seeding.png"));
    connect(m_upSpeedLbl, SIGNAL(clicked()), this, SLOT(capUploadSpeed()));
    m_upSpeedLbl->setFlat(true);
    m_upSpeedLbl->setFocusPolicy(Qt::NoFocus);
    m_upSpeedLbl->setCursor(Qt::PointingHandCursor);
    m_upSpeedLbl->setStyleSheet("text-align:left;");
    m_upSpeedLbl->setMinimumWidth(200);

    m_DHTLbl = new QLabel(tr("DHT: %1 nodes").arg(0), bar);
    m_DHTLbl->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);

    m_altSpeedsBtn = new QPushButton(bar);
    m_altSpeedsBtn->setFlat(true);
    m_altSpeedsBtn->setFocusPolicy(Qt::NoFocus);
    m_altSpeedsBtn->setCursor(Qt::PointingHandCursor);
    updateAltSpeedsBtn(session->isAltGlobalSpeedLimitEnabled());
    connect(m_altSpeedsBtn, SIGNAL(clicked()), this, SLOT(toggleAlternativeSpeeds()));

    // Because on some platforms the default icon size is bigger
    // and it will result in taller/fatter statusbar, even if the
    // icons are actually 16x16
    m_connecStatusLblIcon->setIconSize(QSize(16, 16));
    m_dlSpeedLbl->setIconSize(QSize(16, 16));
    m_upSpeedLbl->setIconSize(QSize(16, 16));
    m_altSpeedsBtn->setIconSize(QSize(28, 16));

    // Set to the known maximum width(plus some padding)
    // so the speed widgets will take the rest of the space
    m_connecStatusLblIcon->setMaximumWidth(16 + 6);
    m_altSpeedsBtn->setMaximumWidth(28 + 6);

    m_statusSep1 = new QFrame(bar);
    m_statusSep1->setFrameStyle(QFrame::VLine);
    m_statusSep1->setFrameShadow(QFrame::Raised);
    m_statusSep2 = new QFrame(bar);
    m_statusSep2->setFrameStyle(QFrame::VLine);
    m_statusSep2->setFrameShadow(QFrame::Raised);
    m_statusSep3 = new QFrame(bar);
    m_statusSep3->setFrameStyle(QFrame::VLine);
    m_statusSep3->setFrameShadow(QFrame::Raised);
    m_statusSep4 = new QFrame(bar);
    m_statusSep4->setFrameStyle(QFrame::VLine);
    m_statusSep4->setFrameShadow(QFrame::Raised);
    m_layout->addWidget(m_DHTLbl);
    m_layout->addWidget(m_statusSep1);
    m_layout->addWidget(m_connecStatusLblIcon);
    m_layout->addWidget(m_statusSep2);
    m_layout->addWidget(m_altSpeedsBtn);
    m_layout->addWidget(m_statusSep4);
    m_layout->addWidget(m_dlSpeedLbl);
    m_layout->addWidget(m_statusSep3);
    m_layout->addWidget(m_upSpeedLbl);

    bar->addPermanentWidget(m_container);
    bar->setStyleSheet("QWidget {margin: 0;}");
    m_container->adjustSize();
    bar->adjustSize();
    // Is DHT enabled
    m_DHTLbl->setVisible(session->isDHTEnabled());
    m_refreshTimer = new QTimer(bar);
    refreshStatusBar();
    connect(m_refreshTimer, SIGNAL(timeout()), this, SLOT(refreshStatusBar()));
    m_refreshTimer->start(1500);
}
Exemplo n.º 8
0
CloudView::CloudView(QWidget* parent)
    : QWidget(parent), clone_task_dialog_(NULL)

{
    setupUi(this);

    int marginTop = 0;
    if (shouldUseFramelessWindow()) {
        marginTop = 0;
    }
#ifdef Q_OS_MAC
    marginTop = 0;
#endif

    layout()->setContentsMargins(1, marginTop, 1, 0);

    // Setup widgets from top down
    setupHeader();

    createAccountView();

    createTabs();

    // tool bar have to be created after tabs, since some of the toolbar
    // actions are provided by the tabs
    // createToolBar();

    setupDropArea();

    setupFooter();

    QVBoxLayout* vlayout = (QVBoxLayout*)layout();
    vlayout->insertWidget(kIndexOfAccountView, account_view_);
    vlayout->insertWidget(kIndexOfTabWidget, tabs_);

    if (shouldUseFramelessWindow()) {
        resizer_ = new QSizeGrip(this);
        resizer_->resize(resizer_->sizeHint());
    }

    refresh_status_bar_timer_ = new QTimer(this);
    connect(refresh_status_bar_timer_, SIGNAL(timeout()), this,
            SLOT(refreshStatusBar()));

    AccountManager* account_mgr = seafApplet->accountManager();
    connect(account_mgr, SIGNAL(accountsChanged()), this,
            SLOT(onAccountChanged()));
    connect(account_mgr, SIGNAL(accountInfoUpdated(const Account&)), this,
            SLOT(onAccountInfoUpdated(const Account&)));

    if (!shouldUseFramelessWindow()) {
        mHeader->setVisible(false);
    }

    connect(ServerStatusService::instance(), SIGNAL(serverStatusChanged()),
            this, SLOT(refreshServerStatus()));
    connect(CustomizationService::instance(),
            SIGNAL(serverLogoFetched(const QUrl&)), this,
            SLOT(onServerLogoFetched(const QUrl&)));

    QTimer::singleShot(0, this, SLOT(onAccountChanged()));
}
Exemplo n.º 9
0
StatusBar::StatusBar(QStatusBar *bar)
  : m_bar(bar)
{
  Preferences* const pref = Preferences::instance();
  connect(QBtSession::instance(), SIGNAL(alternativeSpeedsModeChanged(bool)), this, SLOT(updateAltSpeedsBtn(bool)));
  container = new QWidget(bar);
  layout = new QHBoxLayout(container);
  layout->setContentsMargins(0,0,0,0);

  container->setLayout(layout);
  connecStatusLblIcon = new QPushButton(bar);
  connecStatusLblIcon->setFlat(true);
  connecStatusLblIcon->setFocusPolicy(Qt::NoFocus);
  connecStatusLblIcon->setFixedWidth(32);
  connecStatusLblIcon->setCursor(Qt::PointingHandCursor);
  connecStatusLblIcon->setIcon(QIcon(":/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>"));
  dlSpeedLbl = new QPushButton(bar);
  dlSpeedLbl->setIconSize(QSize(16,16));
  dlSpeedLbl->setIcon(QIcon(":/Icons/skin/download.png"));
  //dlSpeedLbl->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
  connect(dlSpeedLbl, SIGNAL(clicked()), this, SLOT(capDownloadSpeed()));
  dlSpeedLbl->setFlat(true);
  dlSpeedLbl->setFocusPolicy(Qt::NoFocus);
  dlSpeedLbl->setCursor(Qt::PointingHandCursor);

  altSpeedsBtn = new QPushButton(bar);
  altSpeedsBtn->setFixedWidth(36);
  altSpeedsBtn->setIconSize(QSize(32,32));
  altSpeedsBtn->setFlat(true);
  altSpeedsBtn->setFocusPolicy(Qt::NoFocus);
  altSpeedsBtn->setCursor(Qt::PointingHandCursor);
  updateAltSpeedsBtn(pref->isAltBandwidthEnabled());

  connect(altSpeedsBtn, SIGNAL(clicked()), this, SLOT(toggleAlternativeSpeeds()));

  upSpeedLbl = new QPushButton(bar);
  upSpeedLbl->setIconSize(QSize(16,16));
  upSpeedLbl->setIcon(QIcon(":/Icons/skin/seeding.png"));
  //upSpeedLbl->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
  connect(upSpeedLbl, SIGNAL(clicked()), this, SLOT(capUploadSpeed()));
  upSpeedLbl->setFlat(true);
  upSpeedLbl->setFocusPolicy(Qt::NoFocus);
  upSpeedLbl->setCursor(Qt::PointingHandCursor);
  DHTLbl = new QLabel(tr("DHT: %1 nodes").arg(0), bar);
  DHTLbl->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
  statusSep1 = new QFrame(bar);
  statusSep1->setFixedSize(3, dlSpeedLbl->fontMetrics().height());
  statusSep1->setFrameStyle(QFrame::VLine);
  statusSep1->setFrameShadow(QFrame::Raised);
  statusSep2 = new QFrame(bar);
  statusSep2->setFixedSize(3, dlSpeedLbl->fontMetrics().height());
  statusSep2->setFrameStyle(QFrame::VLine);
  statusSep2->setFrameShadow(QFrame::Raised);
  statusSep3 = new QFrame(bar);
  statusSep3->setFixedSize(3, dlSpeedLbl->fontMetrics().height());
  statusSep3->setFrameStyle(QFrame::VLine);
  statusSep3->setFrameShadow(QFrame::Raised);
  statusSep4 = new QFrame(bar);
  statusSep4->setFixedSize(3, dlSpeedLbl->fontMetrics().height());
  statusSep4->setFrameStyle(QFrame::VLine);
  statusSep4->setFrameShadow(QFrame::Raised);
  layout->addWidget(DHTLbl);
  layout->addWidget(statusSep1);
  layout->addWidget(connecStatusLblIcon);
  layout->addWidget(statusSep2);
  layout->addWidget(altSpeedsBtn);
  layout->addWidget(statusSep4);
  layout->addWidget(dlSpeedLbl);
  layout->addWidget(statusSep3);
  layout->addWidget(upSpeedLbl);

  bar->addPermanentWidget(container);
  container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
  //bar->setStyleSheet("QWidget {padding-top: 0; padding-bottom: 0; margin-top: 0; margin-bottom: 0;}\n");
  container->setContentsMargins(0, 0, 0, 1);
  bar->setContentsMargins(0, 0, 0, 0);
  container->setFixedHeight(dlSpeedLbl->fontMetrics().height()+7);
  bar->setFixedHeight(dlSpeedLbl->fontMetrics().height()+9);
  // Is DHT enabled
  DHTLbl->setVisible(pref->isDHTEnabled());
  refreshTimer = new QTimer(bar);
  refreshStatusBar();
  connect(refreshTimer, SIGNAL(timeout()), this, SLOT(refreshStatusBar()));
  refreshTimer->start(1500);
}