diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2012-11-08 17:19:52 +0100 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2012-12-10 02:48:06 +0100 |
commit | 5d2d1c86ae51a7d17fb3e9906dbc6d5f563f19a9 (patch) | |
tree | 4388ca2cf2bb6a85a5a158acfe06a8f5c39724c9 /src/urlbar | |
parent | adblock work (diff) | |
download | rekonq-5d2d1c86ae51a7d17fb3e9906dbc6d5f563f19a9.tar.xz |
Clean up previous commit about adblock and fix enable/disable feature
Diffstat (limited to 'src/urlbar')
-rw-r--r-- | src/urlbar/adblockwidget.cpp | 36 | ||||
-rw-r--r-- | src/urlbar/bookmarkwidget.cpp | 2 | ||||
-rw-r--r-- | src/urlbar/urlbar.cpp | 5 |
3 files changed, 31 insertions, 12 deletions
diff --git a/src/urlbar/adblockwidget.cpp b/src/urlbar/adblockwidget.cpp index 2d317667..136fd2f2 100644 --- a/src/urlbar/adblockwidget.cpp +++ b/src/urlbar/adblockwidget.cpp @@ -24,20 +24,21 @@ * ============================================================ */ -// Auto Includes +// Self Includes #include "adblockwidget.h" #include "adblockwidget.moc" -// Local includes -#include "adblockmanager.h" +// Auto Includes +#include "rekonq.h" // KDE Includes +#include <KDialogButtonBox> #include <KIcon> #include <KLocalizedString> +#include <KStandardGuiItem> // Qt Includes #include <QCheckBox> -#include <QDialogButtonBox> #include <QVBoxLayout> #include <QLabel> #include <QPushButton> @@ -47,7 +48,7 @@ AdBlockWidget::AdBlockWidget(const QUrl &url, QWidget *parent) : QMenu(parent) , _pageUrl(url) , _chBox(new QCheckBox(this)) - , _isAdblockEnabledHere(AdBlockManager::self()->isAdblockEnabledForHost(_pageUrl.host())) + , _isAdblockEnabledHere(true) { setAttribute(Qt::WA_DeleteOnClose); setFixedWidth(320); @@ -62,6 +63,17 @@ AdBlockWidget::AdBlockWidget(const QUrl &url, QWidget *parent) f.setBold(true); title->setFont(f); + QStringList hList = ReKonfig::whiteReferer(); + const QString urlHost = _pageUrl.host(); + Q_FOREACH(const QString &host, hList) + { + if (host.contains(urlHost)) + { + _isAdblockEnabledHere = false; + break; + } + } + // Checkbox _chBox->setText(i18n("Enable adblock for this site")); _chBox->setChecked(_isAdblockEnabledHere); @@ -70,9 +82,9 @@ AdBlockWidget::AdBlockWidget(const QUrl &url, QWidget *parent) layout->addWidget(_chBox); // Ok & Cancel buttons - QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this); - connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); - connect(buttonBox, SIGNAL(rejected()), this, SLOT(close())); + KDialogButtonBox *buttonBox = new KDialogButtonBox(this, Qt::Horizontal); + buttonBox->addButton(KStandardGuiItem::ok(), QDialogButtonBox::AcceptRole, this, SLOT(accept())); + buttonBox->addButton(KStandardGuiItem::cancel(), QDialogButtonBox::RejectRole, this, SLOT(close())); layout->addWidget(buttonBox); } @@ -97,15 +109,19 @@ void AdBlockWidget::accept() bool on = _chBox->isChecked(); if (on != _isAdblockEnabledHere) { + QStringList hosts = ReKonfig::whiteReferer(); + if (on) { kDebug() << "REMOVING IT..."; - AdBlockManager::self()->removeCustomHostRule(_pageUrl.host()); + hosts.removeOne(_pageUrl.host()); } else { - AdBlockManager::self()->addCustomRule(QL1S("@@") + _pageUrl.host()); + hosts << _pageUrl.host(); } + + ReKonfig::setWhiteReferer(hosts); emit updateIcon(); } diff --git a/src/urlbar/bookmarkwidget.cpp b/src/urlbar/bookmarkwidget.cpp index 6c6763b0..6b39c2c8 100644 --- a/src/urlbar/bookmarkwidget.cpp +++ b/src/urlbar/bookmarkwidget.cpp @@ -26,7 +26,7 @@ * ============================================================ */ -// Auto Includes +// Self Includes #include "bookmarkwidget.h" #include "bookmarkwidget.moc" diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp index 5bd126e2..9321d442 100644 --- a/src/urlbar/urlbar.cpp +++ b/src/urlbar/urlbar.cpp @@ -600,7 +600,9 @@ IconButton *UrlBar::addRightIcon(UrlBar::icon ic) } break; case UrlBar::AdBlock: - if (AdBlockManager::self()->isAdblockEnabledForHost(_tab->url().host())) + { + QStringList hosts = ReKonfig::whiteReferer(); + if (!hosts.contains(_tab->url().host())) { rightIcon->setIcon(KIcon("preferences-web-browser-adblock")); rightIcon->setToolTip(i18n("AdBlock is enabled on this site")); @@ -611,6 +613,7 @@ IconButton *UrlBar::addRightIcon(UrlBar::icon ic) rightIcon->setToolTip(i18n("AdBlock is NOT enabled on this site")); } break; + } default: ASSERT_NOT_REACHED("ERROR.. default non extant case!!"); break; |