File indexing completed on 2025-01-19 04:47:01
0001 /* 0002 SPDX-FileCopyrightText: 2016-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "adblockpluginurlinterceptorconfigurewidget.h" 0008 #include "adblockfilterwidget.h" 0009 #include "adblockmanager.h" 0010 #include "globalsettings_webengineurlinterceptoradblock.h" 0011 0012 #include <KSharedConfig> 0013 #include <QHBoxLayout> 0014 0015 AdblockPluginUrlInterceptorConfigureWidget::AdblockPluginUrlInterceptorConfigureWidget(QWidget *parent) 0016 : WebEngineViewer::NetworkPluginUrlInterceptorConfigureWidget(parent) 0017 , mAdblockFilterWidget(new AdblockFilterWidget(this)) 0018 { 0019 auto hbox = new QHBoxLayout(this); 0020 hbox->setContentsMargins({}); 0021 mAdblockFilterWidget->setObjectName(QLatin1StringView("mAdblockFilterWidget")); 0022 hbox->addWidget(mAdblockFilterWidget); 0023 connect(mAdblockFilterWidget, &AdblockFilterWidget::settingsChanged, this, [this]() { 0024 AdblockManager::self()->refreshLists(); 0025 Q_EMIT configureChanged(); 0026 }); 0027 } 0028 0029 AdblockPluginUrlInterceptorConfigureWidget::~AdblockPluginUrlInterceptorConfigureWidget() = default; 0030 0031 void AdblockPluginUrlInterceptorConfigureWidget::loadSettings() 0032 { 0033 mAdblockFilterWidget->loadSettings(); 0034 } 0035 0036 void AdblockPluginUrlInterceptorConfigureWidget::saveSettings() 0037 { 0038 mAdblockFilterWidget->saveSettings(); 0039 } 0040 0041 void AdblockPluginUrlInterceptorConfigureWidget::resetSettings() 0042 { 0043 const bool bUseDefaults = AdBlockSettings::self()->useDefaults(true); 0044 mAdblockFilterWidget->loadSettings(); 0045 AdBlockSettings::self()->useDefaults(bUseDefaults); 0046 } 0047 0048 #include "moc_adblockpluginurlinterceptorconfigurewidget.cpp"