Fixed Adblock crash.
This commit is contained in:
parent
45ddbc5509
commit
6e898eb775
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
Fixed:
|
Fixed:
|
||||||
<ul>
|
<ul>
|
||||||
|
<li>Fixed crash when adding Adblock subscription.</li>
|
||||||
<li>Custom external web browser now correctly opens URLs on some operating systems. This seemed to primarily affect Linux distributions. (bug #123)</li>
|
<li>Custom external web browser now correctly opens URLs on some operating systems. This seemed to primarily affect Linux distributions. (bug #123)</li>
|
||||||
<li>Categories are now not expanded when selected using "Go to next/previous item" in feeds list. (bug #122)</li>
|
<li>Categories are now not expanded when selected using "Go to next/previous item" in feeds list. (bug #122)</li>
|
||||||
<li>Added action to expand/collapse currently selected item in feeds list. (enhancement #121)</li>
|
<li>Added action to expand/collapse currently selected item in feeds list. (enhancement #121)</li>
|
||||||
|
@ -120,7 +120,10 @@ void AdBlockDialog::addSubscription() {
|
|||||||
QString url = dialog.data()->url();
|
QString url = dialog.data()->url();
|
||||||
|
|
||||||
if (AdBlockSubscription *subscription = m_manager->addSubscription(title, url)) {
|
if (AdBlockSubscription *subscription = m_manager->addSubscription(title, url)) {
|
||||||
AdBlockTreeWidget *tree = new AdBlockTreeWidget(subscription, m_ui->m_tabs);
|
AdBlockTreeWidget *tree = new AdBlockTreeWidget(subscription, this);
|
||||||
|
|
||||||
|
connect(tree, SIGNAL(refreshStatusChanged(bool)), this, SLOT(setDisabled(bool)));
|
||||||
|
|
||||||
int index = m_ui->m_tabs->insertTab(m_ui->m_tabs->count() - 1, tree, subscription->title());
|
int index = m_ui->m_tabs->insertTab(m_ui->m_tabs->count() - 1, tree, subscription->title());
|
||||||
|
|
||||||
m_ui->m_tabs->setCurrentIndex(index);
|
m_ui->m_tabs->setCurrentIndex(index);
|
||||||
@ -180,17 +183,9 @@ void AdBlockDialog::learnAboutRules() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockDialog::loadSubscriptions() {
|
void AdBlockDialog::loadSubscriptions() {
|
||||||
setEnabled(false);
|
|
||||||
|
|
||||||
for (int i = 0; i < m_ui->m_tabs->count(); ++i) {
|
for (int i = 0; i < m_ui->m_tabs->count(); ++i) {
|
||||||
AdBlockTreeWidget *tree = qobject_cast<AdBlockTreeWidget*>(m_ui->m_tabs->widget(i));
|
qobject_cast<AdBlockTreeWidget*>(m_ui->m_tabs->widget(i))->refresh();
|
||||||
|
|
||||||
tree->setUpdatesEnabled(false);
|
|
||||||
tree->refresh();
|
|
||||||
tree->setUpdatesEnabled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setEnabled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockDialog::load() {
|
void AdBlockDialog::load() {
|
||||||
@ -199,7 +194,10 @@ void AdBlockDialog::load() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach (AdBlockSubscription *subscription, m_manager->subscriptions()) {
|
foreach (AdBlockSubscription *subscription, m_manager->subscriptions()) {
|
||||||
AdBlockTreeWidget *tree = new AdBlockTreeWidget(subscription, m_ui->m_tabs);
|
AdBlockTreeWidget *tree = new AdBlockTreeWidget(subscription, this);
|
||||||
|
|
||||||
|
connect(tree, SIGNAL(refreshStatusChanged(bool)), this, SLOT(setDisabled(bool)));
|
||||||
|
|
||||||
m_ui->m_tabs->addTab(tree, subscription->title());
|
m_ui->m_tabs->addTab(tree, subscription->title());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,48 +30,15 @@
|
|||||||
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QTimer>
|
|
||||||
#include <QWebFrame>
|
#include <QWebFrame>
|
||||||
|
|
||||||
|
|
||||||
AdBlockIcon::AdBlockIcon(QWidget *window, QWidget *parent)
|
AdBlockIcon::AdBlockIcon(QWidget *window, QWidget *parent)
|
||||||
: PlainToolButton(parent), m_window(window), m_menuAction(NULL), m_flashTimer(NULL), m_timerTicks(0), m_enabled(false) {
|
: PlainToolButton(parent), m_window(window), m_menuAction(NULL), m_enabled(false) {
|
||||||
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 &rule_string, const QUrl &url) {
|
|
||||||
int index = rule_string.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);
|
|
||||||
|
|
||||||
if (filter.isEmpty() || !subscription) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QPair<AdBlockRule*,QUrl> pair;
|
|
||||||
pair.first = new AdBlockRule(filter, subscription);
|
|
||||||
pair.second = url;
|
|
||||||
m_blockedPopups.append(pair);
|
|
||||||
|
|
||||||
//!** FIXME
|
|
||||||
// mApp->desktopNotifications()->showNotification(QPixmap(":images/images/adblock_big.png"), tr("Blocked popup window"), tr("AdBlock blocked unwanted popup window."));
|
|
||||||
|
|
||||||
if (m_flashTimer == NULL) {
|
|
||||||
m_flashTimer = new QTimer(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_flashTimer->isActive()) {
|
|
||||||
stopAnimation();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_flashTimer->setInterval(500);
|
|
||||||
m_flashTimer->start();
|
|
||||||
|
|
||||||
connect(m_flashTimer, SIGNAL(timeout()), this, SLOT(animateIcon()));
|
|
||||||
}
|
|
||||||
|
|
||||||
QAction *AdBlockIcon::menuAction() {
|
QAction *AdBlockIcon::menuAction() {
|
||||||
if (m_menuAction == NULL) {
|
if (m_menuAction == NULL) {
|
||||||
m_menuAction = new QAction(tr("Adblock"), this);
|
m_menuAction = new QAction(tr("Adblock"), this);
|
||||||
@ -193,30 +160,6 @@ void AdBlockIcon::toggleCustomFilter() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockIcon::animateIcon() {
|
|
||||||
m_timerTicks++;
|
|
||||||
|
|
||||||
if (m_timerTicks > 10) {
|
|
||||||
stopAnimation();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (icon().isNull()) {
|
|
||||||
setIcon(qApp->icons()->fromTheme("web-adblock"));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
setIcon(QIcon());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AdBlockIcon::stopAnimation() {
|
|
||||||
m_timerTicks = 0;
|
|
||||||
m_flashTimer->stop();
|
|
||||||
|
|
||||||
disconnect(m_flashTimer, SIGNAL(timeout()), this, SLOT(animateIcon()));
|
|
||||||
setEnabled(m_enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AdBlockIcon::setEnabled(bool enabled) {
|
void AdBlockIcon::setEnabled(bool enabled) {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
setToolTip(tr("Adblock - up and running"));
|
setToolTip(tr("Adblock - up and running"));
|
||||||
|
@ -34,7 +34,6 @@ class AdBlockIcon : public PlainToolButton {
|
|||||||
explicit AdBlockIcon(QWidget *window, QWidget *parent = 0);
|
explicit AdBlockIcon(QWidget *window, QWidget *parent = 0);
|
||||||
virtual ~AdBlockIcon();
|
virtual ~AdBlockIcon();
|
||||||
|
|
||||||
void popupBlocked(const QString &rule_string, const QUrl &url);
|
|
||||||
QAction *menuAction();
|
QAction *menuAction();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@ -45,8 +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 stopAnimation();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mouseReleaseEvent(QMouseEvent *event);
|
void mouseReleaseEvent(QMouseEvent *event);
|
||||||
@ -57,11 +54,7 @@ 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;
|
|
||||||
|
|
||||||
int m_timerTicks;
|
|
||||||
bool m_enabled;
|
bool m_enabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -226,6 +226,10 @@ void AdBlockTreeWidget::keyPressEvent(QKeyEvent* event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockTreeWidget::refresh() {
|
void AdBlockTreeWidget::refresh() {
|
||||||
|
// Disable GUI editing for parent.
|
||||||
|
emit refreshStatusChanged(true);
|
||||||
|
setUpdatesEnabled(false);
|
||||||
|
|
||||||
m_itemChangingBlock = true;
|
m_itemChangingBlock = true;
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
@ -260,6 +264,8 @@ void AdBlockTreeWidget::refresh() {
|
|||||||
|
|
||||||
showRule(0);
|
showRule(0);
|
||||||
m_itemChangingBlock = false;
|
m_itemChangingBlock = false;
|
||||||
|
setUpdatesEnabled(true);
|
||||||
|
emit refreshStatusChanged(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockTreeWidget::clear() {
|
void AdBlockTreeWidget::clear() {
|
||||||
|
@ -53,6 +53,9 @@ class AdBlockTreeWidget : public QTreeWidget {
|
|||||||
protected:
|
protected:
|
||||||
void keyPressEvent(QKeyEvent *event);
|
void keyPressEvent(QKeyEvent *event);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void refreshStatusChanged(bool started);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void adjustItemFeatures(QTreeWidgetItem *item, const AdBlockRule *rule);
|
void adjustItemFeatures(QTreeWidgetItem *item, const AdBlockRule *rule);
|
||||||
void addTopLevelItem(QTreeWidgetItem *item);
|
void addTopLevelItem(QTreeWidgetItem *item);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user