Commit 7dd137f7 authored by Laurent Montel's avatar Laurent Montel 😁

continue to fix adblock support

parent 54637866
...@@ -92,6 +92,7 @@ void AdblockInterceptorInterface::setWebEngineView(QWebEngineView *webEngineView ...@@ -92,6 +92,7 @@ void AdblockInterceptorInterface::setWebEngineView(QWebEngineView *webEngineView
void AdblockInterceptorInterface::slotBlockImage() void AdblockInterceptorInterface::slotBlockImage()
{ {
qDebug() << " void AdblockInterceptorInterface::slotBlockImage()";
if (mCurrentWebHitTest.imageUrl().isValid()) { if (mCurrentWebHitTest.imageUrl().isValid()) {
qDebug() << " mCurrentWebHitTest.imageUrl()"<<mCurrentWebHitTest.imageUrl(); qDebug() << " mCurrentWebHitTest.imageUrl()"<<mCurrentWebHitTest.imageUrl();
//TODO block it. //TODO block it.
......
...@@ -57,6 +57,12 @@ AdBlockBlockableItemsDialog::~AdBlockBlockableItemsDialog() ...@@ -57,6 +57,12 @@ AdBlockBlockableItemsDialog::~AdBlockBlockableItemsDialog()
writeConfig(); writeConfig();
} }
void AdBlockBlockableItemsDialog::accept()
{
saveFilters();
QDialog::accept();
}
void AdBlockBlockableItemsDialog::saveFilters() void AdBlockBlockableItemsDialog::saveFilters()
{ {
mBlockableItems->saveFilters(); mBlockableItems->saveFilters();
......
...@@ -35,6 +35,7 @@ public: ...@@ -35,6 +35,7 @@ public:
void saveFilters(); void saveFilters();
void setAdblockResult(const QVector<AdBlock::AdBlockResult> &result); void setAdblockResult(const QVector<AdBlock::AdBlockResult> &result);
void accept() override;
private: private:
void writeConfig(); void writeConfig();
void readConfig(); void readConfig();
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "adblockblockableitemswidget.h" #include "adblockblockableitemswidget.h"
#include "adblockcreatefilterdialog.h" #include "adblockcreatefilterdialog.h"
#include "adblockinterceptor_debug.h" #include "adblockinterceptor_debug.h"
#include "adblockutil.h"
#include <WebEngineViewer/WebEngineScript> #include <WebEngineViewer/WebEngineScript>
#include <QVBoxLayout> #include <QVBoxLayout>
...@@ -34,6 +35,7 @@ ...@@ -34,6 +35,7 @@
#include <QApplication> #include <QApplication>
#include <QPointer> #include <QPointer>
#include <adblockblockableitemsjob.h> #include <adblockblockableitemsjob.h>
#include <qfile.h>
#include <KIOWidgets/KRun> #include <KIOWidgets/KRun>
using namespace AdBlock; using namespace AdBlock;
...@@ -74,6 +76,7 @@ void AdBlockBlockableItemsWidget::setAdblockResult(const QVector<AdBlockResult> ...@@ -74,6 +76,7 @@ void AdBlockBlockableItemsWidget::setAdblockResult(const QVector<AdBlockResult>
item->setText(Url, res.src); item->setText(Url, res.src);
switch (res.type) { switch (res.type) {
case AdBlock::AdBlockBlockableItemsJob::UnKnown: case AdBlock::AdBlockBlockableItemsJob::UnKnown:
qCDebug(ADBLOCKINTERCEPTOR_LOG) << " unknown ablock type : " << res.src;
//TODO ? //TODO ?
break; break;
case AdBlock::AdBlockBlockableItemsJob::Image: case AdBlock::AdBlockBlockableItemsJob::Image:
...@@ -94,10 +97,22 @@ void AdBlockBlockableItemsWidget::setAdblockResult(const QVector<AdBlockResult> ...@@ -94,10 +97,22 @@ void AdBlockBlockableItemsWidget::setAdblockResult(const QVector<AdBlockResult>
void AdBlockBlockableItemsWidget::saveFilters() void AdBlockBlockableItemsWidget::saveFilters()
{ {
qWarning() << " void AdBlockBlockableItemsWidget::saveFilters() unimplemented yet"; qWarning() << " void AdBlockBlockableItemsWidget::saveFilters() unimplemented yet";
for (int i = 0; i < mListItems->model()->rowCount(); ++i) { // local filters
const QString localRulesFilePath = AdBlock::AdBlockUtil::localFilterPath();
QFile ruleFile(localRulesFilePath);
if (!ruleFile.open(QFile::WriteOnly | QFile::Text | QFile::Append)) {
qCDebug(ADBLOCKINTERCEPTOR_LOG) << "Unable to open rule file" << localRulesFilePath;
return;
}
for (int i = 0; i < mListItems->topLevelItemCount(); ++i) {
QTreeWidgetItem *item = mListItems->topLevelItem(i);
const QString itemStr = item->text(FilterValue);
if (!itemStr.isEmpty()) {
qDebug() << " item !:" << item->text(FilterValue);
}
//TODO //TODO
} }
//TODO
} }
void AdBlockBlockableItemsWidget::customContextMenuRequested(const QPoint &) void AdBlockBlockableItemsWidget::customContextMenuRequested(const QPoint &)
...@@ -168,6 +183,7 @@ void AdBlockBlockableItemsWidget::slotBlockItem() ...@@ -168,6 +183,7 @@ void AdBlockBlockableItemsWidget::slotBlockItem()
if (dlg->exec()) { if (dlg->exec()) {
const QString filter = dlg->filter(); const QString filter = dlg->filter();
item->setText(FilterValue, filter); item->setText(FilterValue, filter);
item->setToolTip(FilterValue, filter);
} }
delete dlg; delete dlg;
} }
......
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