File indexing completed on 2025-01-19 04:47:00
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 "adblockpluginurlinterceptorconfiguredialog.h" 0008 #include "adblockpluginurlinterceptorconfigurewidget.h" 0009 0010 #include <KConfigGroup> 0011 #include <KLocalizedString> 0012 #include <KSharedConfig> 0013 #include <KWindowConfig> 0014 #include <QWindow> 0015 0016 namespace 0017 { 0018 static const char myConfigGroupName[] = "AdblockPluginUrlInterceptorConfigureDialog"; 0019 } 0020 AdblockPluginUrlInterceptorConfigureDialog::AdblockPluginUrlInterceptorConfigureDialog(QWidget *parent) 0021 : PimCommon::ConfigurePluginDialog(parent) 0022 { 0023 setWindowTitle(i18nc("@title:window", "Configure AdBlock Plugin")); 0024 initLayout(); 0025 readConfig(); 0026 } 0027 0028 AdblockPluginUrlInterceptorConfigureDialog::~AdblockPluginUrlInterceptorConfigureDialog() 0029 { 0030 writeConfig(); 0031 } 0032 0033 QWidget *AdblockPluginUrlInterceptorConfigureDialog::createLayout() 0034 { 0035 mAdblockConfigureWidget = new AdblockPluginUrlInterceptorConfigureWidget(this); 0036 return mAdblockConfigureWidget; 0037 } 0038 0039 void AdblockPluginUrlInterceptorConfigureDialog::save() 0040 { 0041 mAdblockConfigureWidget->saveSettings(); 0042 } 0043 0044 void AdblockPluginUrlInterceptorConfigureDialog::load() 0045 { 0046 mAdblockConfigureWidget->loadSettings(); 0047 } 0048 0049 void AdblockPluginUrlInterceptorConfigureDialog::reset() 0050 { 0051 mAdblockConfigureWidget->resetSettings(); 0052 } 0053 0054 void AdblockPluginUrlInterceptorConfigureDialog::help() 0055 { 0056 // TODO we can use in akregator too. We need a specific doc. 0057 showHelp(QStringLiteral("kmail2"), mAdblockConfigureWidget->helpAnchor()); 0058 } 0059 0060 void AdblockPluginUrlInterceptorConfigureDialog::readConfig() 0061 { 0062 create(); // ensure a window is created 0063 windowHandle()->resize(QSize(600, 400)); 0064 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myConfigGroupName)); 0065 KWindowConfig::restoreWindowSize(windowHandle(), group); 0066 resize(windowHandle()->size()); // workaround for QTBUG-40584 0067 } 0068 0069 void AdblockPluginUrlInterceptorConfigureDialog::writeConfig() 0070 { 0071 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myConfigGroupName)); 0072 KWindowConfig::saveWindowSize(windowHandle(), group); 0073 group.sync(); 0074 } 0075 0076 #include "moc_adblockpluginurlinterceptorconfiguredialog.cpp"