Skip to content

Commit

Permalink
Add RSS fetch delay to settings
Browse files Browse the repository at this point in the history
This commit only adds the RSS fetch delay setting to gui and loads it to to RssSession

Part 1 for qbittorrent#8350
  • Loading branch information
jNullj committed Oct 25, 2023
1 parent 9de32a7 commit e79878a
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 25 deletions.
13 changes: 13 additions & 0 deletions src/base/rss/rss_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ QPointer<Session> Session::m_instance = nullptr;
Session::Session()
: m_storeProcessingEnabled(u"RSS/Session/EnableProcessing"_s)
, m_storeRefreshInterval(u"RSS/Session/RefreshInterval"_s, 30)
, m_storeFetchDelay(u"RSS/Session/FetchDelay"_s, 2)
, m_storeMaxArticlesPerFeed(u"RSS/Session/MaxArticlesPerFeed"_s, 50)
, m_workingThread(new QThread)
{
Expand Down Expand Up @@ -116,6 +117,7 @@ Session::Session()
settingsStorage->removeValue(u"RSS/hosts_cookies"_s);
settingsStorage->removeValue(u"Rss/Session/EnableProcessing"_s);
settingsStorage->removeValue(u"Rss/Session/RefreshInterval"_s);
settingsStorage->removeValue(u"RSS/Session/FetchDelay"_s);
settingsStorage->removeValue(u"Rss/Session/MaxArticlesPerFeed"_s);
settingsStorage->removeValue(u"Rss/AutoDownloader/EnableProcessing"_s);
}
Expand Down Expand Up @@ -525,6 +527,17 @@ void Session::setRefreshInterval(const int refreshInterval)
}
}

int Session::fetchDelay() const
{
return m_storeFetchDelay;
}

void Session::setFetchDelay(const int fetchDelay)
{
if (m_storeFetchDelay == fetchDelay) { return; }
m_storeFetchDelay = fetchDelay;
}

QThread *Session::workingThread() const
{
return m_workingThread.get();
Expand Down
4 changes: 4 additions & 0 deletions src/base/rss/rss_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ namespace RSS
int refreshInterval() const;
void setRefreshInterval(int refreshInterval);

int fetchDelay() const;
void setFetchDelay(int fetchDelay);

nonstd::expected<void, QString> addFolder(const QString &path);
nonstd::expected<void, QString> addFeed(const QString &url, const QString &path);
nonstd::expected<void, QString> setFeedURL(const QString &path, const QString &url);
Expand Down Expand Up @@ -161,6 +164,7 @@ namespace RSS

CachedSettingValue<bool> m_storeProcessingEnabled;
CachedSettingValue<int> m_storeRefreshInterval;
CachedSettingValue<int> m_storeFetchDelay;
CachedSettingValue<int> m_storeMaxArticlesPerFeed;
Utils::Thread::UniquePtr m_workingThread;
AsyncFileStorage *m_confFileStorage = nullptr;
Expand Down
3 changes: 3 additions & 0 deletions src/gui/optionsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,7 @@ void OptionsDialog::loadRSSTabOptions()

m_ui->checkRSSEnable->setChecked(rssSession->isProcessingEnabled());
m_ui->spinRSSRefreshInterval->setValue(rssSession->refreshInterval());
m_ui->spinRSSFetchDelay->setValue(rssSession->fetchDelay());
m_ui->spinRSSMaxArticlesPerFeed->setValue(rssSession->maxArticlesPerFeed());
m_ui->checkRSSAutoDownloaderEnable->setChecked(autoDownloader->isProcessingEnabled());
m_ui->textSmartEpisodeFilters->setPlainText(autoDownloader->smartEpisodeFilters().join(u'\n'));
Expand All @@ -1180,6 +1181,7 @@ void OptionsDialog::loadRSSTabOptions()
connect(m_ui->textSmartEpisodeFilters, &QPlainTextEdit::textChanged, this, &OptionsDialog::enableApplyButton);
connect(m_ui->checkSmartFilterDownloadRepacks, &QCheckBox::toggled, this, &OptionsDialog::enableApplyButton);
connect(m_ui->spinRSSRefreshInterval, qSpinBoxValueChanged, this, &OptionsDialog::enableApplyButton);
connect(m_ui->spinRSSFetchDelay, qSpinBoxValueChanged, this, &OptionsDialog::enableApplyButton);
connect(m_ui->spinRSSMaxArticlesPerFeed, qSpinBoxValueChanged, this, &OptionsDialog::enableApplyButton);
}

Expand All @@ -1190,6 +1192,7 @@ void OptionsDialog::saveRSSTabOptions() const

rssSession->setProcessingEnabled(m_ui->checkRSSEnable->isChecked());
rssSession->setRefreshInterval(m_ui->spinRSSRefreshInterval->value());
rssSession->setFetchDelay(m_ui->spinRSSFetchDelay->value());
rssSession->setMaxArticlesPerFeed(m_ui->spinRSSMaxArticlesPerFeed->value());
autoDownloader->setProcessingEnabled(m_ui->checkRSSAutoDownloaderEnable->isChecked());
autoDownloader->setSmartEpisodeFilters(m_ui->textSmartEpisodeFilters->toPlainText().split(u'\n', Qt::SkipEmptyParts));
Expand Down
70 changes: 45 additions & 25 deletions src/gui/optionsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -3077,8 +3077,8 @@ Disable encryption: Only connect to peers without protocol encryption</string>
<rect>
<x>0</x>
<y>0</y>
<width>336</width>
<height>391</height>
<width>541</width>
<height>539</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_27">
Expand All @@ -3097,14 +3097,7 @@ Disable encryption: Only connect to peers without protocol encryption</string>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QLabel" name="label_111">
<property name="text">
<string>Feeds refresh interval:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="QSpinBox" name="spinRSSMaxArticlesPerFeed">
<property name="maximum">
<number>2147483646</number>
Expand All @@ -3114,12 +3107,18 @@ Disable encryption: Only connect to peers without protocol encryption</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Maximum number of articles per feed:</string>
<item row="0" column="2">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="spinRSSRefreshInterval">
Expand All @@ -3137,18 +3136,39 @@ Disable encryption: Only connect to peers without protocol encryption</string>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="2" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Maximum number of articles per feed:</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_111">
<property name="text">
<string>Feeds refresh interval:</string>
</property>
</spacer>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_rss_fetch_delay">
<property name="text">
<string>Delay between requests:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="spinRSSFetchDelay">
<property name="suffix">
<string> sec</string>
</property>
<property name="maximum">
<number>999999</number>
</property>
<property name="value">
<number>2</number>
</property>
</widget>
</item>
</layout>
</item>
Expand Down

0 comments on commit e79878a

Please sign in to comment.