mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-30 00:55:16 +01:00
Extensive work on Adblock.
This commit is contained in:
parent
a4a637b789
commit
cc9c3680c1
@ -431,8 +431,6 @@ set(APP_SOURCES
|
||||
src/network-web/adblock/adblocktreewidget.cpp
|
||||
src/network-web/adblock/followredirectreply.cpp
|
||||
|
||||
|
||||
|
||||
# MAIN sources.
|
||||
src/main.cpp
|
||||
)
|
||||
@ -526,8 +524,6 @@ set(APP_HEADERS
|
||||
src/network-web/adblock/adblockicon.h
|
||||
src/network-web/adblock/adblockmanager.h
|
||||
src/network-web/adblock/adblockmatcher.h
|
||||
src/network-web/adblock/adblockrule.h
|
||||
src/network-web/adblock/adblocksearchtree.h
|
||||
src/network-web/adblock/adblocksubscription.h
|
||||
src/network-web/adblock/adblocktreewidget.h
|
||||
src/network-web/adblock/followredirectreply.h
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.3 KiB |
BIN
resources/graphics/icons/mini-kfaenza/web-adblock-disabled.png
Normal file
BIN
resources/graphics/icons/mini-kfaenza/web-adblock-disabled.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 6.3 KiB |
@ -35,6 +35,7 @@
|
||||
#include "gui/statusbar.h"
|
||||
#include "gui/feedmessageviewer.h"
|
||||
#include "gui/formupdate.h"
|
||||
#include "gui/plaintoolbutton.h"
|
||||
#include "gui/formimportexport.h"
|
||||
#include "gui/formbackupdatabasesettings.h"
|
||||
#include "gui/formrestoredatabasesettings.h"
|
||||
|
@ -39,8 +39,9 @@ void PlainToolButton::paintEvent(QPaintEvent *e) {
|
||||
// Set padding.
|
||||
rect.adjust(m_padding, m_padding, -m_padding, -m_padding);
|
||||
|
||||
|
||||
// Paint the icon.
|
||||
if (underMouse()) {
|
||||
if (underMouse() || isChecked()) {
|
||||
p.setOpacity(0.7);
|
||||
}
|
||||
|
||||
@ -53,7 +54,11 @@ int PlainToolButton::padding() const {
|
||||
|
||||
void PlainToolButton::setPadding(int padding) {
|
||||
m_padding = padding;
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
void PlainToolButton::setChecked(bool checked) {
|
||||
QToolButton::setChecked(checked);
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,9 @@ class PlainToolButton : public QToolButton {
|
||||
int padding() const;
|
||||
void setPadding(int padding);
|
||||
|
||||
public slots:
|
||||
void setChecked(bool checked);
|
||||
|
||||
protected:
|
||||
// Custom look.
|
||||
void paintEvent(QPaintEvent *e);
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
#include "gui/formmain.h"
|
||||
#include "gui/tabwidget.h"
|
||||
#include "gui/plaintoolbutton.h"
|
||||
#include "network-web/adblock/adblockicon.h"
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
|
||||
#include <QToolButton>
|
||||
@ -31,11 +33,10 @@ StatusBar::StatusBar(QWidget *parent) : QStatusBar(parent) {
|
||||
setSizeGripEnabled(false);
|
||||
setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
adblockIcon_ = new AdBlockIcon(this);
|
||||
m_adblockIcon = new AdBlockIcon(this);
|
||||
|
||||
// Initializations of widgets for status bar.
|
||||
m_fullscreenSwitcher = new QToolButton(this);
|
||||
m_fullscreenSwitcher->setAutoRaise(true);
|
||||
m_fullscreenSwitcher = new PlainToolButton(this);
|
||||
m_fullscreenSwitcher->setCheckable(true);
|
||||
m_fullscreenSwitcher->setIcon(qApp->icons()->fromTheme("view-fullscreen"));
|
||||
m_fullscreenSwitcher->setText(tr("Fullscreen mode"));
|
||||
@ -68,22 +69,18 @@ StatusBar::StatusBar(QWidget *parent) : QStatusBar(parent) {
|
||||
addPermanentWidget(m_barProgressFeeds);
|
||||
addPermanentWidget(m_lblProgressDownload);
|
||||
addPermanentWidget(m_barProgressDownload);
|
||||
addPermanentWidget(m_adblockIcon);
|
||||
addPermanentWidget(m_fullscreenSwitcher);
|
||||
addPermanentWidget(adblockIcon_);
|
||||
}
|
||||
|
||||
StatusBar::~StatusBar() {
|
||||
qDebug("Destroying StatusBar instance.");
|
||||
}
|
||||
|
||||
void StatusBar::displayDownloadManager() {
|
||||
qApp->mainForm()->tabWidget()->showDownloadManager();
|
||||
}
|
||||
|
||||
bool StatusBar::eventFilter(QObject *watched, QEvent *event) {
|
||||
if (watched == m_lblProgressDownload || watched == m_barProgressDownload) {
|
||||
if (event->type() == QEvent::MouseButtonPress) {
|
||||
displayDownloadManager();
|
||||
qApp->mainForm()->tabWidget()->showDownloadManager();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,12 +20,11 @@
|
||||
|
||||
#include <QStatusBar>
|
||||
|
||||
#include <adblock/adblockicon.h>
|
||||
|
||||
|
||||
class QProgressBar;
|
||||
class QToolButton;
|
||||
class PlainToolButton;
|
||||
class QLabel;
|
||||
class AdBlockIcon;
|
||||
|
||||
class StatusBar : public QStatusBar {
|
||||
Q_OBJECT
|
||||
@ -35,11 +34,13 @@ class StatusBar : public QStatusBar {
|
||||
explicit StatusBar(QWidget *parent = 0);
|
||||
virtual ~StatusBar();
|
||||
|
||||
inline QToolButton *fullscreenSwitcher() const {
|
||||
inline PlainToolButton *fullscreenSwitcher() const {
|
||||
return m_fullscreenSwitcher;
|
||||
}
|
||||
|
||||
AdBlockIcon *adBlockIcon() { return adblockIcon_; }
|
||||
inline AdBlockIcon *adBlockIcon() {
|
||||
return m_adblockIcon;
|
||||
}
|
||||
|
||||
public slots:
|
||||
// Progress bar operations
|
||||
@ -49,8 +50,6 @@ class StatusBar : public QStatusBar {
|
||||
void showProgressDownload(int progress, const QString &tooltip);
|
||||
void clearProgressDownload();
|
||||
|
||||
void displayDownloadManager();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
|
||||
@ -59,8 +58,8 @@ class StatusBar : public QStatusBar {
|
||||
QLabel *m_lblProgressFeeds;
|
||||
QProgressBar *m_barProgressDownload;
|
||||
QLabel *m_lblProgressDownload;
|
||||
QToolButton *m_fullscreenSwitcher;
|
||||
AdBlockIcon* adblockIcon_;
|
||||
PlainToolButton *m_fullscreenSwitcher;
|
||||
AdBlockIcon* m_adblockIcon;
|
||||
};
|
||||
|
||||
#endif // STATUSBAR_H
|
||||
|
@ -89,6 +89,10 @@ AdBlockDialog::AdBlockDialog(QWidget* parent)
|
||||
buttonBox->setFocus();
|
||||
}
|
||||
|
||||
AdBlockDialog::~AdBlockDialog() {
|
||||
qDebug("Destroying AdBlockDialog instance.");
|
||||
}
|
||||
|
||||
void AdBlockDialog::showRule(const AdBlockRule* rule) const
|
||||
{
|
||||
AdBlockSubscription* subscription = rule->subscription();
|
||||
@ -210,7 +214,7 @@ void AdBlockDialog::load()
|
||||
|
||||
m_loaded = true;
|
||||
|
||||
QTimer::singleShot(50, this, SLOT(loadSubscriptions()));
|
||||
QTimer::singleShot(100, this, SLOT(loadSubscriptions()));
|
||||
}
|
||||
|
||||
void AdBlockDialog::closeEvent(QCloseEvent* ev)
|
||||
|
@ -46,44 +46,45 @@ class AdBlockRule;
|
||||
|
||||
class AdBlockDialog : public QWidget, public Ui_AdBlockDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AdBlockDialog(QWidget* parent = 0);
|
||||
public:
|
||||
explicit AdBlockDialog(QWidget* parent = 0);
|
||||
virtual ~AdBlockDialog();
|
||||
|
||||
void showRule(const AdBlockRule* rule) const;
|
||||
void showRule(const AdBlockRule* rule) const;
|
||||
|
||||
private slots:
|
||||
void addRule();
|
||||
void removeRule();
|
||||
private slots:
|
||||
void addRule();
|
||||
void removeRule();
|
||||
|
||||
void addSubscription();
|
||||
void removeSubscription();
|
||||
void addSubscription();
|
||||
void removeSubscription();
|
||||
|
||||
void currentChanged(int index);
|
||||
void filterString(const QString &string);
|
||||
void enableAdBlock(bool state);
|
||||
void currentChanged(int index);
|
||||
void filterString(const QString &string);
|
||||
void enableAdBlock(bool state);
|
||||
|
||||
void aboutToShowMenu();
|
||||
void learnAboutRules();
|
||||
void aboutToShowMenu();
|
||||
void learnAboutRules();
|
||||
|
||||
void loadSubscriptions();
|
||||
void load();
|
||||
void loadSubscriptions();
|
||||
void load();
|
||||
|
||||
private:
|
||||
void closeEvent(QCloseEvent* ev);
|
||||
private:
|
||||
void closeEvent(QCloseEvent* ev);
|
||||
|
||||
AdBlockManager* m_manager;
|
||||
AdBlockTreeWidget* m_currentTreeWidget;
|
||||
AdBlockSubscription* m_currentSubscription;
|
||||
AdBlockManager* m_manager;
|
||||
AdBlockTreeWidget* m_currentTreeWidget;
|
||||
AdBlockSubscription* m_currentSubscription;
|
||||
|
||||
QAction* m_actionAddRule;
|
||||
QAction* m_actionRemoveRule;
|
||||
QAction* m_actionAddSubscription;
|
||||
QAction* m_actionRemoveSubscription;
|
||||
QAction* m_actionAddRule;
|
||||
QAction* m_actionRemoveRule;
|
||||
QAction* m_actionAddSubscription;
|
||||
QAction* m_actionRemoveSubscription;
|
||||
|
||||
bool m_loaded;
|
||||
bool m_useLimitedEasyList;
|
||||
bool m_loaded;
|
||||
bool m_useLimitedEasyList;
|
||||
};
|
||||
|
||||
#endif // ADBLOCKDIALOG_H
|
||||
|
@ -57,7 +57,16 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="4" column="0" colspan="2">
|
||||
@ -67,10 +76,6 @@
|
||||
<property name="text">
|
||||
<string>Options</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../QuiteRSS.qrc">
|
||||
<normaloff>:/images/images/adblock.png</normaloff>:/images/images/adblock.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -129,7 +134,7 @@
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Ok</set>
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -137,9 +142,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../QuiteRSS.qrc"/>
|
||||
</resources>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>adblockCheckBox</sender>
|
||||
@ -157,5 +160,21 @@
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>clicked(QAbstractButton*)</signal>
|
||||
<receiver>AdBlockDialog</receiver>
|
||||
<slot>close()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>434</x>
|
||||
<y>440</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>272</x>
|
||||
<y>230</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
@ -32,16 +32,18 @@
|
||||
* 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 "adblockicon.h"
|
||||
#include "adblockrule.h"
|
||||
#include "adblockmanager.h"
|
||||
#include "adblocksubscription.h"
|
||||
#include "webpage.h"
|
||||
#include "network-web/adblock/adblockicon.h"
|
||||
|
||||
#include "network-web/adblock/adblockrule.h"
|
||||
#include "network-web/adblock/adblockmanager.h"
|
||||
#include "network-web/adblock/adblocksubscription.h"
|
||||
#include "network-web/webpage.h"
|
||||
#include "network-web/webbrowser.h"
|
||||
|
||||
#include "miscellaneous/application.h"
|
||||
#include "gui/plaintoolbutton.h"
|
||||
#include "gui/formmain.h"
|
||||
#include "gui/tabwidget.h"
|
||||
#include "network-web/webbrowser.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QMouseEvent>
|
||||
@ -50,27 +52,13 @@
|
||||
|
||||
|
||||
AdBlockIcon::AdBlockIcon(QWidget *window, QWidget *parent)
|
||||
: QToolButton(parent)
|
||||
, m_window(window)
|
||||
, m_menuAction(0)
|
||||
, m_flashTimer(0)
|
||||
, m_timerTicks(0)
|
||||
, m_enabled(false)
|
||||
{
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
setStyleSheet("QToolButton { border: none; padding: 0px; }");
|
||||
: PlainToolButton(parent), m_window(window), m_menuAction(0), m_flashTimer(0), m_timerTicks(0), m_enabled(false) {
|
||||
setToolTip(tr("Adblock lets you block unwanted content on web pages."));
|
||||
|
||||
connect(this, SIGNAL(clicked(QPoint)), this, SLOT(showMenu(QPoint)));
|
||||
connect(AdBlockManager::instance(), SIGNAL(enabledChanged(bool)), this, SLOT(setEnabled(bool)));
|
||||
}
|
||||
|
||||
void AdBlockIcon::retranslateStrings()
|
||||
{
|
||||
setToolTip(tr("AdBlock lets you block unwanted content on web pages"));
|
||||
|
||||
AdBlockManager::instance()->customList()->retranslateStrings();
|
||||
}
|
||||
|
||||
void AdBlockIcon::popupBlocked(const QString &ruleString, const QUrl &url)
|
||||
{
|
||||
int index = ruleString.lastIndexOf(QLatin1String(" ("));
|
||||
@ -117,24 +105,25 @@ QAction* AdBlockIcon::menuAction()
|
||||
return m_menuAction;
|
||||
}
|
||||
|
||||
void AdBlockIcon::createMenu(QMenu* menu)
|
||||
void AdBlockIcon::createMenu(QMenu *menu)
|
||||
{
|
||||
if (!menu) {
|
||||
if (menu == NULL) {
|
||||
menu = qobject_cast<QMenu*>(sender());
|
||||
if (!menu) {
|
||||
|
||||
if (menu == NULL) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
menu->clear();
|
||||
|
||||
AdBlockManager* manager = AdBlockManager::instance();
|
||||
AdBlockCustomList* customList = manager->customList();
|
||||
AdBlockManager *manager = AdBlockManager::instance();
|
||||
AdBlockCustomList *customList = manager->customList();
|
||||
|
||||
WebPage* page = qApp->mainForm()->tabWidget()->widget(qApp->mainForm()->tabWidget()->currentIndex())->webBrowser()->view()->page();
|
||||
const QUrl pageUrl = page->mainFrame()->url();
|
||||
|
||||
menu->addAction(tr("Show AdBlock &Settings"), manager, SLOT(showDialog()));
|
||||
menu->addAction(tr("Show Adblock &settings"), manager, SLOT(showDialog()));
|
||||
menu->addSeparator();
|
||||
|
||||
if (!pageUrl.host().isEmpty() && m_enabled && manager->canRunOnScheme(pageUrl.scheme())) {
|
||||
@ -244,10 +233,10 @@ void AdBlockIcon::stopAnimation()
|
||||
void AdBlockIcon::setEnabled(bool enabled)
|
||||
{
|
||||
if (enabled) {
|
||||
setIcon(QIcon(":images/images/adblock.png"));
|
||||
setIcon(qApp->icons()->fromTheme("web-adblock"));
|
||||
}
|
||||
else {
|
||||
setIcon(QIcon(":images/images/adblock-disabled.png"));
|
||||
setIcon(qApp->icons()->fromTheme("web-adblock-disabled"));
|
||||
}
|
||||
|
||||
m_enabled = enabled;
|
||||
|
@ -35,50 +35,49 @@
|
||||
#ifndef ADBLOCKICON_H
|
||||
#define ADBLOCKICON_H
|
||||
|
||||
#include <QToolButton>
|
||||
#include "gui/plaintoolbutton.h"
|
||||
|
||||
#include "adblockrule.h"
|
||||
|
||||
class QMenu;
|
||||
class QUrl;
|
||||
class MainWindow;
|
||||
class AdBlockRule;
|
||||
|
||||
class AdBlockIcon : public QToolButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AdBlockIcon(QWidget *window, QWidget *parent = 0);
|
||||
~AdBlockIcon();
|
||||
class AdBlockIcon : public PlainToolButton {
|
||||
Q_OBJECT
|
||||
public:
|
||||
// Constructors.
|
||||
explicit AdBlockIcon(QWidget *window, QWidget *parent = 0);
|
||||
virtual ~AdBlockIcon();
|
||||
|
||||
void retranslateStrings();
|
||||
void popupBlocked(const QString &ruleString, const QUrl &url);
|
||||
QAction* menuAction();
|
||||
void popupBlocked(const QString &ruleString, const QUrl &url);
|
||||
QAction *menuAction();
|
||||
|
||||
signals:
|
||||
void clicked(QPoint);
|
||||
public slots:
|
||||
void setEnabled(bool enabled);
|
||||
void createMenu(QMenu *menu = NULL);
|
||||
|
||||
public slots:
|
||||
void setEnabled(bool enabled);
|
||||
void createMenu(QMenu* menu = 0);
|
||||
private slots:
|
||||
void showMenu(const QPoint &pos);
|
||||
void toggleCustomFilter();
|
||||
|
||||
private slots:
|
||||
void showMenu(const QPoint &pos);
|
||||
void toggleCustomFilter();
|
||||
void animateIcon();
|
||||
void stopAnimation();
|
||||
|
||||
void animateIcon();
|
||||
void stopAnimation();
|
||||
protected:
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
|
||||
private:
|
||||
void mouseReleaseEvent(QMouseEvent* event);
|
||||
signals:
|
||||
void clicked(QPoint);
|
||||
|
||||
QWidget *m_window;
|
||||
QAction* m_menuAction;
|
||||
private:
|
||||
QWidget *m_window;
|
||||
QAction* m_menuAction;
|
||||
|
||||
QVector<QPair<AdBlockRule*, QUrl> > m_blockedPopups;
|
||||
QTimer* m_flashTimer;
|
||||
QVector<QPair<AdBlockRule*, QUrl> > m_blockedPopups;
|
||||
QTimer* m_flashTimer;
|
||||
|
||||
int m_timerTicks;
|
||||
bool m_enabled;
|
||||
int m_timerTicks;
|
||||
bool m_enabled;
|
||||
};
|
||||
|
||||
#endif // ADBLOCKICON_H
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "miscellaneous/application.h"
|
||||
#include "miscellaneous/settings.h"
|
||||
#include "network-web/silentnetworkaccessmanager.h"
|
||||
#include "gui/formmain.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QTextStream>
|
||||
@ -445,8 +446,14 @@ AdBlockSubscription* AdBlockManager::subscriptionByName(const QString &name) con
|
||||
return 0;
|
||||
}
|
||||
|
||||
AdBlockDialog* AdBlockManager::showDialog()
|
||||
{
|
||||
AdBlockDialog *AdBlockManager::showDialog() {
|
||||
QPointer<AdBlockDialog> form_pointer = new AdBlockDialog();
|
||||
form_pointer.data()->show();
|
||||
form_pointer.data()->raise();
|
||||
form_pointer.data()->activateWindow();
|
||||
form_pointer.data()->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
return form_pointer.data();
|
||||
/*
|
||||
if (!m_adBlockDialog) {
|
||||
m_adBlockDialog = new AdBlockDialog;
|
||||
}
|
||||
@ -455,7 +462,7 @@ AdBlockDialog* AdBlockManager::showDialog()
|
||||
m_adBlockDialog.data()->raise();
|
||||
m_adBlockDialog.data()->activateWindow();
|
||||
|
||||
return m_adBlockDialog.data();
|
||||
return m_adBlockDialog.data();*/
|
||||
}
|
||||
|
||||
void AdBlockManager::showRule()
|
||||
|
@ -70,68 +70,67 @@ class AdBlockSubscription;
|
||||
|
||||
class AdBlockManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AdBlockManager(QObject* parent = 0);
|
||||
~AdBlockManager();
|
||||
public:
|
||||
AdBlockManager(QObject* parent = 0);
|
||||
~AdBlockManager();
|
||||
|
||||
static AdBlockManager* instance();
|
||||
static AdBlockManager* instance();
|
||||
|
||||
static QString filterCharsFromFilename(const QString &name);
|
||||
static QString filterCharsFromFilename(const QString &name);
|
||||
|
||||
static QString ensureUniqueFilename(const QString &name, const QString &appendFormat = QString("(%1)"));
|
||||
static QString ensureUniqueFilename(const QString &name, const QString &appendFormat = QString("(%1)"));
|
||||
|
||||
void load();
|
||||
void save();
|
||||
void load();
|
||||
void save();
|
||||
|
||||
bool isEnabled() const;
|
||||
bool canRunOnScheme(const QString &scheme) const;
|
||||
bool isEnabled() const;
|
||||
bool canRunOnScheme(const QString &scheme) const;
|
||||
|
||||
bool useLimitedEasyList() const;
|
||||
void setUseLimitedEasyList(bool useLimited);
|
||||
bool useLimitedEasyList() const;
|
||||
void setUseLimitedEasyList(bool useLimited);
|
||||
|
||||
QString elementHidingRules() const;
|
||||
QString elementHidingRulesForDomain(const QUrl &url) const;
|
||||
QString elementHidingRules() const;
|
||||
QString elementHidingRulesForDomain(const QUrl &url) const;
|
||||
|
||||
AdBlockSubscription* subscriptionByName(const QString &name) const;
|
||||
QList<AdBlockSubscription*> subscriptions() const;
|
||||
AdBlockSubscription* subscriptionByName(const QString &name) const;
|
||||
QList<AdBlockSubscription*> subscriptions() const;
|
||||
|
||||
QNetworkReply* block(const QNetworkRequest &request);
|
||||
QNetworkReply* block(const QNetworkRequest &request);
|
||||
|
||||
QStringList disabledRules() const;
|
||||
void addDisabledRule(const QString &filter);
|
||||
void removeDisabledRule(const QString &filter);
|
||||
QStringList disabledRules() const;
|
||||
void addDisabledRule(const QString &filter);
|
||||
void removeDisabledRule(const QString &filter);
|
||||
|
||||
AdBlockSubscription* addSubscription(const QString &title, const QString &url);
|
||||
bool removeSubscription(AdBlockSubscription* subscription);
|
||||
AdBlockSubscription* addSubscription(const QString &title, const QString &url);
|
||||
bool removeSubscription(AdBlockSubscription* subscription);
|
||||
|
||||
AdBlockCustomList* customList() const;
|
||||
AdBlockCustomList* customList() const;
|
||||
|
||||
signals:
|
||||
void enabledChanged(bool enabled);
|
||||
signals:
|
||||
void enabledChanged(bool enabled);
|
||||
|
||||
public slots:
|
||||
void setEnabled(bool enabled);
|
||||
void showRule();
|
||||
public slots:
|
||||
void setEnabled(bool enabled);
|
||||
void showRule();
|
||||
void updateAllSubscriptions();
|
||||
|
||||
void updateAllSubscriptions();
|
||||
AdBlockDialog *showDialog();
|
||||
|
||||
AdBlockDialog* showDialog();
|
||||
private:
|
||||
inline bool canBeBlocked(const QUrl &url) const;
|
||||
|
||||
private:
|
||||
inline bool canBeBlocked(const QUrl &url) const;
|
||||
bool m_loaded;
|
||||
bool m_enabled;
|
||||
bool m_useLimitedEasyList;
|
||||
|
||||
bool m_loaded;
|
||||
bool m_enabled;
|
||||
bool m_useLimitedEasyList;
|
||||
QList<AdBlockSubscription*> m_subscriptions;
|
||||
static AdBlockManager* s_adBlockManager;
|
||||
AdBlockMatcher* m_matcher;
|
||||
QStringList m_disabledRules;
|
||||
|
||||
QList<AdBlockSubscription*> m_subscriptions;
|
||||
static AdBlockManager* s_adBlockManager;
|
||||
AdBlockMatcher* m_matcher;
|
||||
QStringList m_disabledRules;
|
||||
|
||||
QPointer<AdBlockDialog> m_adBlockDialog;
|
||||
QPointer<AdBlockDialog> m_adBlockDialog;
|
||||
};
|
||||
|
||||
#endif // ADBLOCKMANAGER_H
|
||||
|
@ -327,18 +327,12 @@ AdBlockSubscription::~AdBlockSubscription()
|
||||
|
||||
// AdBlockCustomList
|
||||
|
||||
AdBlockCustomList::AdBlockCustomList(QObject* parent)
|
||||
: AdBlockSubscription(tr("Custom Rules"), parent)
|
||||
{
|
||||
AdBlockCustomList::AdBlockCustomList(QObject* parent) : AdBlockSubscription(tr("Custom rules"), parent) {
|
||||
setTitle(tr("Custom rules"));
|
||||
// TODO
|
||||
setFilePath(qApp->homeFolderPath() + "/adblock/customlist.txt");
|
||||
}
|
||||
|
||||
void AdBlockCustomList::retranslateStrings()
|
||||
{
|
||||
setTitle(tr("Custom Rules"));
|
||||
}
|
||||
|
||||
void AdBlockCustomList::loadSubscription(const QStringList &disabledRules)
|
||||
{
|
||||
// DuckDuckGo ad whitelist rules
|
||||
|
@ -77,82 +77,80 @@ class FollowRedirectReply;
|
||||
|
||||
class AdBlockSubscription : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AdBlockSubscription(const QString &title, QObject* parent = 0);
|
||||
~AdBlockSubscription();
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AdBlockSubscription(const QString &title, QObject* parent = 0);
|
||||
~AdBlockSubscription();
|
||||
|
||||
QString title() const;
|
||||
void setTitle(const QString &title);
|
||||
QString title() const;
|
||||
void setTitle(const QString &title);
|
||||
|
||||
QString filePath() const;
|
||||
void setFilePath(const QString &path);
|
||||
QString filePath() const;
|
||||
void setFilePath(const QString &path);
|
||||
|
||||
QUrl url() const;
|
||||
void setUrl(const QUrl &url);
|
||||
QUrl url() const;
|
||||
void setUrl(const QUrl &url);
|
||||
|
||||
virtual void loadSubscription(const QStringList &disabledRules);
|
||||
virtual void saveSubscription();
|
||||
virtual void loadSubscription(const QStringList &disabledRules);
|
||||
virtual void saveSubscription();
|
||||
|
||||
const AdBlockRule* rule(int offset) const;
|
||||
QVector<AdBlockRule*> allRules() const;
|
||||
const AdBlockRule* rule(int offset) const;
|
||||
QVector<AdBlockRule*> allRules() const;
|
||||
|
||||
const AdBlockRule* enableRule(int offset);
|
||||
const AdBlockRule* disableRule(int offset);
|
||||
const AdBlockRule* enableRule(int offset);
|
||||
const AdBlockRule* disableRule(int offset);
|
||||
|
||||
virtual bool canEditRules() const;
|
||||
virtual bool canBeRemoved() const;
|
||||
virtual bool canEditRules() const;
|
||||
virtual bool canBeRemoved() const;
|
||||
|
||||
virtual int addRule(AdBlockRule* rule);
|
||||
virtual bool removeRule(int offset);
|
||||
virtual const AdBlockRule* replaceRule(AdBlockRule* rule, int offset);
|
||||
virtual int addRule(AdBlockRule* rule);
|
||||
virtual bool removeRule(int offset);
|
||||
virtual const AdBlockRule* replaceRule(AdBlockRule* rule, int offset);
|
||||
|
||||
public slots:
|
||||
void updateSubscription();
|
||||
public slots:
|
||||
void updateSubscription();
|
||||
|
||||
signals:
|
||||
void subscriptionChanged();
|
||||
void subscriptionUpdated();
|
||||
void subscriptionError(const QString &message);
|
||||
signals:
|
||||
void subscriptionChanged();
|
||||
void subscriptionUpdated();
|
||||
void subscriptionError(const QString &message);
|
||||
|
||||
protected slots:
|
||||
void subscriptionDownloaded();
|
||||
protected slots:
|
||||
void subscriptionDownloaded();
|
||||
|
||||
protected:
|
||||
virtual bool saveDownloadedData(const QByteArray &data);
|
||||
protected:
|
||||
virtual bool saveDownloadedData(const QByteArray &data);
|
||||
|
||||
FollowRedirectReply* m_reply;
|
||||
FollowRedirectReply* m_reply;
|
||||
|
||||
QVector<AdBlockRule*> m_rules;
|
||||
QVector<AdBlockRule*> m_rules;
|
||||
|
||||
private:
|
||||
QString m_title;
|
||||
QString m_filePath;
|
||||
private:
|
||||
QString m_title;
|
||||
QString m_filePath;
|
||||
|
||||
QUrl m_url;
|
||||
bool m_updated;
|
||||
QUrl m_url;
|
||||
bool m_updated;
|
||||
};
|
||||
|
||||
class AdBlockCustomList : public AdBlockSubscription
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AdBlockCustomList(QObject* parent = 0);
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AdBlockCustomList(QObject* parent = 0);
|
||||
|
||||
void retranslateStrings();
|
||||
void loadSubscription(const QStringList &disabledRules);
|
||||
void saveSubscription();
|
||||
|
||||
void loadSubscription(const QStringList &disabledRules);
|
||||
void saveSubscription();
|
||||
bool canEditRules() const;
|
||||
bool canBeRemoved() const;
|
||||
|
||||
bool canEditRules() const;
|
||||
bool canBeRemoved() const;
|
||||
bool containsFilter(const QString &filter) const;
|
||||
bool removeFilter(const QString &filter);
|
||||
|
||||
bool containsFilter(const QString &filter) const;
|
||||
bool removeFilter(const QString &filter);
|
||||
|
||||
int addRule(AdBlockRule* rule);
|
||||
bool removeRule(int offset);
|
||||
const AdBlockRule* replaceRule(AdBlockRule* rule, int offset);
|
||||
int addRule(AdBlockRule* rule);
|
||||
bool removeRule(int offset);
|
||||
const AdBlockRule* replaceRule(AdBlockRule* rule, int offset);
|
||||
};
|
||||
|
||||
#endif // ADBLOCKSUBSCRIPTION_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user