File indexing completed on 2025-01-19 04:46:52
0001 /* 0002 SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "dkimkeyrecordwidget.h" 0008 #include <KConfigGroup> 0009 #include <KSharedConfig> 0010 #include <MessageViewer/DKIMManagerKeyWidget> 0011 #include <QHBoxLayout> 0012 0013 namespace 0014 { 0015 static const char myDKIMKeyRecordWidgetGroupName[] = "DKIMKeyRecordWidget"; 0016 } 0017 0018 DKIMKeyRecordWidget::DKIMKeyRecordWidget(QWidget *parent) 0019 : QWidget(parent) 0020 , mManagerKeyWidget(new MessageViewer::DKIMManagerKeyWidget(this)) 0021 { 0022 auto mainLayout = new QHBoxLayout(this); 0023 mainLayout->setObjectName(QLatin1StringView("mainLayout")); 0024 0025 mManagerKeyWidget->setObjectName(QLatin1StringView("mManagerKeyWidget")); 0026 mainLayout->addWidget(mManagerKeyWidget); 0027 readConfig(); 0028 } 0029 0030 DKIMKeyRecordWidget::~DKIMKeyRecordWidget() 0031 { 0032 writeConfig(); 0033 } 0034 0035 void DKIMKeyRecordWidget::readConfig() 0036 { 0037 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myDKIMKeyRecordWidgetGroupName)); 0038 mManagerKeyWidget->restoreHeaders(group.readEntry("Header", QByteArray())); 0039 } 0040 0041 void DKIMKeyRecordWidget::writeConfig() 0042 { 0043 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myDKIMKeyRecordWidgetGroupName)); 0044 group.writeEntry("Header", mManagerKeyWidget->saveHeaders()); 0045 group.sync(); 0046 } 0047 0048 void DKIMKeyRecordWidget::loadSettings() 0049 { 0050 mManagerKeyWidget->loadKeys(); 0051 } 0052 0053 void DKIMKeyRecordWidget::saveSettings() 0054 { 0055 mManagerKeyWidget->saveKeys(); 0056 } 0057 0058 void DKIMKeyRecordWidget::resetSettings() 0059 { 0060 mManagerKeyWidget->resetKeys(); 0061 } 0062 0063 #include "moc_dkimkeyrecordwidget.cpp"