Plasma

scriptengine.h
1 /*
2  SPDX-FileCopyrightText: 2007 Aaron Seigo <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #ifndef PLASMA_SCRIPTENGINE_H
8 #define PLASMA_SCRIPTENGINE_H
9 
10 #include <plasma/plasma.h>
11 #include <plasma/plasma_export.h>
12 #if PLASMA_ENABLE_DEPRECATED_SINCE(5, 94)
13 #include <plasma/package.h>
14 #endif
15 
16 #include <QObject>
17 #include <QRect>
18 #include <QSizeF>
19 
20 class QPainter;
21 
22 namespace Plasma
23 {
24 class Applet;
25 class AppletScript;
26 class DataEngine;
27 class DataEngineScript;
28 class ScriptEnginePrivate;
29 
30 /**
31  * @class ScriptEngine plasma/scripting/scriptengine.h <Plasma/Scripting/ScriptEngine>
32  *
33  * @short The base class for scripting interfaces to be used in loading
34  * plasmoids of a given language.
35  **/
36 
37 class PLASMA_EXPORT ScriptEngine : public QObject
38 {
39  Q_OBJECT
40 
41 public:
42  ~ScriptEngine() override;
43 
44  /**
45  * Called when it is safe to initialize the internal state of the engine
46  */
47  virtual bool init();
48 
49 protected:
50  explicit ScriptEngine(QObject *parent = nullptr);
51 
52  /**
53  * @return absolute path to the main script file for this plasmoid
54  */
55  virtual QString mainScript() const;
56 
57 #if PLASMA_BUILD_DEPRECATED_SINCE(5, 83)
58  /**
59  * @return the Package associated with this plasmoid which can
60  * be used to request resources, such as images and
61  * interface files.
62  * @deprecated Since 5.83 Use kpackage API instead
63  */
64  PLASMA_DEPRECATED_VERSION(5, 83, "Use kpackage API instead")
65  virtual Package package() const;
66 #endif
67 
68 private:
69  ScriptEnginePrivate *const d;
70 };
71 
72 /**
73  * @param types a set of ComponentTypes flags for which to look up the
74  * language support for
75  * @return a list of all supported languages for the given type(s).
76  **/
78 
79 /**
80  * Loads an Applet script engine for the given language.
81  *
82  * @param language the language to load for
83  * @param applet the Plasma::Applet for this script
84  * @return pointer to the AppletScript or 0 on failure; the caller is responsible
85  * for the return object which will be parented to the Applet
86  **/
87 PLASMA_EXPORT AppletScript *loadScriptEngine(const QString &language, Applet *applet, const QVariantList &args);
88 
89 /**
90  * Loads an DataEngine script engine for the given language.
91  *
92  * @param language the language to load for
93  * @param dataEngine the Plasma::DataEngine for this script;
94  * @return pointer to the DataEngineScript or 0 on failure; the caller is responsible
95  * for the return object which will be parented to the DataEngine
96  **/
97 PLASMA_EXPORT DataEngineScript *loadScriptEngine(const QString &language, DataEngine *dataEngine, const QVariantList &args);
98 
99 } // namespace Plasma
100 
101 #endif
Provides a restricted interface for scripting a DataEngine.
Data provider for plasmoids (Plasma plugins)
Definition: dataengine.h:50
Namespace for everything in libplasma.
Definition: datamodel.cpp:14
The base class for scripting interfaces to be used in loading plasmoids of a given language.
Definition: scriptengine.h:37
QCA_EXPORT void init()
Provides a restricted interface for scripted applets.
Definition: appletscript.h:35
AppletScript * loadScriptEngine(const QString &language, Applet *applet, const QVariantList &args)
Loads an Applet script engine for the given language.
QStringList knownLanguages(Types::ComponentTypes types)
object representing an installed Plasma package
Definition: package.h:76
The base Applet class.
Definition: applet.h:71
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Feb 5 2023 04:14:15 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.