diff --git a/resources/text/CHANGELOG b/resources/text/CHANGELOG
index 12e95862a..86539bc2b 100644
--- a/resources/text/CHANGELOG
+++ b/resources/text/CHANGELOG
@@ -23,6 +23,7 @@
Fixed:
+ - Fixed crash when adding Adblock subscription.
- Custom external web browser now correctly opens URLs on some operating systems. This seemed to primarily affect Linux distributions. (bug #123)
- Categories are now not expanded when selected using "Go to next/previous item" in feeds list. (bug #122)
- Added action to expand/collapse currently selected item in feeds list. (enhancement #121)
diff --git a/src/network-web/adblock/adblockdialog.cpp b/src/network-web/adblock/adblockdialog.cpp
index 6a99c3586..1d527c14e 100755
--- a/src/network-web/adblock/adblockdialog.cpp
+++ b/src/network-web/adblock/adblockdialog.cpp
@@ -120,7 +120,10 @@ void AdBlockDialog::addSubscription() {
QString url = dialog.data()->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());
m_ui->m_tabs->setCurrentIndex(index);
@@ -180,17 +183,9 @@ void AdBlockDialog::learnAboutRules() {
}
void AdBlockDialog::loadSubscriptions() {
- setEnabled(false);
-
for (int i = 0; i < m_ui->m_tabs->count(); ++i) {
- AdBlockTreeWidget *tree = qobject_cast(m_ui->m_tabs->widget(i));
-
- tree->setUpdatesEnabled(false);
- tree->refresh();
- tree->setUpdatesEnabled(true);
+ qobject_cast(m_ui->m_tabs->widget(i))->refresh();
}
-
- setEnabled(true);
}
void AdBlockDialog::load() {
@@ -199,7 +194,10 @@ void AdBlockDialog::load() {
}
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());
}
diff --git a/src/network-web/adblock/adblockicon.cpp b/src/network-web/adblock/adblockicon.cpp
index 8185b3ae4..cb43bd47a 100755
--- a/src/network-web/adblock/adblockicon.cpp
+++ b/src/network-web/adblock/adblockicon.cpp
@@ -30,48 +30,15 @@
#include
#include
-#include
#include
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(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 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() {
if (m_menuAction == NULL) {
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) {
if (enabled) {
setToolTip(tr("Adblock - up and running"));
@@ -232,7 +175,7 @@ void AdBlockIcon::setEnabled(bool enabled) {
void AdBlockIcon::mouseReleaseEvent(QMouseEvent *event) {
if (event->button() == Qt::LeftButton) {
- emit clicked(event->globalPos());
+ emit clicked(event->globalPos());
}
else {
QToolButton::mouseReleaseEvent(event);
diff --git a/src/network-web/adblock/adblockicon.h b/src/network-web/adblock/adblockicon.h
index 6927e2d56..5622cec48 100755
--- a/src/network-web/adblock/adblockicon.h
+++ b/src/network-web/adblock/adblockicon.h
@@ -34,7 +34,6 @@ class AdBlockIcon : public PlainToolButton {
explicit AdBlockIcon(QWidget *window, QWidget *parent = 0);
virtual ~AdBlockIcon();
- void popupBlocked(const QString &rule_string, const QUrl &url);
QAction *menuAction();
public slots:
@@ -45,8 +44,6 @@ class AdBlockIcon : public PlainToolButton {
private slots:
void showMenu(const QPoint &pos);
void toggleCustomFilter();
- void animateIcon();
- void stopAnimation();
protected:
void mouseReleaseEvent(QMouseEvent *event);
@@ -57,11 +54,7 @@ class AdBlockIcon : public PlainToolButton {
private:
QWidget *m_window;
QAction *m_menuAction;
-
QVector > m_blockedPopups;
- QTimer *m_flashTimer;
-
- int m_timerTicks;
bool m_enabled;
};
diff --git a/src/network-web/adblock/adblocktreewidget.cpp b/src/network-web/adblock/adblocktreewidget.cpp
index e2ca57f5e..89981c8a1 100755
--- a/src/network-web/adblock/adblocktreewidget.cpp
+++ b/src/network-web/adblock/adblocktreewidget.cpp
@@ -226,6 +226,10 @@ void AdBlockTreeWidget::keyPressEvent(QKeyEvent* event) {
}
void AdBlockTreeWidget::refresh() {
+ // Disable GUI editing for parent.
+ emit refreshStatusChanged(true);
+ setUpdatesEnabled(false);
+
m_itemChangingBlock = true;
clear();
@@ -260,6 +264,8 @@ void AdBlockTreeWidget::refresh() {
showRule(0);
m_itemChangingBlock = false;
+ setUpdatesEnabled(true);
+ emit refreshStatusChanged(false);
}
void AdBlockTreeWidget::clear() {
diff --git a/src/network-web/adblock/adblocktreewidget.h b/src/network-web/adblock/adblocktreewidget.h
index 3c927287b..0e9ff6a33 100755
--- a/src/network-web/adblock/adblocktreewidget.h
+++ b/src/network-web/adblock/adblocktreewidget.h
@@ -53,6 +53,9 @@ class AdBlockTreeWidget : public QTreeWidget {
protected:
void keyPressEvent(QKeyEvent *event);
+ signals:
+ void refreshStatusChanged(bool started);
+
private:
void adjustItemFeatures(QTreeWidgetItem *item, const AdBlockRule *rule);
void addTopLevelItem(QTreeWidgetItem *item);