TDE System Settings – easy to use control center
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

257 lines
6.6 KiB

  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>
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Library General Public
  7. License as published by the Free Software Foundation; either
  8. version 2 of the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Library General Public License for more details.
  13. You should have received a copy of the GNU Library General Public License
  14. along with this library; see the file COPYING.LIB. If not, write to
  15. the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
  16. Boston, MA 02110-1301, USA.
  17. */
  18. #ifndef KCMULTIDIALOG_H
  19. #define KCMULTIDIALOG_H
  20. #include <tqptrdict.h>
  21. #include <kdialogbase.h>
  22. #include <klocale.h>
  23. #include <kservice.h>
  24. class KCModuleProxy;
  25. class KCModuleInfo;
  26. class KCModule;
  27. /**
  28. * @short A method that offers a KDialogBase containing arbitrary
  29. * Control Modules.
  30. */
  31. class KUTILS_EXPORT KCMultiWidget : public KDialogBase
  32. {
  33. Q_OBJECT
  34. TQ_OBJECT
  35. public:
  36. /**
  37. * Constructs a new KCMultiWidget
  38. *
  39. * @param parent The parent widget
  40. * @param name The widget name
  41. * @param modal If you pass true here, the dialog will be modal
  42. **/
  43. KCMultiWidget( TQWidget *parent=0, const char *name=0, bool modal=false );
  44. /**
  45. * Construct a personalized KCMultiWidget.
  46. *
  47. * @param dialogFace You can use TreeList, Tabbed, Plain, Swallow or
  48. * IconList.
  49. * @param parent Parent of the dialog.
  50. * @param name Dialog name (for internal use only).
  51. * @param modal Controls dialog modality. If @p false, the rest of the
  52. * program interface (example: other dialogs) is accessible while
  53. * the dialog is open.
  54. */
  55. KCMultiWidget( int dialogFace, TQWidget * parent = 0,
  56. const char * name = 0, bool modal = false );
  57. /**
  58. * Destructor
  59. **/
  60. virtual ~KCMultiWidget();
  61. /**
  62. * Add a module.
  63. *
  64. * @param module Specify the name of the module that is to be added
  65. * to the list of modules the dialog will show.
  66. *
  67. * @param withfallback Try harder to load the module. Might result
  68. * in the module appearing outside the dialog.
  69. **/
  70. void addModule(const TQString& module, bool withfallback=true);
  71. /**
  72. * Add a module.
  73. *
  74. * @param moduleinfo Pass a KCModuleInfo object which will be
  75. * used for creating the module. It will be added
  76. * to the list of modules the dialog will show.
  77. *
  78. * @param parentmodulenames The names of the modules that should appear as
  79. * parents in the TreeList. Look at the
  80. * KDialogBase::addPage documentation for more info
  81. * on this.
  82. *
  83. * @param withfallback Try harder to load the module. Might result
  84. * in the module appearing outside the dialog.
  85. **/
  86. void addModule(const KCModuleInfo& moduleinfo, TQStringList
  87. parentmodulenames = TQStringList(), bool withfallback=false);
  88. /**
  89. * @return the current module that is being shown.
  90. */
  91. KCModuleProxy * currentModule();
  92. signals:
  93. /**
  94. * Emitted after all KCModules have been told to save their configuration.
  95. *
  96. * The applyClicked and okClicked signals are emitted before the
  97. * configuration is saved.
  98. */
  99. void configCommitted();
  100. /**
  101. * Emitted after the KCModules have been told to save their configuration.
  102. * It is emitted once for every instance the KCMs that were changed belong
  103. * to.
  104. *
  105. * You can make use of this if you have more than one component in your
  106. * application. instanceName tells you the instance that has to reload its
  107. * configuration.
  108. *
  109. * The applyClicked and okClicked signals are emitted before the
  110. * configuration is saved.
  111. *
  112. * @param instanceName The name of the instance that needs to reload its
  113. * configuration.
  114. */
  115. void configCommitted( const TQCString & instanceName );
  116. /**
  117. * Emitted right before a module is shown.
  118. * Usefull for updating caption, help, etc
  119. *
  120. * @param moduleinfo The module that is about to be shown.
  121. * @sense 3.4
  122. */
  123. void aboutToShow( KCModuleProxy *moduleProxy );
  124. void close();
  125. protected slots:
  126. /**
  127. * This slot is called when the user presses the "Default" Button.
  128. * You can reimplement it if needed.
  129. *
  130. * @note Make sure you call the original implementation.
  131. **/
  132. virtual void slotDefault();
  133. /**
  134. * This slot is called when the user presses the "Reset" Button.
  135. * You can reimplement it if needed.
  136. *
  137. * @note Make sure you call the original implementation.
  138. */
  139. virtual void slotUser1();
  140. virtual void slotUser2();
  141. /**
  142. * This slot is called when the user presses the "Apply" Button.
  143. * You can reimplement it if needed.
  144. *
  145. * @note Make sure you call the original implementation.
  146. **/
  147. virtual void slotApply();
  148. /**
  149. * This slot is called when the user presses the "OK" Button.
  150. * You can reimplement it if needed.
  151. *
  152. * @note Make sure you call the original implementation.
  153. **/
  154. virtual void slotOk();
  155. /**
  156. * This slot is called when the user presses the "Help" Button.
  157. * It reads the DocPath field of the currently selected KControl
  158. * module's .desktop file to find the path to the documentation,
  159. * which it then attempts to load.
  160. *
  161. * You can reimplement this slot if needed.
  162. *
  163. * @note Make sure you call the original implementation.
  164. **/
  165. virtual void slotHelp();
  166. virtual void slotCancel();
  167. private slots:
  168. void slotAboutToShow(TQWidget *);
  169. void clientChanged(bool state);
  170. /**
  171. * Called when entering root mode, and disables
  172. * the Admin Mode button such that the user doesn't do it
  173. * twice.
  174. *
  175. * @since 3.4
  176. */
  177. void disableRModeButton();
  178. /**
  179. * Called when the current module exits from root
  180. * mode. Enables the Administrator Mode button, again.
  181. *
  182. * @since 3.4
  183. */
  184. void rootExit();
  185. /**
  186. *
  187. * Called when the dialog is hidden. It unregisters the modules,
  188. * such that they don't hinder the same modules to be opened in
  189. * another application.
  190. *
  191. * @since 3.4
  192. */
  193. void dialogClosed();
  194. private:
  195. void applyOrRevert(KCModuleProxy * module);
  196. void init();
  197. void apply();
  198. struct CreatedModule
  199. {
  200. KCModuleProxy * kcm;
  201. KService::Ptr service;
  202. bool adminmode;
  203. int buttons;
  204. };
  205. typedef TQValueList<CreatedModule> ModuleList;
  206. ModuleList m_modules;
  207. typedef TQMap<KService::Ptr, KCModuleProxy*> OrphanMap;
  208. OrphanMap m_orphanModules;
  209. TQPtrDict<TQStringList> moduleParentComponents;
  210. TQString _docPath;
  211. int dialogface;
  212. class KCMultiWidgetPrivate;
  213. KCMultiWidgetPrivate *d;
  214. };
  215. #endif //KCMULTIDIALOG_H