File indexing completed on 2025-01-19 04:46:43

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 "confirmaddressconfigurewidget.h"
0008 #include "confirmaddressconfiguretab.h"
0009 #include <KConfigGroup>
0010 #include <KSharedConfig>
0011 #include <QCheckBox>
0012 #include <QRegularExpression>
0013 #include <QVBoxLayout>
0014 
0015 ConfirmAddressConfigureWidget::ConfirmAddressConfigureWidget(QWidget *parent)
0016     : MessageComposer::PluginEditorConfigureBaseWidget(parent)
0017     , mConfirmAddressConfigureTab(new ConfirmAddressConfigureTab(this))
0018 {
0019     auto vboxlayout = new QVBoxLayout(this);
0020     vboxlayout->setContentsMargins({});
0021     vboxlayout->setObjectName(QLatin1StringView("mainlayout"));
0022     mConfirmAddressConfigureTab->setObjectName(QLatin1StringView("confirmaddresstab"));
0023     connect(mConfirmAddressConfigureTab, &ConfirmAddressConfigureTab::configureChanged, this, &ConfirmAddressConfigureWidget::configureChanged);
0024     vboxlayout->addWidget(mConfirmAddressConfigureTab);
0025 }
0026 
0027 ConfirmAddressConfigureWidget::~ConfirmAddressConfigureWidget() = default;
0028 
0029 void ConfirmAddressConfigureWidget::loadSettings()
0030 {
0031     KConfigGroup grp(KSharedConfig::openConfig(), QStringLiteral("Confirm Address"));
0032     mConfirmAddressConfigureTab->loadSettings(grp);
0033 }
0034 
0035 void ConfirmAddressConfigureWidget::saveSettings()
0036 {
0037     KSharedConfig::Ptr config = KSharedConfig::openConfig();
0038     // first, delete all filter groups:
0039     const QStringList filterGroups = config->groupList().filter(QRegularExpression(QStringLiteral("Confirm Address \\d+")));
0040     for (const QString &group : filterGroups) {
0041         config->deleteGroup(group);
0042     }
0043     KConfigGroup grp(config, QStringLiteral("Confirm Address"));
0044     mConfirmAddressConfigureTab->saveSettings(grp);
0045 }
0046 
0047 void ConfirmAddressConfigureWidget::resetSettings()
0048 {
0049     mConfirmAddressConfigureTab->resetSettings();
0050 }
0051 
0052 void ConfirmAddressConfigureWidget::slotEnableChanged(bool state)
0053 {
0054     Q_UNUSED(state)
0055     Q_EMIT configureChanged();
0056 }
0057 
0058 #include "moc_confirmaddressconfigurewidget.cpp"