From 54131001b0dc962eb51bb5258a136cbbd7eb33c7 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Tue, 22 Jun 2010 13:39:49 +0000 Subject: [PATCH] Move RSS settings to a separate dialog --- src/GUI.cpp | 16 ++-- src/GUI.h | 1 + src/options_imp.cpp | 19 ----- src/options_imp.h | 1 - src/preferences.h | 11 +++ src/rss_imp.cpp | 7 ++ src/rss_imp.h | 17 ++-- src/rsssettings.cpp | 54 +++++++++++++ src/rsssettings.h | 56 +++++++++++++ src/src.pro | 10 ++- src/ui/mainwindow.ui | 9 +++ src/ui/options.ui | 179 +----------------------------------------- src/ui/rss.ui | 7 ++ src/ui/rsssettings.ui | 158 +++++++++++++++++++++++++++++++++++++ 14 files changed, 326 insertions(+), 219 deletions(-) create mode 100644 src/rsssettings.cpp create mode 100644 src/rsssettings.h create mode 100644 src/ui/rsssettings.ui diff --git a/src/GUI.cpp b/src/GUI.cpp index d0ff8e6a4..3df5e6aec 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -184,6 +184,9 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis // View settings actionTop_tool_bar->setChecked(Preferences::isToolbarDisplayed()); actionSpeed_in_title_bar->setChecked(Preferences::speedInTitleBar()); + actionRSS_Reader->setChecked(Preferences::isRSSEnabled()); + if(actionRSS_Reader->isChecked()) + displayRSSTab(true); show(); @@ -812,14 +815,6 @@ void GUI::loadPreferences(bool configure_session) { } } - // RSS - if(Preferences::isRSSEnabled()) { - displayRSSTab(true); - rssWidget->updateRefreshInterval(Preferences::getRSSRefreshInterval()); - } else { - displayRSSTab(false); - } - // Torrent properties properties->reloadPreferences(); @@ -1012,8 +1007,9 @@ void GUI::on_actionSpeed_in_title_bar_triggered() { setWindowTitle(tr("qBittorrent %1", "e.g: qBittorrent v0.x").arg(QString::fromUtf8(VERSION))); } - - +void GUI::on_actionRSS_Reader_triggered() { + displayRSSTab(actionRSS_Reader->isChecked()); +} /***************************************************** * * diff --git a/src/GUI.h b/src/GUI.h index 8e2533b71..4ac1c0443 100644 --- a/src/GUI.h +++ b/src/GUI.h @@ -166,6 +166,7 @@ private: QPointer rssWidget; private slots: + void on_actionRSS_Reader_triggered(); void on_actionSpeed_in_title_bar_triggered(); void on_actionTop_tool_bar_triggered(); }; diff --git a/src/options_imp.cpp b/src/options_imp.cpp index c69e22cac..78a1947fc 100644 --- a/src/options_imp.cpp +++ b/src/options_imp.cpp @@ -248,9 +248,6 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ // Misc tab connect(checkIPFilter, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); 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(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkEnableQueueing, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(spinMaxActiveDownloads, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); connect(spinMaxActiveUploads, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); @@ -484,13 +481,6 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ } // End IPFilter preferences settings.endGroup(); - // 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 - settings.endGroup(); // Queueing system settings.beginGroup("Queueing"); settings.setValue(QString::fromUtf8("QueueingEnabled"), isQueueingSystemEnabled()); @@ -807,11 +797,6 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ checkIPFilter->setChecked(Preferences::isFilteringEnabled()); textFilterPath->setText(Preferences::getFilter()); // End IP Filter - // * RSS - checkEnableRSS->setChecked(Preferences::isRSSEnabled()); - spinRSSRefresh->setValue(Preferences::getRSSRefreshInterval()); - spinRSSMaxArticlesPerFeed->setValue(Preferences::getRSSMaxArticlesPerFeed()); - // End RSS preferences // Queueing system preferences checkEnableQueueing->setChecked(Preferences::isQueueingSystemEnabled()); spinMaxActiveDownloads->setValue(Preferences::getMaxActiveDownloads()); @@ -929,10 +914,6 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ return checkDHT->isChecked(); } - bool options_imp::isRSSEnabled() const{ - return checkEnableRSS->isChecked(); - } - bool options_imp::isLSDEnabled() const{ return checkLSD->isChecked(); } diff --git a/src/options_imp.h b/src/options_imp.h index 37da85c7b..62c7473cd 100644 --- a/src/options_imp.h +++ b/src/options_imp.h @@ -95,7 +95,6 @@ protected: bool isDHTPortSameAsBT() const; int getDHTPort() const; bool isLSDEnabled() const; - bool isRSSEnabled() const; int getEncryptionSetting() const; float getDeleteRatio() const; // Proxy options diff --git a/src/preferences.h b/src/preferences.h index 78f9100b6..28ade6fd2 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -744,11 +744,22 @@ public: return settings.value(QString::fromUtf8("Preferences/RSS/RSSRefresh"), 5).toUInt(); } + static void setRSSRefreshInterval(uint interval) { + QSettings settings("qBittorrent", "qBittorrent"); + settings.setValue(QString::fromUtf8("Preferences/RSS/RSSRefresh"), interval); + } + static int getRSSMaxArticlesPerFeed() { QSettings settings("qBittorrent", "qBittorrent"); return settings.value(QString::fromUtf8("Preferences/RSS/RSSMaxArticlesPerFeed"), 50).toInt(); } + static void setRSSMaxArticlesPerFeed(int nb) { + QSettings settings("qBittorrent", "qBittorrent"); + settings.setValue(QString::fromUtf8("Preferences/RSS/RSSMaxArticlesPerFeed"), nb); + } + + // Queueing system static bool isQueueingSystemEnabled() { QSettings settings("qBittorrent", "qBittorrent"); diff --git a/src/rss_imp.cpp b/src/rss_imp.cpp index 92ac4c4a3..711d04412 100644 --- a/src/rss_imp.cpp +++ b/src/rss_imp.cpp @@ -43,6 +43,7 @@ #include "bittorrent.h" #include "cookiesdlg.h" #include "preferences.h" +#include "rsssettings.h" enum NewsCols { NEWS_ICON, NEWS_TITLE_COL, NEWS_URL_COL, NEWS_ID }; @@ -640,3 +641,9 @@ RSSImp::~RSSImp(){ qDebug("RSSImp deleted"); } + +void RSSImp::on_settingsButton_clicked() { + RssSettings rssSettingsDlg(this); + if(rssSettingsDlg.exec()) + updateRefreshInterval(Preferences::getRefreshInterval()); +} diff --git a/src/rss_imp.h b/src/rss_imp.h index b0a0a4d38..14d370f08 100644 --- a/src/rss_imp.h +++ b/src/rss_imp.h @@ -44,11 +44,9 @@ class QTreeWidgetItem; class RSSImp : public QWidget, public Ui::RSS{ Q_OBJECT -private: - RssManager *rssmanager; - Bittorrent *BTSession; - FeedList *listStreams; - QTreeWidgetItem* previous_news; +public: + RSSImp(Bittorrent *BTSession); + ~RSSImp(); public slots: void deleteSelectedItems(); @@ -80,10 +78,13 @@ protected slots: void loadFoldersOpenState(); void displayOverwriteError(QString filename); void on_actionManage_cookies_triggered(); + void on_settingsButton_clicked(); -public: - RSSImp(Bittorrent *BTSession); - ~RSSImp(); +private: + RssManager *rssmanager; + Bittorrent *BTSession; + FeedList *listStreams; + QTreeWidgetItem* previous_news; }; diff --git a/src/rsssettings.cpp b/src/rsssettings.cpp new file mode 100644 index 000000000..fb919cc6d --- /dev/null +++ b/src/rsssettings.cpp @@ -0,0 +1,54 @@ +/* + * Bittorrent Client using Qt4 and libtorrent. + * Copyright (C) 2010 Christophe Dumez + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * In addition, as a special exception, the copyright holders give permission to + * link this program with the OpenSSL project's "OpenSSL" library (or with + * modified versions of it that use the same license as the "OpenSSL" library), + * and distribute the linked executables. You must obey the GNU General Public + * License in all respects for all of the code used other than "OpenSSL". If you + * modify file(s), you may extend this exception to your version of the file(s), + * but you are not obligated to do so. If you do not wish to do so, delete this + * exception statement from your version. + * + * Contact : chris@qbittorrent.org + */ + +#include "rsssettings.h" +#include "ui_rsssettings.h" +#include "preferences.h" + +RssSettings::RssSettings(QWidget *parent) : + QDialog(parent), + ui(new Ui::RssSettings) +{ + ui->setupUi(this); + // Load settings + ui->spinRSSRefresh->setValue(Preferences::getRSSRefreshInterval()); + ui->spinRSSMaxArticlesPerFeed->setValue(Preferences::getRSSMaxArticlesPerFeed()); +} + +RssSettings::~RssSettings() +{ + delete ui; +} + +void RssSettings::on_buttonBox_accepted() { + // Save settings + Preferences::setRSSRefreshInterval(ui->spinRSSRefresh->value()); + Preferences::setRSSMaxArticlesPerFeed(ui->spinRSSMaxArticlesPerFeed->value()); +} diff --git a/src/rsssettings.h b/src/rsssettings.h new file mode 100644 index 000000000..33d455a92 --- /dev/null +++ b/src/rsssettings.h @@ -0,0 +1,56 @@ +/* + * Bittorrent Client using Qt4 and libtorrent. + * Copyright (C) 2010 Christophe Dumez + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * In addition, as a special exception, the copyright holders give permission to + * link this program with the OpenSSL project's "OpenSSL" library (or with + * modified versions of it that use the same license as the "OpenSSL" library), + * and distribute the linked executables. You must obey the GNU General Public + * License in all respects for all of the code used other than "OpenSSL". If you + * modify file(s), you may extend this exception to your version of the file(s), + * but you are not obligated to do so. If you do not wish to do so, delete this + * exception statement from your version. + * + * Contact : chris@qbittorrent.org + */ + +#ifndef RSSSETTINGS_H +#define RSSSETTINGS_H + +#include + +namespace Ui { + class RssSettings; +} + +class RssSettings : public QDialog +{ + Q_OBJECT + +public: + explicit RssSettings(QWidget *parent = 0); + ~RssSettings(); + +protected slots: + void on_buttonBox_accepted(); + +private: + Ui::RssSettings *ui; + +}; + +#endif // RSSSETTINGS_H diff --git a/src/src.pro b/src/src.pro index 5253b125b..006918258 100644 --- a/src/src.pro +++ b/src/src.pro @@ -328,7 +328,8 @@ contains(DEFINES, DISABLE_GUI) { trackerlogin.h \ pieceavailabilitybar.h \ advancedsettings.h \ - cookiesdlg.h + cookiesdlg.h \ + rsssettings.h macx { HEADERS += qmacapplication.h } @@ -360,7 +361,8 @@ contains(DEFINES, DISABLE_GUI) { ui/propertieswidget.ui \ ui/peer.ui \ ui/confirmdeletiondlg.ui \ - ui/cookiesdlg.ui + ui/cookiesdlg.ui \ + ui/rsssettings.ui } SOURCES += main.cpp \ @@ -390,7 +392,8 @@ SOURCES += main.cpp \ peerlistwidget.cpp \ cookiesdlg.cpp \ trackerlist.cpp \ - torrentadditiondlg.cpp + torrentadditiondlg.cpp \ + rsssettings.cpp macx { SOURCES += qmacapplication.cpp @@ -398,3 +401,4 @@ SOURCES += main.cpp \ } DESTDIR = . + diff --git a/src/ui/mainwindow.ui b/src/ui/mainwindow.ui index 43d4f4860..07caae4c2 100644 --- a/src/ui/mainwindow.ui +++ b/src/ui/mainwindow.ui @@ -79,6 +79,7 @@ + @@ -301,6 +302,14 @@ Show transfer speed in title bar + + + true + + + RSS Reader + + diff --git a/src/ui/options.ui b/src/ui/options.ui index 96f5d31e8..1fd98f263 100644 --- a/src/ui/options.ui +++ b/src/ui/options.ui @@ -179,21 +179,6 @@ ItemIsSelectable|ItemIsEnabled - - - RSS - - - AlignHCenter|AlignVCenter|AlignCenter - - - - :/Icons/rss32.png:/Icons/rss32.png - - - ItemIsSelectable|ItemIsEnabled - - Advanced @@ -225,7 +210,7 @@ 0 - -24 + 0 506 430 @@ -2613,168 +2598,6 @@ QGroupBox { - - - - - - true - - - - - 0 - 0 - 524 - 406 - - - - - - - RSS - - - true - - - false - - - - - - - - - 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 - - - 100 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - diff --git a/src/ui/rss.ui b/src/ui/rss.ui index 85b435ddc..e2440ed45 100644 --- a/src/ui/rss.ui +++ b/src/ui/rss.ui @@ -89,6 +89,13 @@ + + + + Settings... + + + diff --git a/src/ui/rsssettings.ui b/src/ui/rsssettings.ui new file mode 100644 index 000000000..7caec5cb4 --- /dev/null +++ b/src/ui/rsssettings.ui @@ -0,0 +1,158 @@ + + + RssSettings + + + + 0 + 0 + 468 + 137 + + + + RSS Reader Settings + + + + + + + + + 48 + 48 + + + + + 48 + 48 + + + + + + + :/Icons/rss32.png + + + true + + + + + + + RSS feeds refresh interval: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 1 + + + 999999 + + + 5 + + + + + + + minutes + + + + + + + Maximum number of articles per feed: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 9999 + + + 100 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + RssSettings + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + RssSettings + reject() + + + 316 + 260 + + + 286 + 274 + + + + +