From 30aa59f582c6b94ce170a84b7e4e4f1a142264d7 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Tue, 10 Apr 2007 09:31:25 +0000 Subject: [PATCH] - Kept on working on bandwidth allocation per torrent - Fixed a crash in search engine when systray integration was disabled --- TODO | 3 ++- src/GUI.cpp | 11 ++++++++--- src/MainWindow.ui | 10 ++++++++++ src/allocationDlg.h | 10 ++++++++++ src/bandwidth_limit.ui | 18 +----------------- src/searchEngine.cpp | 4 ++-- src/searchEngine.h | 3 ++- 7 files changed, 35 insertions(+), 24 deletions(-) diff --git a/TODO b/TODO index e37e06ce4..104983ded 100644 --- a/TODO +++ b/TODO @@ -44,4 +44,5 @@ - Use its UPnP/NAT-PMP built-in support instead of ours - Use its piece prioritization support - Improve ratio display / calculation / saving / per torrent... -- Allow to set upload / download limit per torrent (right click menu) \ No newline at end of file +- Allow to set upload / download limit per torrent (right click menu) +- Use buttonboxes when possible \ No newline at end of file diff --git a/src/GUI.cpp b/src/GUI.cpp index c6d194115..7c3023961 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -54,12 +54,14 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){ setupUi(this); setWindowTitle(tr("qBittorrent %1", "e.g: qBittorrent v0.x").arg(VERSION)); + QSettings settings("qBittorrent", "qBittorrent"); + systrayIntegration = settings.value("Options/Misc/Behaviour/SystrayIntegration", true).toBool(); // Finished torrents tab finishedTorrentTab = new FinishedTorrents(this, &BTSession); tabs->addTab(finishedTorrentTab, tr("Finished")); tabs->setTabIcon(1, QIcon(QString::fromUtf8(":/Icons/skin/seeding.png"))); // Search engine tab - searchEngine = new SearchEngine(&BTSession, myTrayIcon); + searchEngine = new SearchEngine(&BTSession, myTrayIcon, systrayIntegration); tabs->addTab(searchEngine, tr("Search")); tabs->setTabIcon(2, QIcon(QString::fromUtf8(":/Icons/skin/search.png"))); // RSS tab @@ -87,6 +89,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){ actionStart_All->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/play_all.png"))); actionClearLog->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/delete.png"))); actionPreview_file->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/preview.png"))); + //TODO: set icons for Upload/Download limit actions // actionDocumentation->setIcon(QIcon(QString::fromUtf8(":/Icons/help.png"))); connecStatusLblIcon = new QLabel(); connecStatusLblIcon->setFrameShape(QFrame::NoFrame); @@ -157,8 +160,6 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){ connect(infoBar, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayInfoBarMenu(const QPoint&))); // Create tray icon if (QSystemTrayIcon::isSystemTrayAvailable()){ - QSettings settings("qBittorrent", "qBittorrent"); - systrayIntegration = settings.value("Options/Misc/Behaviour/SystrayIntegration", true).toBool(); if(systrayIntegration){ createTrayIcon(); } @@ -295,6 +296,10 @@ void GUI::togglePausedState(const QModelIndex& index){ } } +// void GUI::on_actionSet_download_limit_triggered(){ +// new BandwidthAllocationDialog(this, +// } + void GUI::on_actionPreview_file_triggered(){ if(tabs->currentIndex() > 1) return; bool inDownloadList = true; diff --git a/src/MainWindow.ui b/src/MainWindow.ui index 11718ac83..4edd4cddc 100644 --- a/src/MainWindow.ui +++ b/src/MainWindow.ui @@ -530,6 +530,16 @@ Report a bug + + + Set upload limit + + + + + Set download limit + + diff --git a/src/allocationDlg.h b/src/allocationDlg.h index 7376a6d5a..aef2e49dc 100644 --- a/src/allocationDlg.h +++ b/src/allocationDlg.h @@ -58,6 +58,7 @@ class BandwidthAllocationDialog : public QDialog, private Ui_bandwidth_dlg { // val = -1; // bandwidthSlider->setValue(val); // } + connect(buttonBox, SIGNAL(accepted()), this, SLOT(setBandwidth())); } ~BandwidthAllocationDialog(){ @@ -75,6 +76,15 @@ class BandwidthAllocationDialog : public QDialog, private Ui_bandwidth_dlg { } } + void setBandwidth(){ + int val = bandwidthSlider->value(); + if(uploadMode) + h.set_upload_limit(val); + else + h.set_download_limit(val); + close(); + } + private: bool uploadMode; bittorrent *BTSession; diff --git a/src/bandwidth_limit.ui b/src/bandwidth_limit.ui index 165caff73..42e5e4a1f 100644 --- a/src/bandwidth_limit.ui +++ b/src/bandwidth_limit.ui @@ -6,7 +6,7 @@ 0 0 222 - 99 + 129 @@ -93,22 +93,6 @@ - - buttonBox - accepted() - bandwidth_dlg - accept() - - - 212 - 77 - - - 157 - 98 - - - buttonBox rejected() diff --git a/src/searchEngine.cpp b/src/searchEngine.cpp index 6846ba87a..705f6ad34 100644 --- a/src/searchEngine.cpp +++ b/src/searchEngine.cpp @@ -42,7 +42,7 @@ #define SEARCHHISTORY_MAXSIZE 50 -SearchEngine::SearchEngine(bittorrent *BTSession, QSystemTrayIcon *myTrayIcon) : QWidget(){ +SearchEngine::SearchEngine(bittorrent *BTSession, QSystemTrayIcon *myTrayIcon, bool systrayIntegration) : QWidget(), systrayIntegration(systrayIntegration){ setupUi(this); this->BTSession = BTSession; this->myTrayIcon = myTrayIcon; @@ -526,7 +526,7 @@ void SearchEngine::on_update_nova_button_clicked(){ void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus){ QSettings settings("qBittorrent", "qBittorrent"); int useOSD = settings.value("Options/OSDEnabled", 1).toInt(); - if(useOSD == 1 || (useOSD == 2 && (isMinimized() || isHidden()))) { + if(systrayIntegration && (useOSD == 1 || (useOSD == 2 && (isMinimized() || isHidden())))) { myTrayIcon->showMessage(tr("Search Engine"), tr("Search has finished"), QSystemTrayIcon::Information, TIME_TRAY_BALLOON); } if(exitcode){ diff --git a/src/searchEngine.h b/src/searchEngine.h index c61da7610..a2f9dd592 100644 --- a/src/searchEngine.h +++ b/src/searchEngine.h @@ -49,9 +49,10 @@ class SearchEngine : public QWidget, public Ui::search_engine{ SearchListDelegate *SearchDelegate; bittorrent *BTSession; QSystemTrayIcon *myTrayIcon; + bool systrayIntegration; public: - SearchEngine(bittorrent *BTSession, QSystemTrayIcon *myTrayIcon); + SearchEngine(bittorrent *BTSession, QSystemTrayIcon *myTrayIcon, bool systrayIntegration); ~SearchEngine(); float getNovaVersion(const QString& novaPath) const; QByteArray getNovaChangelog(const QString& novaPath) const;