More changes for Adblock.
This commit is contained in:
parent
4e168373b6
commit
fccf25e1f6
5 changed files with 19 additions and 24 deletions
|
@ -93,7 +93,7 @@
|
||||||
#define PLACEHOLDER_UNREAD_COUNTS "%unread"
|
#define PLACEHOLDER_UNREAD_COUNTS "%unread"
|
||||||
#define PLACEHOLDER_ALL_COUNTS "%all"
|
#define PLACEHOLDER_ALL_COUNTS "%all"
|
||||||
|
|
||||||
#define ADBLOCK_CUSTOM_LIST_FILENAME "customlist.txt"
|
#define ADBLOCK_CUSTOM_LIST_FILENAME "custom_rules.txt"
|
||||||
#define ADBLOCK_BASE_DIRECTORY_NAME "data/adblock"
|
#define ADBLOCK_BASE_DIRECTORY_NAME "data/adblock"
|
||||||
#define ADBLOCK_FILTERS_HELP "https://adblockplus.org/en/filters"
|
#define ADBLOCK_FILTERS_HELP "https://adblockplus.org/en/filters"
|
||||||
#define ADBLOCK_EASYLIST_URL "https://easylist-downloads.adblockplus.org/easylist.txt"
|
#define ADBLOCK_EASYLIST_URL "https://easylist-downloads.adblockplus.org/easylist.txt"
|
||||||
|
|
|
@ -60,16 +60,16 @@ AdBlockAddSubscriptionDialog::AdBlockAddSubscriptionDialog(QWidget *parent)
|
||||||
<< Subscription("ABPindo (Indonesian)", "https://indonesianadblockrules.googlecode.com/hg/subscriptions/abpindo.txt")
|
<< Subscription("ABPindo (Indonesian)", "https://indonesianadblockrules.googlecode.com/hg/subscriptions/abpindo.txt")
|
||||||
<< Subscription("ChinaList (Chinese)", "http://adblock-chinalist.googlecode.com/svn/trunk/adblock.txt")
|
<< Subscription("ChinaList (Chinese)", "http://adblock-chinalist.googlecode.com/svn/trunk/adblock.txt")
|
||||||
<< Subscription("Malware Domains list", "https://easylist-downloads.adblockplus.org/malwaredomains_full.txt") <<
|
<< Subscription("Malware Domains list", "https://easylist-downloads.adblockplus.org/malwaredomains_full.txt") <<
|
||||||
Subscription(tr("Other list"), QString());
|
Subscription(tr("Another subscription"), QString());
|
||||||
|
|
||||||
foreach (const Subscription &subscription, m_knownSubscriptions) {
|
foreach (const Subscription &subscription, m_knownSubscriptions) {
|
||||||
m_ui->m_cmbPresets->addItem(subscription.m_title);
|
m_ui->m_cmbPresets->addItem(subscription.m_title);
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(m_ui->m_cmbPresets, SIGNAL(currentIndexChanged(int)), this, SLOT(indexChanged(int)));
|
connect(m_ui->m_cmbPresets, SIGNAL(currentIndexChanged(int)), this, SLOT(onSubscriptionPresetChanged(int)));
|
||||||
connect(m_ui->m_txtTitle->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(checkInputs()));
|
connect(m_ui->m_txtTitle->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(checkInputs()));
|
||||||
connect(m_ui->m_txtUrl->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(checkInputs()));
|
connect(m_ui->m_txtUrl->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(checkInputs()));
|
||||||
indexChanged(0);
|
onSubscriptionPresetChanged(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AdBlockAddSubscriptionDialog::title() const {
|
QString AdBlockAddSubscriptionDialog::title() const {
|
||||||
|
@ -80,7 +80,7 @@ QString AdBlockAddSubscriptionDialog::url() const {
|
||||||
return m_ui->m_txtUrl->lineEdit()->text();
|
return m_ui->m_txtUrl->lineEdit()->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockAddSubscriptionDialog::indexChanged(int index) {
|
void AdBlockAddSubscriptionDialog::onSubscriptionPresetChanged(int index) {
|
||||||
const Subscription subscription = m_knownSubscriptions.at(index);
|
const Subscription subscription = m_knownSubscriptions.at(index);
|
||||||
|
|
||||||
// "Other" entry.
|
// "Other" entry.
|
||||||
|
@ -89,14 +89,7 @@ void AdBlockAddSubscriptionDialog::indexChanged(int index) {
|
||||||
m_ui->m_txtUrl->lineEdit()->clear();
|
m_ui->m_txtUrl->lineEdit()->clear();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = subscription.m_title.indexOf(QLatin1Char('('));
|
m_ui->m_txtTitle->lineEdit()->setText( subscription.m_title);
|
||||||
QString title = subscription.m_title;
|
|
||||||
|
|
||||||
if (pos > 0) {
|
|
||||||
title = title.left(pos).trimmed();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_ui->m_txtTitle->lineEdit()->setText(title);
|
|
||||||
m_ui->m_txtTitle->lineEdit()->setCursorPosition(0);
|
m_ui->m_txtTitle->lineEdit()->setCursorPosition(0);
|
||||||
m_ui->m_txtUrl->lineEdit()->setText(subscription.m_url);
|
m_ui->m_txtUrl->lineEdit()->setText(subscription.m_url);
|
||||||
m_ui->m_txtUrl->lineEdit()->setCursorPosition(0);
|
m_ui->m_txtUrl->lineEdit()->setCursorPosition(0);
|
||||||
|
|
|
@ -43,7 +43,7 @@ class AdBlockAddSubscriptionDialog : public QDialog {
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
// Index of selected list changed.
|
// Index of selected list changed.
|
||||||
void indexChanged(int index);
|
void onSubscriptionPresetChanged(int index);
|
||||||
void checkInputs();
|
void checkInputs();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -55,8 +55,6 @@ AdBlockDialog::AdBlockDialog(QWidget* parent) : QDialog(parent), m_ui(new Ui::Ad
|
||||||
|
|
||||||
// Load the contents.
|
// Load the contents.
|
||||||
load();
|
load();
|
||||||
|
|
||||||
m_ui->m_buttonBox->setFocus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AdBlockDialog::~AdBlockDialog() {
|
AdBlockDialog::~AdBlockDialog() {
|
||||||
|
@ -88,7 +86,7 @@ void AdBlockDialog::createConnections() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockDialog::showRule(const AdBlockRule *rule) const {
|
void AdBlockDialog::showRule(const AdBlockRule *rule) const {
|
||||||
AdBlockSubscription *subscription = rule->subscription();
|
const AdBlockSubscription *subscription = rule->subscription();
|
||||||
|
|
||||||
if (subscription == NULL) {
|
if (subscription == NULL) {
|
||||||
return;
|
return;
|
||||||
|
@ -115,11 +113,11 @@ void AdBlockDialog::removeRule() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockDialog::addSubscription() {
|
void AdBlockDialog::addSubscription() {
|
||||||
AdBlockAddSubscriptionDialog dialog(this);
|
QPointer<AdBlockAddSubscriptionDialog> dialog = new AdBlockAddSubscriptionDialog(this);
|
||||||
|
|
||||||
if (dialog.exec() == QDialog::Accepted) {
|
if (dialog.data()->exec() == QDialog::Accepted) {
|
||||||
QString title = dialog.title();
|
QString title = dialog.data()->title();
|
||||||
QString url = dialog.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, m_ui->m_tabs);
|
||||||
|
@ -128,6 +126,8 @@ void AdBlockDialog::addSubscription() {
|
||||||
m_ui->m_tabs->setCurrentIndex(index);
|
m_ui->m_tabs->setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete dialog.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockDialog::removeSubscription() {
|
void AdBlockDialog::removeSubscription() {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>535</width>
|
<width>535</width>
|
||||||
<height>408</height>
|
<height>466</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -32,7 +32,9 @@
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Note that Adblock may significantly slow this application down once you activate huge subscriptions. Too many rules is not good for performance. Also, make sure you restart application after you disable Adblock if you wish to have low memory footprint. Adblock is known to use much system memory.</string>
|
<string>Note that Adblock may significantly slow this application down once you activate huge subscriptions. Too many rules is not good for performance. Also, make sure you restart application after you disable Adblock if you wish to have low memory footprint. Adblock is known to use much system memory.
|
||||||
|
|
||||||
|
Also note that some resources are cached by internal web browser. Thus, after changing some rules or subscriptions they will fully apply only for newly opened web browser tabs.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="wordWrap">
|
<property name="wordWrap">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
|
Loading…
Add table
Reference in a new issue