1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the Qt Designer of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
21 | ** included in the packaging of this file. Please review the following |
22 | ** information to ensure the GNU General Public License requirements will |
23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
24 | ** |
25 | ** $QT_END_LICENSE$ |
26 | ** |
27 | ****************************************************************************/ |
28 | |
29 | // |
30 | // W A R N I N G |
31 | // ------------- |
32 | // |
33 | // This file is not part of the Qt API. It exists for the convenience |
34 | // of Qt Designer. This header |
35 | // file may change from version to version without notice, or even be removed. |
36 | // |
37 | // We mean it. |
38 | // |
39 | |
40 | #ifndef PLUGINMANAGER_H |
41 | #define PLUGINMANAGER_H |
42 | |
43 | #include "shared_global_p.h" |
44 | #include "shared_enums_p.h" |
45 | |
46 | #include <QtCore/qshareddata.h> |
47 | #include <QtCore/qmap.h> |
48 | #include <QtCore/qpair.h> |
49 | #include <QtCore/qobject.h> |
50 | #include <QtCore/qstringlist.h> |
51 | |
52 | QT_BEGIN_NAMESPACE |
53 | |
54 | class QDesignerFormEditorInterface; |
55 | class QDesignerCustomWidgetInterface; |
56 | class QDesignerPluginManagerPrivate; |
57 | |
58 | class QDesignerCustomWidgetSharedData; |
59 | |
60 | /* Information contained in the Dom XML of a custom widget. */ |
61 | class QDESIGNER_SHARED_EXPORT QDesignerCustomWidgetData { |
62 | public: |
63 | // StringPropertyType: validation mode and translatable flag. |
64 | typedef QPair<qdesigner_internal::TextPropertyValidationMode, bool> StringPropertyType; |
65 | |
66 | explicit QDesignerCustomWidgetData(const QString &pluginPath = QString()); |
67 | |
68 | enum ParseResult { ParseOk, ParseWarning, ParseError }; |
69 | ParseResult parseXml(const QString &xml, const QString &name, QString *errorMessage); |
70 | |
71 | QDesignerCustomWidgetData(const QDesignerCustomWidgetData&); |
72 | QDesignerCustomWidgetData& operator=(const QDesignerCustomWidgetData&); |
73 | ~QDesignerCustomWidgetData(); |
74 | |
75 | bool isNull() const; |
76 | |
77 | QString pluginPath() const; |
78 | |
79 | // Data as parsed from the widget's domXML(). |
80 | QString xmlClassName() const; |
81 | // Optional. The language the plugin is supposed to be used with. |
82 | QString xmlLanguage() const; |
83 | // Optional. method used to add pages to a container with a container extension |
84 | QString xmlAddPageMethod() const; |
85 | // Optional. Base class |
86 | QString xmlExtends() const; |
87 | // Optional. The name to be used in the widget box. |
88 | QString xmlDisplayName() const; |
89 | // Type of a string property |
90 | bool xmlStringPropertyType(const QString &name, StringPropertyType *type) const; |
91 | // Custom tool tip of property |
92 | QString propertyToolTip(const QString &name) const; |
93 | |
94 | private: |
95 | QSharedDataPointer<QDesignerCustomWidgetSharedData> m_d; |
96 | }; |
97 | |
98 | class QDESIGNER_SHARED_EXPORT QDesignerPluginManager: public QObject |
99 | { |
100 | Q_OBJECT |
101 | public: |
102 | using CustomWidgetList = QList<QDesignerCustomWidgetInterface *>; |
103 | |
104 | explicit QDesignerPluginManager(QDesignerFormEditorInterface *core); |
105 | ~QDesignerPluginManager() override; |
106 | |
107 | QDesignerFormEditorInterface *core() const; |
108 | |
109 | QObject *instance(const QString &plugin) const; |
110 | |
111 | QStringList registeredPlugins() const; |
112 | |
113 | QStringList findPlugins(const QString &path); |
114 | |
115 | QStringList pluginPaths() const; |
116 | void setPluginPaths(const QStringList &plugin_paths); |
117 | |
118 | QStringList disabledPlugins() const; |
119 | void setDisabledPlugins(const QStringList &disabled_plugins); |
120 | |
121 | QStringList failedPlugins() const; |
122 | QString failureReason(const QString &pluginName) const; |
123 | |
124 | QObjectList instances() const; |
125 | |
126 | CustomWidgetList registeredCustomWidgets() const; |
127 | QDesignerCustomWidgetData customWidgetData(QDesignerCustomWidgetInterface *w) const; |
128 | QDesignerCustomWidgetData customWidgetData(const QString &className) const; |
129 | |
130 | bool registerNewPlugins(); |
131 | |
132 | public slots: |
133 | bool syncSettings(); |
134 | void ensureInitialized(); |
135 | |
136 | private: |
137 | void updateRegisteredPlugins(); |
138 | void registerPath(const QString &path); |
139 | void registerPlugin(const QString &plugin); |
140 | |
141 | private: |
142 | static QStringList defaultPluginPaths(); |
143 | |
144 | QDesignerPluginManagerPrivate *m_d; |
145 | }; |
146 | |
147 | QT_END_NAMESPACE |
148 | |
149 | #endif // PLUGINMANAGER_H |
150 | |