Falkon Develop
Cross-platform Qt-based web browser
adblockaddsubscriptiondialog.cpp
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2010-2017 David Rosca <nowrep@gmail.com>
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation, either version 3 of the License, or
8* (at your option) any later version.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17* ============================================================ */
19#include "ui_adblockaddsubscriptiondialog.h"
20#include "adblockmanager.h"
21
23 : QDialog(parent)
25{
26 ui->setupUi(this);
27
28 m_knownSubscriptions << Subscription(QSL("EasyList (English)"), ADBLOCK_EASYLIST_URL)
29 << Subscription(QSL("NoCoin List"), ADBLOCK_NOCOINLIST_URL)
30 << Subscription(QSL("EasyList (Spanish)"), QSL("https://easylist-downloads.adblockplus.org/easylistspanish.txt"))
31 << Subscription(QSL("IsraelList (Hebrew)"), QSL("http://secure.fanboy.co.nz/israelilist/IsraelList.txt"))
32 << Subscription(QSL("NLBlock (Dutch)"), QSL("https://www.ergensin.nl/adblock/nlblock.txt"))
33 << Subscription(QSL("Peter Lowe's list (English)"), QSL("http://pgl.yoyo.org/adservers/serverlist.php?hostformat=adblockplus&mimetype=plaintext"))
34 << Subscription(QSL("PLgeneral (Polish)"), QSL("http://www.niecko.pl/adblock/adblock.txt"))
35 << Subscription(QSL("EasyPrivacy (English)"), QSL("http://easylist-downloads.adblockplus.org/easyprivacy.txt"))
36 << Subscription(QSL("RU Adlist (Russian)"), QSL("https://easylist-downloads.adblockplus.org/advblock.txt"))
37 << Subscription(QSL("ABPindo (Indonesian)"), QSL("https://raw.githubusercontent.com/heradhis/indonesianadblockrules/master/subscriptions/abpindo.txt"))
38 << Subscription(QSL("Easylist China (Chinese)"), QSL("https://easylist-downloads.adblockplus.org/easylistchina.txt"))
39 << Subscription(QSL("Anti-Adblock Killer"), QSL("https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt"))
40 << Subscription(tr("Other..."), QString());
41
42 for (const Subscription &subscription : std::as_const(m_knownSubscriptions)) {
43 ui->comboBox->addItem(subscription.title);
44 }
45
46 connect(ui->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(indexChanged(int)));
47 indexChanged(0);
48}
49
51{
52 return ui->title->text();
53}
54
56{
57 return ui->url->text();
58}
59
60void AdBlockAddSubscriptionDialog::indexChanged(int index)
61{
62 const Subscription subscription = m_knownSubscriptions.at(index);
63
64 // "Other..." entry
65 if (subscription.url.isEmpty()) {
66 ui->title->clear();
67 ui->url->clear();
68 }
69 else {
70 int pos = subscription.title.indexOf(QLatin1Char('('));
71 QString title = subscription.title;
72
73 if (pos > 0) {
74 title = title.left(pos).trimmed();
75 }
76
77 ui->title->setText(title);
78 ui->title->setCursorPosition(0);
79
80 ui->url->setText(subscription.url);
81 ui->url->setCursorPosition(0);
82 }
83}
84
86{
87 delete ui;
88}
#define ADBLOCK_NOCOINLIST_URL
#define ADBLOCK_EASYLIST_URL
AdBlockAddSubscriptionDialog(QWidget *parent=nullptr)
#define QSL(x)
Definition: qzcommon.h:40