Plasma

appletscript.cpp
1 /*
2  SPDX-FileCopyrightText: 2007 Aaron Seigo <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "scripting/appletscript.h"
8 
9 #include "kconfig.h"
10 
11 #include "applet.h"
12 #if PLASMA_BUILD_DEPRECATED_SINCE(5, 83)
13 #include "package.h"
14 #endif
15 #include "private/applet_p.h"
16 
17 namespace Plasma
18 {
19 class AppletScriptPrivate
20 {
21 public:
22  Applet *applet;
23 };
24 
26  : ScriptEngine(parent)
27  , d(new AppletScriptPrivate)
28 {
29  d->applet = nullptr;
30 }
31 
32 AppletScript::~AppletScript()
33 {
34  delete d;
35 }
36 
38 {
39  d->applet = applet;
40 }
41 
43 {
44  Q_ASSERT(d->applet);
45  return d->applet;
46 }
47 
49 {
50  Q_UNUSED(constraints);
51 }
52 
54 {
55  return QList<QAction *>();
56 }
57 
59 {
60  if (applet()) {
61  applet()->setHasConfigurationInterface(hasInterface);
62  }
63 }
64 
65 void AppletScript::setConfigurationRequired(bool req, const QString &reason)
66 {
67  if (applet()) {
68  applet()->setConfigurationRequired(req, reason);
69  }
70 }
71 
73 {
74  if (applet()) {
75  applet()->setLaunchErrorMessage(reason);
76  }
77 }
78 
80 {
81  if (applet()) {
83  }
84 }
85 
87 {
88 }
89 
91 {
92  Q_ASSERT(d->applet);
93  return d->applet->filePath("mainscript");
94 }
95 
96 #if PLASMA_BUILD_DEPRECATED_SINCE(5, 83)
98 {
99  Q_ASSERT(d->applet);
100  return d->applet->package();
101 }
102 #endif
103 
104 #if PLASMA_BUILD_DEPRECATED_SINCE(5, 81)
106 {
107  Q_ASSERT(d->applet);
108  return d->applet->pluginInfo();
109 }
110 #endif
111 
113 {
114  Q_ASSERT(d->applet);
115  Plasma::Containment *cont = qobject_cast<Plasma::Containment *>(d->applet);
116  if (cont) {
117  return cont->containmentType();
118  } else {
120  }
121 }
122 
124 {
125  Q_ASSERT(d->applet);
126  Plasma::Containment *cont = qobject_cast<Plasma::Containment *>(d->applet);
127  if (cont) {
128  cont->setContainmentType(type);
129  }
130 }
131 
132 } // Plasma namespace
133 
134 #include "moc_appletscript.cpp"
void setHasConfigurationInterface(bool hasInterface)
Sets whether or not this script has a configuration interface or not.
Namespace for everything in libplasma.
Definition: datamodel.cpp:14
void setLaunchErrorMessage(const QString &reason=QString())
The base class for scripting interfaces to be used in loading plasmoids of a given language.
Definition: scriptengine.h:37
Q_EMITQ_EMIT
Package package() const override
void configNeedsSaving()
Emitted when an applet has changed values in its configuration and wishes for them to be saved at the...
QString mainScript() const override
void setConfigurationRequired(bool needsConfiguring, const QString &reason=QString())
When the applet needs to be configured before being usable, this method can be called to show a stand...
Definition: applet.cpp:561
@ NoContainmentType
Definition: plasma.h:115
virtual QList< QAction * > contextualActions()
Returns a list of context-related QAction instances.
void setContainmentType(Plasma::Types::ContainmentType type)
Plasma::Applet * applet() const
Returns the Plasma::Applet associated with this script component.
AppletScript(QObject *parent=nullptr)
Default constructor for an AppletScript.
void configNeedsSaving() const
ContainmentType
This enumeration describes the type of the Containment.
Definition: plasma.h:114
Plasma::Types::ContainmentType containmentType() const
void setConfigurationRequired(bool req, const QString &reason=QString())
virtual void constraintsEvent(Plasma::Types::Constraints constraints)
Called when any of the geometry constraints have been updated.
void setHasConfigurationInterface(bool hasInterface)
Sets whether or not this applet provides a user interface for configuring the applet.
Definition: applet.cpp:802
void setLaunchErrorMessage(const QString &reason=QString())
Call this method when the applet fails to launch properly.
Definition: applet.cpp:246
virtual void configChanged()
Configure was changed.
object representing an installed Plasma package
Definition: package.h:76
void setApplet(Plasma::Applet *applet)
Sets the applet associated with this AppletScript.
The base class for plugins that provide backgrounds and applet grouping containers.
Definition: containment.h:45
The base Applet class.
Definition: applet.h:71
KPluginInfo description() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Feb 7 2023 04:15:01 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.