mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-31 01:24:49 +01:00
Fixed Adblock crash.
This commit is contained in:
parent
45ddbc5509
commit
6e898eb775
@ -23,6 +23,7 @@
|
||||
|
||||
Fixed:
|
||||
<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>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>
|
||||
|
@ -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<AdBlockTreeWidget*>(m_ui->m_tabs->widget(i));
|
||||
|
||||
tree->setUpdatesEnabled(false);
|
||||
tree->refresh();
|
||||
tree->setUpdatesEnabled(true);
|
||||
qobject_cast<AdBlockTreeWidget*>(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());
|
||||
}
|
||||
|
||||
|
@ -30,48 +30,15 @@
|
||||
|
||||
#include <QMenu>
|
||||
#include <QMouseEvent>
|
||||
#include <QTimer>
|
||||
#include <QWebFrame>
|
||||
|
||||
|
||||
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<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() {
|
||||
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);
|
||||
|
@ -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<QPair<AdBlockRule*,QUrl> > m_blockedPopups;
|
||||
QTimer *m_flashTimer;
|
||||
|
||||
int m_timerTicks;
|
||||
bool m_enabled;
|
||||
};
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user