Enhancements to add sub dialog.
This commit is contained in:
parent
a12d6a4764
commit
f0fadfcdbe
@ -21,73 +21,79 @@
|
||||
#include "definitions/definitions.h"
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QCheckBox>
|
||||
|
||||
|
||||
AdBlockAddSubscriptionDialog::AdBlockAddSubscriptionDialog(QWidget* parent)
|
||||
: QDialog(parent), m_ui(new Ui::AdBlockAddSubscriptionDialog) {
|
||||
m_ui->setupUi(this);
|
||||
m_knownSubscriptions << Subscription(QSL("EasyList (English)"), ADBLOCK_EASYLIST_URL)
|
||||
<< Subscription(QSL("BSI Lista Polska (Polish)"), QSL("http://www.bsi.info.pl/filtrABP.txt"))
|
||||
<< Subscription(QSL("EasyList Czech and Slovak (Czech)"),
|
||||
QSL("https://raw.githubusercontent.com/tomasko126/easylistczechandslovak/master/filters.txt"))
|
||||
<< Subscription(QSL("dutchblock (Dutch)"), QSL("http://groenewoudt.net/dutchblock/list.txt"))
|
||||
<< Subscription(QSL("Filtros Nauscopicos (Spanish)"), QSL("http://abp.mozilla-hispano.org/nauscopio/filtros.txt"))
|
||||
<< Subscription(QSL("IsraelList (Hebrew)"), QSL("http://secure.fanboy.co.nz/israelilist/IsraelList.txt"))
|
||||
<< Subscription(QSL("NLBlock (Dutch)"), QSL("http://www.verzijlbergh.com/adblock/nlblock.txt"))
|
||||
<< Subscription(QSL("Peter Lowe's list (English)"),
|
||||
QSL("http://pgl.yoyo.org/adservers/serverlist.php?hostformat=adblockplus&mimetype=plaintext"))
|
||||
<< Subscription(QSL("PLgeneral (Polish)"), QSL("http://www.niecko.pl/adblock/adblock.txt"))
|
||||
<< Subscription(QSL("Schacks Adblock Plus liste (Danish)"), QSL("http://adblock.schack.dk/block.txt"))
|
||||
<< Subscription(QSL("Xfiles (Italian)"), QSL("http://mozilla.gfsolone.com/filtri.txt"))
|
||||
<< Subscription(QSL("EasyPrivacy (English)"), QSL("http://easylist-downloads.adblockplus.org/easyprivacy.txt"))
|
||||
<< Subscription(QSL("RU Adlist (Russian)"), QSL("https://easylist-downloads.adblockplus.org/advblock.txt"))
|
||||
<< Subscription(QSL("ABPindo (Indonesian)"),
|
||||
QSL("https://raw.githubusercontent.com/heradhis/indonesianadblockrules/master/subscriptions/abpindo.txt"))
|
||||
<< Subscription(QSL("Easylist China (Chinese)"), QSL("https://easylist-downloads.adblockplus.org/easylistchina.txt"))
|
||||
<< Subscription(QSL("Anti-Adblock Killer"),
|
||||
QSL("https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt"))
|
||||
<< Subscription(tr("Other..."), QString());
|
||||
: QDialog(parent), m_ui(new Ui::AdBlockAddSubscriptionDialog) {
|
||||
m_ui->setupUi(this);
|
||||
m_knownSubscriptions << Subscription(QSL("EasyList (English)"), ADBLOCK_EASYLIST_URL)
|
||||
<< Subscription(QSL("BSI Lista Polska (Polish)"), QSL("http://www.bsi.info.pl/filtrABP.txt"))
|
||||
<< Subscription(QSL("EasyList Czech and Slovak (Czech)"),
|
||||
QSL("https://raw.githubusercontent.com/tomasko126/easylistczechandslovak/master/filters.txt"))
|
||||
<< Subscription(QSL("dutchblock (Dutch)"), QSL("http://groenewoudt.net/dutchblock/list.txt"))
|
||||
<< Subscription(QSL("Filtros Nauscopicos (Spanish)"), QSL("http://abp.mozilla-hispano.org/nauscopio/filtros.txt"))
|
||||
<< Subscription(QSL("IsraelList (Hebrew)"), QSL("http://secure.fanboy.co.nz/israelilist/IsraelList.txt"))
|
||||
<< Subscription(QSL("NLBlock (Dutch)"), QSL("http://www.verzijlbergh.com/adblock/nlblock.txt"))
|
||||
<< Subscription(QSL("Peter Lowe's list (English)"),
|
||||
QSL("http://pgl.yoyo.org/adservers/serverlist.php?hostformat=adblockplus&mimetype=plaintext"))
|
||||
<< Subscription(QSL("PLgeneral (Polish)"), QSL("http://www.niecko.pl/adblock/adblock.txt"))
|
||||
<< Subscription(QSL("Schacks Adblock Plus liste (Danish)"), QSL("http://adblock.schack.dk/block.txt"))
|
||||
<< Subscription(QSL("Xfiles (Italian)"), QSL("http://mozilla.gfsolone.com/filtri.txt"))
|
||||
<< Subscription(QSL("EasyPrivacy (English)"), QSL("http://easylist-downloads.adblockplus.org/easyprivacy.txt"))
|
||||
<< Subscription(QSL("RU Adlist (Russian)"), QSL("https://easylist-downloads.adblockplus.org/advblock.txt"))
|
||||
<< Subscription(QSL("ABPindo (Indonesian)"),
|
||||
QSL("https://raw.githubusercontent.com/heradhis/indonesianadblockrules/master/subscriptions/abpindo.txt"))
|
||||
<< Subscription(QSL("Easylist China (Chinese)"), QSL("https://easylist-downloads.adblockplus.org/easylistchina.txt"))
|
||||
<< Subscription(QSL("Anti-Adblock Killer"),
|
||||
QSL("https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt"));
|
||||
|
||||
foreach (const Subscription& subscription, m_knownSubscriptions) {
|
||||
m_ui->m_cmbPresets->addItem(subscription.m_title);
|
||||
}
|
||||
foreach (const Subscription& subscription, m_knownSubscriptions) {
|
||||
m_ui->m_cmbPresets->addItem(subscription.m_title);
|
||||
}
|
||||
|
||||
connect(m_ui->comboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||
&AdBlockAddSubscriptionDialog::indexChanged);
|
||||
indexChanged(0);
|
||||
connect(m_ui->m_cmbPresets, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||
&AdBlockAddSubscriptionDialog::indexChanged);
|
||||
connect(m_ui->m_cbUsePredefined, &QCheckBox::toggled, this, &AdBlockAddSubscriptionDialog::presetsEnabledChanged);
|
||||
|
||||
m_ui->m_cbUsePredefined->setChecked(true);
|
||||
indexChanged(0);
|
||||
}
|
||||
|
||||
QString AdBlockAddSubscriptionDialog::title() const {
|
||||
return m_ui->m_txtTitle->text();
|
||||
return m_ui->m_txtTitle->text();
|
||||
}
|
||||
|
||||
QString AdBlockAddSubscriptionDialog::url() const {
|
||||
return m_ui->m_txtUrl->text();
|
||||
return m_ui->m_txtUrl->text();
|
||||
}
|
||||
|
||||
void AdBlockAddSubscriptionDialog::indexChanged(int index) {
|
||||
const Subscription subscription = m_knownSubscriptions.at(index);
|
||||
const Subscription subscription = m_knownSubscriptions.at(index);
|
||||
const int pos = subscription.m_title.indexOf(QLatin1Char('('));
|
||||
|
||||
// "Other..." entry.
|
||||
if (subscription.m_url.isEmpty()) {
|
||||
m_ui->m_txtTitle->clear();
|
||||
m_ui->m_txtUrl->clear();
|
||||
}
|
||||
else {
|
||||
int pos = subscription.m_title.indexOf(QLatin1Char('('));
|
||||
QString title = subscription.m_title;
|
||||
if (pos > 0) {
|
||||
m_ui->m_txtTitle->setText(subscription.m_title.left(pos).trimmed());
|
||||
}
|
||||
else {
|
||||
m_ui->m_txtTitle->setText(subscription.m_title);
|
||||
}
|
||||
|
||||
if (pos > 0) {
|
||||
title = title.left(pos).trimmed();
|
||||
}
|
||||
m_ui->m_txtUrl->setText(subscription.m_url);
|
||||
}
|
||||
|
||||
m_ui->m_txtTitle->setText(title);
|
||||
m_ui->m_txtTitle->setCursorPosition(0);
|
||||
m_ui->m_txtUrl->setText(subscription.m_url);
|
||||
m_ui->m_txtUrl->setCursorPosition(0);
|
||||
}
|
||||
void AdBlockAddSubscriptionDialog::presetsEnabledChanged(bool enabled) {
|
||||
m_ui->m_txtTitle->setEnabled(!enabled);
|
||||
m_ui->m_txtUrl->setEnabled(!enabled);
|
||||
|
||||
if (!enabled) {
|
||||
// Presets are disabled, clear txts.
|
||||
m_ui->m_txtTitle->clear();
|
||||
m_ui->m_txtUrl->clear();
|
||||
m_ui->m_txtTitle->setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
AdBlockAddSubscriptionDialog::~AdBlockAddSubscriptionDialog() {
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ class AdBlockAddSubscriptionDialog : public QDialog {
|
||||
|
||||
private slots:
|
||||
void indexChanged(int index);
|
||||
void presetsEnabledChanged(bool enabled);
|
||||
|
||||
private:
|
||||
Ui::AdBlockAddSubscriptionDialog* m_ui;
|
||||
|
Loading…
x
Reference in New Issue
Block a user