1 | /* This file is part of the KDE project |
2 | Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> |
3 | Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org> |
4 | Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk> |
5 | |
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 version 2 as published by the Free Software Foundation. |
9 | |
10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | Boston, MA 02110-1301, USA. |
19 | */ |
20 | |
21 | #ifndef __KATE_PLUGINMANAGER_H__ |
22 | #define __KATE_PLUGINMANAGER_H__ |
23 | |
24 | #include "katemain.h" |
25 | |
26 | #include <kate/plugin.h> |
27 | #include <kate/pluginmanager.h> |
28 | |
29 | #include <KService> |
30 | #include <KConfigBase> |
31 | |
32 | #include <QObject> |
33 | #include <QLinkedList> |
34 | |
35 | class KateMainWindow; |
36 | |
37 | class KatePluginInfo |
38 | { |
39 | public: |
40 | bool load; |
41 | bool alwaysLoad; |
42 | KService::Ptr service; |
43 | Kate::Plugin *plugin; |
44 | QString saveName() const; |
45 | }; |
46 | |
47 | typedef QList<KatePluginInfo> KatePluginList; |
48 | |
49 | class KatePluginManager : public QObject |
50 | { |
51 | Q_OBJECT |
52 | |
53 | public: |
54 | KatePluginManager(QObject *parent); |
55 | ~KatePluginManager(); |
56 | |
57 | static KatePluginManager *self(); |
58 | |
59 | Kate::PluginManager *pluginManager () const |
60 | { |
61 | return m_pluginManager; |
62 | } |
63 | |
64 | void unloadAllPlugins (); |
65 | |
66 | void enableAllPluginsGUI (KateMainWindow *win, KConfigBase *config = 0); |
67 | void disableAllPluginsGUI (KateMainWindow *win); |
68 | |
69 | void loadConfig (KConfig*); |
70 | void writeConfig (KConfig*); |
71 | |
72 | void loadPlugin (KatePluginInfo *item); |
73 | void unloadPlugin (KatePluginInfo *item); |
74 | |
75 | void enablePluginGUI (KatePluginInfo *item, KateMainWindow *win, KConfigBase *config = 0); |
76 | void enablePluginGUI (KatePluginInfo *item); |
77 | |
78 | void disablePluginGUI (KatePluginInfo *item, KateMainWindow *win); |
79 | void disablePluginGUI (KatePluginInfo *item); |
80 | |
81 | inline KatePluginList & pluginList () |
82 | { |
83 | return m_pluginList; |
84 | } |
85 | |
86 | Kate::Plugin *plugin (const QString &name); |
87 | bool pluginAvailable (const QString &name); |
88 | |
89 | Kate::Plugin *loadPlugin (const QString &name, bool permanent = true); |
90 | void unloadPlugin (const QString &name, bool permanent = true); |
91 | |
92 | private: |
93 | Kate::PluginManager *m_pluginManager; |
94 | |
95 | void setupPluginList (); |
96 | |
97 | /** |
98 | * all known plugins |
99 | */ |
100 | KatePluginList m_pluginList; |
101 | |
102 | /** |
103 | * fast access map from name => plugin info |
104 | * uses the info stored in the plugin list |
105 | */ |
106 | QMap<QString, KatePluginInfo *> m_name2Plugin; |
107 | }; |
108 | |
109 | #endif |
110 | // kate: space-indent on; indent-width 2; replace-tabs on; |
111 | |
112 | |