TDE core libraries
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.

kpluginselector_p.h 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /* This file is part of the KDE project
  2. Copyright (C) 2003 Matthias Kretz <kretz@kde.org>
  3. This library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Library General Public
  5. License version 2 as published by the Free Software Foundation.
  6. This library is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  9. Library General Public License for more details.
  10. You should have received a copy of the GNU Library General Public License
  11. along with this library; see the file COPYING.LIB. If not, write to
  12. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  13. Boston, MA 02110-1301, USA.
  14. */
  15. #ifndef KPLUGINSELECTOR_P_H
  16. #define KPLUGINSELECTOR_P_H
  17. #include <tqwidget.h>
  18. #include <kdelibs_export.h>
  19. class KConfigGroup;
  20. class TQListViewItem;
  21. class KPluginInfo;
  22. class KCModuleInfo;
  23. /**
  24. * This is a widget to configure what Plugins should be loaded. This widget is
  25. * used by KPluginSelector and has no direct use.
  26. *
  27. * @internal
  28. * @see KPluginSelector
  29. *
  30. * @author Matthias Kretz <kretz@kde.org>
  31. * @since 3.2
  32. */
  33. class KPluginSelectionWidget : public TQWidget
  34. {
  35. Q_OBJECT
  36. public:
  37. /**
  38. * Create a new Plugin Selector widget.
  39. *
  40. * @param plugininfos A list of KPluginInfo objects containing the
  41. * necessary information for the plugins you want to
  42. * add the selector's list.
  43. * @param kps A KPluginSelector object.
  44. * @param parent The parent widget.
  45. * @param catname The translated name of the category.
  46. * @param category The unstranslated category key name.
  47. * @param config Set the KConfigGroup object that holds the
  48. * state of the plugins being enabled or not.
  49. * @param name The name of the widget (passed to TQWidget)
  50. *
  51. * @internal
  52. */
  53. KPluginSelectionWidget( const TQValueList<KPluginInfo*> & plugininfos,
  54. KPluginSelector * kps, TQWidget * parent, const TQString & catname,
  55. const TQString & category, KConfigGroup * config = 0,
  56. const char * name = 0 );
  57. virtual ~KPluginSelectionWidget();
  58. /**
  59. * Returns the translated category name
  60. *
  61. * @internal
  62. */
  63. TQString catName() const;
  64. /**
  65. * Tell the KPluginInfo objects to load their state (enabled/disabled).
  66. */
  67. virtual void load();
  68. /**
  69. * It tells the KPluginInfo objects to save their current state
  70. * (enabled/disabled).
  71. */
  72. virtual void save();
  73. /**
  74. * @return whether the plugin is enabled in the ListView or not.
  75. */
  76. bool pluginChecked( const TQString & pluginName ) const;
  77. signals:
  78. /**
  79. * Emits true when at least one embedded KCM is changed, or the plugin
  80. * selection was changed.
  81. * Emits false when the configuration is back to what it was.
  82. */
  83. void changed( bool );
  84. /**
  85. * Emitted after the config of an embedded KCM has been saved. The
  86. * argument is the name of the parent component that needs to reload
  87. * its config
  88. */
  89. void configCommitted( const TQCString & instanceName );
  90. protected:
  91. /**
  92. * Reimplement in your subclass if you have special needs: The standard
  93. * implementation looks at the KPluginInfo objects to find the
  94. * needed information. But if, for some reason, your program doesn't
  95. * work with that here's your chance to get it working.
  96. *
  97. * @return Whether the plugin is loaded.
  98. */
  99. virtual bool pluginIsLoaded( const TQString & pluginName ) const;
  100. private slots:
  101. /**
  102. * Called when a TQCheckListItem is checked or unchecked. It calls
  103. * checkDependencies on the Plugin and then updateConfigPage.
  104. *
  105. * @internal
  106. */
  107. void executed( TQListViewItem * );
  108. /**
  109. * Called whenever the visible config page should change (plugin
  110. * selection changed, plugin checked changed)
  111. *
  112. * First it checks for a widget for the plugin - if there is one, great:
  113. * show it.
  114. * If there is none, check whether there should be one and try to load
  115. * the KCM. If there are more than one KCM create a TabWidget and put
  116. * all of them inside, else just use the "bare" KCM. If there is no KCM
  117. * us the infoPage( NoKCM ). If there should be one but it can't be
  118. * loaded us the infoPage( LoadError ).
  119. * Depending on whether the currently selected Plugin is checked or not
  120. * disable or enable the "page" (which is the TabWidget or the KCM).
  121. *
  122. * @internal
  123. */
  124. void updateConfigPage( KPluginInfo * plugininfo, bool checked );
  125. void updateConfigPage();
  126. /**
  127. * Whenever an embedded KCM emits the changed signal we count the number
  128. * of changed KCMs. If it becomes one we emit changed( true ), if it
  129. * becomes zero we emit changed( false ).
  130. *
  131. * @internal
  132. */
  133. void clientChanged( bool );
  134. /**
  135. * Called whenever the tabWidget changes. It checks whether this
  136. * KPluginSelectionWidget is shown and sets the currentplugininfo
  137. * accordingly.
  138. */
  139. void tabWidgetChanged( TQWidget * );
  140. private:
  141. /**
  142. * Load a KCM from a KCModuleInfo. If successfull connect changed
  143. * signal and return the module. If not, create a label showing "Error",
  144. * show the loaderError and return the label.
  145. *
  146. * @internal
  147. */
  148. TQWidget * insertKCM( TQWidget * parent, const KCModuleInfo & );
  149. /**
  150. * Embed the KCMs for the plugin into the widgetstack
  151. *
  152. * @internal
  153. */
  154. void embeddPluginKCMs( KPluginInfo *, bool );
  155. void init( const TQValueList<KPluginInfo*> & plugininfos, const TQString & );
  156. void checkDependencies( const KPluginInfo * );
  157. struct KPluginSelectionWidgetPrivate;
  158. KPluginSelectionWidgetPrivate * d;
  159. };
  160. // vim: sw=4 sts=4 et
  161. #endif // KPLUGINSELECTOR_P_H