File indexing completed on 2024-12-22 05:01:02

0001 /*
0002  *   kmail: KDE mail client
0003  *   SPDX-FileCopyrightText: 2016-2024 Laurent Montel <montel@kde.org>
0004  *   SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 // -*- c++ -*-
0008 // configuredialog_p.h: classes internal to ConfigureDialog
0009 // see configuredialog.h for details.
0010 
0011 #pragma once
0012 
0013 #include "configmodule.h"
0014 #include "kmail_export.h"
0015 class QTabWidget;
0016 class ConfigureDialog;
0017 
0018 // Individual tab of a ConfigModuleWithTabs
0019 class ConfigModuleTab : public QWidget
0020 {
0021     Q_OBJECT
0022 public:
0023     explicit ConfigModuleTab(QWidget *parent = nullptr)
0024         : QWidget(parent)
0025     {
0026     }
0027 
0028     ~ConfigModuleTab() override = default;
0029 
0030     virtual void save() = 0;
0031     void defaults();
0032 Q_SIGNALS:
0033     // forwarded to the ConfigModule
0034     void changed(bool);
0035 public Q_SLOTS:
0036     void slotEmitChanged();
0037     void load();
0038 
0039 protected:
0040     bool mEmitChanges{true};
0041 
0042 private:
0043     // reimplement this for loading values of settings which are available
0044     // via GlobalSettings
0045     virtual void doLoadFromGlobalSettings()
0046     {
0047     }
0048 
0049     // reimplement this for loading values of settings which are not available
0050     // via GlobalSettings
0051     virtual void doLoadOther()
0052     {
0053     }
0054 
0055     // reimplement this for loading default values of settings which are
0056     // not available via GlobalSettings (KConfigXT).
0057     virtual void doResetToDefaultsOther()
0058     {
0059     }
0060 };
0061 
0062 /*
0063  * ConfigModuleWithTabs represents a kcm with several tabs.
0064  * It simply forwards load and save operations to all tabs.
0065  */
0066 class KMAIL_EXPORT ConfigModuleWithTabs : public ConfigModule
0067 {
0068     Q_OBJECT
0069 public:
0070     explicit ConfigModuleWithTabs(QObject *parent, const KPluginMetaData &data);
0071     ~ConfigModuleWithTabs() override = default;
0072 
0073     // don't reimplement any of those methods
0074     void load() override;
0075     void save() override;
0076     void defaults() override;
0077 
0078 protected:
0079     void addTab(ConfigModuleTab *tab, const QString &title);
0080 
0081 private:
0082     QTabWidget *const mTabWidget;
0083     bool mWasInitialized = false;
0084 };