diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2012-02-14 11:27:54 +0100 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2012-03-13 10:24:42 +0100 |
commit | 1c97a54381cd6a5bfd1fb6d97e8695f1b1d49166 (patch) | |
tree | dbc2071257705803b98a322c93d5214a6d336199 /src/adblock/adblockmanager.cpp | |
parent | Let rekonq block sparse images (this idea has been copied from Arora) (diff) | |
download | rekonq-1c97a54381cd6a5bfd1fb6d97e8695f1b1d49166.tar.xz |
Add dialog allowing adblock to list blocked/hided elements and unblock
some of them
Diffstat (limited to 'src/adblock/adblockmanager.cpp')
-rw-r--r-- | src/adblock/adblockmanager.cpp | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/src/adblock/adblockmanager.cpp b/src/adblock/adblockmanager.cpp index 27fb4020..8005c7e5 100644 --- a/src/adblock/adblockmanager.cpp +++ b/src/adblock/adblockmanager.cpp @@ -34,6 +34,8 @@ // Local Includes #include "adblocknetworkreply.h" #include "adblockwidget.h" +#include "blockedelementswidget.h" + #include "webpage.h" // KDE Includes @@ -68,6 +70,12 @@ bool AdBlockManager::isEnabled() } +bool AdBlockManager::isHidingElements() +{ + return _isHideAdsEnabled; +} + + void AdBlockManager::loadSettings() { // first, check this... @@ -88,10 +96,13 @@ void AdBlockManager::loadSettings() _hostWhiteList.clear(); _hostBlackList.clear(); + _whiteList.clear(); _blackList.clear(); _hideList.clear(); + clearElementsLists(); + KConfigGroup settingsGroup(_adblockConfig, "Settings"); _isAdblockEnabled = settingsGroup.readEntry("adBlockEnabled", false); kDebug() << "ADBLOCK ENABLED = " << _isAdblockEnabled; @@ -232,7 +243,7 @@ QNetworkReply *AdBlockManager::block(const QNetworkRequest &request, WebPage *pa { kDebug() << "ADBLOCK: BLACK RULE Matched by string: " << urlString; AdBlockNetworkReply *reply = new AdBlockNetworkReply(request, urlString, this); - // TODO: add it to blocked list + _blockedElements << request.url().toString(); page->setHasAdBlockedElements(true); return reply; } @@ -261,7 +272,7 @@ QNetworkReply *AdBlockManager::block(const QNetworkRequest &request, WebPage *pa } AdBlockNetworkReply *reply = new AdBlockNetworkReply(request, urlString, this); - // TODO: add it to blocked list + _blockedElements << request.url().toString(); page->setHasAdBlockedElements(true); return reply; } @@ -297,7 +308,7 @@ void AdBlockManager::applyHidingRules(WebPage *page) kDebug() << "Hide element: " << el.localName(); el.setStyleProperty(QL1S("visibility"), QL1S("hidden")); el.removeFromDocument(); - // TODO: add it to hided list + _hidedElements++; page->setHasAdBlockedElements(true); } } @@ -374,5 +385,29 @@ void AdBlockManager::addCustomRule(const QString &stringRule) AdBlockRule rule(stringRule); _blackList << rule; - // TODO: update page? + emit reloadCurrentPage(); +} + + +void AdBlockManager::showBlockedItemDialog() +{ + QPointer<KDialog> dialog = new KDialog(); + dialog->setCaption(i18nc("@title:window", "Blocked & hided elements")); + dialog->setButtons(KDialog::Ok); + + BlockedElementsWidget widget(this); + widget.setBlockedElements(_blockedElements); + widget.setHidedElements(_hidedElements); + + dialog->setMainWidget(&widget); + dialog->exec(); + + dialog->deleteLater(); +} + + +void AdBlockManager::clearElementsLists() +{ + _blockedElements.clear(); + _hidedElements = 0; } |