mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
Added EasyPrivacy into known third party subscriptions
- also fixed crashes when not having adblock enabled on startup see #329
This commit is contained in:
parent
699f309ffd
commit
e06517bdd4
@ -38,6 +38,7 @@ AdBlockAddSubscriptionDialog::AdBlockAddSubscriptionDialog(QWidget* parent)
|
||||
<< Subscription("PLgeneral (Polish)", "http://www.niecko.pl/adblock/adblock.txt")
|
||||
<< Subscription("Schacks Adblock Plus liste (Danish)", "http://adblock.schack.dk/block.txt")
|
||||
<< Subscription("Xfiles (Italian)", "http://mozilla.gfsolone.com/filtri.txt")
|
||||
<< Subscription("EasyPrivacy (English)", "http://easylist-downloads.adblockplus.org/easyprivacy.txt")
|
||||
<< Subscription("Antisocial (English)", "http://adversity.googlecode.com/hg/Antisocial.txt");
|
||||
|
||||
foreach(const Subscription & subscription, m_knownSubscriptions) {
|
||||
@ -62,7 +63,14 @@ void AdBlockAddSubscriptionDialog::indexChanged(int index)
|
||||
{
|
||||
const Subscription &subscription = m_knownSubscriptions.at(index);
|
||||
|
||||
ui->title->setText(subscription.title);
|
||||
int pos = subscription.title.indexOf('(');
|
||||
QString title = subscription.title;
|
||||
|
||||
if (pos > 0) {
|
||||
title = title.left(pos).trimmed();
|
||||
}
|
||||
|
||||
ui->title->setText(title);
|
||||
ui->title->setCursorPosition(0);
|
||||
|
||||
ui->url->setText(subscription.url);
|
||||
|
@ -31,6 +31,7 @@ AdBlockDialog::AdBlockDialog(QWidget* parent)
|
||||
, m_manager(AdBlockManager::instance())
|
||||
, m_currentTreeWidget(0)
|
||||
, m_currentSubscription(0)
|
||||
, m_loaded(false)
|
||||
{
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
setupUi(this);
|
||||
@ -50,14 +51,11 @@ AdBlockDialog::AdBlockDialog(QWidget* parent)
|
||||
buttonMenu->setMenu(menu);
|
||||
connect(menu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowMenu()));
|
||||
|
||||
connect(adblockCheckBox, SIGNAL(toggled(bool)), m_manager, SLOT(setEnabled(bool)));
|
||||
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)));
|
||||
|
||||
foreach(AdBlockSubscription * subscription, m_manager->subscriptions()) {
|
||||
AdBlockTreeWidget* tree = new AdBlockTreeWidget(subscription, tabWidget);
|
||||
tabWidget->addTab(tree, subscription->title());
|
||||
}
|
||||
load();
|
||||
|
||||
buttonBox->setFocus();
|
||||
}
|
||||
@ -125,13 +123,24 @@ void AdBlockDialog::currentChanged(int index)
|
||||
|
||||
void AdBlockDialog::filterString(const QString &string)
|
||||
{
|
||||
m_currentTreeWidget->filterString(string);
|
||||
if (m_currentTreeWidget && adblockCheckBox->isChecked()) {
|
||||
m_currentTreeWidget->filterString(string);
|
||||
}
|
||||
}
|
||||
|
||||
void AdBlockDialog::enableAdBlock(bool state)
|
||||
{
|
||||
m_manager->setEnabled(state);
|
||||
|
||||
if (state) {
|
||||
load();
|
||||
}
|
||||
}
|
||||
|
||||
void AdBlockDialog::aboutToShowMenu()
|
||||
{
|
||||
bool subscriptionEditable = m_currentSubscription->canEditRules();
|
||||
bool subscriptionRemovable = m_currentSubscription->canBeRemoved();
|
||||
bool subscriptionEditable = m_currentSubscription && m_currentSubscription->canEditRules();
|
||||
bool subscriptionRemovable = m_currentSubscription && m_currentSubscription->canBeRemoved();
|
||||
|
||||
m_actionAddRule->setEnabled(subscriptionEditable);
|
||||
m_actionRemoveRule->setEnabled(subscriptionEditable);
|
||||
@ -142,3 +151,17 @@ void AdBlockDialog::learnAboutRules()
|
||||
{
|
||||
mApp->addNewTab(QUrl("http://adblockplus.org/en/filters"));
|
||||
}
|
||||
|
||||
void AdBlockDialog::load()
|
||||
{
|
||||
if (m_loaded || !adblockCheckBox->isChecked()) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach(AdBlockSubscription * subscription, m_manager->subscriptions()) {
|
||||
AdBlockTreeWidget* tree = new AdBlockTreeWidget(subscription, tabWidget);
|
||||
tabWidget->addTab(tree, subscription->title());
|
||||
}
|
||||
|
||||
m_loaded = true;
|
||||
}
|
||||
|
@ -46,11 +46,14 @@ private slots:
|
||||
|
||||
void currentChanged(int index);
|
||||
void filterString(const QString &string);
|
||||
void enableAdBlock(bool state);
|
||||
|
||||
void aboutToShowMenu();
|
||||
void learnAboutRules();
|
||||
|
||||
private:
|
||||
void load();
|
||||
|
||||
AdBlockManager* m_manager;
|
||||
AdBlockTreeWidget* m_currentTreeWidget;
|
||||
AdBlockSubscription* m_currentSubscription;
|
||||
@ -59,6 +62,8 @@ private:
|
||||
QAction* m_actionRemoveRule;
|
||||
QAction* m_actionAddSubscription;
|
||||
QAction* m_actionRemoveSubscription;
|
||||
|
||||
bool m_loaded;
|
||||
};
|
||||
|
||||
#endif // ADBLOCKDIALOG_H
|
||||
|
@ -53,12 +53,19 @@ AdBlockManager* AdBlockManager::instance()
|
||||
|
||||
void AdBlockManager::setEnabled(bool enabled)
|
||||
{
|
||||
if (isEnabled() == enabled) {
|
||||
if (m_enabled == enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_enabled = enabled;
|
||||
mApp->sendMessages(Qz::AM_SetAdBlockIconEnabled, enabled);
|
||||
|
||||
Settings settings;
|
||||
settings.beginGroup("AdBlock");
|
||||
settings.setValue("enabled", m_enabled);
|
||||
settings.endGroup();
|
||||
|
||||
load();
|
||||
}
|
||||
|
||||
QList<AdBlockSubscription*> AdBlockManager::subscriptions() const
|
||||
@ -157,7 +164,7 @@ bool AdBlockManager::removeSubscription(AdBlockSubscription* subscription)
|
||||
|
||||
void AdBlockManager::load()
|
||||
{
|
||||
if (!m_enabled || m_loaded) {
|
||||
if (m_loaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user