1 /*
2     SPDX-FileCopyrightText: 2009 Aaron Seigo <aseigo@kde.org>
3 
4     SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include <QJSValue>
10 #include <QWeakPointer>
11 
12 #include "applet.h"
13 
14 namespace Plasma
15 {
16 class Containment;
17 } // namespace Plasma
18 
19 class ShellCorona;
20 
21 namespace WorkspaceScripting
22 {
23 class ScriptEngine;
24 
25 class Containment : public Applet
26 {
27     Q_OBJECT
28     /// FIXME: add NOTIFY
29     Q_PROPERTY(QString version READ version)
30     Q_PROPERTY(QStringList configKeys READ configKeys)
31     Q_PROPERTY(QStringList configGroups READ configGroups)
32     Q_PROPERTY(QStringList globalConfigKeys READ globalConfigKeys)
33     Q_PROPERTY(QStringList globalConfigGroups READ globalConfigGroups)
34     Q_PROPERTY(QStringList currentConfigGroup WRITE setCurrentConfigGroup READ currentConfigGroup)
35     Q_PROPERTY(QString wallpaperPlugin READ wallpaperPlugin WRITE setWallpaperPlugin)
36     Q_PROPERTY(QString wallpaperMode READ wallpaperMode WRITE setWallpaperMode)
37     Q_PROPERTY(bool locked READ locked WRITE setLocked)
38     Q_PROPERTY(QString type READ type)
39     Q_PROPERTY(QString formFactor READ formFactor)
40     Q_PROPERTY(QList<int> widgetIds READ widgetIds)
41     Q_PROPERTY(int screen READ screen)
42     Q_PROPERTY(int id READ id)
43 
44 public:
45     explicit Containment(Plasma::Containment *containment, ScriptEngine *parent);
46     ~Containment() override;
47 
48     uint id() const;
49     QString type() const;
50     QString formFactor() const;
51     QList<int> widgetIds() const;
52 
53     int screen() const;
54 
55     Plasma::Applet *applet() const override;
56     Plasma::Containment *containment() const;
57 
58     QString wallpaperPlugin() const;
59     void setWallpaperPlugin(const QString &wallpaperPlugin);
60     QString wallpaperMode() const;
61     void setWallpaperMode(const QString &wallpaperMode);
62 
63     Q_INVOKABLE QJSValue widgetById(const QJSValue &paramId = QJSValue()) const;
64     Q_INVOKABLE QJSValue
65     addWidget(const QJSValue &v = QJSValue(), qreal x = -1, qreal y = -1, qreal w = -1, qreal h = -1, const QVariantList &args = QVariantList());
66     Q_INVOKABLE QJSValue widgets(const QString &widgetType = QString()) const;
67 
68 public Q_SLOTS:
69     void remove();
70     void showConfigurationInterface();
71 
72 protected:
73     ShellCorona *corona() const;
74 
75 private:
76     class Private;
77     Private *const d;
78 };
79 
80 }
81