-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPluginLoader.h
137 lines (118 loc) · 3.51 KB
/
PluginLoader.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#ifndef PLUGINLOADER_H
#define PLUGINLOADER_H
#include <deadbeef/deadbeef.h>
#include <QtWidgets>
#include <QAction>
#include <QQuickWidget>
#include <QQmlImageProviderBase>
#include "DBApi.h"
#include "DefaultPlugins.h"
extern DBApi *api;
extern QStringList default_plugins;
class PluginLoader;
class LoadedWidget : public QObject{
Q_OBJECT
public:
LoadedWidget(DBWidgetInfo &wi, PluginLoader *pl);
~LoadedWidget();
void setMovable(bool state);
void setMain(bool value);
void setVisible(bool visible);
// Default widget info (read-only)
const DBWidgetInfo header;
// instance of same plugin
quint32 instance;
// Properties:
// friendlyName - Widget friendly name
// internalName - Widget internal name
// empty titlebar, used for dockable widgets, internal use only (to show/hide titlebar)
QWidget *empty_titlebar_toolbar;
QWidget *widget;
// can be toolbar
QWidget *true_parent;
};
// General Qt Quick widget encapsulation
class DBQuickWidget : public QQuickWidget, DBWidget {
Q_OBJECT
public:
DBQuickWidget(QWidget *parent, DBApi *api, QString source);
protected:
void resizeEvent(QResizeEvent *) override;
};
class PluginLoader : public QObject{
Q_OBJECT
public:
PluginLoader ();
~PluginLoader();
// loads all widgets from config
// to be called by MainWindow
void RestoreWidgets(QMainWindow *parent);
public:
//// widgetLibrary
//
// Add new widget to database
// Called by every external plugin (registerWidget function)
void widgetLibraryAppend(DBWidgetInfo *);
// Add new quick widget to database
void widgetLibraryAppend(QString url);
protected:
// get widget info from database
DBWidgetInfo *widgetLibraryGet(int num);
DBWidgetInfo *widgetLibraryGet(const QString);
int widgetLibraryGetNum(const QString);
//// loadedWidgets
//
// loads Widget from library
// supports multiple instances
int loadFromWidgetLibrary(int num);
public:
// widgetLibrary (copy)
QList<DBWidgetInfo *> getWidgetLibrary();
// widgets (remember to free)
QList<DBWidgetInfo>* getWidgets();
// widget at
DBWidgetInfo getWidgetAt(int num);
DBWidgetInfo getWidget(QString internalName);
// Main Widget list
QStringList getMainWidgets();
// get total amount of instances for a specific widget
quint32 getTotalInstances(QString name);
// get current mainwidget (internalName)
QString getMainWidget();
private:
// list of widgets that can be added
QList<DBWidgetInfo *> widgetLibrary;
// list of widgets that have been loaded
QList<LoadedWidget *> loadedWidgets;
// Default plugins list
DefaultPlugins dp;
// design mode on/off
bool areWidgetsLocked;
// current main widget selected
LoadedWidget *mainWidget = nullptr;
// pointer to mainWindow, if needed
QMainWindow *mainWindow = nullptr;
int statusBarCount = 0;
public slots:
// load widget
int addWidget(int num);
int addWidget(QString internalName);
// unload widget
int removeWidget(int num);
int removeWidget(QString internalName);
// Sorts widgetLibrary in alphabetic order
void widgetLibrarySort();
// lock widgets toggle
void setDesignMode(bool on);
//
int setMainWidget(QString internalName);
//
void setVisible(QString internalName, bool state);
signals:
//
void widgetAdded(int num);
void widgetRemoved(QString);
void widgetLibraryAdded(DBWidgetInfo i);
};
//}
#endif // PLUGINLOADER_H