Commit 2308a398 authored by Laurent Montel's avatar Laurent Montel 😁

Continue to implement it

parent e77684a4
......@@ -48,8 +48,7 @@ AdblockManager *AdblockManager::self()
}
AdblockManager::AdblockManager(QObject *parent)
: QObject(parent),
mEnabled(false)
: QObject(parent)
{
mAdBlockMatcher = new AdBlockMatcher(this);
reloadConfig();
......@@ -62,14 +61,15 @@ AdblockManager::~AdblockManager()
void AdblockManager::reloadConfig()
{
mEnabled = AdBlock::AdBlockSettings::self()->adBlockEnabled();
qDebug() << " void AdblockManager::reloadConfig()" << mEnabled << " " << this;
bool enabled = AdBlock::AdBlockSettings::self()->adBlockEnabled();
enabledChanged(enabled);
qDebug() << " void AdblockManager::reloadConfig()" << enabled << " " << this;
//TODO
}
bool AdblockManager::isEnabled() const
{
return mEnabled;
return mAdBlockMatcher->isEnabled();
}
bool AdblockManager::interceptRequest(const QWebEngineUrlRequestInfo &info)
......
......@@ -37,6 +37,9 @@ public:
bool interceptRequest(const QWebEngineUrlRequestInfo &info);
Q_SIGNALS:
void enabledChanged(bool);
public Q_SLOTS:
void reloadConfig();
......
......@@ -41,9 +41,10 @@
using namespace AdBlock;
AdBlockMatcher::AdBlockMatcher(AdblockManager *manager)
: QObject(manager)
, m_manager(manager)
, m_manager(manager),
m_enabled(false)
{
//FIXME connect(manager, SIGNAL(enabledChanged(bool)), this, SLOT(enabledChanged(bool)));
connect(manager, &AdblockManager::enabledChanged, this, &AdBlockMatcher::enabledChanged);
}
AdBlockMatcher::~AdBlockMatcher()
......@@ -145,6 +146,11 @@ QString AdBlockMatcher::elementHidingRulesForDomain(const QString &domain) const
return rules;
}
bool AdBlockMatcher::isEnabled() const
{
return m_enabled;
}
void AdBlockMatcher::update()
{
clear();
......@@ -248,7 +254,8 @@ void AdBlockMatcher::clear()
void AdBlockMatcher::enabledChanged(bool enabled)
{
if (enabled) {
m_enabled = enabled;
if (m_enabled) {
update();
} else {
clear();
......
......@@ -63,6 +63,8 @@ public:
QString elementHidingRules() const;
QString elementHidingRulesForDomain(const QString &domain) const;
bool isEnabled() const;
public Q_SLOTS:
void update();
void clear();
......@@ -83,6 +85,7 @@ private:
QString m_elementHidingRules;
AdBlockSearchTree m_networkBlockTree;
AdBlockSearchTree m_networkExceptionTree;
bool m_enabled;
};
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment