From 4c5f349f494ce8818fb1011be81ff8fe56fae39a Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Fri, 11 Jul 2008 17:43:57 +0000 Subject: [PATCH] - FEATURE: RSS can now be disabled from program preferences - COSMETIC: RSS Tab is now hidden as a default --- Changelog | 2 + src/GUI.cpp | 40 ++++++-- src/GUI.h | 1 + src/options.ui | 241 ++++++++++++++++++++++++-------------------- src/options_imp.cpp | 31 +++++- src/options_imp.h | 2 + 6 files changed, 191 insertions(+), 126 deletions(-) diff --git a/Changelog b/Changelog index 2e9f1a38d..2efe048bf 100644 --- a/Changelog +++ b/Changelog @@ -1,7 +1,9 @@ * Unknown - Christophe Dumez - v1.2.0 - FEATURE: DHT is always ON (no longer used as fallback) - FEATURE: The number of DHT nodes is displayed + - FEATURE: RSS can now be disabled from program preferences - COSMETIC: Transfer speed, ratio and DHT nodes are displayed in status bar + - COSMETIC: RSS Tab is now hidden as a default * Unknown - Christophe Dumez - v1.1.0 - FEATURE: Web interface to control qbittorrent (Ishan Arora) diff --git a/src/GUI.cpp b/src/GUI.cpp index 4978c77a8..09c2d0f48 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -147,8 +147,14 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis tabs->addTab(finishedTorrentTab, tr("Finished") + QString::fromUtf8(" (0/0)")); tabs->setTabIcon(1, QIcon(QString::fromUtf8(":/Icons/skin/seeding.png"))); connect(finishedTorrentTab, SIGNAL(torrentDoubleClicked(QString, bool)), this, SLOT(torrentDoubleClicked(QString, bool))); - connect(finishedTorrentTab, SIGNAL(finishedTorrentsNumberChanged(unsigned int)), this, SLOT(updateFinishedTorrentNumber(unsigned int))); + // Search engine tab + searchEngine = new SearchEngine(BTSession, myTrayIcon, systrayIntegration); + tabs->addTab(searchEngine, tr("Search")); + tabs->setTabIcon(2, QIcon(QString::fromUtf8(":/Icons/skin/search.png"))); + readSettings(); + // RSS Tab + rssWidget = 0; // Smooth torrent switching between tabs Downloading <--> Finished connect(downloadingTorrentTab, SIGNAL(torrentFinished(QString)), finishedTorrentTab, SLOT(addTorrent(QString))); connect(finishedTorrentTab, SIGNAL(torrentMovedFromFinishedList(QString)), downloadingTorrentTab, SLOT(addTorrent(QString))); @@ -160,15 +166,6 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis configureSession(true); // Resume unfinished torrents BTSession->resumeUnfinishedTorrents(); - // Search engine tab - searchEngine = new SearchEngine(BTSession, myTrayIcon, systrayIntegration); - tabs->addTab(searchEngine, tr("Search")); - tabs->setTabIcon(2, QIcon(QString::fromUtf8(":/Icons/skin/search.png"))); - // RSS tab - rssWidget = new RSSImp(); - tabs->addTab(rssWidget, tr("RSS")); - tabs->setTabIcon(3, QIcon(QString::fromUtf8(":/Icons/rss32.png"))); - readSettings(); // Add torrent given on command line processParams(torrentCmdLine); // Initialize Web UI @@ -241,7 +238,8 @@ GUI::~GUI() { delete statusSep1; delete statusSep2; delete statusSep3; - delete rssWidget; + if(rssWidget != 0) + delete rssWidget; delete searchEngine; delete refresher; delete downloadingTorrentTab; @@ -274,6 +272,20 @@ GUI::~GUI() { qDebug("5"); } +void GUI::displayRSSTab(bool enable) { + if(enable) { + // RSS tab + rssWidget = new RSSImp(); + tabs->addTab(rssWidget, tr("RSS")); + tabs->setTabIcon(3, QIcon(QString::fromUtf8(":/Icons/rss32.png"))); + } else { + if(rssWidget != 0) { + delete rssWidget; + rssWidget = 0; + } + } +} + void GUI::updateRatio() { // Update ratio info float ratio = 1.; @@ -1092,6 +1104,12 @@ void GUI::configureSession(bool deleteOptions) { BTSession->disableIPFilter(); downloadingTorrentTab->setBottomTabEnabled(1, false); } + // RSS + if(options->isRSSEnabled()) { + displayRSSTab(true); + } else { + displayRSSTab(false); + } // Clean up if(deleteOptions) { delete options; diff --git a/src/GUI.h b/src/GUI.h index 9b1af6a4f..21516ba7d 100644 --- a/src/GUI.h +++ b/src/GUI.h @@ -179,6 +179,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{ protected: void closeEvent(QCloseEvent *); void hideEvent(QHideEvent *); + void displayRSSTab(bool enable); public: // Construct / Destruct diff --git a/src/options.ui b/src/options.ui index e9abf7038..bdaa7c81f 100644 --- a/src/options.ui +++ b/src/options.ui @@ -1562,7 +1562,7 @@ :/Icons/configure.png:/Icons/configure.png - + @@ -1622,117 +1622,136 @@ RSS - + - - - - - - 48 - 48 - - - - - 48 - 48 - - - - - - - :/Icons/rss32.png - - - true - - - - - - - - - - - RSS feeds refresh interval: - - - - - - - 1 - - - 999999 - - - 5 - - - - - - - minutes - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - Maximum number of articles per feed: - - - - - - - 9999 - - - 50 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - + + + Enable RSS support + + + + + + + false + + + RSS settings + + + + + + + + + 48 + 48 + + + + + 48 + 48 + + + + + + + :/Icons/rss32.png + + + true + + + + + + + + + + + RSS feeds refresh interval: + + + + + + + 1 + + + 999999 + + + 5 + + + + + + + minutes + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Maximum number of articles per feed: + + + + + + + 9999 + + + 50 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + diff --git a/src/options_imp.cpp b/src/options_imp.cpp index 8504e9699..54a2ec03e 100644 --- a/src/options_imp.cpp +++ b/src/options_imp.cpp @@ -140,8 +140,9 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ connect(checkMaxUploadsPerTorrent, SIGNAL(stateChanged(int)), this, SLOT(enableMaxUploadsLimitPerTorrent(int))); connect(checkRatioLimit, SIGNAL(stateChanged(int)), this, SLOT(enableShareRatio(int))); connect(checkRatioRemove, SIGNAL(stateChanged(int)), this, SLOT(enableDeleteRatio(int))); - // IP Filter tab - connect(checkIPFilter, SIGNAL(stateChanged(int)), this, SLOT(enableFilter(int))); + // Misc tab + connect(checkIPFilter, SIGNAL(stateChanged(int)), this, SLOT(enableFilter(int))); + connect(checkEnableRSS, SIGNAL(stateChanged(int)), this, SLOT(enableRSS(int))); // Web UI tab connect(checkWebUi, SIGNAL(toggled(bool)), this, SLOT(enableWebUi(bool))); @@ -205,6 +206,7 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ connect(textFilterPath, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton())); connect(spinRSSRefresh, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); connect(spinRSSMaxArticlesPerFeed, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); + connect(checkEnableRSS, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); // Web UI tab connect(checkWebUi, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(spinWebUiPort, SIGNAL(valueChanged(int)), this, SLOT(enableApplyButton())); @@ -338,8 +340,9 @@ void options_imp::saveOptions(){ } // End IPFilter preferences settings.endGroup(); - // * RSS + // RSS settings.beginGroup("RSS"); + settings.setValue(QString::fromUtf8("RSSEnabled"), isRSSEnabled()); settings.setValue(QString::fromUtf8("RSSRefresh"), spinRSSRefresh->value()); settings.setValue(QString::fromUtf8("RSSMaxArticlesPerFeed"), spinRSSMaxArticlesPerFeed->value()); // End RSS preferences @@ -607,6 +610,12 @@ void options_imp::loadOptions(){ settings.endGroup(); // * RSS settings.beginGroup("RSS"); + checkEnableRSS->setChecked(settings.value(QString::fromUtf8("RSSEnabled"), false).toBool()); + if(isRSSEnabled()) { + enableRSS(2); // Enable + } else { + enableRSS(0); // Disable + } spinRSSRefresh->setValue(settings.value(QString::fromUtf8("RSSRefresh"), 5).toInt()); spinRSSMaxArticlesPerFeed->setValue(settings.value(QString::fromUtf8("RSSMaxArticlesPerFeed"), 50).toInt()); // End RSS preferences @@ -658,6 +667,10 @@ bool options_imp::isDHTEnabled() const{ return checkDHT->isChecked(); } +bool options_imp::isRSSEnabled() const{ + return checkEnableRSS->isChecked(); +} + bool options_imp::isPeXEnabled() const{ return checkPeX->isChecked(); } @@ -850,7 +863,7 @@ void options_imp::enableMaxUploadsLimitPerTorrent(int checkBoxValue){ } void options_imp::enableFilter(int checkBoxValue){ - if(checkBoxValue!=2){ + if(checkBoxValue != 2){ //Disable lblFilterPath->setEnabled(false); textFilterPath->setEnabled(false); @@ -863,6 +876,16 @@ void options_imp::enableFilter(int checkBoxValue){ } } +void options_imp::enableRSS(int checkBoxValue) { + if(checkBoxValue != 2){ + //Disable + groupRSSSettings->setEnabled(false); + }else{ + //enable + groupRSSSettings->setEnabled(true); + } +} + void options_imp::enableUploadLimit(int checkBoxValue){ if(checkBoxValue != 2){ //Disable diff --git a/src/options_imp.h b/src/options_imp.h index 709dcdb6a..be3cb0b47 100644 --- a/src/options_imp.h +++ b/src/options_imp.h @@ -99,6 +99,7 @@ class options_imp : public QDialog, private Ui::Dialog { bool isDHTEnabled() const; bool isPeXEnabled() const; bool isLSDEnabled() const; + bool isRSSEnabled() const; bool shouldSpoofAzureus() const; int getEncryptionSetting() const; float getDesiredRatio() const; @@ -123,6 +124,7 @@ class options_imp : public QDialog, private Ui::Dialog { void enableShareRatio(int checkBoxValue); void enableDeleteRatio(int checkBoxValue); void enableFilter(int checkBoxValue); + void enableRSS(int checkBoxValue); void setStyle(int style); void on_buttonBox_accepted(); void closeEvent(QCloseEvent *e);