add more spacing
[personal-kdebase.git] / workspace / systemsettings / kcmultiwidget.h
blob8a7dffea5cb8f7f7636f82cab34ef286f8bdd4c7
1 /*
2 Copyright (c) 2000 Matthias Elter <elter@kde.org>
3 Copyright (c) 2003 Daniel Molkentin <molkentin@kde.org>
4 Copyright (c) 2003 Matthias Kretz <kretz@kde.org>
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
23 #ifndef KCMULTIWIDGET_H
24 #define KCMULTIWIDGET_H
26 // Qt
27 #include <QtCore/QHash>
28 #include <QtCore/QList>
30 // KDE
31 #include <kpagedialog.h>
32 #include <kservice.h>
34 class KCModuleProxy;
35 class KCModuleInfo;
37 /**
38 * @short A method that offers a KDialog containing arbitrary Control Modules.
40 class /*KUTILS_EXPORT*/ KCMultiWidget : public KPageDialog
42 Q_OBJECT
44 public:
45 /**
46 * Constructs a new KCMultiWidget
48 * @param parent The parent widget
49 * @param modality Qt::WindowModality value indicating the modality of the window.
50 **/
51 KCMultiWidget( QWidget *parent=0,
52 Qt::WindowModality modality = Qt::NonModal );
54 /**
55 * Initialize the KIconDialog widget
57 * @param caption Specify the caption for the KIconDialog
58 * @param modality Qt::WindowModality value indicating the modality of the window.
59 * If @p Qt::NonModal, the rest of the program interface
60 * (example: other dialogs) is accessible while the dialog is open.
61 **/
62 void InitKIconDialog(const QString& caption,
63 Qt::WindowModality modality = Qt::NonModal);
65 /**
66 * Destructor
67 **/
68 virtual ~KCMultiWidget();
70 /**
71 * Add a module.
73 * @param moduleinfo Pass a KCModuleInfo object which will be
74 * used for creating the module. It will be added
75 * to the list of modules the dialog will show.
76 **/
77 void addModule(const KCModuleInfo& moduleinfo);
79 /**
80 * @return the current module that is being shown.
82 KCModuleProxy * currentModule();
84 /**
85 * Ask if it is ok to close the dialog
87 bool queryClose();
89 signals:
90 /**
91 * Emitted after all KCModules have been told to save their configuration.
93 * The applyClicked signal is emitted before the configuration is saved.
95 void configCommitted();
97 /**
98 * Emitted after the KCModules have been told to save their configuration.
99 * It is emitted once for every instance the KCMs that were changed belong
100 * to.
102 * You can make use of this if you have more than one component in your
103 * application. instanceName tells you the instance that has to reload its
104 * configuration.
106 * The applyClicked signal is emitted before the configuration is saved.
108 * @param instanceName The name of the instance that needs to reload its
109 * configuration.
111 void configCommitted( const QByteArray & instanceName );
114 * Emitted right before a module is shown.
115 * Useful for updating caption, help, etc
117 * @param moduleinfo The module that is about to be shown.
118 * @sense 3.4
120 void aboutToShow( KCModuleProxy *moduleProxy );
122 protected slots:
124 * This slot is called when the user presses the "Default" Button.
125 * You can reimplement it if needed.
127 * @note Make sure you call the original implementation.
129 virtual void slotDefault();
132 * This slot is called when the user presses the "Reset" Button.
133 * You can reimplement it if needed.
135 * @note Make sure you call the original implementation.
137 virtual void slotReset();
140 * This slot is called when the user presses the "Apply" Button.
141 * You can reimplement it if needed.
143 * @note Make sure you call the original implementation.
145 virtual void slotApply();
148 * This slot is called when the user presses the "Help" Button.
149 * It reads the DocPath field of the currently selected KControl
150 * module's .desktop file to find the path to the documentation,
151 * which it then attempts to load.
153 * You can reimplement this slot if needed.
155 * @note Make sure you call the original implementation.
157 virtual void slotHelp();
159 private slots:
161 void slotAboutToShow(QWidget *);
163 void slotAboutToShow(KPageWidgetItem* current, KPageWidgetItem* before);
165 void clientChanged(bool state);
167 // Currently unused. Whenever root mode comes back
168 #if 0
170 * Called when entering root mode, and disables
171 * the Admin Mode button such that the user doesn't do it
172 * twice.
174 void disableRModeButton();
177 * Called when the current module exits from root
178 * mode. Enables the Administrator Mode button, again.
180 void rootExit();
181 #endif
183 private:
186 void init();
188 void apply(KCModuleProxy *module);
189 void reset(KCModuleProxy *module);
190 void defaults(KCModuleProxy *module);
192 bool queryClose(KCModuleProxy *);
194 struct CreatedModule
196 KCModuleProxy * kcm;
197 KService::Ptr service;
198 bool adminmode;
200 typedef QList<CreatedModule> ModuleList;
201 ModuleList m_modules;
203 QHash<KCModuleProxy*,QStringList> moduleParentComponents;
204 QString _docPath;
206 class KCMultiWidgetPrivate;
207 KCMultiWidgetPrivate *d;
210 #endif //KCMULTIWIDGET_H