File indexing completed on 2024-05-12 04:57:49
0001 /* ============================================================ 0002 * Falkon - Qt web browser 0003 * Copyright (C) 2010-2017 David Rosca <nowrep@gmail.com> 0004 * 0005 * This program is free software: you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation, either version 3 of the License, or 0008 * (at your option) any later version. 0009 * 0010 * This program is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License 0016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0017 * ============================================================ */ 0018 #include "adblockaddsubscriptiondialog.h" 0019 #include "ui_adblockaddsubscriptiondialog.h" 0020 #include "adblockmanager.h" 0021 0022 AdBlockAddSubscriptionDialog::AdBlockAddSubscriptionDialog(QWidget* parent) 0023 : QDialog(parent) 0024 , ui(new Ui::AdBlockAddSubscriptionDialog) 0025 { 0026 ui->setupUi(this); 0027 0028 m_knownSubscriptions << Subscription(QSL("EasyList (English)"), ADBLOCK_EASYLIST_URL) 0029 << Subscription(QSL("NoCoin List"), ADBLOCK_NOCOINLIST_URL) 0030 << Subscription(QSL("EasyList (Spanish)"), QSL("https://easylist-downloads.adblockplus.org/easylistspanish.txt")) 0031 << Subscription(QSL("IsraelList (Hebrew)"), QSL("http://secure.fanboy.co.nz/israelilist/IsraelList.txt")) 0032 << Subscription(QSL("NLBlock (Dutch)"), QSL("https://www.ergensin.nl/adblock/nlblock.txt")) 0033 << Subscription(QSL("Peter Lowe's list (English)"), QSL("http://pgl.yoyo.org/adservers/serverlist.php?hostformat=adblockplus&mimetype=plaintext")) 0034 << Subscription(QSL("PLgeneral (Polish)"), QSL("http://www.niecko.pl/adblock/adblock.txt")) 0035 << Subscription(QSL("EasyPrivacy (English)"), QSL("http://easylist-downloads.adblockplus.org/easyprivacy.txt")) 0036 << Subscription(QSL("RU Adlist (Russian)"), QSL("https://easylist-downloads.adblockplus.org/advblock.txt")) 0037 << Subscription(QSL("ABPindo (Indonesian)"), QSL("https://raw.githubusercontent.com/heradhis/indonesianadblockrules/master/subscriptions/abpindo.txt")) 0038 << Subscription(QSL("Easylist China (Chinese)"), QSL("https://easylist-downloads.adblockplus.org/easylistchina.txt")) 0039 << Subscription(QSL("Anti-Adblock Killer"), QSL("https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt")) 0040 << Subscription(tr("Other..."), QString()); 0041 0042 for (const Subscription &subscription : std::as_const(m_knownSubscriptions)) { 0043 ui->comboBox->addItem(subscription.title); 0044 } 0045 0046 connect(ui->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(indexChanged(int))); 0047 indexChanged(0); 0048 } 0049 0050 QString AdBlockAddSubscriptionDialog::title() const 0051 { 0052 return ui->title->text(); 0053 } 0054 0055 QString AdBlockAddSubscriptionDialog::url() const 0056 { 0057 return ui->url->text(); 0058 } 0059 0060 void AdBlockAddSubscriptionDialog::indexChanged(int index) 0061 { 0062 const Subscription subscription = m_knownSubscriptions.at(index); 0063 0064 // "Other..." entry 0065 if (subscription.url.isEmpty()) { 0066 ui->title->clear(); 0067 ui->url->clear(); 0068 } 0069 else { 0070 int pos = subscription.title.indexOf(QLatin1Char('(')); 0071 QString title = subscription.title; 0072 0073 if (pos > 0) { 0074 title = title.left(pos).trimmed(); 0075 } 0076 0077 ui->title->setText(title); 0078 ui->title->setCursorPosition(0); 0079 0080 ui->url->setText(subscription.url); 0081 ui->url->setCursorPosition(0); 0082 } 0083 } 0084 0085 AdBlockAddSubscriptionDialog::~AdBlockAddSubscriptionDialog() 0086 { 0087 delete ui; 0088 }