Refactoring of Adblock component.
This commit is contained in:
parent
cc9c3680c1
commit
57428510d4
1
.gitignore
vendored
1
.gitignore
vendored
@ -21,4 +21,5 @@
|
|||||||
*.app
|
*.app
|
||||||
|
|
||||||
# Other files.
|
# Other files.
|
||||||
|
*.autosave
|
||||||
*.user*
|
*.user*
|
@ -703,6 +703,7 @@ include_directories (
|
|||||||
${CMAKE_SOURCE_DIR}/src
|
${CMAKE_SOURCE_DIR}/src
|
||||||
${CMAKE_SOURCE_DIR}/src/gui
|
${CMAKE_SOURCE_DIR}/src/gui
|
||||||
${CMAKE_SOURCE_DIR}/src/network-web
|
${CMAKE_SOURCE_DIR}/src/network-web
|
||||||
|
${CMAKE_SOURCE_DIR}/src/network-web/adblock
|
||||||
${CMAKE_SOURCE_DIR}/src/dynamic-shortcuts
|
${CMAKE_SOURCE_DIR}/src/dynamic-shortcuts
|
||||||
${CMAKE_BINARY_DIR}/src
|
${CMAKE_BINARY_DIR}/src
|
||||||
)
|
)
|
||||||
|
@ -93,6 +93,9 @@
|
|||||||
#define PLACEHOLDER_UNREAD_COUNTS "%unread"
|
#define PLACEHOLDER_UNREAD_COUNTS "%unread"
|
||||||
#define PLACEHOLDER_ALL_COUNTS "%all"
|
#define PLACEHOLDER_ALL_COUNTS "%all"
|
||||||
|
|
||||||
|
#define ADBLOCK_FILTERS_HELP "http://adblockplus.org/en/filters"
|
||||||
|
#define ADBLOCK_EASYLIST_URL "https://easylist-downloads.adblockplus.org/easylist.txt"
|
||||||
|
|
||||||
#define BACKUP_NAME_SETTINGS "config"
|
#define BACKUP_NAME_SETTINGS "config"
|
||||||
#define BACKUP_SUFFIX_SETTINGS ".ini.backup"
|
#define BACKUP_SUFFIX_SETTINGS ".ini.backup"
|
||||||
#define BACKUP_NAME_DATABASE "database"
|
#define BACKUP_NAME_DATABASE "database"
|
||||||
|
25
src/gui/formsettings.ui
Normal file → Executable file
25
src/gui/formsettings.ui
Normal file → Executable file
@ -88,7 +88,7 @@
|
|||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QStackedWidget" name="m_stackedSettings">
|
<widget class="QStackedWidget" name="m_stackedSettings">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>6</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="m_pageGeneral">
|
<widget class="QWidget" name="m_pageGeneral">
|
||||||
<layout class="QFormLayout" name="formLayout_5">
|
<layout class="QFormLayout" name="formLayout_5">
|
||||||
@ -345,6 +345,11 @@ Authors of this application are NOT responsible for lost data.</string>
|
|||||||
</item>
|
</item>
|
||||||
<item row="6" column="0" colspan="2">
|
<item row="6" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="m_lblMysqlInfo">
|
<widget class="QLabel" name="m_lblMysqlInfo">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<italic>true</italic>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Note that speed of used MySQL server and latency of used connection medium HEAVILY influences the final performance of this application. Using slow database connections leads to bad performance when browsing feeds or messages.
|
<string>Note that speed of used MySQL server and latency of used connection medium HEAVILY influences the final performance of this application. Using slow database connections leads to bad performance when browsing feeds or messages.
|
||||||
|
|
||||||
@ -414,8 +419,8 @@ MySQL backend will automatically use database with name "rssguard". Do
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>100</width>
|
<width>740</width>
|
||||||
<height>30</height>
|
<height>451</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
@ -492,8 +497,8 @@ MySQL backend will automatically use database with name "rssguard". Do
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>167</width>
|
<width>734</width>
|
||||||
<height>219</height>
|
<height>425</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QFormLayout" name="formLayout">
|
<layout class="QFormLayout" name="formLayout">
|
||||||
@ -896,6 +901,11 @@ MySQL backend will automatically use database with name "rssguard". Do
|
|||||||
</item>
|
</item>
|
||||||
<item row="5" column="0" colspan="2">
|
<item row="5" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="m_lblMouseGestures">
|
<widget class="QLabel" name="m_lblMouseGestures">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<italic>true</italic>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Mouse gestures work with middle mouse button. Possible gestures are:
|
<string>Mouse gestures work with middle mouse button. Possible gestures are:
|
||||||
• previous web page (drag mouse left),
|
• previous web page (drag mouse left),
|
||||||
@ -1361,6 +1371,11 @@ MySQL backend will automatically use database with name "rssguard". Do
|
|||||||
</item>
|
</item>
|
||||||
<item row="4" column="0" colspan="2">
|
<item row="4" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="label_9">
|
<widget class="QLabel" name="label_9">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<italic>true</italic>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Enter format for count of messages displayed next to each feed/category in feed list. Use "%all" and "%unread" strings which are placeholders for the actual count of all (or unread) messages.</string>
|
<string>Enter format for count of messages displayed next to each feed/category in feed list. Use "%all" and "%unread" strings which are placeholders for the actual count of all (or unread) messages.</string>
|
||||||
</property>
|
</property>
|
||||||
|
4
src/gui/tabwidget.h
Normal file → Executable file
4
src/gui/tabwidget.h
Normal file → Executable file
@ -59,6 +59,10 @@ class TabWidget : public QTabWidget {
|
|||||||
return static_cast<TabContent*>(QTabWidget::widget(index));
|
return static_cast<TabContent*>(QTabWidget::widget(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline TabContent *currentWidget() const {
|
||||||
|
return static_cast<TabContent*>(QTabWidget::currentWidget());
|
||||||
|
}
|
||||||
|
|
||||||
// Initializes TabWidget with tabs, this includes initialization
|
// Initializes TabWidget with tabs, this includes initialization
|
||||||
// of main "Feeds" widget.
|
// of main "Feeds" widget.
|
||||||
void initializeTabs();
|
void initializeTabs();
|
||||||
|
@ -1,46 +1,38 @@
|
|||||||
/* ============================================================
|
// This file is part of RSS Guard.
|
||||||
* QuiteRSS is a open-source cross-platform RSS/Atom news feeds reader
|
//
|
||||||
* Copyright (C) 2011-2015 QuiteRSS Team <quiterssteam@gmail.com>
|
// Copyright (C) 2014-2015 by Martin Rotter <rotter.martinos@gmail.com>
|
||||||
*
|
// Copyright (C) 2010-2014 by David Rosca <nowrep@gmail.com>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
//
|
||||||
* it under the terms of the GNU General Public License as published by
|
// RSS Guard is free software: you can redistribute it and/or modify
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// it under the terms of the GNU General Public License as published by
|
||||||
* (at your option) any later version.
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
*
|
// (at your option) any later version.
|
||||||
* This program is distributed in the hope that it will be useful,
|
//
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// RSS Guard is distributed in the hope that it will be useful,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* GNU General Public License for more details.
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
*
|
// GNU General Public License for more details.
|
||||||
* You should have received a copy of the GNU General Public License
|
//
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// You should have received a copy of the GNU General Public License
|
||||||
* ============================================================ */
|
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
/* ============================================================
|
|
||||||
* QupZilla - WebKit based browser
|
|
||||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
* ============================================================ */
|
|
||||||
#include "adblockaddsubscriptiondialog.h"
|
|
||||||
#include "adblockmanager.h"
|
|
||||||
#include "ui_adblockaddsubscriptiondialog.h"
|
|
||||||
|
|
||||||
AdBlockAddSubscriptionDialog::AdBlockAddSubscriptionDialog(QWidget* parent)
|
#include "network-web/adblock/adblockaddsubscriptiondialog.h"
|
||||||
: QDialog(parent)
|
|
||||||
, ui(new Ui::AdBlockAddSubscriptionDialog)
|
#include "network-web/adblock/adblockmanager.h"
|
||||||
{
|
#include "definitions/definitions.h"
|
||||||
ui->setupUi(this);
|
#include "miscellaneous/application.h"
|
||||||
|
#include "miscellaneous/iconfactory.h"
|
||||||
|
#include "gui/lineeditwithstatus.h"
|
||||||
|
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
|
||||||
|
AdBlockAddSubscriptionDialog::AdBlockAddSubscriptionDialog(QWidget *parent)
|
||||||
|
: QDialog(parent), m_ui(new Ui::AdBlockAddSubscriptionDialog) {
|
||||||
|
m_ui->setupUi(this);
|
||||||
|
|
||||||
|
setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint);
|
||||||
|
setWindowIcon(qApp->icons()->fromTheme("web-adblock"));
|
||||||
|
|
||||||
m_knownSubscriptions << Subscription("EasyList (English)", ADBLOCK_EASYLIST_URL)
|
m_knownSubscriptions << Subscription("EasyList (English)", ADBLOCK_EASYLIST_URL)
|
||||||
<< Subscription("Fanboy's List (English)", "http://www.fanboy.co.nz/adblock/fanboy-adblock.txt")
|
<< Subscription("Fanboy's List (English)", "http://www.fanboy.co.nz/adblock/fanboy-adblock.txt")
|
||||||
@ -63,52 +55,72 @@ AdBlockAddSubscriptionDialog::AdBlockAddSubscriptionDialog(QWidget* parent)
|
|||||||
<< Subscription("RU AdList (Russian, Ukrainian)", "https://easylist-downloads.adblockplus.org/advblock.txt")
|
<< Subscription("RU AdList (Russian, Ukrainian)", "https://easylist-downloads.adblockplus.org/advblock.txt")
|
||||||
<< Subscription("ABPindo (Indonesian)", "https://indonesianadblockrules.googlecode.com/hg/subscriptions/abpindo.txt")
|
<< Subscription("ABPindo (Indonesian)", "https://indonesianadblockrules.googlecode.com/hg/subscriptions/abpindo.txt")
|
||||||
<< Subscription("ChinaList (Chinese)", "http://adblock-chinalist.googlecode.com/svn/trunk/adblock.txt")
|
<< Subscription("ChinaList (Chinese)", "http://adblock-chinalist.googlecode.com/svn/trunk/adblock.txt")
|
||||||
<< Subscription("Malware Domains list", "https://easylist-downloads.adblockplus.org/malwaredomains_full.txt");
|
<< Subscription("Malware Domains list", "https://easylist-downloads.adblockplus.org/malwaredomains_full.txt") <<
|
||||||
|
Subscription(tr("Other list"), QString());
|
||||||
|
|
||||||
foreach (const Subscription &subscription, m_knownSubscriptions) {
|
foreach (const Subscription &subscription, m_knownSubscriptions) {
|
||||||
ui->comboBox->addItem(subscription.title);
|
m_ui->m_cmbPresets->addItem(subscription.m_title);
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(ui->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(indexChanged(int)));
|
connect(m_ui->m_cmbPresets, SIGNAL(currentIndexChanged(int)), this, SLOT(indexChanged(int)));
|
||||||
|
connect(m_ui->m_txtTitle->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(checkInputs()));
|
||||||
|
connect(m_ui->m_txtUrl->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(checkInputs()));
|
||||||
indexChanged(0);
|
indexChanged(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AdBlockAddSubscriptionDialog::title() const
|
QString AdBlockAddSubscriptionDialog::title() const {
|
||||||
{
|
return m_ui->m_txtTitle->lineEdit()->text();
|
||||||
return ui->title->text();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AdBlockAddSubscriptionDialog::url() const
|
QString AdBlockAddSubscriptionDialog::url() const {
|
||||||
{
|
return m_ui->m_txtUrl->lineEdit()->text();
|
||||||
return ui->url->text();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockAddSubscriptionDialog::indexChanged(int index)
|
void AdBlockAddSubscriptionDialog::indexChanged(int index) {
|
||||||
{
|
|
||||||
const Subscription subscription = m_knownSubscriptions.at(index);
|
const Subscription subscription = m_knownSubscriptions.at(index);
|
||||||
|
|
||||||
// "Other..." entry
|
// "Other" entry.
|
||||||
if (subscription.url.isEmpty()) {
|
if (subscription.m_url.isEmpty()) {
|
||||||
ui->title->clear();
|
m_ui->m_txtTitle->lineEdit()->clear();
|
||||||
ui->url->clear();
|
m_ui->m_txtUrl->lineEdit()->clear();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = subscription.title.indexOf(QLatin1Char('('));
|
int pos = subscription.m_title.indexOf(QLatin1Char('('));
|
||||||
QString title = subscription.title;
|
QString title = subscription.m_title;
|
||||||
|
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
title = title.left(pos).trimmed();
|
title = title.left(pos).trimmed();
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->title->setText(title);
|
m_ui->m_txtTitle->lineEdit()->setText(title);
|
||||||
ui->title->setCursorPosition(0);
|
m_ui->m_txtTitle->lineEdit()->setCursorPosition(0);
|
||||||
|
m_ui->m_txtUrl->lineEdit()->setText(subscription.m_url);
|
||||||
ui->url->setText(subscription.url);
|
m_ui->m_txtUrl->lineEdit()->setCursorPosition(0);
|
||||||
ui->url->setCursorPosition(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AdBlockAddSubscriptionDialog::~AdBlockAddSubscriptionDialog()
|
void AdBlockAddSubscriptionDialog::checkInputs() {
|
||||||
{
|
bool is_ok = true;
|
||||||
delete ui;
|
|
||||||
|
if (!m_ui->m_txtTitle->lineEdit()->text().simplified().isEmpty()) {
|
||||||
|
m_ui->m_txtTitle->setStatus(WidgetWithStatus::Ok, tr("Entered title is okay."));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_ui->m_txtTitle->setStatus(WidgetWithStatus::Error, tr("Entered title is empty."));
|
||||||
|
is_ok = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_ui->m_txtUrl->lineEdit()->text().simplified().isEmpty()) {
|
||||||
|
m_ui->m_txtUrl->setStatus(WidgetWithStatus::Ok, tr("Entered url is okay."));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_ui->m_txtUrl->setStatus(WidgetWithStatus::Error, tr("Entered url is empty."));
|
||||||
|
is_ok = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_ui->m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(is_ok);
|
||||||
|
}
|
||||||
|
|
||||||
|
AdBlockAddSubscriptionDialog::~AdBlockAddSubscriptionDialog() {
|
||||||
|
delete m_ui;
|
||||||
}
|
}
|
||||||
|
@ -1,78 +1,68 @@
|
|||||||
/* ============================================================
|
// This file is part of RSS Guard.
|
||||||
* QuiteRSS is a open-source cross-platform RSS/Atom news feeds reader
|
//
|
||||||
* Copyright (C) 2011-2015 QuiteRSS Team <quiterssteam@gmail.com>
|
// Copyright (C) 2014-2015 by Martin Rotter <rotter.martinos@gmail.com>
|
||||||
*
|
// Copyright (C) 2010-2014 by David Rosca <nowrep@gmail.com>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
//
|
||||||
* it under the terms of the GNU General Public License as published by
|
// RSS Guard is free software: you can redistribute it and/or modify
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// it under the terms of the GNU General Public License as published by
|
||||||
* (at your option) any later version.
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
*
|
// (at your option) any later version.
|
||||||
* This program is distributed in the hope that it will be useful,
|
//
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// RSS Guard is distributed in the hope that it will be useful,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* GNU General Public License for more details.
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
*
|
// GNU General Public License for more details.
|
||||||
* You should have received a copy of the GNU General Public License
|
//
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// You should have received a copy of the GNU General Public License
|
||||||
* ============================================================ */
|
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
/* ============================================================
|
|
||||||
* QupZilla - WebKit based browser
|
|
||||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
* ============================================================ */
|
|
||||||
#ifndef ADBLOCKADDSUBSCRIPTIONDIALOG_H
|
#ifndef ADBLOCKADDSUBSCRIPTIONDIALOG_H
|
||||||
#define ADBLOCKADDSUBSCRIPTIONDIALOG_H
|
#define ADBLOCKADDSUBSCRIPTIONDIALOG_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
|
#include "ui_adblockaddsubscriptiondialog.h"
|
||||||
|
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
namespace Ui
|
|
||||||
{
|
namespace Ui {
|
||||||
class AdBlockAddSubscriptionDialog;
|
class AdBlockAddSubscriptionDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
class AdBlockAddSubscriptionDialog : public QDialog
|
class AdBlockAddSubscriptionDialog : public QDialog {
|
||||||
{
|
Q_OBJECT
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AdBlockAddSubscriptionDialog(QWidget* parent = 0);
|
// Constructors.
|
||||||
~AdBlockAddSubscriptionDialog();
|
explicit AdBlockAddSubscriptionDialog(QWidget *parent = 0);
|
||||||
|
virtual ~AdBlockAddSubscriptionDialog();
|
||||||
|
|
||||||
QString title() const;
|
QString title() const;
|
||||||
QString url() const;
|
QString url() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void indexChanged(int index);
|
// Index of selected list changed.
|
||||||
|
void indexChanged(int index);
|
||||||
|
void checkInputs();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::AdBlockAddSubscriptionDialog* ui;
|
struct Subscription {
|
||||||
|
public:
|
||||||
|
QString m_title;
|
||||||
|
QString m_url;
|
||||||
|
|
||||||
struct Subscription {
|
explicit Subscription() {
|
||||||
QString title;
|
}
|
||||||
QString url;
|
|
||||||
|
|
||||||
Subscription() {}
|
explicit Subscription(const QString &title, const QString &url) {
|
||||||
|
m_title = title;
|
||||||
|
m_url = url;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Subscription(const QString &t, const QString &u) {
|
Ui::AdBlockAddSubscriptionDialog *m_ui;
|
||||||
title = t;
|
QVector<Subscription> m_knownSubscriptions;
|
||||||
url = u;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
QVector<Subscription> m_knownSubscriptions;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ADBLOCKADDSUBSCRIPTIONDIALOG_H
|
#endif // ADBLOCKADDSUBSCRIPTIONDIALOG_H
|
||||||
|
@ -7,38 +7,32 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>557</width>
|
<width>557</width>
|
||||||
<height>162</height>
|
<height>142</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Add Subscription</string>
|
<string>Add subscription</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QFormLayout" name="formLayout">
|
<layout class="QFormLayout">
|
||||||
<item row="1" column="0" colspan="2">
|
<item row="0" column="0" colspan="2">
|
||||||
<widget class="QComboBox" name="comboBox"/>
|
<widget class="QComboBox" name="m_cmbPresets"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="m_lblTitle">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Title:</string>
|
<string>Title:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="2" column="0">
|
||||||
<widget class="QLineEdit" name="title"/>
|
<widget class="QLabel" name="m_lblUrl">
|
||||||
</item>
|
|
||||||
<item row="3" column="0">
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Address:</string>
|
<string>Address:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
|
||||||
<widget class="QLineEdit" name="url"/>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="m_buttonBox">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -47,19 +41,39 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0" colspan="2">
|
<item row="3" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="label_3">
|
<spacer name="m_vertSpacer">
|
||||||
<property name="text">
|
<property name="orientation">
|
||||||
<string>Add new subscription to AdBlock:</string>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="LineEditWithStatus" name="m_txtTitle" native="true"/>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="LineEditWithStatus" name="m_txtUrl" native="true"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>LineEditWithStatus</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>lineeditwithstatus.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>m_buttonBox</sender>
|
||||||
<signal>accepted()</signal>
|
<signal>accepted()</signal>
|
||||||
<receiver>AdBlockAddSubscriptionDialog</receiver>
|
<receiver>AdBlockAddSubscriptionDialog</receiver>
|
||||||
<slot>accept()</slot>
|
<slot>accept()</slot>
|
||||||
@ -75,7 +89,7 @@
|
|||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>m_buttonBox</sender>
|
||||||
<signal>rejected()</signal>
|
<signal>rejected()</signal>
|
||||||
<receiver>AdBlockAddSubscriptionDialog</receiver>
|
<receiver>AdBlockAddSubscriptionDialog</receiver>
|
||||||
<slot>reject()</slot>
|
<slot>reject()</slot>
|
||||||
|
@ -1,37 +1,21 @@
|
|||||||
/* ============================================================
|
// This file is part of RSS Guard.
|
||||||
* QuiteRSS is a open-source cross-platform RSS/Atom news feeds reader
|
//
|
||||||
* Copyright (C) 2011-2015 QuiteRSS Team <quiterssteam@gmail.com>
|
// Copyright (C) 2014-2015 by Martin Rotter <rotter.martinos@gmail.com>
|
||||||
*
|
// Copyright (C) 2010-2014 by David Rosca <nowrep@gmail.com>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
//
|
||||||
* it under the terms of the GNU General Public License as published by
|
// RSS Guard is free software: you can redistribute it and/or modify
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// it under the terms of the GNU General Public License as published by
|
||||||
* (at your option) any later version.
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
*
|
// (at your option) any later version.
|
||||||
* This program is distributed in the hope that it will be useful,
|
//
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// RSS Guard is distributed in the hope that it will be useful,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* GNU General Public License for more details.
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
*
|
// GNU General Public License for more details.
|
||||||
* You should have received a copy of the GNU General Public License
|
//
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// You should have received a copy of the GNU General Public License
|
||||||
* ============================================================ */
|
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
/* ============================================================
|
|
||||||
* QupZilla - WebKit based browser
|
|
||||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
* ============================================================ */
|
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2009, Benjamin C. Meyer <ben@meyerhome.net>
|
* Copyright (c) 2009, Benjamin C. Meyer <ben@meyerhome.net>
|
||||||
*
|
*
|
||||||
@ -60,40 +44,38 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "adblockblockednetworkreply.h"
|
#include "network-web/adblock/adblockblockednetworkreply.h"
|
||||||
#include "adblocksubscription.h"
|
|
||||||
#include "adblockrule.h"
|
#include "network-web/adblock/adblocksubscription.h"
|
||||||
|
#include "network-web/adblock/adblockrule.h"
|
||||||
|
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
AdBlockBlockedNetworkReply::AdBlockBlockedNetworkReply(const AdBlockRule* rule, QObject* parent)
|
|
||||||
: QNetworkReply(parent)
|
AdBlockBlockedNetworkReply::AdBlockBlockedNetworkReply(const AdBlockRule *rule, QObject *parent)
|
||||||
{
|
: QNetworkReply(parent) {
|
||||||
setOperation(QNetworkAccessManager::GetOperation);
|
setOperation(QNetworkAccessManager::GetOperation);
|
||||||
setError(QNetworkReply::ContentAccessDenied, QString("AdBlock: %1 (%2)").arg(rule->subscription()->title(), rule->filter()));
|
setError(QNetworkReply::ContentAccessDenied, QString("Adblock: %1 (%2)").arg(rule->subscription()->title(), rule->filter()));
|
||||||
|
|
||||||
open(QIODevice::ReadOnly);
|
open(QIODevice::ReadOnly);
|
||||||
|
|
||||||
QTimer::singleShot(0, this, SLOT(delayedFinished()));
|
QTimer::singleShot(0, this, SLOT(delayedFinished()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockBlockedNetworkReply::setRequest(const QNetworkRequest &request)
|
void AdBlockBlockedNetworkReply::abort() {
|
||||||
{
|
}
|
||||||
|
|
||||||
|
void AdBlockBlockedNetworkReply::setRequest(const QNetworkRequest &request) {
|
||||||
QNetworkReply::setRequest(request);
|
QNetworkReply::setRequest(request);
|
||||||
setUrl(request.url());
|
setUrl(request.url());
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 AdBlockBlockedNetworkReply::readData(char* data, qint64 maxSize)
|
qint64 AdBlockBlockedNetworkReply::readData(char *data, qint64 maxSize) {
|
||||||
{
|
|
||||||
Q_UNUSED(data);
|
Q_UNUSED(data);
|
||||||
Q_UNUSED(maxSize);
|
Q_UNUSED(maxSize);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockBlockedNetworkReply::delayedFinished()
|
void AdBlockBlockedNetworkReply::delayedFinished() {
|
||||||
{
|
|
||||||
emit error(QNetworkReply::ContentAccessDenied);
|
emit error(QNetworkReply::ContentAccessDenied);
|
||||||
emit finished();
|
emit finished();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,37 +1,21 @@
|
|||||||
/* ============================================================
|
// This file is part of RSS Guard.
|
||||||
* QuiteRSS is a open-source cross-platform RSS/Atom news feeds reader
|
//
|
||||||
* Copyright (C) 2011-2015 QuiteRSS Team <quiterssteam@gmail.com>
|
// Copyright (C) 2014-2015 by Martin Rotter <rotter.martinos@gmail.com>
|
||||||
*
|
// Copyright (C) 2010-2014 by David Rosca <nowrep@gmail.com>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
//
|
||||||
* it under the terms of the GNU General Public License as published by
|
// RSS Guard is free software: you can redistribute it and/or modify
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// it under the terms of the GNU General Public License as published by
|
||||||
* (at your option) any later version.
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
*
|
// (at your option) any later version.
|
||||||
* This program is distributed in the hope that it will be useful,
|
//
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// RSS Guard is distributed in the hope that it will be useful,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* GNU General Public License for more details.
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
*
|
// GNU General Public License for more details.
|
||||||
* You should have received a copy of the GNU General Public License
|
//
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// You should have received a copy of the GNU General Public License
|
||||||
* ============================================================ */
|
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
/* ============================================================
|
|
||||||
* QupZilla - WebKit based browser
|
|
||||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
* ============================================================ */
|
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2009, Benjamin C. Meyer <ben@meyerhome.net>
|
* Copyright (c) 2009, Benjamin C. Meyer <ben@meyerhome.net>
|
||||||
*
|
*
|
||||||
@ -65,25 +49,24 @@
|
|||||||
|
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
|
|
||||||
|
|
||||||
class AdBlockRule;
|
class AdBlockRule;
|
||||||
class AdBlockSubscription;
|
class AdBlockSubscription;
|
||||||
|
|
||||||
class AdBlockBlockedNetworkReply : public QNetworkReply
|
class AdBlockBlockedNetworkReply : public QNetworkReply{
|
||||||
{
|
Q_OBJECT
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AdBlockBlockedNetworkReply(const AdBlockRule* rule, QObject* parent = 0);
|
explicit AdBlockBlockedNetworkReply(const AdBlockRule *rule, QObject *parent = 0);
|
||||||
void abort() {}
|
|
||||||
|
|
||||||
void setRequest(const QNetworkRequest &request);
|
void abort();
|
||||||
|
void setRequest(const QNetworkRequest &request);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
qint64 readData(char* data, qint64 maxSize);
|
qint64 readData(char *data, qint64 maxSize);
|
||||||
|
|
||||||
private slots:
|
|
||||||
void delayedFinished();
|
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void delayedFinished();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ADBLOCKBLOCKEDNETWORKREPLY_H
|
#endif // ADBLOCKBLOCKEDNETWORKREPLY_H
|
||||||
|
@ -1,42 +1,31 @@
|
|||||||
/* ============================================================
|
// This file is part of RSS Guard.
|
||||||
* QuiteRSS is a open-source cross-platform RSS/Atom news feeds reader
|
//
|
||||||
* Copyright (C) 2011-2015 QuiteRSS Team <quiterssteam@gmail.com>
|
// Copyright (C) 2014-2015 by Martin Rotter <rotter.martinos@gmail.com>
|
||||||
*
|
// Copyright (C) 2010-2014 by David Rosca <nowrep@gmail.com>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
//
|
||||||
* it under the terms of the GNU General Public License as published by
|
// RSS Guard is free software: you can redistribute it and/or modify
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// it under the terms of the GNU General Public License as published by
|
||||||
* (at your option) any later version.
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
*
|
// (at your option) any later version.
|
||||||
* This program is distributed in the hope that it will be useful,
|
//
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// RSS Guard is distributed in the hope that it will be useful,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* GNU General Public License for more details.
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
*
|
// GNU General Public License for more details.
|
||||||
* You should have received a copy of the GNU General Public License
|
//
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// You should have received a copy of the GNU General Public License
|
||||||
* ============================================================ */
|
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
/* ============================================================
|
|
||||||
* QupZilla - WebKit based browser
|
#include "network-web/adblock/adblockdialog.h"
|
||||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
|
||||||
*
|
#include "network-web/adblock/adblockmanager.h"
|
||||||
* This program is free software: you can redistribute it and/or modify
|
#include "network-web/adblock/adblocksubscription.h"
|
||||||
* it under the terms of the GNU General Public License as published by
|
#include "network-web/adblock/adblocktreewidget.h"
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
#include "network-web/adblock/adblockaddsubscriptiondialog.h"
|
||||||
* (at your option) any later version.
|
#include "miscellaneous/application.h"
|
||||||
*
|
#include "miscellaneous/iconfactory.h"
|
||||||
* This program is distributed in the hope that it will be useful,
|
#include "gui/tabwidget.h"
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
#include "gui/formmain.h"
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
* ============================================================ */
|
|
||||||
#include "adblockdialog.h"
|
|
||||||
#include "adblockmanager.h"
|
|
||||||
#include "adblocksubscription.h"
|
|
||||||
#include "adblocktreewidget.h"
|
|
||||||
#include "adblockaddsubscriptiondialog.h"
|
|
||||||
|
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
@ -44,98 +33,99 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
|
|
||||||
AdBlockDialog::AdBlockDialog(QWidget* parent)
|
|
||||||
: QWidget(parent)
|
AdBlockDialog::AdBlockDialog(QWidget* parent) : QDialog(parent), m_ui(new Ui::AdBlockDialog),
|
||||||
, m_manager(AdBlockManager::instance())
|
m_manager(AdBlockManager::instance()), m_currentTreeWidget(NULL),
|
||||||
, m_currentTreeWidget(0)
|
m_currentSubscription(NULL), m_loaded(false), m_useLimitedEasyList(false) {
|
||||||
, m_currentSubscription(0)
|
m_ui->setupUi(this);
|
||||||
, m_loaded(false)
|
|
||||||
, m_useLimitedEasyList(false)
|
|
||||||
{
|
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
setupUi(this);
|
setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint);
|
||||||
|
setWindowIcon(qApp->icons()->fromTheme("web-adblock"));
|
||||||
|
|
||||||
const QRect screen = QApplication::desktop()->screenGeometry();
|
m_ui->m_checkEnable->setChecked(m_manager->isEnabled());
|
||||||
const QRect size = geometry();
|
m_ui->m_checkUseLimitedEasyList->setVisible(false);
|
||||||
move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2);
|
m_ui->m_btnOptions->setIcon(qApp->icons()->fromTheme("web-adblock"));
|
||||||
tabWidget->setDocumentMode(false);
|
m_ui->m_btnOptions->setText(m_ui->m_btnOptions->text() + " ");
|
||||||
#ifdef Q_OS_MAC
|
|
||||||
tabWidget->setDocumentMode(false);
|
|
||||||
#endif
|
|
||||||
adblockCheckBox->setChecked(m_manager->isEnabled());
|
|
||||||
|
|
||||||
buttonOptions->setText(buttonOptions->text() % " ");
|
// Setup the menu.
|
||||||
|
setupMenu();
|
||||||
|
|
||||||
QMenu* menu = new QMenu(buttonOptions);
|
// Initialize connections.
|
||||||
m_actionAddRule = menu->addAction(tr("Add Rule"), this, SLOT(addRule()));
|
createConnections();
|
||||||
m_actionRemoveRule = menu->addAction(tr("Remove Rule"), this, SLOT(removeRule()));
|
|
||||||
menu->addSeparator();
|
|
||||||
m_actionAddSubscription = menu->addAction(tr("Add Subscription"), this, SLOT(addSubscription()));
|
|
||||||
m_actionRemoveSubscription = menu->addAction(tr("Remove Subscription"), this, SLOT(removeSubscription()));
|
|
||||||
menu->addAction(tr("Update Subscriptions"), m_manager, SLOT(updateAllSubscriptions()));
|
|
||||||
menu->addSeparator();
|
|
||||||
menu->addAction(tr("Learn about writing rules..."), this, SLOT(learnAboutRules()));
|
|
||||||
|
|
||||||
buttonOptions->setMenu(menu);
|
|
||||||
connect(menu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowMenu()));
|
|
||||||
|
|
||||||
connect(adblockCheckBox, SIGNAL(toggled(bool)), this, SLOT(enableAdBlock(bool)));
|
|
||||||
connect(search, SIGNAL(textChanged(QString)), this, SLOT(filterString(QString)));
|
|
||||||
connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int)));
|
|
||||||
connect(buttonBox, SIGNAL(accepted()), this, SLOT(close()));
|
|
||||||
|
|
||||||
|
// Load the contents.
|
||||||
load();
|
load();
|
||||||
|
|
||||||
buttonBox->setFocus();
|
m_ui->m_buttonBox->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
AdBlockDialog::~AdBlockDialog() {
|
AdBlockDialog::~AdBlockDialog() {
|
||||||
qDebug("Destroying AdBlockDialog instance.");
|
qDebug("Destroying AdBlockDialog instance.");
|
||||||
|
delete m_ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockDialog::showRule(const AdBlockRule* rule) const
|
void AdBlockDialog::setupMenu() {
|
||||||
{
|
QMenu *menu = new QMenu(m_ui->m_btnOptions);
|
||||||
|
|
||||||
|
m_actionAddRule = menu->addAction(tr("Add rule"), this, SLOT(addRule()));
|
||||||
|
m_actionRemoveRule = menu->addAction(tr("Remove rule"), this, SLOT(removeRule()));
|
||||||
|
menu->addSeparator();
|
||||||
|
m_actionAddSubscription = menu->addAction(tr("Add subscription"), this, SLOT(addSubscription()));
|
||||||
|
m_actionRemoveSubscription = menu->addAction(tr("Remove subscription"), this, SLOT(removeSubscription()));
|
||||||
|
menu->addAction(tr("Update subscriptions"), m_manager, SLOT(updateAllSubscriptions()));
|
||||||
|
menu->addSeparator();
|
||||||
|
menu->addAction(tr("Rules writing guide"), this, SLOT(learnAboutRules()));
|
||||||
|
|
||||||
|
m_ui->m_btnOptions->setMenu(menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdBlockDialog::createConnections() {
|
||||||
|
connect(m_ui->m_btnOptions->menu(), SIGNAL(aboutToShow()), this, SLOT(aboutToShowMenu()));
|
||||||
|
connect(m_ui->m_checkEnable, SIGNAL(toggled(bool)), this, SLOT(enableAdBlock(bool)));
|
||||||
|
connect(m_ui->m_txtFilter, SIGNAL(textChanged(QString)), this, SLOT(filterString(QString)));
|
||||||
|
connect(m_ui->m_tabs, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int)));
|
||||||
|
connect(m_ui->m_buttonBox, SIGNAL(accepted()), this, SLOT(close()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdBlockDialog::showRule(const AdBlockRule* rule) const {
|
||||||
AdBlockSubscription* subscription = rule->subscription();
|
AdBlockSubscription* subscription = rule->subscription();
|
||||||
if (!subscription) {
|
|
||||||
|
if (subscription == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < tabWidget->count(); ++i) {
|
for (int i = 0; i < m_ui->m_tabs->count(); i++) {
|
||||||
AdBlockTreeWidget* treeWidget = qobject_cast<AdBlockTreeWidget*>(tabWidget->widget(i));
|
AdBlockTreeWidget* treeWidget = qobject_cast<AdBlockTreeWidget*>(m_ui->m_tabs->widget(i));
|
||||||
|
|
||||||
if (subscription == treeWidget->subscription()) {
|
if (subscription == treeWidget->subscription()) {
|
||||||
treeWidget->showRule(rule);
|
treeWidget->showRule(rule);
|
||||||
tabWidget->setCurrentIndex(i);
|
m_ui->m_tabs->setCurrentIndex(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockDialog::addRule()
|
void AdBlockDialog::addRule() {
|
||||||
{
|
|
||||||
m_currentTreeWidget->addRule();
|
m_currentTreeWidget->addRule();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockDialog::removeRule()
|
void AdBlockDialog::removeRule() {
|
||||||
{
|
|
||||||
m_currentTreeWidget->removeRule();
|
m_currentTreeWidget->removeRule();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockDialog::addSubscription()
|
void AdBlockDialog::addSubscription() {
|
||||||
{
|
|
||||||
AdBlockAddSubscriptionDialog dialog(this);
|
AdBlockAddSubscriptionDialog dialog(this);
|
||||||
if (dialog.exec() != QDialog::Accepted) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString title = dialog.title();
|
if (dialog.exec() == QDialog::Accepted) {
|
||||||
QString url = dialog.url();
|
QString title = dialog.title();
|
||||||
|
QString url = dialog.url();
|
||||||
|
|
||||||
if (AdBlockSubscription* subscription = m_manager->addSubscription(title, url)) {
|
if (AdBlockSubscription *subscription = m_manager->addSubscription(title, url)) {
|
||||||
AdBlockTreeWidget* tree = new AdBlockTreeWidget(subscription, tabWidget);
|
AdBlockTreeWidget *tree = new AdBlockTreeWidget(subscription, m_ui->m_tabs);
|
||||||
int index = tabWidget->insertTab(tabWidget->count() - 1, tree, subscription->title());
|
int index = m_ui->m_tabs->insertTab(m_ui->m_tabs->count() - 1, tree, subscription->title());
|
||||||
|
|
||||||
tabWidget->setCurrentIndex(index);
|
m_ui->m_tabs->setCurrentIndex(index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,26 +136,24 @@ void AdBlockDialog::removeSubscription()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockDialog::currentChanged(int index)
|
void AdBlockDialog::currentChanged(int index) {
|
||||||
{
|
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
m_currentTreeWidget = qobject_cast<AdBlockTreeWidget*>(tabWidget->widget(index));
|
m_currentTreeWidget = qobject_cast<AdBlockTreeWidget*>(m_ui->m_tabs->widget(index));
|
||||||
m_currentSubscription = m_currentTreeWidget->subscription();
|
m_currentSubscription = m_currentTreeWidget->subscription();
|
||||||
|
|
||||||
bool isEasyList = m_currentSubscription->url() == QUrl(ADBLOCK_EASYLIST_URL);
|
bool is_easylist = m_currentSubscription->url() == QUrl(ADBLOCK_EASYLIST_URL);
|
||||||
useLimitedEasyList->setVisible(isEasyList);
|
m_ui->m_checkUseLimitedEasyList->setEnabled(is_easylist && m_ui->m_checkEnable->isChecked());
|
||||||
|
m_ui->m_checkUseLimitedEasyList->setVisible(is_easylist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockDialog::filterString(const QString &string)
|
void AdBlockDialog::filterString(const QString &string) {
|
||||||
{
|
if (m_currentTreeWidget && m_ui->m_checkEnable->isChecked()) {
|
||||||
if (m_currentTreeWidget && adblockCheckBox->isChecked()) {
|
|
||||||
m_currentTreeWidget->filterString(string);
|
m_currentTreeWidget->filterString(string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockDialog::enableAdBlock(bool state)
|
void AdBlockDialog::enableAdBlock(bool state) {
|
||||||
{
|
|
||||||
m_manager->setEnabled(state);
|
m_manager->setEnabled(state);
|
||||||
|
|
||||||
if (state) {
|
if (state) {
|
||||||
@ -173,8 +161,7 @@ void AdBlockDialog::enableAdBlock(bool state)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockDialog::aboutToShowMenu()
|
void AdBlockDialog::aboutToShowMenu() {
|
||||||
{
|
|
||||||
bool subscriptionEditable = m_currentSubscription && m_currentSubscription->canEditRules();
|
bool subscriptionEditable = m_currentSubscription && m_currentSubscription->canEditRules();
|
||||||
bool subscriptionRemovable = m_currentSubscription && m_currentSubscription->canBeRemoved();
|
bool subscriptionRemovable = m_currentSubscription && m_currentSubscription->canBeRemoved();
|
||||||
|
|
||||||
@ -183,34 +170,30 @@ void AdBlockDialog::aboutToShowMenu()
|
|||||||
m_actionRemoveSubscription->setEnabled(subscriptionRemovable);
|
m_actionRemoveSubscription->setEnabled(subscriptionRemovable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockDialog::learnAboutRules()
|
void AdBlockDialog::learnAboutRules() {
|
||||||
{
|
qApp->mainForm()->tabWidget()->addBrowser(true, true, QUrl(ADBLOCK_FILTERS_HELP));
|
||||||
// TODO
|
QTimer::singleShot(100, this, SLOT(close()));
|
||||||
//mainApp->mainWindow()->openNewsTab_ = NEW_TAB_FOREGROUND;
|
|
||||||
//mainApp->mainWindow()->createWebTab(QUrl("http://adblockplus.org/en/filters"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockDialog::loadSubscriptions()
|
void AdBlockDialog::loadSubscriptions() {
|
||||||
{
|
for (int i = 0; i < m_ui->m_tabs->count(); ++i) {
|
||||||
for (int i = 0; i < tabWidget->count(); ++i) {
|
qobject_cast<AdBlockTreeWidget*>(m_ui->m_tabs->widget(i))->refresh();
|
||||||
AdBlockTreeWidget* treeWidget = qobject_cast<AdBlockTreeWidget*>(tabWidget->widget(i));
|
|
||||||
treeWidget->refresh();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockDialog::load()
|
void AdBlockDialog::load()
|
||||||
{
|
{
|
||||||
if (m_loaded || !adblockCheckBox->isChecked()) {
|
if (m_loaded || !m_ui->m_checkEnable->isChecked()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (AdBlockSubscription* subscription, m_manager->subscriptions()) {
|
foreach (AdBlockSubscription* subscription, m_manager->subscriptions()) {
|
||||||
AdBlockTreeWidget* tree = new AdBlockTreeWidget(subscription, tabWidget);
|
AdBlockTreeWidget* tree = new AdBlockTreeWidget(subscription, m_ui->m_tabs);
|
||||||
tabWidget->addTab(tree, subscription->title());
|
m_ui->m_tabs->addTab(tree, subscription->title());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_useLimitedEasyList = m_manager->useLimitedEasyList();
|
m_useLimitedEasyList = m_manager->useLimitedEasyList();
|
||||||
useLimitedEasyList->setChecked(m_useLimitedEasyList);
|
m_ui->m_checkUseLimitedEasyList->setChecked(m_useLimitedEasyList);
|
||||||
|
|
||||||
m_loaded = true;
|
m_loaded = true;
|
||||||
|
|
||||||
@ -219,8 +202,8 @@ void AdBlockDialog::load()
|
|||||||
|
|
||||||
void AdBlockDialog::closeEvent(QCloseEvent* ev)
|
void AdBlockDialog::closeEvent(QCloseEvent* ev)
|
||||||
{
|
{
|
||||||
if (useLimitedEasyList->isChecked() != m_useLimitedEasyList) {
|
if (m_ui->m_checkUseLimitedEasyList->isChecked() != m_useLimitedEasyList) {
|
||||||
m_manager->setUseLimitedEasyList(useLimitedEasyList->isChecked());
|
m_manager->setUseLimitedEasyList(m_ui->m_checkUseLimitedEasyList->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget::closeEvent(ev);
|
QWidget::closeEvent(ev);
|
||||||
|
@ -1,58 +1,47 @@
|
|||||||
/* ============================================================
|
// This file is part of RSS Guard.
|
||||||
* QuiteRSS is a open-source cross-platform RSS/Atom news feeds reader
|
//
|
||||||
* Copyright (C) 2011-2015 QuiteRSS Team <quiterssteam@gmail.com>
|
// Copyright (C) 2011-2015 by Martin Rotter <rotter.martinos@gmail.com>
|
||||||
*
|
// Copyright (C) 2010-2014 by David Rosca <nowrep@gmail.com>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
//
|
||||||
* it under the terms of the GNU General Public License as published by
|
// RSS Guard is free software: you can redistribute it and/or modify
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// it under the terms of the GNU General Public License as published by
|
||||||
* (at your option) any later version.
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
*
|
// (at your option) any later version.
|
||||||
* This program is distributed in the hope that it will be useful,
|
//
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// RSS Guard is distributed in the hope that it will be useful,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* GNU General Public License for more details.
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
*
|
// GNU General Public License for more details.
|
||||||
* You should have received a copy of the GNU General Public License
|
//
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// You should have received a copy of the GNU General Public License
|
||||||
* ============================================================ */
|
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
/* ============================================================
|
|
||||||
* QupZilla - WebKit based browser
|
|
||||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
* ============================================================ */
|
|
||||||
#ifndef ADBLOCKDIALOG_H
|
#ifndef ADBLOCKDIALOG_H
|
||||||
#define ADBLOCKDIALOG_H
|
#define ADBLOCKDIALOG_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QDialog>
|
||||||
|
|
||||||
#include "ui_adblockdialog.h"
|
#include "ui_adblockdialog.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class AdBlockDialog;
|
||||||
|
}
|
||||||
|
|
||||||
class AdBlockSubscription;
|
class AdBlockSubscription;
|
||||||
class AdBlockTreeWidget;
|
class AdBlockTreeWidget;
|
||||||
class AdBlockManager;
|
class AdBlockManager;
|
||||||
class AdBlockRule;
|
class AdBlockRule;
|
||||||
|
|
||||||
class AdBlockDialog : public QWidget, public Ui_AdBlockDialog
|
class AdBlockDialog : public QDialog {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AdBlockDialog(QWidget* parent = 0);
|
// Constructors.
|
||||||
|
explicit AdBlockDialog(QWidget *parent = 0);
|
||||||
virtual ~AdBlockDialog();
|
virtual ~AdBlockDialog();
|
||||||
|
|
||||||
void showRule(const AdBlockRule* rule) const;
|
void showRule(const AdBlockRule *rule) const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void addRule();
|
void addRule();
|
||||||
@ -71,9 +60,14 @@ class AdBlockDialog : public QWidget, public Ui_AdBlockDialog
|
|||||||
void loadSubscriptions();
|
void loadSubscriptions();
|
||||||
void load();
|
void load();
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
void closeEvent(QCloseEvent* ev);
|
void closeEvent(QCloseEvent* ev);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setupMenu();
|
||||||
|
void createConnections();
|
||||||
|
|
||||||
|
Ui::AdBlockDialog *m_ui;
|
||||||
AdBlockManager* m_manager;
|
AdBlockManager* m_manager;
|
||||||
AdBlockTreeWidget* m_currentTreeWidget;
|
AdBlockTreeWidget* m_currentTreeWidget;
|
||||||
AdBlockSubscription* m_currentSubscription;
|
AdBlockSubscription* m_currentSubscription;
|
||||||
@ -88,4 +82,3 @@ class AdBlockDialog : public QWidget, public Ui_AdBlockDialog
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif // ADBLOCKDIALOG_H
|
#endif // ADBLOCKDIALOG_H
|
||||||
|
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>AdBlockDialog</class>
|
<class>AdBlockDialog</class>
|
||||||
<widget class="QWidget" name="AdBlockDialog">
|
<widget class="QDialog" name="AdBlockDialog">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>546</width>
|
<width>451</width>
|
||||||
<height>462</height>
|
<height>408</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>AdBlock Configuration</string>
|
<string>Adblock settings</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="adblockCheckBox">
|
<widget class="QCheckBox" name="m_checkEnable">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Enable AdBlock</string>
|
<string>Enable Adblock</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="checked">
|
<property name="checked">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@ -25,34 +25,22 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<widget class="QLabel" name="m_lblInfo">
|
||||||
<item>
|
<property name="font">
|
||||||
<widget class="QLineEdit" name="search">
|
<font>
|
||||||
<property name="placeholderText">
|
<italic>true</italic>
|
||||||
<string>Search...</string>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="text">
|
||||||
</item>
|
<string>Note that Adblock may significantly slow this application down once you activate huge subscriptions. Too many rules is not good for performance. Also, make sure you restart application after you disable Adblock if you wish to have low memory footprint. Adblock is known to use much system memory.</string>
|
||||||
<item>
|
</property>
|
||||||
<spacer name="horizontalSpacer_2">
|
<property name="wordWrap">
|
||||||
<property name="orientation">
|
<bool>true</bool>
|
||||||
<enum>Qt::Horizontal</enum>
|
</property>
|
||||||
</property>
|
</widget>
|
||||||
<property name="sizeType">
|
|
||||||
<enum>QSizePolicy::Fixed</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>50</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QWidget" name="adblockWidget" native="true">
|
<widget class="QWidget" name="m_adBlockWidget" native="true">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
@ -72,12 +60,19 @@
|
|||||||
<item row="4" column="0" colspan="2">
|
<item row="4" column="0" colspan="2">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="buttonOptions">
|
<widget class="QPushButton" name="m_btnOptions">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Options</string>
|
<string>Options</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="m_txtFilter">
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Filter rules</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@ -91,30 +86,10 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>AdBlock</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="m_tabs"/>
|
||||||
<property name="currentIndex">
|
|
||||||
<number>-1</number>
|
|
||||||
</property>
|
|
||||||
<property name="documentMode">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
@ -122,14 +97,17 @@
|
|||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="useLimitedEasyList">
|
<widget class="QCheckBox" name="m_checkUseLimitedEasyList">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Use only essential part of EasyList (for performance reasons)</string>
|
<string>Use only essential part of EasyList (for performance reasons)</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="m_buttonBox">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -145,9 +123,9 @@
|
|||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>adblockCheckBox</sender>
|
<sender>m_checkEnable</sender>
|
||||||
<signal>toggled(bool)</signal>
|
<signal>toggled(bool)</signal>
|
||||||
<receiver>adblockWidget</receiver>
|
<receiver>m_adBlockWidget</receiver>
|
||||||
<slot>setEnabled(bool)</slot>
|
<slot>setEnabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
@ -161,7 +139,7 @@
|
|||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>m_buttonBox</sender>
|
||||||
<signal>clicked(QAbstractButton*)</signal>
|
<signal>clicked(QAbstractButton*)</signal>
|
||||||
<receiver>AdBlockDialog</receiver>
|
<receiver>AdBlockDialog</receiver>
|
||||||
<slot>close()</slot>
|
<slot>close()</slot>
|
||||||
|
@ -1,37 +1,21 @@
|
|||||||
/* ============================================================
|
// This file is part of RSS Guard.
|
||||||
* QuiteRSS is a open-source cross-platform RSS/Atom news feeds reader
|
//
|
||||||
* Copyright (C) 2011-2015 QuiteRSS Team <quiterssteam@gmail.com>
|
// Copyright (C) 2014-2015 by Martin Rotter <rotter.martinos@gmail.com>
|
||||||
*
|
// Copyright (C) 2010-2014 by David Rosca <nowrep@gmail.com>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
//
|
||||||
* it under the terms of the GNU General Public License as published by
|
// RSS Guard is free software: you can redistribute it and/or modify
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// it under the terms of the GNU General Public License as published by
|
||||||
* (at your option) any later version.
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
*
|
// (at your option) any later version.
|
||||||
* This program is distributed in the hope that it will be useful,
|
//
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// RSS Guard is distributed in the hope that it will be useful,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* GNU General Public License for more details.
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
*
|
// GNU General Public License for more details.
|
||||||
* You should have received a copy of the GNU General Public License
|
//
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// You should have received a copy of the GNU General Public License
|
||||||
* ============================================================ */
|
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
/* ============================================================
|
|
||||||
* QupZilla - WebKit based browser
|
|
||||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
* ============================================================ */
|
|
||||||
#include "network-web/adblock/adblockicon.h"
|
#include "network-web/adblock/adblockicon.h"
|
||||||
|
|
||||||
#include "network-web/adblock/adblockrule.h"
|
#include "network-web/adblock/adblockrule.h"
|
||||||
@ -39,7 +23,6 @@
|
|||||||
#include "network-web/adblock/adblocksubscription.h"
|
#include "network-web/adblock/adblocksubscription.h"
|
||||||
#include "network-web/webpage.h"
|
#include "network-web/webpage.h"
|
||||||
#include "network-web/webbrowser.h"
|
#include "network-web/webbrowser.h"
|
||||||
|
|
||||||
#include "miscellaneous/application.h"
|
#include "miscellaneous/application.h"
|
||||||
#include "gui/plaintoolbutton.h"
|
#include "gui/plaintoolbutton.h"
|
||||||
#include "gui/formmain.h"
|
#include "gui/formmain.h"
|
||||||
@ -52,20 +35,17 @@
|
|||||||
|
|
||||||
|
|
||||||
AdBlockIcon::AdBlockIcon(QWidget *window, QWidget *parent)
|
AdBlockIcon::AdBlockIcon(QWidget *window, QWidget *parent)
|
||||||
: PlainToolButton(parent), m_window(window), m_menuAction(0), m_flashTimer(0), m_timerTicks(0), m_enabled(false) {
|
: PlainToolButton(parent), m_window(window), m_menuAction(NULL), m_flashTimer(NULL), m_timerTicks(NULL), m_enabled(false) {
|
||||||
setToolTip(tr("Adblock lets you block unwanted content on web pages."));
|
|
||||||
|
|
||||||
connect(this, SIGNAL(clicked(QPoint)), this, SLOT(showMenu(QPoint)));
|
connect(this, SIGNAL(clicked(QPoint)), this, SLOT(showMenu(QPoint)));
|
||||||
connect(AdBlockManager::instance(), SIGNAL(enabledChanged(bool)), this, SLOT(setEnabled(bool)));
|
connect(AdBlockManager::instance(), SIGNAL(enabledChanged(bool)), this, SLOT(setEnabled(bool)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockIcon::popupBlocked(const QString &ruleString, const QUrl &url)
|
void AdBlockIcon::popupBlocked(const QString &rule_string, const QUrl &url) {
|
||||||
{
|
int index = rule_string.lastIndexOf(QLatin1String(" ("));
|
||||||
int index = ruleString.lastIndexOf(QLatin1String(" ("));
|
const QString subscription_ame = rule_string.left(index);
|
||||||
|
const QString filter = rule_string.mid(index + 2, rule_string.size() - index - 3);
|
||||||
|
AdBlockSubscription* subscription = AdBlockManager::instance()->subscriptionByName(subscription_ame);
|
||||||
|
|
||||||
const QString subscriptionName = ruleString.left(index);
|
|
||||||
const QString filter = ruleString.mid(index + 2, ruleString.size() - index - 3);
|
|
||||||
AdBlockSubscription* subscription = AdBlockManager::instance()->subscriptionByName(subscriptionName);
|
|
||||||
if (filter.isEmpty() || !subscription) {
|
if (filter.isEmpty() || !subscription) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -78,7 +58,7 @@ void AdBlockIcon::popupBlocked(const QString &ruleString, const QUrl &url)
|
|||||||
//!** FIXME
|
//!** FIXME
|
||||||
// mApp->desktopNotifications()->showNotification(QPixmap(":images/images/adblock_big.png"), tr("Blocked popup window"), tr("AdBlock blocked unwanted popup window."));
|
// mApp->desktopNotifications()->showNotification(QPixmap(":images/images/adblock_big.png"), tr("Blocked popup window"), tr("AdBlock blocked unwanted popup window."));
|
||||||
|
|
||||||
if (!m_flashTimer) {
|
if (m_flashTimer == NULL) {
|
||||||
m_flashTimer = new QTimer(this);
|
m_flashTimer = new QTimer(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,21 +72,20 @@ void AdBlockIcon::popupBlocked(const QString &ruleString, const QUrl &url)
|
|||||||
connect(m_flashTimer, SIGNAL(timeout()), this, SLOT(animateIcon()));
|
connect(m_flashTimer, SIGNAL(timeout()), this, SLOT(animateIcon()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QAction* AdBlockIcon::menuAction()
|
QAction *AdBlockIcon::menuAction() {
|
||||||
{
|
if (m_menuAction == NULL) {
|
||||||
if (!m_menuAction) {
|
m_menuAction = new QAction(tr("Adblock"), this);
|
||||||
m_menuAction = new QAction(tr("AdBlock"), this);
|
m_menuAction->setMenu(new QMenu(this));
|
||||||
m_menuAction->setMenu(new QMenu);
|
|
||||||
connect(m_menuAction->menu(), SIGNAL(aboutToShow()), this, SLOT(createMenu()));
|
connect(m_menuAction->menu(), SIGNAL(aboutToShow()), this, SLOT(createMenu()));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_menuAction->setIcon(QIcon(m_enabled ? ":images/images/adblock.png" : ":images/images/adblock-disabled.png"));
|
m_menuAction->setIcon(m_enabled ? qApp->icons()->fromTheme("web-adblock") : qApp->icons()->fromTheme("web-adblock"));
|
||||||
|
|
||||||
return m_menuAction;
|
return m_menuAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockIcon::createMenu(QMenu *menu)
|
void AdBlockIcon::createMenu(QMenu *menu) {
|
||||||
{
|
|
||||||
if (menu == NULL) {
|
if (menu == NULL) {
|
||||||
menu = qobject_cast<QMenu*>(sender());
|
menu = qobject_cast<QMenu*>(sender());
|
||||||
|
|
||||||
@ -118,43 +97,47 @@ void AdBlockIcon::createMenu(QMenu *menu)
|
|||||||
menu->clear();
|
menu->clear();
|
||||||
|
|
||||||
AdBlockManager *manager = AdBlockManager::instance();
|
AdBlockManager *manager = AdBlockManager::instance();
|
||||||
AdBlockCustomList *customList = manager->customList();
|
AdBlockCustomList *custom_list = manager->customList();
|
||||||
|
|
||||||
WebPage* page = qApp->mainForm()->tabWidget()->widget(qApp->mainForm()->tabWidget()->currentIndex())->webBrowser()->view()->page();
|
WebPage* page = qApp->mainForm()->tabWidget()->currentWidget()->webBrowser()->view()->page();
|
||||||
const QUrl pageUrl = page->mainFrame()->url();
|
const QUrl page_url = page->mainFrame()->url();
|
||||||
|
|
||||||
menu->addAction(tr("Show Adblock &settings"), manager, SLOT(showDialog()));
|
menu->addAction(tr("Show Adblock &settings"), manager, SLOT(showDialog()));
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
|
|
||||||
if (!pageUrl.host().isEmpty() && m_enabled && manager->canRunOnScheme(pageUrl.scheme())) {
|
if (!page_url.host().isEmpty() && m_enabled && manager->canRunOnScheme(page_url.scheme())) {
|
||||||
const QString host = pageUrl.host().contains(QLatin1String("www.")) ? pageUrl.host().mid(4) : pageUrl.host();
|
const QString host = page_url.host().contains(QLatin1String("www.")) ? page_url.host().mid(4) : page_url.host();
|
||||||
const QString hostFilter = QString("@@||%1^$document").arg(host);
|
const QString host_filter = QString("@@||%1^$document").arg(host);
|
||||||
const QString pageFilter = QString("@@|%1|$document").arg(pageUrl.toString());
|
const QString page_filter = QString("@@|%1|$document").arg(page_url.toString());
|
||||||
|
|
||||||
QAction* act = menu->addAction(tr("Disable on %1").arg(host));
|
QAction *act;
|
||||||
|
|
||||||
|
act = menu->addAction(tr("Disable on %1").arg(host));
|
||||||
act->setCheckable(true);
|
act->setCheckable(true);
|
||||||
act->setChecked(customList->containsFilter(hostFilter));
|
act->setChecked(custom_list->containsFilter(host_filter));
|
||||||
act->setData(hostFilter);
|
act->setData(host_filter);
|
||||||
connect(act, SIGNAL(triggered()), this, SLOT(toggleCustomFilter()));
|
connect(act, SIGNAL(triggered()), this, SLOT(toggleCustomFilter()));
|
||||||
|
|
||||||
act = menu->addAction(tr("Disable only on this page"));
|
act = menu->addAction(tr("Disable only on this page"));
|
||||||
act->setCheckable(true);
|
act->setCheckable(true);
|
||||||
act->setChecked(customList->containsFilter(pageFilter));
|
act->setChecked(custom_list->containsFilter(page_filter));
|
||||||
act->setData(pageFilter);
|
act->setData(page_filter);
|
||||||
connect(act, SIGNAL(triggered()), this, SLOT(toggleCustomFilter()));
|
connect(act, SIGNAL(triggered()), this, SLOT(toggleCustomFilter()));
|
||||||
|
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_blockedPopups.isEmpty()) {
|
if (!m_blockedPopups.isEmpty()) {
|
||||||
menu->addAction(tr("Blocked Popup Windows"))->setEnabled(false);
|
menu->addAction(tr("Blocked popup windows"))->setEnabled(false);
|
||||||
|
|
||||||
for (int i = 0; i < m_blockedPopups.count(); i++) {
|
for (int i = 0; i < m_blockedPopups.count(); i++) {
|
||||||
const QPair<AdBlockRule*, QUrl> &pair = m_blockedPopups.at(i);
|
const QPair<AdBlockRule*,QUrl> &pair = m_blockedPopups.at(i);
|
||||||
|
|
||||||
QString address = pair.second.toString().right(55);
|
QString address = pair.second.toString().right(55);
|
||||||
QString actionText = tr("%1 with (%2)").arg(address, pair.first->filter()).replace(QLatin1Char('&'), QLatin1String("&&"));
|
QString actionText = tr("%1 with (%2)").arg(address,
|
||||||
|
pair.first->filter()).replace(QLatin1Char('&'), QLatin1String("&&"));
|
||||||
|
|
||||||
QAction* action = menu->addAction(actionText, manager, SLOT(showRule()));
|
QAction *action = menu->addAction(actionText, manager, SLOT(showRule()));
|
||||||
action->setData(QVariant::fromValue((void*)pair.first));
|
action->setData(QVariant::fromValue((void*)pair.first));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -162,98 +145,96 @@ void AdBlockIcon::createMenu(QMenu *menu)
|
|||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
|
|
||||||
QVector<WebPage::AdBlockedEntry> entries = page->adBlockedEntries();
|
QVector<WebPage::AdBlockedEntry> entries = page->adBlockedEntries();
|
||||||
|
|
||||||
if (entries.isEmpty()) {
|
if (entries.isEmpty()) {
|
||||||
menu->addAction(tr("No content blocked"))->setEnabled(false);
|
menu->addAction(tr("No content blocked"))->setEnabled(false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
menu->addAction(tr("Blocked URL (AdBlock Rule) - click to edit rule"))->setEnabled(false);
|
menu->addAction(tr("Blocked some content - click to edit rule"))->setEnabled(false);
|
||||||
|
|
||||||
foreach (const WebPage::AdBlockedEntry &entry, entries) {
|
foreach (const WebPage::AdBlockedEntry &entry, entries) {
|
||||||
QString address = entry.url.toString().right(55);
|
QString address = entry.url.toString().right(55);
|
||||||
QString actionText = tr("%1 with (%2)").arg(address, entry.rule->filter()).replace(QLatin1Char('&'), QLatin1String("&&"));
|
QString action_text = tr("%1 with (%2)").arg(address,
|
||||||
|
entry.rule->filter()).replace(QLatin1Char('&'), QLatin1String("&&"));
|
||||||
|
|
||||||
QAction* action = menu->addAction(actionText, manager, SLOT(showRule()));
|
QAction *action = menu->addAction(action_text, manager, SLOT(showRule()));
|
||||||
action->setData(QVariant::fromValue((void*)entry.rule));
|
action->setData(QVariant::fromValue((void*)entry.rule));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockIcon::showMenu(const QPoint &pos)
|
void AdBlockIcon::showMenu(const QPoint &pos) {
|
||||||
{
|
|
||||||
QMenu menu;
|
QMenu menu;
|
||||||
createMenu(&menu);
|
createMenu(&menu);
|
||||||
|
|
||||||
menu.exec(pos);
|
menu.exec(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockIcon::toggleCustomFilter()
|
void AdBlockIcon::toggleCustomFilter() {
|
||||||
{
|
QAction *action = qobject_cast<QAction*>(sender());
|
||||||
QAction* action = qobject_cast<QAction*>(sender());
|
|
||||||
if (!action) {
|
if (action == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString filter = action->data().toString();
|
const QString filter = action->data().toString();
|
||||||
AdBlockManager* manager = AdBlockManager::instance();
|
AdBlockManager* manager = AdBlockManager::instance();
|
||||||
AdBlockCustomList* customList = manager->customList();
|
AdBlockCustomList* custom_list = manager->customList();
|
||||||
|
|
||||||
if (customList->containsFilter(filter)) {
|
if (custom_list->containsFilter(filter)) {
|
||||||
customList->removeFilter(filter);
|
custom_list->removeFilter(filter);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
AdBlockRule* rule = new AdBlockRule(filter, customList);
|
AdBlockRule *rule = new AdBlockRule(filter, custom_list);
|
||||||
customList->addRule(rule);
|
custom_list->addRule(rule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockIcon::animateIcon()
|
void AdBlockIcon::animateIcon() {
|
||||||
{
|
m_timerTicks++;
|
||||||
++m_timerTicks;
|
|
||||||
if (m_timerTicks > 10) {
|
if (m_timerTicks > 10) {
|
||||||
stopAnimation();
|
stopAnimation();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (icon().isNull()) {
|
if (icon().isNull()) {
|
||||||
setIcon(QIcon(":images/images/adblock.png"));
|
setIcon(qApp->icons()->fromTheme("web-adblock"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setIcon(QIcon());
|
setIcon(QIcon());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockIcon::stopAnimation()
|
void AdBlockIcon::stopAnimation() {
|
||||||
{
|
|
||||||
m_timerTicks = 0;
|
m_timerTicks = 0;
|
||||||
m_flashTimer->stop();
|
m_flashTimer->stop();
|
||||||
disconnect(m_flashTimer, SIGNAL(timeout()), this, SLOT(animateIcon()));
|
|
||||||
|
|
||||||
|
disconnect(m_flashTimer, SIGNAL(timeout()), this, SLOT(animateIcon()));
|
||||||
setEnabled(m_enabled);
|
setEnabled(m_enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockIcon::setEnabled(bool enabled)
|
void AdBlockIcon::setEnabled(bool enabled) {
|
||||||
{
|
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
|
setToolTip(tr("Adblock - up and running"));
|
||||||
setIcon(qApp->icons()->fromTheme("web-adblock"));
|
setIcon(qApp->icons()->fromTheme("web-adblock"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
setToolTip(tr("Adblock - not running"));
|
||||||
setIcon(qApp->icons()->fromTheme("web-adblock-disabled"));
|
setIcon(qApp->icons()->fromTheme("web-adblock-disabled"));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_enabled = enabled;
|
m_enabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockIcon::mouseReleaseEvent(QMouseEvent* event)
|
void AdBlockIcon::mouseReleaseEvent(QMouseEvent *event) {
|
||||||
{
|
if (event->button() == Qt::LeftButton) {
|
||||||
if (event->button() == Qt::LeftButton && rect().contains(event->pos())) {
|
|
||||||
if (event->modifiers() != Qt::ControlModifier) {
|
|
||||||
emit clicked(event->globalPos());
|
emit clicked(event->globalPos());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QToolButton::mouseReleaseEvent(event);
|
QToolButton::mouseReleaseEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AdBlockIcon::~AdBlockIcon()
|
AdBlockIcon::~AdBlockIcon() {
|
||||||
{
|
qDebug("Destroying AdBlockIcon instance.");
|
||||||
}
|
}
|
||||||
|
@ -1,37 +1,21 @@
|
|||||||
/* ============================================================
|
// This file is part of RSS Guard.
|
||||||
* QuiteRSS is a open-source cross-platform RSS/Atom news feeds reader
|
//
|
||||||
* Copyright (C) 2011-2015 QuiteRSS Team <quiterssteam@gmail.com>
|
// Copyright (C) 2014-2015 by Martin Rotter <rotter.martinos@gmail.com>
|
||||||
*
|
// Copyright (C) 2010-2014 by David Rosca <nowrep@gmail.com>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
//
|
||||||
* it under the terms of the GNU General Public License as published by
|
// RSS Guard is free software: you can redistribute it and/or modify
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// it under the terms of the GNU General Public License as published by
|
||||||
* (at your option) any later version.
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
*
|
// (at your option) any later version.
|
||||||
* This program is distributed in the hope that it will be useful,
|
//
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// RSS Guard is distributed in the hope that it will be useful,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* GNU General Public License for more details.
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
*
|
// GNU General Public License for more details.
|
||||||
* You should have received a copy of the GNU General Public License
|
//
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// You should have received a copy of the GNU General Public License
|
||||||
* ============================================================ */
|
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
/* ============================================================
|
|
||||||
* QupZilla - WebKit based browser
|
|
||||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
* ============================================================ */
|
|
||||||
#ifndef ADBLOCKICON_H
|
#ifndef ADBLOCKICON_H
|
||||||
#define ADBLOCKICON_H
|
#define ADBLOCKICON_H
|
||||||
|
|
||||||
@ -44,12 +28,13 @@ class AdBlockRule;
|
|||||||
|
|
||||||
class AdBlockIcon : public PlainToolButton {
|
class AdBlockIcon : public PlainToolButton {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructors.
|
// Constructors.
|
||||||
explicit AdBlockIcon(QWidget *window, QWidget *parent = 0);
|
explicit AdBlockIcon(QWidget *window, QWidget *parent = 0);
|
||||||
virtual ~AdBlockIcon();
|
virtual ~AdBlockIcon();
|
||||||
|
|
||||||
void popupBlocked(const QString &ruleString, const QUrl &url);
|
void popupBlocked(const QString &rule_string, const QUrl &url);
|
||||||
QAction *menuAction();
|
QAction *menuAction();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@ -59,7 +44,6 @@ class AdBlockIcon : public PlainToolButton {
|
|||||||
private slots:
|
private slots:
|
||||||
void showMenu(const QPoint &pos);
|
void showMenu(const QPoint &pos);
|
||||||
void toggleCustomFilter();
|
void toggleCustomFilter();
|
||||||
|
|
||||||
void animateIcon();
|
void animateIcon();
|
||||||
void stopAnimation();
|
void stopAnimation();
|
||||||
|
|
||||||
@ -71,10 +55,10 @@ class AdBlockIcon : public PlainToolButton {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget *m_window;
|
QWidget *m_window;
|
||||||
QAction* m_menuAction;
|
QAction *m_menuAction;
|
||||||
|
|
||||||
QVector<QPair<AdBlockRule*, QUrl> > m_blockedPopups;
|
QVector<QPair<AdBlockRule*,QUrl>> m_blockedPopups;
|
||||||
QTimer* m_flashTimer;
|
QTimer *m_flashTimer;
|
||||||
|
|
||||||
int m_timerTicks;
|
int m_timerTicks;
|
||||||
bool m_enabled;
|
bool m_enabled;
|
||||||
|
@ -58,26 +58,20 @@
|
|||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
AdBlockManager* AdBlockManager::s_adBlockManager = 0;
|
AdBlockManager* AdBlockManager::s_adBlockManager = NULL;
|
||||||
|
|
||||||
AdBlockManager::AdBlockManager(QObject* parent)
|
AdBlockManager::AdBlockManager(QObject* parent)
|
||||||
: QObject(parent)
|
: QObject(parent), m_loaded(false), m_enabled(false), m_useLimitedEasyList(true),
|
||||||
, m_loaded(false)
|
m_matcher(new AdBlockMatcher(this)), m_subscriptions(QList<AdBlockSubscription*>()) {
|
||||||
, m_enabled(true)
|
|
||||||
, m_useLimitedEasyList(true)
|
|
||||||
, m_matcher(new AdBlockMatcher(this)), m_subscriptions(QList<AdBlockSubscription*>())
|
|
||||||
{
|
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
AdBlockManager::~AdBlockManager()
|
AdBlockManager::~AdBlockManager() {
|
||||||
{
|
|
||||||
qDeleteAll(m_subscriptions);
|
qDeleteAll(m_subscriptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
AdBlockManager* AdBlockManager::instance()
|
AdBlockManager* AdBlockManager::instance() {
|
||||||
{
|
if (s_adBlockManager == NULL) {
|
||||||
if (!s_adBlockManager) {
|
|
||||||
s_adBlockManager = new AdBlockManager(SilentNetworkAccessManager::instance());
|
s_adBlockManager = new AdBlockManager(SilentNetworkAccessManager::instance());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,6 +126,7 @@ void AdBlockManager::setEnabled(bool enabled)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_enabled = enabled;
|
m_enabled = enabled;
|
||||||
|
|
||||||
emit enabledChanged(enabled);
|
emit enabledChanged(enabled);
|
||||||
|
|
||||||
Settings *settings = qApp->settings();
|
Settings *settings = qApp->settings();
|
||||||
@ -139,7 +134,10 @@ void AdBlockManager::setEnabled(bool enabled)
|
|||||||
settings->setValue("enabled", m_enabled);
|
settings->setValue("enabled", m_enabled);
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
|
|
||||||
|
// Load subscriptions and other data.
|
||||||
load();
|
load();
|
||||||
|
|
||||||
|
// Inform others (mainly ICON and MATCHER), that there are some changes.
|
||||||
// TODO
|
// TODO
|
||||||
//mainApp->reloadUserStyleBrowser();
|
//mainApp->reloadUserStyleBrowser();
|
||||||
}
|
}
|
||||||
@ -207,10 +205,10 @@ void AdBlockManager::removeDisabledRule(const QString &filter)
|
|||||||
m_disabledRules.removeOne(filter);
|
m_disabledRules.removeOne(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
AdBlockSubscription* AdBlockManager::addSubscription(const QString &title, const QString &url)
|
AdBlockSubscription *AdBlockManager::addSubscription(const QString &title, const QString &url)
|
||||||
{
|
{
|
||||||
if (title.isEmpty() || url.isEmpty()) {
|
if (title.isEmpty() || url.isEmpty()) {
|
||||||
return 0;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString fileName = filterCharsFromFilename(title.toLower()) + ".txt";
|
QString fileName = filterCharsFromFilename(title.toLower()) + ".txt";
|
||||||
@ -281,6 +279,7 @@ void AdBlockManager::load()
|
|||||||
QDateTime lastUpdate = settings->value("AdBlock","lastUpdate", QDateTime()).toDateTime();
|
QDateTime lastUpdate = settings->value("AdBlock","lastUpdate", QDateTime()).toDateTime();
|
||||||
|
|
||||||
if (!m_enabled) {
|
if (!m_enabled) {
|
||||||
|
// We loaded settings, but Adblock should be disabled. Do not continue to save memory.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,22 +446,12 @@ AdBlockSubscription* AdBlockManager::subscriptionByName(const QString &name) con
|
|||||||
}
|
}
|
||||||
|
|
||||||
AdBlockDialog *AdBlockManager::showDialog() {
|
AdBlockDialog *AdBlockManager::showDialog() {
|
||||||
QPointer<AdBlockDialog> form_pointer = new AdBlockDialog();
|
QPointer<AdBlockDialog> form_pointer = new AdBlockDialog(qApp->mainForm());
|
||||||
form_pointer.data()->show();
|
form_pointer.data()->show();
|
||||||
form_pointer.data()->raise();
|
form_pointer.data()->raise();
|
||||||
form_pointer.data()->activateWindow();
|
form_pointer.data()->activateWindow();
|
||||||
form_pointer.data()->setAttribute(Qt::WA_DeleteOnClose, true);
|
form_pointer.data()->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||||
return form_pointer.data();
|
return form_pointer.data();
|
||||||
/*
|
|
||||||
if (!m_adBlockDialog) {
|
|
||||||
m_adBlockDialog = new AdBlockDialog;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_adBlockDialog.data()->show();
|
|
||||||
m_adBlockDialog.data()->raise();
|
|
||||||
m_adBlockDialog.data()->activateWindow();
|
|
||||||
|
|
||||||
return m_adBlockDialog.data();*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockManager::showRule()
|
void AdBlockManager::showRule()
|
||||||
|
@ -35,8 +35,6 @@
|
|||||||
#ifndef ADBLOCKMANAGER_H
|
#ifndef ADBLOCKMANAGER_H
|
||||||
#define ADBLOCKMANAGER_H
|
#define ADBLOCKMANAGER_H
|
||||||
|
|
||||||
#define ADBLOCK_EASYLIST_URL "https://easylist-downloads.adblockplus.org/easylist.txt"
|
|
||||||
|
|
||||||
#ifndef QSL
|
#ifndef QSL
|
||||||
#if QT_VERSION >= 0x050000
|
#if QT_VERSION >= 0x050000
|
||||||
#define QSL(x) QStringLiteral(x)
|
#define QSL(x) QStringLiteral(x)
|
||||||
@ -103,7 +101,7 @@ class AdBlockManager : public QObject
|
|||||||
void addDisabledRule(const QString &filter);
|
void addDisabledRule(const QString &filter);
|
||||||
void removeDisabledRule(const QString &filter);
|
void removeDisabledRule(const QString &filter);
|
||||||
|
|
||||||
AdBlockSubscription* addSubscription(const QString &title, const QString &url);
|
AdBlockSubscription *addSubscription(const QString &title, const QString &url);
|
||||||
bool removeSubscription(AdBlockSubscription* subscription);
|
bool removeSubscription(AdBlockSubscription* subscription);
|
||||||
|
|
||||||
AdBlockCustomList* customList() const;
|
AdBlockCustomList* customList() const;
|
||||||
@ -126,11 +124,10 @@ class AdBlockManager : public QObject
|
|||||||
bool m_useLimitedEasyList;
|
bool m_useLimitedEasyList;
|
||||||
|
|
||||||
QList<AdBlockSubscription*> m_subscriptions;
|
QList<AdBlockSubscription*> m_subscriptions;
|
||||||
static AdBlockManager* s_adBlockManager;
|
|
||||||
AdBlockMatcher* m_matcher;
|
AdBlockMatcher* m_matcher;
|
||||||
QStringList m_disabledRules;
|
QStringList m_disabledRules;
|
||||||
|
|
||||||
QPointer<AdBlockDialog> m_adBlockDialog;
|
static AdBlockManager* s_adBlockManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ADBLOCKMANAGER_H
|
#endif // ADBLOCKMANAGER_H
|
||||||
|
@ -37,10 +37,7 @@
|
|||||||
#include "adblockrule.h"
|
#include "adblockrule.h"
|
||||||
#include "adblocksubscription.h"
|
#include "adblocksubscription.h"
|
||||||
|
|
||||||
AdBlockMatcher::AdBlockMatcher(AdBlockManager* manager)
|
AdBlockMatcher::AdBlockMatcher(AdBlockManager* manager) : QObject(manager), m_manager(manager) {
|
||||||
: QObject(manager)
|
|
||||||
, m_manager(manager)
|
|
||||||
{
|
|
||||||
connect(manager, SIGNAL(enabledChanged(bool)), this, SLOT(enabledChanged(bool)));
|
connect(manager, SIGNAL(enabledChanged(bool)), this, SLOT(enabledChanged(bool)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +114,7 @@ QString AdBlockMatcher::elementHidingRulesForDomain(const QString &domain) const
|
|||||||
if (!rule->matchDomain(domain))
|
if (!rule->matchDomain(domain))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (Q_UNLIKELY(addedRulesCount == 1000)) {
|
if (addedRulesCount == 1000) {
|
||||||
rules.append(rule->cssSelector());
|
rules.append(rule->cssSelector());
|
||||||
rules.append(QLatin1String("{display:none !important;}\n"));
|
rules.append(QLatin1String("{display:none !important;}\n"));
|
||||||
addedRulesCount = 0;
|
addedRulesCount = 0;
|
||||||
@ -205,7 +202,7 @@ void AdBlockMatcher::update()
|
|||||||
if (rule->isDomainRestricted()) {
|
if (rule->isDomainRestricted()) {
|
||||||
m_domainRestrictedCssRules.append(rule);
|
m_domainRestrictedCssRules.append(rule);
|
||||||
}
|
}
|
||||||
else if (Q_UNLIKELY(hidingRulesCount == 1000)) {
|
else if (hidingRulesCount == 1000) {
|
||||||
m_elementHidingRules.append(rule->cssSelector());
|
m_elementHidingRules.append(rule->cssSelector());
|
||||||
m_elementHidingRules.append(QLatin1String("{display:none !important;} "));
|
m_elementHidingRules.append(QLatin1String("{display:none !important;} "));
|
||||||
hidingRulesCount = 0;
|
hidingRulesCount = 0;
|
||||||
@ -238,8 +235,10 @@ void AdBlockMatcher::clear()
|
|||||||
|
|
||||||
void AdBlockMatcher::enabledChanged(bool enabled)
|
void AdBlockMatcher::enabledChanged(bool enabled)
|
||||||
{
|
{
|
||||||
if (enabled)
|
if (enabled) {
|
||||||
update();
|
update();
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
clear();
|
clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ class AdBlockSubscription;
|
|||||||
class AdBlockRule
|
class AdBlockRule
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AdBlockRule(const QString &filter = QString(), AdBlockSubscription* subscription = 0);
|
AdBlockRule(const QString &filter = QString(), AdBlockSubscription* subscription = NULL);
|
||||||
~AdBlockRule();
|
~AdBlockRule();
|
||||||
|
|
||||||
AdBlockRule* copy() const;
|
AdBlockRule* copy() const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user