Krita Source Code Documentation
Loading...
Searching...
No Matches
PythonPluginManager.h
Go to the documentation of this file.
1/*
2 * This file is part of PyKrita, Krita' Python scripting plugin.
3 *
4 * SPDX-FileCopyrightText: 2013 Alex Turbov <i.zaufi@gmail.com>
5 * SPDX-FileCopyrightText: 2014-2016 Boudewijn Rempt <boud@valdyas.org>
6 * SPDX-FileCopyrightText: 2017 Jouni Pentikäinen (joupent@gmail.com)
7 *
8 * SPDX-License-Identifier: LGPL-2.0-or-later
9 */
10#ifndef PYTHONMODULEMANAGER_H
11#define PYTHONMODULEMANAGER_H
12
13#include <QObject>
14#include "version_checker.h"
15#include "PythonPluginsModel.h"
16
18
23{
24public:
28 QString moduleFilePathPart() const;
29
30 bool isValid() const;
31
32 inline const QString& errorReason() const
33 {
34 return m_errorReason;
35 }
36
37 inline bool isEnabled() const
38 {
39 return m_enabled;
40 }
41
42 inline bool isBroken() const
43 {
44 return m_broken;
45 }
46
47 inline bool isUnstable() const
48 {
49 return m_unstable;
50 }
51
52 QString name() const
53 {
54 return m_name;
55 }
56
57 QString moduleName() const
58 {
59 return m_moduleName;
60 }
61
62 QVariant property(const QString &name) const
63 {
64 return m_properties.value(name, "");
65 }
66
67 QString comment() const
68 {
69 return m_comment;
70 }
71
72 QString manual() const
73 {
74 return m_manual;
75 }
76
77private:
78 friend class PythonPluginManager;
79
81 m_properties["X-Python-Dependencies"] = QStringList();
82 }
83
85 bool m_enabled{false};
86 bool m_broken{false};
87 bool m_unstable{false};
88 bool m_loaded{false};
89
90 QString m_name;
91 QString m_moduleName;
92 QString m_comment;
93 QString m_manual;
94
95 QMap<QString, QVariant> m_properties;
96};
97
102class PythonPluginManager : public QObject
103{
104 Q_OBJECT
105
106public:
108
109 const QList<PythonPlugin>& plugins() const;
110 PythonPlugin *plugin(int index);
111
112 void scanPlugins();
114 void setPluginEnabled(PythonPlugin &plugin, bool enabled);
115
117
118public Q_SLOTS:
119 void unloadAllModules();
120
121private:
124
125 static bool verifyModuleExists(PythonPlugin &);
127 static QPair<QString, PyKrita::version_checker> parseDependency(const QString&);
128
130
132};
133
134#endif //PYTHONMODULEMANAGER_H
QList< QString > QStringList
QList< PythonPlugin > m_plugins
PythonPluginsModel * model()
void setPluginEnabled(PythonPlugin &plugin, bool enabled)
PythonPlugin * plugin(int index)
PythonPluginsModel m_model
static bool verifyModuleExists(PythonPlugin &)
const QList< PythonPlugin > & plugins() const
void loadModule(PythonPlugin &plugin)
static void verifyDependenciesSetStatus(PythonPlugin &)
static QPair< QString, PyKrita::version_checker > parseDependency(const QString &)
void unloadModule(PythonPlugin &plugin)
QString comment() const
QString name() const
bool isBroken() const
bool isEnabled() const
bool isUnstable() const
QString moduleName() const
const QString & errorReason() const
QMap< QString, QVariant > m_properties
QString moduleFilePathPart() const
QString manual() const
QVariant property(const QString &name) const