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
void AdblockInterceptorInterface::slotBlockImage()
{
qDebug() << " void AdblockInterceptorInterface::slotBlockImage()";
if (mCurrentWebHitTest.imageUrl().isValid()) {
qDebug() << " mCurrentWebHitTest.imageUrl()"<<mCurrentWebHitTest.imageUrl();
//TODO block it.
......
......@@ -57,6 +57,12 @@ AdBlockBlockableItemsDialog::~AdBlockBlockableItemsDialog()
writeConfig();
}
void AdBlockBlockableItemsDialog::accept()
{
saveFilters();
QDialog::accept();
}
void AdBlockBlockableItemsDialog::saveFilters()
{
mBlockableItems->saveFilters();
......
......@@ -35,6 +35,7 @@ public:
void saveFilters();
void setAdblockResult(const QVector<AdBlock::AdBlockResult> &result);
void accept() override;
private:
void writeConfig();
void readConfig();
......
......@@ -20,6 +20,7 @@
#include "adblockblockableitemswidget.h"
#include "adblockcreatefilterdialog.h"
#include "adblockinterceptor_debug.h"
#include "adblockutil.h"
#include <WebEngineViewer/WebEngineScript>
#include <QVBoxLayout>
......@@ -34,6 +35,7 @@
#include <QApplication>
#include <QPointer>
#include <adblockblockableitemsjob.h>
#include <qfile.h>
#include <KIOWidgets/KRun>
using namespace AdBlock;
......@@ -74,6 +76,7 @@ void AdBlockBlockableItemsWidget::setAdblockResult(const QVector<AdBlockResult>
item->setText(Url, res.src);
switch (res.type) {
case AdBlock::AdBlockBlockableItemsJob::UnKnown:
qCDebug(ADBLOCKINTERCEPTOR_LOG) << " unknown ablock type : " << res.src;
//TODO ?
break;
case AdBlock::AdBlockBlockableItemsJob::Image:
......@@ -94,10 +97,22 @@ void AdBlockBlockableItemsWidget::setAdblockResult(const QVector<AdBlockResult>
void AdBlockBlockableItemsWidget::saveFilters()
{
qWarning() << " void AdBlockBlockableItemsWidget::saveFilters() unimplemented yet";
for (int i = 0; i < mListItems->model()->rowCount(); ++i) {
//TODO
// 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
}
}
void AdBlockBlockableItemsWidget::customContextMenuRequested(const QPoint &)
......@@ -168,6 +183,7 @@ void AdBlockBlockableItemsWidget::slotBlockItem()
if (dlg->exec()) {
const QString filter = dlg->filter();
item->setText(FilterValue, filter);
item->setToolTip(FilterValue, filter);
}
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