1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-25 14:04:23 +00:00

- Fix indentation

This commit is contained in:
Christophe Dumez 2009-11-04 15:07:50 +00:00
parent bc308741b7
commit 92dd4c8c5b

View File

@ -241,10 +241,10 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
connect(scrapeTimer, SIGNAL(timeout()), this, SLOT(scrapeTrackers()));
scrapeTimer->start(20000);
qDebug("GUI Built");
}
}
// Destructor
GUI::~GUI() {
// Destructor
GUI::~GUI() {
qDebug("GUI destruction");
hide();
// Do this as soon as possible
@ -294,9 +294,9 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
qDebug("4");
delete BTSession;
qDebug("5");
}
}
void GUI::displayRSSTab(bool enable) {
void GUI::displayRSSTab(bool enable) {
if(enable) {
// RSS tab
if(rssWidget == 0) {
@ -310,9 +310,9 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
rssWidget = 0;
}
}
}
}
void GUI::scrapeTrackers() {
void GUI::scrapeTrackers() {
std::vector<torrent_handle> torrents = BTSession->getTorrents();
std::vector<torrent_handle>::iterator torrentIT;
for(torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) {
@ -320,9 +320,9 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
if(!h.is_valid()) continue;
h.scrape_tracker();
}
}
}
void GUI::updateRatio() {
void GUI::updateRatio() {
// Update ratio info
float ratio = 1.;
session_status sessionStatus = BTSession->getSessionStatus();
@ -339,30 +339,30 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
ratioLbl->setText(tr("Ratio: %1").arg(QString(QByteArray::number(ratio, 'f', 1))));
// Update DHT nodes
DHTLbl->setText(tr("DHT: %1 nodes").arg(QString::number(sessionStatus.dht_nodes)));
}
}
void GUI::on_actionWebsite_triggered() const {
void GUI::on_actionWebsite_triggered() const {
QDesktopServices::openUrl(QUrl(QString::fromUtf8("http://www.qbittorrent.org")));
}
}
void GUI::on_actionDocumentation_triggered() const {
void GUI::on_actionDocumentation_triggered() const {
QDesktopServices::openUrl(QUrl(QString::fromUtf8("http://wiki.qbittorrent.org")));
}
}
void GUI::on_actionBugReport_triggered() const {
void GUI::on_actionBugReport_triggered() const {
QDesktopServices::openUrl(QUrl(QString::fromUtf8("http://bugs.qbittorrent.org")));
}
}
void GUI::writeSettings() {
void GUI::writeSettings() {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
settings.beginGroup(QString::fromUtf8("MainWindow"));
settings.setValue(QString::fromUtf8("size"), size());
settings.setValue(QString::fromUtf8("pos"), pos());
settings.endGroup();
}
}
// called when a torrent has finished
void GUI::finishedTorrent(QTorrentHandle& h) const {
// called when a torrent has finished
void GUI::finishedTorrent(QTorrentHandle& h) const {
qDebug("In GUI, a torrent has finished");
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
bool show_msg = true;
@ -379,33 +379,33 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
if(show_msg && systrayIntegration && useNotificationBalloons) {
myTrayIcon->showMessage(tr("Download finished"), tr("%1 has finished downloading.", "e.g: xxx.avi has finished downloading.").arg(fileName), QSystemTrayIcon::Information, TIME_TRAY_BALLOON);
}
}
}
void GUI::addedTorrent(QTorrentHandle& h) const {
void GUI::addedTorrent(QTorrentHandle& h) const {
if(h.is_seed()) {
finishedTorrentTab->addTorrent(h.hash());
} else {
downloadingTorrentTab->addTorrent(h.hash());
}
}
}
void GUI::pausedTorrent(QTorrentHandle& h) const {
void GUI::pausedTorrent(QTorrentHandle& h) const {
if(h.is_seed()) {
finishedTorrentTab->pauseTorrent(h.hash());
} else {
downloadingTorrentTab->pauseTorrent(h.hash());
}
}
}
void GUI::resumedTorrent(QTorrentHandle& h) const {
void GUI::resumedTorrent(QTorrentHandle& h) const {
if(h.is_seed()) {
finishedTorrentTab->updateTorrent(h);
} else {
downloadingTorrentTab->updateTorrent(h);
}
}
}
void GUI::checkedTorrent(QTorrentHandle& h) const {
void GUI::checkedTorrent(QTorrentHandle& h) const {
if(h.is_seed()) {
// Move torrent to finished tab
downloadingTorrentTab->deleteTorrent(h.hash());
@ -418,10 +418,10 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
downloadingTorrentTab->addTorrent(h.hash());
}
}
}
}
// Notification when disk is full
void GUI::fullDiskError(QTorrentHandle& h, QString msg) const {
// Notification when disk is full
void GUI::fullDiskError(QTorrentHandle& h, QString msg) const {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
bool useNotificationBalloons = settings.value(QString::fromUtf8("Preferences/General/NotificationBaloons"), true).toBool();
if(systrayIntegration && useNotificationBalloons) {
@ -432,9 +432,9 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
qDebug("Full disk error, pausing torrent %s", hash.toLocal8Bit().data());
setPaused(h);
BTSession->addConsoleMessage(tr("An error occured (full disk?), '%1' paused.", "e.g: An error occured (full disk?), 'xxx.avi' paused.").arg(h.name()));
}
}
void GUI::setPaused(QTorrentHandle &h) const {
void GUI::setPaused(QTorrentHandle &h) const {
if(!h.is_paused()) {
// FIXME in v1.6.0: Add Error state and stop using pause for this
h.pause();
@ -447,9 +447,9 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
}else{
downloadingTorrentTab->pauseTorrent(h.hash());
}
}
}
void GUI::createKeyboardShortcuts() {
void GUI::createKeyboardShortcuts() {
actionCreate_torrent->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+N")));
actionOpen->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+O")));
actionExit->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+Q")));
@ -473,36 +473,36 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
actionPause_All->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+Shift+P")));
actionDecreasePriority->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+-")));
actionIncreasePriority->setShortcut(QKeySequence(QString::fromUtf8("Ctrl++")));
}
}
// Keyboard shortcuts slots
void GUI::displayDownTab() const {
// Keyboard shortcuts slots
void GUI::displayDownTab() const {
tabs->setCurrentIndex(0);
}
}
void GUI::displayUpTab() const {
void GUI::displayUpTab() const {
tabs->setCurrentIndex(1);
}
}
void GUI::displaySearchTab() const {
void GUI::displaySearchTab() const {
tabs->setCurrentIndex(2);
}
}
void GUI::displayRSSTab() const {
void GUI::displayRSSTab() const {
tabs->setCurrentIndex(3);
}
}
// End of keyboard shortcuts slots
// End of keyboard shortcuts slots
void GUI::readSettings() {
void GUI::readSettings() {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
settings.beginGroup(QString::fromUtf8("MainWindow"));
resize(settings.value(QString::fromUtf8("size"), size()).toSize());
move(settings.value(QString::fromUtf8("pos"), screenCenter()).toPoint());
settings.endGroup();
}
}
void GUI::balloonClicked() {
void GUI::balloonClicked() {
if(isHidden()) {
show();
if(isMinimized()) {
@ -511,15 +511,15 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
raise();
activateWindow();
}
}
}
void GUI::acceptConnection() {
void GUI::acceptConnection() {
clientConnection = localServer->nextPendingConnection();
connect(clientConnection, SIGNAL(disconnected()), this, SLOT(readParamsOnSocket()));
qDebug("accepted connection from another instance");
}
}
void GUI::readParamsOnSocket() {
void GUI::readParamsOnSocket() {
if(clientConnection) {
QByteArray params = clientConnection->readAll();
if(!params.isEmpty()) {
@ -527,28 +527,28 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
qDebug("Received parameters from another instance");
}
}
}
}
void GUI::handleDownloadFromUrlFailure(QString url, QString reason) const{
void GUI::handleDownloadFromUrlFailure(QString url, QString reason) const{
// Display a message box
QMessageBox::critical(0, tr("Url download error"), tr("Couldn't download file at url: %1, reason: %2.").arg(url).arg(reason));
}
}
void GUI::on_actionSet_global_upload_limit_triggered() {
void GUI::on_actionSet_global_upload_limit_triggered() {
qDebug("actionSet_global_upload_limit_triggered");
new BandwidthAllocationDialog(this, true, BTSession, QStringList());
}
}
void GUI::on_actionShow_console_triggered() {
void GUI::on_actionShow_console_triggered() {
new consoleDlg(this, BTSession);
}
}
void GUI::on_actionSet_global_download_limit_triggered() {
void GUI::on_actionSet_global_download_limit_triggered() {
qDebug("actionSet_global_download_limit_triggered");
new BandwidthAllocationDialog(this, false, BTSession, QStringList());
}
}
void GUI::on_actionPreview_file_triggered() {
void GUI::on_actionPreview_file_triggered() {
QString hash;
switch(tabs->currentIndex()){
case 0:
@ -562,9 +562,9 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
}
QTorrentHandle h = BTSession->getTorrentHandle(hash);
new previewSelect(this, h);
}
}
void GUI::openDestinationFolder() const {
void GUI::openDestinationFolder() const {
QStringList hashes;
switch(tabs->currentIndex()){
case 0:
@ -585,9 +585,9 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
QDesktopServices::openUrl(QString("file://")+savePath);
}
}
}
}
void GUI::copyMagnetURI() const {
void GUI::copyMagnetURI() const {
QStringList hashes;
switch(tabs->currentIndex()){
case 0:
@ -607,9 +607,9 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
}
}
qApp->clipboard()->setText(magnet_uris.join("\n"));
}
}
void GUI::goBuyPage() const {
void GUI::goBuyPage() const {
QStringList hashes;
switch(tabs->currentIndex()){
case 0:
@ -626,31 +626,31 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
QTorrentHandle h = BTSession->getTorrentHandle(hash);
QDesktopServices::openUrl("http://match.sharemonkey.com/?info_hash="+hash+"&n="+h.name()+"&cid=33");
}
}
}
// Necessary if we want to close the window
// in one time if "close to systray" is enabled
void GUI::on_actionExit_triggered() {
// Necessary if we want to close the window
// in one time if "close to systray" is enabled
void GUI::on_actionExit_triggered() {
force_exit = true;
close();
}
}
void GUI::previewFile(QString filePath) {
void GUI::previewFile(QString filePath) {
QDesktopServices::openUrl(QString("file://")+filePath);
}
}
int GUI::getCurrentTabIndex() const{
int GUI::getCurrentTabIndex() const{
if(isMinimized() || isHidden())
return -1;
return tabs->currentIndex();
}
}
void GUI::setTabText(int index, QString text) const {
void GUI::setTabText(int index, QString text) const {
tabs->setTabText(index, text);
}
}
// Toggle Main window visibility
void GUI::toggleVisibility(QSystemTrayIcon::ActivationReason e) {
// Toggle Main window visibility
void GUI::toggleVisibility(QSystemTrayIcon::ActivationReason e) {
if(e == QSystemTrayIcon::Trigger || e == QSystemTrayIcon::DoubleClick) {
if(isHidden()) {
show();
@ -667,10 +667,10 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
hide();
}
}
}
}
// Center window
QPoint GUI::screenCenter() const{
// Center window
QPoint GUI::screenCenter() const{
int scrn = 0;
QWidget *w = this->topLevelWidget();
@ -683,22 +683,22 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
QRect desk(QApplication::desktop()->availableGeometry(scrn));
return QPoint((desk.width() - this->frameGeometry().width()) / 2, (desk.height() - this->frameGeometry().height()) / 2);
}
}
// Display About Dialog
void GUI::on_actionAbout_triggered() {
// Display About Dialog
void GUI::on_actionAbout_triggered() {
//About dialog
new about(this);
}
}
void GUI::showEvent(QShowEvent *e) {
void GUI::showEvent(QShowEvent *e) {
qDebug("** Show Event **");
updateLists(true);
e->accept();
}
}
// Called when we close the program
void GUI::closeEvent(QCloseEvent *e) {
// Called when we close the program
void GUI::closeEvent(QCloseEvent *e) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
bool goToSystrayOnExit = settings.value(QString::fromUtf8("Preferences/General/CloseToTray"), false).toBool();
@ -734,16 +734,16 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
// Accept exit
e->accept();
qApp->exit();
}
}
// Display window to create a torrent
void GUI::on_actionCreate_torrent_triggered() {
// Display window to create a torrent
void GUI::on_actionCreate_torrent_triggered() {
createtorrent *ct = new createtorrent(this);
connect(ct, SIGNAL(torrent_to_seed(QString)), this, SLOT(addTorrent(QString)));
}
}
bool GUI::event(QEvent * e) {
bool GUI::event(QEvent * e) {
if(e->type() == QEvent::WindowStateChange) {
//Now check to see if the window is minimised
if(isMinimized()) {
@ -755,10 +755,10 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
}
}
return QMainWindow::event(e);
}
}
// Action executed when a file is dropped
void GUI::dropEvent(QDropEvent *event) {
// Action executed when a file is dropped
void GUI::dropEvent(QDropEvent *event) {
event->acceptProposedAction();
QStringList files;
if(event->mimeData()->hasUrls()) {
@ -793,27 +793,27 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
BTSession->addTorrent(file);
}
}
}
}
// Decode if we accept drag 'n drop or not
void GUI::dragEnterEvent(QDragEnterEvent *event) {
// Decode if we accept drag 'n drop or not
void GUI::dragEnterEvent(QDragEnterEvent *event) {
foreach(const QString &mime, event->mimeData()->formats()){
qDebug("mimeData: %s", mime.toLocal8Bit().data());
}
if (event->mimeData()->hasFormat(QString::fromUtf8("text/plain")) || event->mimeData()->hasFormat(QString::fromUtf8("text/uri-list"))) {
event->acceptProposedAction();
}
}
}
/*****************************************************
/*****************************************************
* *
* Torrent *
* *
*****************************************************/
// Display a dialog to allow user to add
// torrents to download list
void GUI::on_actionOpen_triggered() {
// Display a dialog to allow user to add
// torrents to download list
void GUI::on_actionOpen_triggered() {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
// Open File Open Dialog
// Note: it is possible to select more than one file
@ -836,10 +836,10 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
top_dir.removeLast();
settings.setValue(QString::fromUtf8("MainWindowLastDir"), top_dir.join(QDir::separator()));
}
}
}
// delete from download list AND from hard drive
void GUI::on_actionDelete_Permanently_triggered() {
// delete from download list AND from hard drive
void GUI::on_actionDelete_Permanently_triggered() {
QStringList hashes;
bool inDownloadList = true;
switch(tabs->currentIndex()){
@ -879,16 +879,16 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
// Remove the torrent
BTSession->deleteTorrent(hash, true);
}
}
}
void GUI::deleteTorrent(QString hash) {
void GUI::deleteTorrent(QString hash) {
// Delete item from list
downloadingTorrentTab->deleteTorrent(hash);
finishedTorrentTab->deleteTorrent(hash);
}
}
// delete selected items in the list
void GUI::on_actionDelete_triggered() {
// delete selected items in the list
void GUI::on_actionDelete_triggered() {
QStringList hashes;
bool inDownloadList = true;
switch(tabs->currentIndex()){
@ -931,13 +931,13 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
// Remove the torrent
BTSession->deleteTorrent(hash, false);
}
}
}
// As program parameters, we can get paths or urls.
// This function parse the parameters and call
// the right addTorrent function, considering
// the parameter type.
void GUI::processParams(const QStringList& params) {
// As program parameters, we can get paths or urls.
// This function parse the parameters and call
// the right addTorrent function, considering
// the parameter type.
void GUI::processParams(const QStringList& params) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Preferences/Downloads/AdditionDialog"), true).toBool();
foreach(QString param, params) {
@ -959,13 +959,13 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
}
}
}
}
}
void GUI::addTorrent(QString path) {
void GUI::addTorrent(QString path) {
BTSession->addTorrent(path);
}
}
void GUI::processDownloadedFiles(QString path, QString url) {
void GUI::processDownloadedFiles(QString path, QString url) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Preferences/Downloads/AdditionDialog"), true).toBool();
if(useTorrentAdditionDialog) {
@ -974,10 +974,10 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
}else{
BTSession->addTorrent(path, false, url);
}
}
}
// Set BT session configuration
void GUI::configureSession(bool deleteOptions) {
// Set BT session configuration
void GUI::configureSession(bool deleteOptions) {
qDebug("Configuring session");
// General
bool new_displaySpeedInTitle = options->speedInTitleBar();
@ -1245,20 +1245,20 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
options->deleteLater();
}
qDebug("Session configured");
}
}
void GUI::updateUnfinishedTorrentNumber(unsigned int nb) {
void GUI::updateUnfinishedTorrentNumber(unsigned int nb) {
unsigned int paused = BTSession->getUnfinishedPausedTorrentsNb();
tabs->setTabText(0, tr("Downloads") +QString::fromUtf8(" (")+misc::toQString(nb-paused)+"/"+misc::toQString(nb)+QString::fromUtf8(")"));
}
}
void GUI::updateFinishedTorrentNumber(unsigned int nb) {
void GUI::updateFinishedTorrentNumber(unsigned int nb) {
unsigned int paused = BTSession->getFinishedPausedTorrentsNb();
tabs->setTabText(1, tr("Finished") +QString::fromUtf8(" (")+misc::toQString(nb-paused)+"/"+misc::toQString(nb)+QString::fromUtf8(")"));
}
}
// Allow to change action on double-click
void GUI::torrentDoubleClicked(QString hash, bool finished) {
// Allow to change action on double-click
void GUI::torrentDoubleClicked(QString hash, bool finished) {
int action;
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QTorrentHandle h = BTSession->getTorrentHandle(hash);
@ -1287,10 +1287,10 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
}
break;
}
}
}
// Toggle paused state of selected torrent
void GUI::togglePausedState(QString hash) {
// Toggle paused state of selected torrent
void GUI::togglePausedState(QString hash) {
if(tabs->currentIndex() > 1) return;
bool inDownloadList = true;
if(tabs->currentIndex() == 1)
@ -1313,10 +1313,10 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
updateFinishedTorrentNumber(finishedTorrentTab->getNbTorrentsInList());
}
}
}
}
// Pause All Downloads in DL list
void GUI::on_actionPause_All_triggered() {
// Pause All Downloads in DL list
void GUI::on_actionPause_All_triggered() {
bool change = false;
std::vector<torrent_handle> torrents = BTSession->getTorrents();
std::vector<torrent_handle>::iterator torrentIT;
@ -1331,9 +1331,9 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList());
updateFinishedTorrentNumber(finishedTorrentTab->getNbTorrentsInList());
}
}
}
void GUI::on_actionIncreasePriority_triggered() {
void GUI::on_actionIncreasePriority_triggered() {
if(tabs->currentIndex() != 0)
return;
QStringList hashes = downloadingTorrentTab->getSelectedTorrents();
@ -1341,19 +1341,19 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
BTSession->increaseDlTorrentPriority(hash);
}
updateLists();
}
}
void GUI::on_actionDecreasePriority_triggered() {
void GUI::on_actionDecreasePriority_triggered() {
Q_ASSERT(tabs->currentIndex() == 0);
QStringList hashes = downloadingTorrentTab->getSelectedTorrents();
foreach(const QString &hash, hashes) {
BTSession->decreaseDlTorrentPriority(hash);
}
updateLists();
}
}
// pause selected items in the list
void GUI::on_actionPause_triggered() {
// pause selected items in the list
void GUI::on_actionPause_triggered() {
bool inDownloadList = true;
if(tabs->currentIndex() > 1) return;
if(tabs->currentIndex() == 1)
@ -1377,10 +1377,10 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
}
}
}
}
}
// Resume All Downloads in DL list
void GUI::on_actionStart_All_triggered() {
// Resume All Downloads in DL list
void GUI::on_actionStart_All_triggered() {
bool change = false;
std::vector<torrent_handle> torrents = BTSession->getTorrents();
std::vector<torrent_handle>::iterator torrentIT;
@ -1395,10 +1395,10 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList());
updateFinishedTorrentNumber(finishedTorrentTab->getNbTorrentsInList());
}
}
}
// start selected items in the list
void GUI::on_actionStart_triggered() {
// start selected items in the list
void GUI::on_actionStart_triggered() {
bool inDownloadList = true;
if(tabs->currentIndex() > 1) return;
if(tabs->currentIndex() == 1)
@ -1421,17 +1421,17 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
}
}
}
}
}
void GUI::addUnauthenticatedTracker(QPair<QTorrentHandle,QString> tracker) {
void GUI::addUnauthenticatedTracker(QPair<QTorrentHandle,QString> tracker) {
// Trackers whose authentication was cancelled
if(unauthenticated_trackers.indexOf(tracker) < 0) {
unauthenticated_trackers << tracker;
}
}
}
// display properties of selected items
void GUI::on_actionTorrent_Properties_triggered() {
// display properties of selected items
void GUI::on_actionTorrent_Properties_triggered() {
if(tabs->currentIndex() > 1) return;
switch(tabs->currentIndex()){
case 1: // DL List
@ -1440,9 +1440,9 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
default:
downloadingTorrentTab->propertiesSelection();
}
}
}
void GUI::updateLists(bool force) {
void GUI::updateLists(bool force) {
if(isVisible() || force) {
// update global informations
dlSpeedLbl->setText(tr("DL: %1 KiB/s").arg(QString(QByteArray::number(BTSession->getPayloadDownloadRate()/1024., 'f', 1))));
@ -1474,18 +1474,18 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
QString up_rate = QByteArray::number(BTSession->getSessionStatus().payload_upload_rate/1024, 'f', 1);
setWindowTitle(tr("qBittorrent %1 (DL: %2KiB/s, UP: %3KiB/s)", "%1 is qBittorrent version").arg(QString::fromUtf8(VERSION)).arg(dl_rate).arg(up_rate));
}
}
}
// Called when a tracker requires authentication
void GUI::trackerAuthenticationRequired(QTorrentHandle& h) {
// Called when a tracker requires authentication
void GUI::trackerAuthenticationRequired(QTorrentHandle& h) {
if(unauthenticated_trackers.indexOf(QPair<QTorrentHandle,QString>(h, h.current_tracker())) < 0) {
// Tracker login
new trackerLogin(this, h);
}
}
}
// Check connection status and display right icon
void GUI::checkConnectionStatus() {
// Check connection status and display right icon
void GUI::checkConnectionStatus() {
// qDebug("Checking connection status");
// Update Ratio
updateRatio();
@ -1518,15 +1518,15 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
connecStatusLblIcon->setPixmap(QPixmap(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>"));
}
}
}
/*****************************************************
/*****************************************************
* *
* Utils *
* *
*****************************************************/
void GUI::downloadFromURLList(const QStringList& url_list) {
void GUI::downloadFromURLList(const QStringList& url_list) {
foreach(const QString url, url_list) {
if(url.startsWith("magnet:", Qt::CaseInsensitive)) {
BTSession->addMagnetUri(url);
@ -1534,15 +1534,15 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
BTSession->downloadFromUrl(url);
}
}
}
}
/*****************************************************
/*****************************************************
* *
* Options *
* *
*****************************************************/
void GUI::createSystrayDelayed() {
void GUI::createSystrayDelayed() {
static int timeout = 10;
if(QSystemTrayIcon::isSystemTrayAvailable()) {
// Ok, systray integration is now supported
@ -1561,9 +1561,9 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
delete systrayCreator;
}
}
}
}
void GUI::createTrayIcon() {
void GUI::createTrayIcon() {
// Tray icon
#ifdef Q_WS_WIN
myTrayIcon = new QSystemTrayIcon(QIcon(QString::fromUtf8(":/Icons/skin/qbittorrent16.png")), this);
@ -1588,17 +1588,17 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
// End of Icon Menu
connect(myTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(toggleVisibility(QSystemTrayIcon::ActivationReason)));
myTrayIcon->show();
}
}
// Display Program Options
void GUI::on_actionOptions_triggered() {
// Display Program Options
void GUI::on_actionOptions_triggered() {
options = new options_imp(this);
connect(options, SIGNAL(status_changed(bool)), this, SLOT(OptionsSaved(bool)));
options->show();
}
}
// Is executed each time options are saved
void GUI::OptionsSaved(bool deleteOptions) {
// Is executed each time options are saved
void GUI::OptionsSaved(bool deleteOptions) {
BTSession->addConsoleMessage(tr("Options were saved successfully."));
bool newSystrayIntegration = options->systrayIntegration();
if(newSystrayIntegration != systrayIntegration) {
@ -1623,9 +1623,9 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
}
// Update session
configureSession(deleteOptions);
}
}
bool GUI::initWebUi(QString username, QString password, int port) {
bool GUI::initWebUi(QString username, QString password, int port) {
if(httpServer)
httpServer->close();
else
@ -1637,18 +1637,18 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
else
QMessageBox::critical(this, "Web User Interface Error", "Unable to initialize HTTP Server on port " + misc::toQString(port));
return success;
}
}
/*****************************************************
/*****************************************************
* *
* HTTP Downloader *
* *
*****************************************************/
// Display an input dialog to prompt user for
// an url
void GUI::on_actionDownload_from_URL_triggered() {
// Display an input dialog to prompt user for
// an url
void GUI::on_actionDownload_from_URL_triggered() {
downloadFromURL *downloadFromURLDialog = new downloadFromURL(this);
connect(downloadFromURLDialog, SIGNAL(urlsReadyToBeDownloaded(const QStringList&)), BTSession, SLOT(downloadFromURLList(const QStringList&)));
}
}