summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2012-03-06 11:16:04 +0100
committerAndrea Diamantini <adjam7@gmail.com>2012-03-13 10:24:42 +0100
commit6f072c5dfcac294a12283d4ba93e22d50df9c660 (patch)
tree76b4e27b03bf9976a66cd5bc02462851b9e659f4 /src
parentClean up adblock manager code and fix unblock feature (diff)
downloadrekonq-6f072c5dfcac294a12283d4ba93e22d50df9c660.tar.xz
Let user change his mind enabling block/unblock
Diffstat (limited to 'src')
-rw-r--r--src/adblock/adblockmanager.cpp5
-rw-r--r--src/adblock/blockedelementswidget.cpp25
-rw-r--r--src/adblock/blockedelementswidget.h4
3 files changed, 25 insertions, 9 deletions
diff --git a/src/adblock/adblockmanager.cpp b/src/adblock/adblockmanager.cpp
index 39040767..b5739144 100644
--- a/src/adblock/adblockmanager.cpp
+++ b/src/adblock/adblockmanager.cpp
@@ -425,6 +425,11 @@ void AdBlockManager::showBlockedItemDialog()
dialog->setMainWidget(&widget);
dialog->exec();
+ Q_FOREACH(const QString &r, widget.rulesToAdd())
+ {
+ addCustomRule(r);
+ }
+
if (widget.pageNeedsReload())
emit reloadCurrentPage();
diff --git a/src/adblock/blockedelementswidget.cpp b/src/adblock/blockedelementswidget.cpp
index 58b96299..8c02134f 100644
--- a/src/adblock/blockedelementswidget.cpp
+++ b/src/adblock/blockedelementswidget.cpp
@@ -92,18 +92,25 @@ void BlockedElementsWidget::unblockElement()
if (!buttonClicked)
return;
- QString newText = i18n("Unblocked");
- if (buttonClicked->text() == newText)
- return;
-
- QString urlString = buttonClicked->property("URLTOUNBLOCK").toString();
+ QString urlString = QL1S("@@") + buttonClicked->property("URLTOUNBLOCK").toString();
kDebug() << "urlString: " << urlString;
- buttonClicked->setText(newText);
- buttonClicked->setIcon(KIcon("dialog-ok"));
+ QString newText = i18n("Unblocked");
+ QString buttonText = buttonClicked->text().remove('&');
+ if (buttonText == newText)
+ {
+ buttonClicked->setText(i18n("Unblock"));
+ buttonClicked->setIcon(KIcon("dialog-ok-apply"));
- AdBlockManager *m = qobject_cast<AdBlockManager *>(_manager);
- m->addCustomRule(QL1S("@@") + urlString, false);
+ _rulesToAdd.removeOne(urlString);
+ }
+ else
+ {
+ buttonClicked->setText(newText);
+ buttonClicked->setIcon(KIcon("dialog-ok"));
+ _rulesToAdd << urlString;
+ }
+
_reloadPage = true;
}
diff --git a/src/adblock/blockedelementswidget.h b/src/adblock/blockedelementswidget.h
index d1b0b387..c796be87 100644
--- a/src/adblock/blockedelementswidget.h
+++ b/src/adblock/blockedelementswidget.h
@@ -49,13 +49,17 @@ public:
void setHidedElements(int);
bool pageNeedsReload() { return _reloadPage; };
+
+ QStringList rulesToAdd() { return _rulesToAdd; };
private Q_SLOTS:
void unblockElement();
private:
QObject *_manager;
+
bool _reloadPage;
+ QStringList _rulesToAdd;
};
#endif // BLOCKED_ELEMENTS_WIDGET_H