KCMUtils

kcmodulecontainer.h
1 /*
2  This file is part of the KDE libraries
3  SPDX-FileCopyrightText: 2004 Frans Englich <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #ifndef KCMODULECONTAINER_H
9 #define KCMODULECONTAINER_H
10 
11 #include <QString>
12 #include <QStringList>
13 
14 #include <KCModule>
15 #include <kcmutils_export.h>
16 
17 class QWidget;
18 
19 class KCModuleProxy;
20 
21 #if KCMUTILS_ENABLE_DEPRECATED_SINCE(5, 66)
22 /**
23  * @brief KCModuleContainer is a convenience class encapsulating several KCModules.
24  *
25  * The KCModuleContainer class is a convenience class for organizing a multiple set
26  * of KCModule. KCModuleContainer is a sub class of KCModule and builds an interface mainly
27  * consisting of a tab widget where each tab contains one of the modules specified via one of the
28  * constructors. KCModuleContainer can handle modules which requires root permissions. What you
29  * most likely want is the KCMODULECONTAINER macro. \n
30  * Sometimes it is of interest to detect in runtime whether a module should be loaded or not. This
31  * can be achieved by sub classing KCModuleContainer, doing the probing/testing checks and then manually
32  * call addModule for each module which should be displayed. When all calls to addModule is done, call
33  * finalize() which performs some necessary final steps.
34  *
35  * @deprecated since 5.66, no known users.
36  *
37  * @author Frans Englich <[email protected]>
38  */
39 class KCMUTILS_EXPORT KCModuleContainer : public KCModule
40 {
41  Q_OBJECT
42 public:
43  /**
44  * Creates a KCModuleContainer with tabs, each one containing one of the
45  * specified modules in @p mods.
46  *
47  * @param parent the parent QWidget.
48  * @param mods The list of KCModules to be loaded. The name of each
49  * KCModule is its service name, that is the name of the desktop file without
50  * the ".desktop" part
51  *
52  * @deprecated since 5.66, no known users.
53  */
54  KCMUTILS_DEPRECATED_VERSION(5, 66, "No known users")
55  KCModuleContainer(QWidget *parent, const QStringList &mods);
56 
57  /**
58  * This is a convenience function, instead of building a QStringList you
59  * can specify the modules in a comma separated QString. For example;
60  * \code
61  * KCModuleContainer* cont = KCModuleContainer( this, "kcm_misc", QString("kcm_energy, kcm_keyboard ,kcm_useraccount, kcm_mouse") );
62  * \endcode
63  * The other constructor takes its modules in a QStringlist which also can be constructed from a
64  * string and thus you will have to be explicit on the data type.
65  *
66  * What you probably want is the KCMODULECONTAINER macro which builds an KCModule
67  * for you, taking the modules you want as argument.
68  *
69  * @param parent The parent widget
70  * @param mods The modules to load
71  * @return The KCModule containing the requested modules.
72  *
73  * @deprecated since 5.66, no known users.
74  */
75  KCMUTILS_DEPRECATED_VERSION(5, 66, "No known users")
76  explicit KCModuleContainer(QWidget *parent, const QString &mods = QString());
77 
78  /**
79  * Adds the specified module to the tab widget. Setting the tab icon, text,
80  * tool tip, connecting the signals is what it does.
81  *
82  * @param module the name of the module to add. The name is the desktop file's name
83  * without the ".desktop" part.
84  *
85  * @deprecated since 5.66, no known users.
86  */
87  KCMUTILS_DEPRECATED_VERSION(5, 66, "No known users")
88  void addModule(const QString &module);
89 
90  /**
91  * Default destructor.
92  */
93  ~KCModuleContainer() override;
94 
95  /**
96  * @reimp
97  */
98  void save() override;
99 
100  /**
101  * @reimp
102  */
103  void load() override;
104 
105  /**
106  * @reimp
107  */
108  void defaults() override;
109 
110 private Q_SLOTS:
111 
112  /**
113  * Enables/disables the Admin Mode button, as appropriate.
114  */
115  void tabSwitched(int);
116 
117  void moduleChanged(KCModuleProxy *proxy);
118 
119 private:
120  void init();
121 
122  class KCModuleContainerPrivate;
123  KCModuleContainerPrivate *const d;
124 };
125 
126 /**
127  * This macro creates an factory declaration which when run creates an KCModule with specified
128  * modules. For example:
129  * \code
130  * KCMODULECONTAINER("kcm_fonts,kcm_keyboard,kcm_foo", misc_modules)
131  * \endcode
132  * would create a KCModule with three tabs, each containing one of the specified KCMs. Each
133  * use of the macro must be accompanied by a desktop file where the factory name equals
134  * the second argument in the macro(in this example, misc_modules). \n
135  * The module container takes care of testing the contained modules when being shown, as well
136  * as when the module itself is asked whether it should be shown.
137  *
138  * @param modules the modules to put in the container
139  * @param factoryName what factory name the module should have
140  *
141  * @deprecated since 5.66, no known users.
142  */
143 // clang-format off
144 #define KCMODULECONTAINER(modules, factoryName) \
145  class KCModuleContainer##factoryName : public KCModuleContainer \
146  { \
147  public: \
148  KCModuleContainer##factoryName(QWidget *parent, const QVariantList &) \
149  : KCModuleContainer(parent, QLatin1String(modules)) \
150  { \
151  } \
152  }; \
153  K_PLUGIN_FACTORY(KCModuleContainer##factoryName##Factory, \
154  registerPlugin<KCModuleContainer#factoryName>(); \
155  )
156 // clang-format on
157 #endif
158 #endif // KCMODULECONTAINER_H
KCModuleContainer is a convenience class encapsulating several KCModules.
Encapsulates a KCModule for embedding.
Definition: kcmoduleproxy.h:55
Q_SLOTSQ_SLOTS
virtual void load()
virtual void defaults()
virtual void save()
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Jun 26 2022 03:51:23 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.