diff --git a/Changelog b/Changelog
index 9d86e10c7..848c20503 100644
--- a/Changelog
+++ b/Changelog
@@ -6,6 +6,7 @@
- FEATURE: Display pieces size in torrent properties
- FEATURE: Added "Time Active/Seeded" column to transfer list
- FEATURE: Give feedback regarding the IP filter parsing
+ - FEATURE: Added a button to reload the IP filter
- COSMETIC: Same deletion confirmation dialog in the GUI and Web UI
- COSMETIC: Simplified the top toolbar
- COSMETIC: Display execution log as a tab instead of a modal window
diff --git a/src/preferences/options.ui b/src/preferences/options.ui
index 801be29a7..e9ae2e68c 100644
--- a/src/preferences/options.ui
+++ b/src/preferences/options.ui
@@ -923,7 +923,7 @@ QGroupBox {
0
- 0
+ -51
506
457
@@ -1349,8 +1349,8 @@ QGroupBox {
- 22
- 22
+ 28
+ 27
@@ -1358,6 +1358,28 @@ QGroupBox {
+ -
+
+
+
+ 28
+ 27
+
+
+
+ Reload the filter
+
+
+
+
+
+
+ 16
+ 16
+
+
+
+
@@ -1770,7 +1792,7 @@ QGroupBox {
0
- -7
+ 0
581
422
@@ -2154,8 +2176,8 @@ QGroupBox {
0
0
- 524
- 414
+ 377
+ 229
@@ -2317,8 +2339,8 @@ QGroupBox {
0
0
- 524
- 414
+ 98
+ 28
diff --git a/src/preferences/options_imp.cpp b/src/preferences/options_imp.cpp
index 926833376..e3209d6c7 100644
--- a/src/preferences/options_imp.cpp
+++ b/src/preferences/options_imp.cpp
@@ -49,11 +49,13 @@
#include "advancedsettings.h"
#include "scannedfoldersmodel.h"
#include "qinisettings.h"
+#include "qbtsession.h"
using namespace libtorrent;
// Constructor
-options_imp::options_imp(QWidget *parent):QDialog(parent){
+options_imp::options_imp(QWidget *parent):
+ QDialog(parent), m_refreshingIpFilter(false) {
qDebug("-> Constructing Options");
setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
@@ -66,6 +68,7 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
tabSelection->item(TAB_SPEED)->setIcon(misc::getIcon("chronometer"));
tabSelection->item(TAB_WEBUI)->setIcon(misc::getIcon("network-server"));
tabSelection->item(TAB_ADVANCED)->setIcon(misc::getIcon("preferences-other"));
+ IpFilterRefreshBtn->setIcon(misc::getIcon("view-refresh"));
hsplitter->setCollapsible(0, false);
hsplitter->setCollapsible(1, false);
@@ -1146,3 +1149,27 @@ void options_imp::showConnectionTab()
tabSelection->setCurrentRow(2);
}
+void options_imp::on_IpFilterRefreshBtn_clicked() {
+ if(m_refreshingIpFilter) return;
+ m_refreshingIpFilter = true;
+ // Updating program preferences
+ Preferences pref;
+ pref.setFilteringEnabled(true);
+ pref.setFilter(getFilter());
+ // Force refresh
+ connect(QBtSession::instance(), SIGNAL(ipFilterParsed(bool, int)), SLOT(handleIPFilterParsed(bool, int)));
+ setCursor(QCursor(Qt::WaitCursor));
+ QBtSession::instance()->enableIPFilter(getFilter(), true);
+}
+
+void options_imp::handleIPFilterParsed(bool error, int ruleCount)
+{
+ setCursor(QCursor(Qt::ArrowCursor));
+ if(error) {
+ QMessageBox::warning(this, tr("Parsing error"), tr("Failed to parse the provided IP filter"));
+ } else {
+ QMessageBox::information(this, tr("Succesfully refreshed"), tr("Successfuly parsed the provided IP filter: %1 rules were applied.", "%1 is a number").arg(ruleCount));
+ }
+ m_refreshingIpFilter = false;
+ disconnect(QBtSession::instance(), SIGNAL(ipFilterParsed(bool, int)), this, SLOT(handleIPFilterParsed(bool, int)));
+}
diff --git a/src/preferences/options_imp.h b/src/preferences/options_imp.h
index 34fb2cff4..a3363657b 100644
--- a/src/preferences/options_imp.h
+++ b/src/preferences/options_imp.h
@@ -80,6 +80,8 @@ protected slots:
void on_addScanFolderButton_clicked();
void on_removeScanFolderButton_clicked();
void handleScanFolderViewSelectionChanged();
+ void on_IpFilterRefreshBtn_clicked();
+ void handleIPFilterParsed(bool error, int ruleCount);
public slots:
void setLocale(QString locale);
@@ -138,6 +140,7 @@ private:
// IP Filter
bool isFilteringEnabled() const;
QString getFilter() const;
+ bool m_refreshingIpFilter;
// Queueing system
bool isQueueingSystemEnabled() const;
int getMaxActiveDownloads() const;
diff --git a/src/qtlibtorrent/qbtsession.cpp b/src/qtlibtorrent/qbtsession.cpp
index eb44530bc..b9b9ff382 100644
--- a/src/qtlibtorrent/qbtsession.cpp
+++ b/src/qtlibtorrent/qbtsession.cpp
@@ -1745,16 +1745,16 @@ void QBtSession::setDHTPort(int dht_port) {
}
// Enable IP Filtering
-void QBtSession::enableIPFilter(QString filter) {
+void QBtSession::enableIPFilter(const QString &filter_path, bool force) {
qDebug("Enabling IPFiler");
if(!filterParser) {
filterParser = new FilterParserThread(this, s);
connect(filterParser.data(), SIGNAL(IPFilterParsed(int)), SLOT(handleIPFilterParsed(int)));
connect(filterParser.data(), SIGNAL(IPFilterError()), SLOT(handleIPFilterError()));
}
- if(filterPath.isEmpty() || filterPath != filter) {
- filterPath = filter;
- filterParser->processFilterFile(filter);
+ if(filterPath.isEmpty() || filterPath != filter_path || force) {
+ filterPath = filter_path;
+ filterParser->processFilterFile(filter_path);
}
}
@@ -2554,9 +2554,11 @@ qlonglong QBtSession::getETA(const QString &hash) const
void QBtSession::handleIPFilterParsed(int ruleCount)
{
addConsoleMessage(tr("Successfuly parsed the provided IP filter: %1 rules were applied.", "%1 is a number").arg(ruleCount));
+ emit ipFilterParsed(false, ruleCount);
}
void QBtSession::handleIPFilterError()
{
addConsoleMessage(tr("Error: Failed to parse the provided IP filter."), "red");
+ emit ipFilterParsed(true, 0);
}
diff --git a/src/qtlibtorrent/qbtsession.h b/src/qtlibtorrent/qbtsession.h
index 09e00b902..da9db1ee9 100644
--- a/src/qtlibtorrent/qbtsession.h
+++ b/src/qtlibtorrent/qbtsession.h
@@ -117,7 +117,7 @@ public slots:
/* End Web UI */
void preAllocateAllFiles(bool b);
void saveFastResumeData();
- void enableIPFilter(QString filter);
+ void enableIPFilter(const QString &filter_path, bool force=false);
void disableIPFilter();
void setQueueingEnabled(bool enable);
void handleDownloadFailure(QString url, QString reason);
@@ -203,6 +203,7 @@ signals:
void newBanMessage(const QString &msg);
void alternativeSpeedsModeChanged(bool alternative);
void recursiveTorrentDownloadPossible(const QTorrentHandle &h);
+ void ipFilterParsed(bool error, int ruleCount);
private:
#if LIBTORRENT_VERSION_MINOR < 15