File indexing completed on 2025-02-16 04:49:30
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 "checkbeforesendconfigurewidget.h" 0008 #include <KConfigGroup> 0009 #include <KLocalizedString> 0010 #include <KSharedConfig> 0011 #include <QCheckBox> 0012 #include <QVBoxLayout> 0013 namespace 0014 { 0015 static const char myConfigGroupName[] = "Check Before Send"; 0016 } 0017 CheckBeforeSendConfigureWidget::CheckBeforeSendConfigureWidget(QWidget *parent) 0018 : MessageComposer::PluginEditorConfigureBaseWidget(parent) 0019 , mCheckPlainTextMail(new QCheckBox(i18n("Send as plain text"), this)) 0020 , mCheckMailTransport(new QCheckBox(i18n("Use SMTP server defined in identity"), this)) 0021 , mCheckDuplicateEmailsAddresses(new QCheckBox(i18n("Check duplicated emails addresses"), this)) 0022 , mCheckSendAttachments(new QCheckBox(i18n("Check send attachment"), this)) 0023 { 0024 auto mainLayout = new QVBoxLayout(this); 0025 mainLayout->setContentsMargins({}); 0026 mainLayout->setObjectName(QLatin1StringView("mainlayout")); 0027 0028 mCheckPlainTextMail->setObjectName(QLatin1StringView("checkplaintext")); 0029 connect(mCheckPlainTextMail, &QCheckBox::clicked, this, &CheckBeforeSendConfigureWidget::configureChanged); 0030 mainLayout->addWidget(mCheckPlainTextMail); 0031 0032 mCheckMailTransport->setObjectName(QLatin1StringView("smtpdefinedinidentity")); 0033 connect(mCheckMailTransport, &QCheckBox::clicked, this, &CheckBeforeSendConfigureWidget::configureChanged); 0034 mainLayout->addWidget(mCheckMailTransport); 0035 0036 mCheckDuplicateEmailsAddresses->setObjectName(QLatin1StringView("checkduplicatedemailsaddresses")); 0037 connect(mCheckDuplicateEmailsAddresses, &QCheckBox::clicked, this, &CheckBeforeSendConfigureWidget::configureChanged); 0038 mainLayout->addWidget(mCheckDuplicateEmailsAddresses); 0039 0040 mCheckSendAttachments->setObjectName(QLatin1StringView("checksendattachment")); 0041 connect(mCheckSendAttachments, &QCheckBox::clicked, this, &CheckBeforeSendConfigureWidget::configureChanged); 0042 mainLayout->addWidget(mCheckSendAttachments); 0043 0044 mainLayout->addStretch(1); 0045 } 0046 0047 CheckBeforeSendConfigureWidget::~CheckBeforeSendConfigureWidget() = default; 0048 0049 void CheckBeforeSendConfigureWidget::loadSettings() 0050 { 0051 KConfigGroup grp(KSharedConfig::openConfig(), QLatin1StringView(myConfigGroupName)); 0052 mCheckPlainTextMail->setChecked(grp.readEntry("SendPlainText", false)); 0053 mCheckMailTransport->setChecked(grp.readEntry("SmtpDefinedInIdentity", false)); 0054 mCheckDuplicateEmailsAddresses->setChecked(grp.readEntry("CheckDuplicatedEmails", false)); 0055 mCheckSendAttachments->setChecked(grp.readEntry("CheckSendAttachment", false)); 0056 } 0057 0058 void CheckBeforeSendConfigureWidget::saveSettings() 0059 { 0060 KConfigGroup grp(KSharedConfig::openConfig(), QLatin1StringView(myConfigGroupName)); 0061 grp.writeEntry("SendPlainText", mCheckPlainTextMail->isChecked()); 0062 grp.writeEntry("SmtpDefinedInIdentity", mCheckMailTransport->isChecked()); 0063 grp.writeEntry("CheckDuplicatedEmails", mCheckDuplicateEmailsAddresses->isChecked()); 0064 grp.writeEntry("CheckSendAttachment", mCheckSendAttachments->isChecked()); 0065 } 0066 0067 void CheckBeforeSendConfigureWidget::resetSettings() 0068 { 0069 mCheckPlainTextMail->setChecked(false); 0070 mCheckMailTransport->setChecked(false); 0071 mCheckSendAttachments->setChecked(false); 0072 mCheckDuplicateEmailsAddresses->setChecked(false); 0073 } 0074 0075 #include "moc_checkbeforesendconfigurewidget.cpp"