File indexing completed on 2024-12-22 05:01:02
0001 /* 0002 * kmail: KDE mail client 0003 * SPDX-FileCopyrightText: 2000 Espen Sand <espen@kde.org> 0004 * SPDX-FileCopyrightText: 2001-2003 Marc Mutz <mutz@kde.org> 0005 * Contains code segments and ideas from earlier kmail dialog code. 0006 * 0007 * SPDX-License-Identifier: GPL-2.0-or-later 0008 * 0009 */ 0010 0011 // my headers: 0012 #include "configuredialog.h" 0013 0014 #include "kmkernel.h" 0015 #include "settings/kmailsettings.h" 0016 0017 #include <KPluginMetaData> 0018 #include <QPushButton> 0019 0020 ConfigureDialog::ConfigureDialog(QWidget *parent, bool modal) 0021 : KCMultiDialog(parent) 0022 { 0023 setFaceType(List); 0024 setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Help | QDialogButtonBox::RestoreDefaults | QDialogButtonBox::Cancel | QDialogButtonBox::Apply 0025 | QDialogButtonBox::Reset); 0026 setModal(modal); 0027 const QList<KPluginMetaData> availablePlugins = KPluginMetaData::findPlugins(QStringLiteral("pim6/kcms/kmail")); 0028 for (const KPluginMetaData &metaData : availablePlugins) { 0029 addModule(metaData); 0030 } 0031 0032 connect(button(QDialogButtonBox::Ok), &QPushButton::clicked, this, &ConfigureDialog::slotOk); 0033 connect(button(QDialogButtonBox::Apply), &QPushButton::clicked, this, &ConfigureDialog::slotApply); 0034 connect(button(QDialogButtonBox::Help), &QPushButton::clicked, this, &ConfigureDialog::slotHelpClicked); 0035 connect(button(QDialogButtonBox::Cancel), &QPushButton::clicked, this, &ConfigureDialog::slotUser1Clicked); 0036 connect(button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked, this, &ConfigureDialog::slotDefaultClicked); 0037 connect(button(QDialogButtonBox::Reset), &QPushButton::clicked, this, &ConfigureDialog::slotUser1Clicked); 0038 } 0039 0040 QSize ConfigureDialog::sizeHint() const 0041 { 0042 const int width = KMailSettings::self()->configureDialogWidth(); 0043 const int height = KMailSettings::self()->configureDialogHeight(); 0044 return {width, height}; 0045 } 0046 0047 void ConfigureDialog::hideEvent(QHideEvent *ev) 0048 { 0049 KMailSettings::self()->setConfigureDialogWidth(width()); 0050 KMailSettings::self()->setConfigureDialogHeight(height()); 0051 KPageDialog::hideEvent(ev); 0052 } 0053 0054 ConfigureDialog::~ConfigureDialog() = default; 0055 0056 void ConfigureDialog::slotApply() 0057 { 0058 slotApplyClicked(); 0059 if (KMKernel::self()) { 0060 KMKernel::self()->slotRequestConfigSync(); 0061 } 0062 Q_EMIT configChanged(); 0063 } 0064 0065 void ConfigureDialog::slotOk() 0066 { 0067 slotOkClicked(); 0068 if (KMKernel::self()) { 0069 KMKernel::self()->slotRequestConfigSync(); 0070 } 0071 Q_EMIT configChanged(); 0072 } 0073 0074 #include "moc_configuredialog.cpp"