Plasma

containment.cpp
1 /*
2  SPDX-FileCopyrightText: 2007 Aaron Seigo <[email protected]>
3  SPDX-FileCopyrightText: 2008 Ménard Alexis <[email protected]>
4  SPDX-FileCopyrightText: 2009 Chani Armitage <[email protected]>
5  SPDX-FileCopyrightText: 2012 Marco Martin <[email protected]>
6 
7  SPDX-License-Identifier: LGPL-2.0-or-later
8 */
9 
10 #include "containment.h"
11 #include "private/containment_p.h"
12 
13 #include "config-plasma.h"
14 
15 #include <QClipboard>
16 #include <QContextMenuEvent>
17 #include <QDebug>
18 #include <QFile>
19 #include <QMimeData>
20 #include <QMimeDatabase>
21 #include <QPainter>
22 #include <QTemporaryFile>
23 
24 #include <KAuthorized>
25 #include <KConfigLoader>
26 #include <KConfigSkeleton>
27 #include <KLocalizedString>
28 
29 #include "containmentactions.h"
30 #include "corona.h"
31 #include "debug_p.h"
32 #include "pluginloader.h"
33 
34 #include "private/applet_p.h"
35 
36 #include "plasma/plasma.h"
37 
38 namespace Plasma
39 {
40 Containment::Containment(QObject *parentObject, const KPluginMetaData &data, const QVariantList &args)
41  : Applet(parentObject, data, args)
42  , d(new ContainmentPrivate(this))
43 {
44  // WARNING: do not access config() OR globalConfig() in this method!
45  // that requires a scene, which is not available at this point
47 }
48 
49 #if PLASMA_BUILD_DEPRECATED_SINCE(5, 86)
50 Containment::Containment(QObject *parent, const QString &serviceId, uint containmentId)
51  : Applet(parent, serviceId, containmentId)
52  , d(new ContainmentPrivate(this))
53 {
54  // WARNING: do not access config() OR globalConfig() in this method!
55  // that requires a scene, which is not available at this point
58 }
59 
60 Containment::Containment(QObject *parent, const QVariantList &args)
61  : Applet(parent, args)
62  , d(new ContainmentPrivate(this))
63 {
64  // WARNING: do not access config() OR globalConfig() in this method!
65  // that requires a scene, which is not available at this point
67 }
68 
69 Containment::Containment(const KPluginMetaData &md, uint appletId)
70  : Applet(md, nullptr, appletId)
71  , d(new ContainmentPrivate(this))
72 {
73  // WARNING: do not access config() OR globalConfig() in this method!
74  // that requires a scene, which is not available at this point
76 }
77 #endif
78 
79 Containment::~Containment()
80 {
81  qDeleteAll(d->localActionPlugins);
82  delete d;
83 }
84 
86 {
87  Applet::init();
88  static_cast<Applet *>(this)->d->setupScripting();
89 
90  if (d->type == Types::NoContainmentType) {
91  // setContainmentType(Plasma::Types::DesktopContainment);
92  // Try to determine the containment type. It must be done as soon as possible
93  QString type = pluginMetaData().value(QStringLiteral("X-Plasma-ContainmentType"));
94 
95  if (type == QLatin1String("Panel")) {
97  } else if (type == QLatin1String("Custom")) {
99  } else if (type == QLatin1String("CustomPanel")) {
101  // default to desktop
102  } else {
104  }
105  }
106 
107  // connect actions
108  ContainmentPrivate::addDefaultActions(actions(), this);
109  bool unlocked = immutability() == Types::Mutable;
110 
111  // fix the text of the actions that need title()
112  // btw, do we really want to use title() when it's a desktopcontainment?
113  QAction *closeApplet = actions()->action(QStringLiteral("remove"));
114  if (closeApplet) {
115  closeApplet->setText(i18nc("%1 is the name of the applet", "Remove %1", title()));
116  }
117 
118  QAction *configAction = actions()->action(QStringLiteral("configure"));
119  if (configAction) {
120  if (d->type == Types::PanelContainment || d->type == Types::CustomPanelContainment) {
121  configAction->setText(i18n("Enter Edit Mode"));
122  configAction->setIcon(QIcon::fromTheme(QStringLiteral("document-edit")));
123  } else {
124  configAction->setText(i18nc("%1 is the name of the applet", "Configure %1...", title()));
125  }
126  }
127 
128  QAction *appletBrowserAction = actions()->action(QStringLiteral("add widgets"));
129  if (appletBrowserAction) {
130  appletBrowserAction->setVisible(unlocked);
131  appletBrowserAction->setEnabled(unlocked);
132  connect(appletBrowserAction, SIGNAL(triggered()), this, SLOT(triggerShowAddWidgets()));
133  }
134 
135  if (immutability() != Types::SystemImmutable && corona()) {
136  QAction *lockDesktopAction = corona()->actions()->action(QStringLiteral("lock widgets"));
137  // keep a pointer so nobody notices it moved to corona
138  if (lockDesktopAction) {
139  actions()->addAction(QStringLiteral("lock widgets"), lockDesktopAction);
140  }
141  }
142 
143  // HACK: this is valid only in the systray case
145  if (Plasma::Applet *p = qobject_cast<Plasma::Applet *>(parent())) {
146  Q_EMIT p->containment()->configureRequested(a);
147  }
148  });
149 }
150 
151 // helper function for sorting the list of applets
152 bool appletConfigLessThan(const KConfigGroup &c1, const KConfigGroup &c2)
153 {
154  int i1 = c1.readEntry("id", 0);
155  int i2 = c2.readEntry("id", 0);
156 
157  return (i1 < i2);
158 }
159 
161 {
162  /*
163  #ifndef NDEBUG
164  // qCDebug(LOG_PLASMA) << "!!!!!!!!!!!!initConstraints" << group.name() << d->type;
165  // qCDebug(LOG_PLASMA) << " location:" << group.readEntry("location", (int)d->location);
166  // qCDebug(LOG_PLASMA) << " geom:" << group.readEntry("geometry", geometry());
167  // qCDebug(LOG_PLASMA) << " formfactor:" << group.readEntry("formfactor", (int)d->formFactor);
168  // qCDebug(LOG_PLASMA) << " screen:" << group.readEntry("screen", d->screen);
169  #endif
170  */
171  setLocation((Plasma::Types::Location)group.readEntry("location", (int)d->location));
172  setFormFactor((Plasma::Types::FormFactor)group.readEntry("formfactor", (int)d->formFactor));
173  d->lastScreen = group.readEntry("lastScreen", d->lastScreen);
174 
175  setWallpaper(group.readEntry("wallpaperplugin", ContainmentPrivate::defaultWallpaper));
176 
177  d->activityId = group.readEntry("activityId", QString());
178 
180  restoreContents(group);
181  setImmutability((Types::ImmutabilityType)group.readEntry("immutability", (int)Types::Mutable));
182 
183  if (isContainment() && KAuthorized::authorize(QStringLiteral("plasma/containment_actions"))) {
184  KConfigGroup cfg = KConfigGroup(corona()->config(), "ActionPlugins");
186 
187  // qCDebug(LOG_PLASMA) << cfg.keyList();
188  if (cfg.exists()) {
189  const auto keyList = cfg.keyList();
190  for (const QString &key : keyList) {
191  // qCDebug(LOG_PLASMA) << "loading" << key;
192  setContainmentActions(key, cfg.readEntry(key, QString()));
193  }
194  } else { // shell defaults
195  KConfigGroup defaultActionsCfg;
196 
197  switch (d->type) {
199  /* fall through*/
201  defaultActionsCfg = KConfigGroup(KSharedConfig::openConfig(corona()->kPackage().filePath("defaults")), "Panel");
202  break;
204  defaultActionsCfg = KConfigGroup(KSharedConfig::openConfig(corona()->kPackage().filePath("defaults")), "Desktop");
205  break;
206  default:
207  // for any other type of containment, there are no defaults
208  break;
209  }
210  if (defaultActionsCfg.isValid()) {
211  defaultActionsCfg = KConfigGroup(&defaultActionsCfg, "ContainmentActions");
212  const auto keyList = defaultActionsCfg.keyList();
213  for (const QString &key : keyList) {
214  setContainmentActions(key, defaultActionsCfg.readEntry(key, QString()));
215  }
216  }
217  }
218  }
219  Applet::restore(group);
220 }
221 
223 {
224  if (Applet::d->transient) {
225  return;
226  }
227 
228  KConfigGroup group = g;
229  if (!group.isValid()) {
230  group = config();
231  }
232 
233  // locking is saved in Applet::save
234  Applet::save(group);
235 
236  // group.writeEntry("screen", d->screen);
237  group.writeEntry("lastScreen", d->lastScreen);
238  group.writeEntry("formfactor", (int)d->formFactor);
239  group.writeEntry("location", (int)d->location);
240  group.writeEntry("activityId", d->activityId);
241 
242  group.writeEntry("wallpaperplugin", d->wallpaper);
243 
244  saveContents(group);
245 }
246 
248 {
249  KConfigGroup applets(&group, "Applets");
250  for (const Applet *applet : std::as_const(d->applets)) {
251  KConfigGroup appletConfig(&applets, QString::number(applet->id()));
252  applet->save(appletConfig);
253  }
254 }
255 
257 {
258  KConfigGroup applets(&group, "Applets");
259 
260  // restore the applets ordered by id
261  QStringList groups = applets.groupList();
262  std::sort(groups.begin(), groups.end());
263 
264  // Sort the applet configs in order of geometry to ensure that applets
265  // are added from left to right or top to bottom for a panel containment
266  QList<KConfigGroup> appletConfigs;
267  for (const QString &appletGroup : std::as_const(groups)) {
268  // qCDebug(LOG_PLASMA) << "reading from applet group" << appletGroup;
269  KConfigGroup appletConfig(&applets, appletGroup);
270  appletConfigs.append(appletConfig);
271  }
272  std::stable_sort(appletConfigs.begin(), appletConfigs.end(), appletConfigLessThan);
273 
274  QMutableListIterator<KConfigGroup> it(appletConfigs);
275  while (it.hasNext()) {
276  KConfigGroup &appletConfig = it.next();
277  if (appletConfig.readEntry(QStringLiteral("transient"), false)) {
278  appletConfig.deleteGroup();
279  continue;
280  }
281  int appId = appletConfig.name().toUInt();
282  QString plugin = appletConfig.readEntry("plugin", QString());
283 
284  if (plugin.isEmpty()) {
285  continue;
286  }
287 
288  d->createApplet(plugin, QVariantList(), appId);
289  }
290 
291  // if there are no applets, none of them is "loading"
292  if (Containment::applets().isEmpty()) {
293  d->appletsUiReady = true;
294  }
295  const auto lstApplets = Containment::applets();
296  for (Applet *applet : lstApplets) {
297  if (!applet->pluginMetaData().isValid()) {
298  applet->updateConstraints(Plasma::Types::UiReadyConstraint);
299  }
300  }
301 }
302 
304 {
305  return d->type;
306 }
307 
309 {
310  if (d->type == type) {
311  return;
312  }
313 
314  d->type = type;
316 }
317 
319 {
320  if (Plasma::Corona *corona = qobject_cast<Corona *>(parent())) {
321  return corona;
322  // case in which this containment is child of an applet, hello systray :)
323  } else {
324  Plasma::Applet *parentApplet = qobject_cast<Plasma::Applet *>(parent());
325  if (parentApplet && parentApplet->containment()) {
326  return parentApplet->containment()->corona();
327  }
328  }
329 
330  return nullptr;
331 }
332 
334 {
335  if (d->formFactor == formFactor) {
336  return;
337  }
338 
339  // qCDebug(LOG_PLASMA) << "switching FF to " << formFactor;
340  d->formFactor = formFactor;
341 
343 
344  KConfigGroup c = config();
345  c.writeEntry("formfactor", (int)formFactor);
347  Q_EMIT formFactorChanged(formFactor);
348 }
349 
351 {
352  if (d->containmentDisplayHints == hints) {
353  return;
354  }
355 
356  d->containmentDisplayHints = hints;
357  Q_EMIT containmentDisplayHintsChanged(hints);
358 }
359 
361 {
362  if (d->location == location) {
363  return;
364  }
365 
366  d->location = location;
367 
368  for (Applet *applet : std::as_const(d->applets)) {
369  applet->updateConstraints(Plasma::Types::LocationConstraint);
370  }
371 
373 
374  KConfigGroup c = config();
375  c.writeEntry("location", (int)location);
377  Q_EMIT locationChanged(location);
378 }
379 
380 Applet *Containment::createApplet(const QString &name, const QVariantList &args)
381 {
382  Plasma::Applet *applet = d->createApplet(name, args);
383  if (applet) {
384  Q_EMIT appletCreated(applet);
385  }
386  return applet;
387 }
388 
390 {
391  if (!applet) {
392 #ifndef NDEBUG
393  // qCDebug(LOG_PLASMA) << "adding null applet!?!";
394 #endif
395  return;
396  }
397 
398  if (immutability() != Types::Mutable && !applet->property("org.kde.plasma:force-create").toBool()) {
399  return;
400  }
401 
402 #ifndef NDEBUG
403  if (d->applets.contains(applet)) {
404  // qCDebug(LOG_PLASMA) << "already have this applet!";
405  }
406 #endif
407 
408  Containment *currentContainment = applet->containment();
409 
410  if (currentContainment && currentContainment != this) {
411  Q_EMIT currentContainment->appletRemoved(applet);
412 
413  disconnect(applet, nullptr, currentContainment, nullptr);
414  connect(currentContainment, nullptr, applet, nullptr);
415  KConfigGroup oldConfig = applet->config();
416  currentContainment->d->applets.removeAll(applet);
417  applet->setParent(this);
418 
419  // now move the old config to the new location
420  // FIXME: this doesn't seem to get the actual main config group containing plugin=, etc
421  KConfigGroup c = config().group("Applets").group(QString::number(applet->id()));
422  oldConfig.reparent(&c);
423  applet->d->resetConfigurationObject();
424 
425  disconnect(applet, &Applet::activated, currentContainment, &Applet::activated);
426  // change the group to its configloader, if any
427  // FIXME: this is very, very brutal
428  if (applet->configScheme()) {
429  const QString oldGroupPrefix = QStringLiteral("Containments") + QString::number(currentContainment->id()) + QStringLiteral("Applets");
430  const QString newGroupPrefix = QStringLiteral("Containments") + QString::number(id()) + QStringLiteral("Applets");
431 
432  applet->configScheme()->setCurrentGroup(applet->configScheme()->currentGroup().replace(0, oldGroupPrefix.length(), newGroupPrefix));
433 
434  const auto items = applet->configScheme()->items();
435  for (KConfigSkeletonItem *item : items) {
436  item->setGroup(item->group().replace(0, oldGroupPrefix.length(), newGroupPrefix));
437  }
438  }
439  } else {
440  applet->setParent(this);
441  }
442 
443  // make sure the applets are sorted by id
444  auto position = std::lower_bound(d->applets.begin(), d->applets.end(), applet, [](Plasma::Applet *a1, Plasma::Applet *a2) {
445  return a1->id() < a2->id();
446  });
447  d->applets.insert(position, applet);
448 
449  if (!d->uiReady) {
450  d->loadingApplets << applet;
451  }
452 
454  connect(applet, SIGNAL(appletDeleted(Plasma::Applet *)), this, SLOT(appletDeleted(Plasma::Applet *)));
455  connect(applet, SIGNAL(statusChanged(Plasma::Types::ItemStatus)), this, SLOT(checkStatus(Plasma::Types::ItemStatus)));
456  connect(applet, &Applet::activated, this, &Applet::activated);
457  connect(this, &Containment::containmentDisplayHintsChanged, applet, &Applet::containmentDisplayHintsChanged);
458 
459  if (!currentContainment) {
460  const bool isNew = applet->d->mainConfigGroup()->entryMap().isEmpty();
461 
462  if (!isNew) {
463  applet->restore(*applet->d->mainConfigGroup());
464  }
465 
466  applet->init();
467  applet->d->setupScripting();
468 
469  if (isNew) {
470  applet->save(*applet->d->mainConfigGroup());
472  }
473  // FIXME: an on-appear animation would be nice to have again
474  }
475 
476  applet->updateConstraints(Plasma::Types::AllConstraints);
478 
479  Q_EMIT appletAdded(applet);
480 
481  if (!currentContainment) {
484  }
485 
486  applet->d->scheduleModificationNotification();
487 }
488 
490 {
491  return d->applets;
492 }
493 
495 {
496  Q_ASSERT(corona());
497  if (Corona *c = corona()) {
498  return c->screenForContainment(this);
499  } else {
500  return -1;
501  }
502 }
503 
505 {
506  return d->lastScreen;
507 }
508 
509 void Containment::setWallpaper(const QString &pluginName)
510 {
511  if (pluginName != d->wallpaper) {
512  d->wallpaper = pluginName;
513 
514  KConfigGroup cfg = config();
515  cfg.writeEntry("wallpaperplugin", d->wallpaper);
518  }
519 }
520 
521 QString Containment::wallpaper() const
522 {
523  return d->wallpaper;
524 }
525 
526 void Containment::setContainmentActions(const QString &trigger, const QString &pluginName)
527 {
528  KConfigGroup cfg = d->containmentActionsConfig();
529  ContainmentActions *plugin = nullptr;
530 
531  plugin = containmentActions().value(trigger);
532  if (plugin && plugin->metadata().pluginId() != pluginName) {
533  containmentActions().remove(trigger);
534  delete plugin;
535  plugin = nullptr;
536  }
537 
538  if (pluginName.isEmpty()) {
539  cfg.deleteEntry(trigger);
540  } else if (plugin) {
541  // it already existed, just reload config
542  plugin->setContainment(this); // to be safe
543  // FIXME make a truly unique config group
544  KConfigGroup pluginConfig = KConfigGroup(&cfg, trigger);
545  plugin->restore(pluginConfig);
546 
547  } else {
548  plugin = PluginLoader::self()->loadContainmentActions(this, pluginName);
549 
550  if (plugin) {
551  cfg.writeEntry(trigger, pluginName);
552  containmentActions().insert(trigger, plugin);
553  plugin->setContainment(this);
554  KConfigGroup pluginConfig = KConfigGroup(&cfg, trigger);
555  plugin->restore(pluginConfig);
556  } else {
557  // bad plugin... gets removed. is this a feature or a bug?
558  cfg.deleteEntry(trigger);
559  }
560  }
561 
563 }
564 
566 {
567  return d->localActionPlugins;
568 }
569 
570 bool Containment::isUiReady() const
571 {
572  return d->uiReady && d->appletsUiReady && Applet::d->started;
573 }
574 
575 void Containment::setActivity(const QString &activityId)
576 {
577  if (activityId.isEmpty() || d->activityId == activityId) {
578  return;
579  }
580 
581  d->activityId = activityId;
582  KConfigGroup c = config();
583  c.writeEntry("activityId", activityId);
584 
586  Q_EMIT activityChanged(activityId);
587 }
588 
590 {
591  return d->activityId;
592 }
593 
594 void Containment::reactToScreenChange()
595 {
596  int newScreen = screen();
597 
598  if (newScreen >= 0) {
599  d->lastScreen = newScreen;
600  KConfigGroup c = config();
601  c.writeEntry("lastScreen", d->lastScreen);
603  }
604 
605  Q_EMIT screenChanged(newScreen);
606 }
607 
608 } // Plasma namespace
609 
610 #include "moc_containment.cpp"
virtual void saveContents(KConfigGroup &group) const
Called when the contents of the containment should be saved.
void append(const T &value)
void restore(KConfigGroup &group) override
QAction * addAction(const QString &name, const QObject *receiver=nullptr, const char *member=nullptr)
void setFormFactor(Plasma::Types::FormFactor formFactor)
Sets the form factor for this Containment.
QString readEntry(const char *key, const char *aDefault=nullptr) const
void writeEntry(const char *key, const char *value, WriteConfigFlags pFlags=Normal)
void setWallpaper(const QString &pluginName)
Sets wallpaper plugin.
QAction * action(const QString &name) const
void appletAdded(Plasma::Applet *applet)
This signal is emitted when a new applet is added in the containment It may happen in the following s...
KConfigGroup config() const
Returns the KConfigGroup to access the applets configuration.
Definition: applet.cpp:270
virtual void save(KConfigGroup &group) const
Saves state information about this applet that will be accessed when next instantiated in the restore...
Definition: applet.cpp:178
void setCurrentGroup(const QString &group)
KActionCollection * actions() const
Returns the collection of actions for this Applet.
Definition: applet.cpp:705
ItemStatus
Status of an applet.
Definition: plasma.h:270
KConfigLoader * configScheme() const
Returns the config skeleton object from this applet's package, if any.
Definition: applet.cpp:319
@ LocationConstraint
The Location of an object.
Definition: plasma.h:42
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
Namespace for everything in libplasma.
Definition: datamodel.cpp:14
QString number(int n, int base)
void deleteEntry(const char *key, WriteConfigFlags pFlags=Normal)
KConfigSkeletonItem::List items() const
Q_EMITQ_EMIT
void appletCreated(Plasma::Applet *applet)
This signal is emitted when a new applet is created by the containment.
@ CustomContainment
A containment that is neither a desktop nor a panel but something application specific.
Definition: plasma.h:119
uint id() const
Definition: applet.cpp:173
KPluginMetaData pluginMetaData() const
Definition: applet.cpp:485
@ DesktopContainment
A desktop containment.
Definition: plasma.h:116
QIcon fromTheme(const QString &name)
bool isValid() const
void configNeedsSaving()
Emitted when an applet has changed values in its configuration and wishes for them to be saved at the...
Corona * corona() const
Returns the Corona (if any) that this Containment is hosted by.
ContainmentActions * loadContainmentActions(Containment *parent, const QString &containmentActionsName, const QVariantList &args=QVariantList())
Load a ContainmentActions plugin.
Containment * containment() const
Definition: applet.cpp:731
@ NoContainmentType
Definition: plasma.h:115
void statusChanged(Plasma::Types::ItemStatus status)
Emitted when the applet status changes.
void setImmutability(const Types::ImmutabilityType immutable)
Sets the immutability type for this applet (not immutable, user immutable or system immutable)
Definition: applet.cpp:527
FormFactor
The FormFactor enumeration describes how a Plasma::Applet should arrange itself.
Definition: plasma.h:72
void deleteGroup(const char *group, WriteConfigFlags flags=Normal)
virtual void restoreContents(KConfigGroup &group)
Called when the contents of the containment should be loaded.
KActionCollection * actions() const
The actions associated with this Corona.
Definition: corona.cpp:443
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
@ Mutable
The item can be modified in any way.
Definition: plasma.h:236
static KSharedConfig::Ptr openConfig(const QString &fileName=QString(), OpenFlags mode=FullConfig, QStandardPaths::StandardLocation type=QStandardPaths::GenericConfigLocation)
void setContainmentActions(const QString &trigger, const QString &pluginName)
Sets a containmentactions plugin.
void save(KConfigGroup &group) const override
void appletRemoved(Plasma::Applet *applet)
This signal is emitted when an applet is destroyed.
Plasma::Types::ContainmentType containmentType() const
Returns the type of containment.
The base ContainmentActions class.
void reparent(KConfigBase *parent, WriteConfigFlags pFlags=Normal)
bool exists() const
void setIcon(const QIcon &icon)
void containmentTypeChanged()
emitted when the containment type changed
QString i18n(const char *text, const TYPE &arg...)
KPluginMetaData metadata() const
bool hasNext() const const
void setContainmentDisplayHints(Plasma::Types::ContainmentDisplayHints hints)
Set Display hints that come from the containment that suggest the applet how to look and behave.
@ SystemImmutable
the item is locked down by the system, the user can't unlock it
Definition: plasma.h:239
@ CustomPanelContainment
A customized desktop panel.
Definition: plasma.h:121
A bookkeeping Scene for Plasma::Applets.
Definition: corona.h:27
virtual void init()
This method is called once the applet is loaded and added to a Corona.
Definition: applet.cpp:168
ContainmentType
This enumeration describes the type of the Containment.
Definition: plasma.h:114
bool isEmpty() const const
QString currentGroup() const
int length() const const
KPackage::Package kPackage() const
Accessor for the associated Package object if any.
Definition: applet.cpp:345
void setContainment(Containment *newContainment)
newContainment the containment the plugin should be associated with.
void setText(const QString &text)
KConfigGroup group(const char *group)
int lastScreen() const
@ StartupCompletedConstraint
application startup has completed
Definition: plasma.h:45
uint toUInt(bool *ok, int base) const const
bool toBool() const const
bool value(const QString &key, bool defaultValue) const
QString & replace(int position, int n, QChar after)
KCONFIGCORE_EXPORT bool authorize(const QString &action)
void setVisible(bool)
void activated()
Emitted when activation is requested due to, for example, a global keyboard shortcut.
@ FormFactorConstraint
The FormFactor for an object.
Definition: plasma.h:41
void wallpaperChanged()
Emitted when the wallpaper plugin is changed.
bool isContainment() const
Definition: applet.cpp:929
void addApplet(Applet *applet)
Add an existing applet to this Containment.
void init() override
Reimplemented from Applet.
Definition: containment.cpp:85
virtual void restore(KConfigGroup &group)
Restores state information about this applet saved previously in save(KConfigGroup&).
Definition: applet.cpp:211
void flushPendingConstraintsEvents()
Sends all pending constraints updates to the applet.
Definition: applet.cpp:602
void setEnabled(bool)
QStringList keyList() const
void locationChanged(Plasma::Types::Location location)
Emitted when the location has changed.
void activityChanged(const QString &activity)
Emitted when the activity id has changed.
QString activity() const
void setHasConfigurationInterface(bool hasInterface)
Sets whether or not this applet provides a user interface for configuring the applet.
Definition: applet.cpp:802
static PluginLoader * self()
Return the active plugin loader.
void setParent(QObject *parent)
Location
The Location enumeration describes where on screen an element, such as an Applet or its managing cont...
Definition: plasma.h:158
@ UiReadyConstraint
The ui has been completely loaded.
Definition: plasma.h:47
ImmutabilityType
Defines the immutability of items like applets, corona and containments they can be free to modify,...
Definition: plasma.h:235
void configureRequested(Plasma::Applet *applet)
Emitted when the user wants to configure/change the containment, or an applet inside it.
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QList::iterator begin()
QString name() const
void formFactorChanged(Plasma::Types::FormFactor formFactor)
Emitted when the formFactor has changed.
void setContainmentType(Plasma::Types::ContainmentType type)
Sets the type of this containment.
void setActivity(const QString &activityId)
Sets the current activity by id.
QList< Applet * > applets() const
QList::iterator end()
@ PanelContainment
A desktop panel.
Definition: plasma.h:117
QString pluginId() const
void appletDeleted(Plasma::Applet *applet)
Emitted when the applet is deleted.
The base class for plugins that provide backgrounds and applet grouping containers.
Definition: containment.h:45
void setLocation(Plasma::Types::Location location)
Informs the Corona as to what position it is in.
QHash< QString, ContainmentActions * > & containmentActions()
QObject * parent() const const
The base Applet class.
Definition: applet.h:71
void screenChanged(int newScreen)
This signal indicates that a containment has been associated (or dissociated) with a physical screen.
void updateConstraints(Plasma::Types::Constraints constraints=Plasma::Types::AllConstraints)
Called when any of the geometry constraints have been updated.
Definition: applet.cpp:350
virtual void restore(const KConfigGroup &config)
This method should be called once the plugin is loaded or settings are changed.
Applet * createApplet(const QString &name, const QVariantList &args=QVariantList())
Adds an applet to this Containment.
QVariant property(const char *name) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Sep 26 2023 04:05:56 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.