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 QString manual();
31
32 bool isValid() const;
33
34 QString statusText();
35
36 inline const QString& errorReason() const
37 {
38 return m_errorReason;
39 }
40
41 inline bool isEnabled() const
42 {
43 return m_enabled;
44 }
45
46 inline bool isBroken() const
47 {
48 return m_broken;
49 }
50
51 inline bool isUnstable() const
52 {
53 return m_unstable;
54 }
55
56 QString name() const
57 {
58 return m_name;
59 }
60
61 QString moduleName() const
62 {
63 return m_moduleName;
64 }
65
66 QString desktopFilePath() const
67 {
68 return m_desktopFilePath;
69 }
70
71 QVariant property(const QString &name) const
72 {
73 return m_properties.value(name, "");
74 }
75
76 QString comment() const
77 {
78 return m_comment;
79 }
80
81private:
82 friend class PythonPluginManager;
83
85 m_properties["X-Python-Dependencies"] = QStringList();
86 }
87
89 bool m_enabled{false};
90 bool m_broken{false};
91 bool m_unstable{false};
92 bool m_loaded{false};
93
94 QString m_name;
95 QString m_moduleName;
97 QString m_comment;
98 QString m_manualPath;
99 QString m_manual;
100
101 QMap<QString, QVariant> m_properties;
102};
103
108class PythonPluginManager : public QObject
109{
110 Q_OBJECT
111
112public:
114
115 const QList<PythonPlugin>& plugins() const;
116 PythonPlugin *plugin(int index);
117
118 void scanPlugins();
120 void setPluginEnabled(PythonPlugin &plugin, bool enabled);
121
123
124public Q_SLOTS:
125 void unloadAllModules();
126
127private:
130
131 static bool verifyModuleExists(PythonPlugin &);
133 static QPair<QString, PyKrita::version_checker> parseDependency(const QString&);
134
136
138};
139
140#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
QString desktopFilePath() const
const QString & errorReason() const
QMap< QString, QVariant > m_properties
QString moduleFilePathPart() const
QVariant property(const QString &name) const