void MainWindow::setupTimers() { QTimer *keysTimer = new QTimer; keysTimer->setInterval(10); QObject::connect(keysTimer, SIGNAL(timeout()), this, SLOT(checkKeys())); keysTimer->start(); QTimer *timer = new QTimer; timer->setInterval(1000); QObject::connect(timer, SIGNAL(timeout()), this, SLOT(updateStandartText())); QObject::connect(timer, SIGNAL(timeout()), this, SLOT(updateInform())); timer->start(); }
void MainWindow::checkKeys() { int key = wgetch(stdscr); if (key == ERR) return; if (key == '+') session->set_download_rate_limit(session->download_rate_limit() + 10000); else if (key == '-') session->set_download_rate_limit(session->download_rate_limit() - 10000); else if (key == 'a') main->invertAgressive(); updateStandartText(); updateInform(); }
void SeedManager::checkKeys() { int key = wgetch(stdscr); if (key == ERR) return; if (key == KEY_DOWN) firstDisplayingTorrent = min(int(session->get_torrents().size() - numberDisplayingTorrents()), firstDisplayingTorrent + 1); else if (key == KEY_UP) firstDisplayingTorrent = max(0, firstDisplayingTorrent - 1); else if (key == '+') session->set_upload_rate_limit(session->upload_rate_limit() + 10000); else if (key == '-') session->set_upload_rate_limit(session->upload_rate_limit() - 10000); updateInform(); }
SeedManager::SeedManager(QString rate, QObject *parent) : QObject(parent) { informationFlushed = false; firstDisplayingTorrent = 0; session = new libtorrent::session; session->listen_on(std::make_pair(6881, 6889)); session->set_alert_mask(0); session->set_upload_rate_limit(rate.toInt() * 1000); findTorrents(); QTimer *timer = new QTimer(this); timer->setInterval(1000); QObject::connect(timer, SIGNAL(timeout()), this, SLOT(updateInform())); timer->start(); QTimer *checkForErrorsTimer = new QTimer(this); checkForErrorsTimer->setInterval(120000); QObject::connect(checkForErrorsTimer, SIGNAL(timeout()), this, SLOT(checkForErrors())); checkForErrorsTimer->start(); QTimer *findNewTorrents = new QTimer(this); findNewTorrents->setInterval(600 * 1000); QObject::connect(findNewTorrents, SIGNAL(timeout()), this, SLOT(findTorrents())); findNewTorrents->start(); QTimer *checkKeys = new QTimer(this); checkKeys->setInterval(10); QObject::connect(checkKeys, SIGNAL(timeout()), this, SLOT(checkKeys())); checkKeys->start(); initscr(); nodelay(stdscr, true); keypad(stdscr, true); noecho(); }
void redraw(void) { /* erase warning line if necessary */ if ((warntimer <= udcounter && hwarncount <= udcounter) && (warncount || hwarncount)) { W_ClearWindow(warnw); } if (warntimer <= udcounter && warncount) { W_MaskText(w, center - (warncount / 2) * W_Textwidth, winside - W_Textheight - HUD_Y, backColor, warningbuf, warncount, W_RegularFont); warncount = 0; } if (hwarntimer <= udcounter && hwarncount) { W_MaskText(w, center - (hwarncount / 2) * W_Textwidth, HUD_Y, backColor, hwarningbuf, hwarncount, W_BoldFont); hwarncount = 0; } if(W_IsBuffered(w)) { /* buffered, clear the entire buffer [BDyess] */ W_ClearBuffer(w); clearcount = 0; clearlcount = 0; tractcurrent = tracthead; } else { if (W_FastClear) { W_ClearWindow(w); clearcount = 0; clearlcount = 0; tractcurrent = tracthead; } else { while (clearcount) { clearcount--; /* XFIX */ W_CacheClearArea(w, clearzone[clearcount].x, clearzone[clearcount].y, clearzone[clearcount].width, clearzone[clearcount].height); } while (clearlcount) { clearlcount--; /* XFIX */ W_CacheLine(w, clearline[0][clearlcount], clearline[1][clearlcount], clearline[2][clearlcount], clearline[3][clearlcount], backColor); } /* XFIX */ W_FlushClearAreaCache(w); W_FlushLineCaches(w); /* erase the tractor lines [BDyess] */ for (tractrunner = tracthead; tractrunner != tractcurrent; tractrunner = tractrunner->next) { W_MakeTractLine(w, tractrunner->sx, tractrunner->sy, tractrunner->d1x, tractrunner->d1y, backColor); W_MakeTractLine(w, tractrunner->sx, tractrunner->sy, tractrunner->d2x, tractrunner->d2y, backColor); } tractcurrent = tracthead; } } local(); /* redraw local window */ /* XFIX */ W_FlushLineCaches(w); stline(0); /* draw dashboard [BDyess] */ /* flush buffers [BDyess] */ W_DisplayBuffer(tstatw); /* dashboard [BDyess] */ W_DisplayBuffer(w); /* local [BDyess] */ /* would do it in W_EventsPending, just have it here so the display is updated sooner. */ W_Flush(); if (W_IsMapped(statwin)) { updateStats(); } if (W_IsMapped(newstatwin)) { updateNewStats(); } updateInform(); /* check and update info window [BDyess] */ /* XFIX: last since its least accurate information */ if (mapmode) { map(); /* write the buffered data, if any [BDyess] */ W_DisplayBuffer(mapw); } }