File indexing completed on 2024-04-28 05:49:32

0001 /* This file is part of the KDE project
0002    SPDX-FileCopyrightText: 2001 Christoph Cullmann <cullmann@kde.org>
0003    SPDX-FileCopyrightText: 2001 Joseph Wenninger <jowenn@kde.org>
0004    SPDX-FileCopyrightText: 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
0005 
0006    SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #pragma once
0010 
0011 #include <KPluginMetaData>
0012 
0013 class KConfig;
0014 class KateMainWindow;
0015 class KConfigBase;
0016 namespace KTextEditor
0017 {
0018 class Plugin;
0019 }
0020 
0021 class KatePluginInfo
0022 {
0023 public:
0024     bool load = false;
0025     bool defaultLoad = false;
0026     KPluginMetaData metaData;
0027     KTextEditor::Plugin *plugin = nullptr;
0028     int sortOrder = 0;
0029     QString saveName() const;
0030     bool operator<(const KatePluginInfo &other) const;
0031 };
0032 
0033 typedef std::vector<KatePluginInfo> KatePluginList;
0034 
0035 class KatePluginManager
0036 {
0037 public:
0038     explicit KatePluginManager();
0039     ~KatePluginManager();
0040 
0041     void unloadAllPlugins();
0042 
0043     void enableAllPluginsGUI(KateMainWindow *win, KConfigBase *config = nullptr);
0044     void disableAllPluginsGUI(KateMainWindow *win);
0045 
0046     void loadConfig(KConfig *);
0047     void writeConfig(KConfig *);
0048 
0049     bool loadPlugin(KatePluginInfo *item);
0050     void unloadPlugin(KatePluginInfo *item);
0051 
0052     static void enablePluginGUI(KatePluginInfo *item, KateMainWindow *win, KConfigBase *config = nullptr);
0053     static void enablePluginGUI(KatePluginInfo *item);
0054 
0055     static void disablePluginGUI(KatePluginInfo *item, KateMainWindow *win);
0056     static void disablePluginGUI(KatePluginInfo *item);
0057 
0058     inline KatePluginList &pluginList()
0059     {
0060         return m_pluginList;
0061     }
0062 
0063     KTextEditor::Plugin *plugin(const QString &name);
0064 
0065 private:
0066     void setupPluginList();
0067 
0068     /**
0069      * all known plugins
0070      */
0071     KatePluginList m_pluginList;
0072 };