Changeset View
Changeset View
Standalone View
Standalone View
shell/scripting/widget.h
Show All 15 Lines | |||||
16 | * Free Software Foundation, Inc., | 16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #ifndef WIDGET | 20 | #ifndef WIDGET | ||
21 | #define WIDGET | 21 | #define WIDGET | ||
22 | 22 | | |||
23 | #include <QWeakPointer> | 23 | #include <QWeakPointer> | ||
24 | #include <QJSValue> | ||||
24 | 25 | | |||
25 | #include "applet.h" | 26 | #include "applet.h" | ||
26 | 27 | | |||
27 | namespace Plasma | 28 | namespace Plasma | ||
28 | { | 29 | { | ||
29 | class Applet; | 30 | class Applet; | ||
30 | } // namespace Plasma | 31 | } // namespace Plasma | ||
31 | 32 | | |||
32 | namespace WorkspaceScripting | 33 | namespace WorkspaceScripting | ||
33 | { | 34 | { | ||
34 | 35 | | |||
35 | class Widget : public Applet | 36 | class Widget : public Applet | ||
36 | { | 37 | { | ||
37 | Q_OBJECT | 38 | Q_OBJECT | ||
38 | Q_PROPERTY(QString type READ type) | 39 | Q_PROPERTY(QString type READ type) | ||
39 | Q_PROPERTY(QString version READ version) | 40 | Q_PROPERTY(QString version READ version) | ||
40 | Q_PROPERTY(int id READ id) | 41 | Q_PROPERTY(int id READ id) | ||
41 | Q_PROPERTY(QStringList configKeys READ configKeys) | 42 | Q_PROPERTY(QStringList configKeys READ configKeys) | ||
42 | Q_PROPERTY(QStringList configGroups READ configGroups) | 43 | Q_PROPERTY(QStringList configGroups READ configGroups) | ||
43 | Q_PROPERTY(QStringList globalConfigKeys READ globalConfigKeys) | 44 | Q_PROPERTY(QStringList globalConfigKeys READ globalConfigKeys) | ||
44 | Q_PROPERTY(QStringList globalConfigGroups READ globalConfigGroups) | 45 | Q_PROPERTY(QStringList globalConfigGroups READ globalConfigGroups) | ||
45 | Q_PROPERTY(int index WRITE setIndex READ index) | 46 | Q_PROPERTY(int index WRITE setIndex READ index) | ||
46 | Q_PROPERTY(QRectF geometry WRITE setGeometry READ geometry) | 47 | //We pass our js based QRect wrapper instead of a simple QRectF | ||
48 | Q_PROPERTY(QJSValue geometry WRITE setGeometry READ geometry) | ||||
47 | Q_PROPERTY(QStringList currentConfigGroup WRITE setCurrentConfigGroup READ currentConfigGroup) | 49 | Q_PROPERTY(QStringList currentConfigGroup WRITE setCurrentConfigGroup READ currentConfigGroup) | ||
48 | Q_PROPERTY(QString globalShortcut WRITE setGlobalShortcut READ globalShorcut) | 50 | Q_PROPERTY(QString globalShortcut WRITE setGlobalShortcut READ globalShorcut) | ||
49 | Q_PROPERTY(bool locked READ locked WRITE setLocked) | 51 | Q_PROPERTY(bool locked READ locked WRITE setLocked) | ||
50 | 52 | | |||
51 | public: | 53 | public: | ||
52 | explicit Widget(Plasma::Applet *applet, QObject *parent = nullptr); | 54 | explicit Widget(Plasma::Applet *applet, QObject *parent = nullptr); | ||
53 | ~Widget() override; | 55 | ~Widget() override; | ||
54 | 56 | | |||
55 | uint id() const; | 57 | uint id() const; | ||
56 | QString type() const; | 58 | QString type() const; | ||
57 | 59 | | |||
58 | int index() const; | 60 | int index() const; | ||
59 | void setIndex(int index); | 61 | void setIndex(int index); | ||
60 | 62 | | |||
61 | QRectF geometry() const; | 63 | QJSValue geometry() const; | ||
62 | void setGeometry(const QRectF &geometry); | 64 | void setGeometry(const QJSValue &geometry); | ||
63 | 65 | | |||
64 | void setGlobalShortcut(const QString &shortcut); | 66 | void setGlobalShortcut(const QString &shortcut); | ||
65 | QString globalShorcut() const; | 67 | QString globalShorcut() const; | ||
66 | 68 | | |||
67 | Plasma::Applet *applet() const override; | 69 | Plasma::Applet *applet() const override; | ||
68 | 70 | | |||
69 | public Q_SLOTS: | 71 | public Q_SLOTS: | ||
70 | void remove(); | 72 | void remove(); | ||
71 | void showConfigurationInterface(); | 73 | void showConfigurationInterface(); | ||
72 | 74 | | |||
73 | // from the applet interface | | |||
74 | QVariant readConfig(const QString &key, const QVariant &def = QString()) const override { return Applet::readConfig(key, def); } | | |||
75 | void writeConfig(const QString &key, const QVariant &value) override { Applet::writeConfig(key, value); } | | |||
76 | | ||||
77 | QVariant readGlobalConfig(const QString &key, const QVariant &def = QString()) const override { return Applet::readGlobalConfig(key, def); } | | |||
78 | void writeGlobalConfig(const QString &key, const QVariant &value) override { Applet::writeGlobalConfig(key, value); } | | |||
79 | | ||||
80 | void reloadConfig() override { Applet::reloadConfig(); } | | |||
81 | | ||||
82 | private: | 75 | private: | ||
83 | class Private; | 76 | class Private; | ||
84 | Private * const d; | 77 | Private * const d; | ||
85 | }; | 78 | }; | ||
86 | 79 | | |||
87 | } | 80 | } | ||
88 | 81 | | |||
89 | #endif | 82 | #endif | ||
90 | 83 | |