Warning: That file was not part of the compilation database. It may have many parsing errors.

1// This file is part of Pate, Kate' Python scripting plugin.
2//
3// Copyright (C) 2006 Paul Giannaros <paul@giannaros.org>
4// Copyright (C) 2012, 2013 Shaheed Haque <srhaque@theiet.org>
5// Copyright (C) 2013 Alex Turbov <i.zaufi@gmail.com>
6//
7// This library is free software; you can redistribute it and/or
8// modify it under the terms of the GNU Library General Public
9// License as published by the Free Software Foundation; either
10// version 2 of the License, or (at your option) version 3.
11//
12// This library is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15// Library General Public License for more details.
16//
17// You should have received a copy of the GNU Library General Public License
18// along with this library; see the file COPYING.LIB. If not, write to
19// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20// Boston, MA 02110-1301, USA.
21//
22
23#ifndef _PATE_PLUGIN_H_
24# define _PATE_PLUGIN_H_
25
26# include <Python.h>
27# include <kate/mainwindow.h>
28# include <kate/plugin.h>
29# include <kate/pluginconfigpageinterface.h>
30
31# include <QList>
32
33# include "engine.h"
34# include "ui_manager.h"
35
36// Fwd decls
37class QPushButton;
38class QCheckBox;
39class QTreeView;
40
41namespace Pate
42{
43/**
44 * The Pate plugin supports the creation of Kate scripts in Python. The script
45 * modules must provide a \c .desktop file describing the plugin name, comment
46 * and particular Python module to load.
47 *
48 * The modules which are found, along with three pre-defined support modules
49 * (\c kate, \c kate.gui and \c pate) are displayed and managed through this
50 * plugin.
51 *
52 * The modules which are failed to load gets disabled in a manager. Usable
53 * modules can be enabled by the user, and any methods decorated with
54 * \c kate.action or \c kate.configPage will be hooked into Kate as appropriate.
55 *
56 * Configuration support has these elements:
57 *
58 * - Configuration of the Pate plugin itself. This is stored in \c katerc as for
59 * other Kate plugins in appropriately named groups.
60 *
61 * - Configuration of modules. This is provided via \c kate.configuration which
62 * allows each module native Python object configuration storage via
63 * katepaterc. Plugins which wish to can hook their configuration into
64 * Kate's configuration system using \c kate.configPage.
65 */
66class Plugin
67 : public Kate::Plugin
68 , public Kate::PluginConfigPageInterface
69{
70 Q_OBJECT
71 Q_INTERFACES(Kate::PluginConfigPageInterface)
72
73public:
74 explicit Plugin(QObject* = 0, const QList<QVariant>& = QList<QVariant>());
75 virtual ~Plugin();
76
77 Kate::PluginView* createView(Kate::MainWindow*);
78
79 /**
80 * Read the configuration for the plugin.
81 */
82 virtual void readSessionConfig(KConfigBase* config, const QString& groupPrefix);
83
84 /**
85 * Write the configuration for the plugin.
86 */
87 virtual void writeSessionConfig(KConfigBase* config, const QString& groupPrefix);
88
89 //BEGIN PluginConfigPageInterface
90 uint configPages() const;
91 Kate::PluginConfigPage* configPage(uint number = 0, QWidget* parent = 0, const char* name = 0);
92 QString configPageName(uint number = 0) const;
93 QString configPageFullName(uint number = 0) const;
94 KIcon configPageIcon(uint number = 0) const;
95 //END PluginConfigPageInterface
96
97 /// Read-only access to the engine
98 const Pate::Engine& engine() const;
99 /// Read-write access to the engine
100 Pate::Engine& engine();
101 /// Check if engine is initialized properly,
102 /// show a passive popup if it doesn't
103 bool checkEngineShowPopup() const;
104 void setFailureReason(QString);
105
106private:
107 friend class ConfigPage;
108 void reloadModuleConfigPages() const;
109 static QString getSessionPrivateStorageFilename(KConfigBase*);
110
111 mutable QList<PyObject*> m_moduleConfigPages;
112 Pate::Engine m_engine;
113 QString m_engineFailureReason;
114 bool m_autoReload;
115};
116
117/**
118 * The Pate plugin view.
119 */
120class PluginView
121 : public Kate::PluginView
122 , public Kate::XMLGUIClient
123{
124 Q_OBJECT
125
126public:
127 PluginView(Kate::MainWindow*, Plugin*);
128 ~PluginView();
129
130public Q_SLOTS:
131 void aboutPate();
132
133private:
134 Plugin* m_plugin;
135};
136
137/**
138 * The Pate plugin's configuration view.
139 */
140class ConfigPage : public Kate::PluginConfigPage
141{
142 Q_OBJECT
143
144public:
145 explicit ConfigPage(QWidget* = 0, Plugin* = 0);
146 virtual ~ConfigPage();
147
148public Q_SLOTS:
149 virtual void apply();
150 virtual void reset();
151 virtual void defaults();
152
153private:
154 Plugin* m_plugin;
155 Ui::ManagerPage m_manager;
156};
157
158/**
159 * A page used if an error occurred trying to load a plugin's config page.
160 */
161class ErrorConfigPage : public Kate::PluginConfigPage
162{
163 Q_OBJECT
164
165public:
166 explicit ErrorConfigPage(QWidget* parent = 0, const QString& traceback = QString());
167
168public Q_SLOTS:
169 virtual void apply() {}
170 virtual void reset() {}
171 virtual void defaults() {}
172};
173
174} // namespace Pate
175#endif // _PATE_PLUGIN_H_
176// kate: indent-width 4;
177

Warning: That file was not part of the compilation database. It may have many parsing errors.