Plasma-framework

containment.cpp
1/*
2 SPDX-FileCopyrightText: 2007 Aaron Seigo <aseigo@kde.org>
3 SPDX-FileCopyrightText: 2008 Ménard Alexis <darktears31@gmail.com>
4 SPDX-FileCopyrightText: 2009 Chani Armitage <chani@kde.org>
5 SPDX-FileCopyrightText: 2012 Marco Martin <notmart@kde.org>
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 <QQuickItem>
23#include <QTemporaryFile>
24
25#include <KAuthorized>
26#include <KConfigLoader>
27#include <KConfigSkeleton>
28#include <KLocalizedString>
29
30#include <plasmaactivities/info.h>
31
32#include "containmentactions.h"
33#include "corona.h"
34#include "debug_p.h"
35#include "pluginloader.h"
36
37#include "private/applet_p.h"
38
39#include "plasma/plasma.h"
40
41namespace Plasma
42{
43Containment::Containment(QObject *parentObject, const KPluginMetaData &data, const QVariantList &args)
44 : Applet(parentObject, data, args)
45 , d(new ContainmentPrivate(this))
46{
47 // WARNING: do not access config() OR globalConfig() in this method!
48 // that requires a scene, which is not available at this point
50
51 // Try to determine the containment type. It must be done as soon as possible
52 const QString type = pluginMetaData().value(QStringLiteral("X-Plasma-ContainmentType"));
53 QMetaEnum metaEnum = QMetaEnum::fromType<Plasma::Containment::Type>();
54 d->type = (Plasma::Containment::Type)metaEnum.keyToValue(type.toLocal8Bit().constData());
56 qCWarning(LOG_PLASMA) << "Unknown containment type requested:" << type << pluginMetaData().fileName()
57 << "check Plasma::Containment::Type for supported values";
58 }
59}
60
61Containment::~Containment()
62{
63 disconnect(corona(), nullptr, this, nullptr);
64 qDeleteAll(d->localActionPlugins);
65 delete d;
66}
67
69{
71
72 connect(corona(), &Plasma::Corona::availableScreenRectChanged, this, [this](int screenId) {
73 if (screenId == screen() || screenId == lastScreen()) {
75 }
76 });
77 connect(corona(), &Plasma::Corona::availableScreenRegionChanged, this, [this](int screenId) {
78 if (screenId == screen() || screenId == lastScreen()) {
80 }
81 });
82 connect(corona(), &Plasma::Corona::screenGeometryChanged, this, [this](int screenId) {
83 if (screenId == screen()) {
85 }
86 });
87
88 QMap<QString, QAction *> actions = static_cast<Applet *>(this)->d->actions;
89 // connect actions
90 ContainmentPrivate::addDefaultActions(actions, this);
91 bool unlocked = immutability() == Types::Mutable;
92
93 // fix the text of the actions that need title()
94 // btw, do we really want to use title() when it's a desktopcontainment?
95 QAction *closeApplet = internalAction(QStringLiteral("remove"));
96 if (closeApplet) {
97 closeApplet->setText(i18nc("%1 is the name of the applet", "Remove %1", title()));
98 }
99
100 QAction *configAction = internalAction(QStringLiteral("configure"));
101 if (configAction) {
102 if (d->type == Containment::Type::Panel || d->type == Containment::Type::CustomPanel) {
103 configAction->setText(i18n("Enter Edit Mode"));
104 configAction->setIcon(QIcon::fromTheme(QStringLiteral("document-edit")));
105 } else {
106 configAction->setText(i18nc("%1 is the name of the applet", "Configure %1...", title()));
107 }
108 }
109
110 QAction *appletBrowserAction = internalAction(QStringLiteral("add widgets"));
111 if (appletBrowserAction) {
112 appletBrowserAction->setVisible(unlocked);
113 appletBrowserAction->setEnabled(unlocked);
114 connect(appletBrowserAction, SIGNAL(triggered()), this, SLOT(triggerShowAddWidgets()));
115 }
116
118 QAction *lockDesktopAction = corona()->action(QStringLiteral("lock widgets"));
119 // keep a pointer so nobody notices it moved to corona
120 if (lockDesktopAction) {
121 setInternalAction(QStringLiteral("lock widgets"), lockDesktopAction);
122 }
123 }
124
125 // HACK: this is valid only in the systray case
127 if (Plasma::Applet *p = qobject_cast<Plasma::Applet *>(parent())) {
128 Q_EMIT p->containment()->configureRequested(a);
129 }
130 });
131}
132
133// helper function for sorting the list of applets
134bool appletConfigLessThan(const KConfigGroup &c1, const KConfigGroup &c2)
135{
136 int i1 = c1.readEntry("id", 0);
137 int i2 = c2.readEntry("id", 0);
138
139 return (i1 < i2);
140}
141
143{
144 /*
145 #ifndef NDEBUG
146 // qCDebug(LOG_PLASMA) << "!!!!!!!!!!!!initConstraints" << group.name() << d->type;
147 // qCDebug(LOG_PLASMA) << " location:" << group.readEntry("location", (int)d->location);
148 // qCDebug(LOG_PLASMA) << " geom:" << group.readEntry("geometry", geometry());
149 // qCDebug(LOG_PLASMA) << " formfactor:" << group.readEntry("formfactor", (int)d->formFactor);
150 // qCDebug(LOG_PLASMA) << " screen:" << group.readEntry("screen", d->screen);
151 #endif
152 */
153 setLocation((Plasma::Types::Location)group.readEntry("location", (int)d->location));
154 setFormFactor((Plasma::Types::FormFactor)group.readEntry("formfactor", (int)d->formFactor));
155 d->lastScreen = group.readEntry("lastScreen", d->lastScreen);
156
157 setWallpaperPlugin(group.readEntry("wallpaperplugin", ContainmentPrivate::defaultWallpaperPlugin));
158
159 d->activityId = group.readEntry("activityId", QString());
160
162 restoreContents(group);
164
165 if (isContainment() && KAuthorized::authorize(QStringLiteral("plasma/containment_actions"))) {
166 KConfigGroup cfg = KConfigGroup(corona()->config(), QStringLiteral("ActionPlugins"));
167 cfg = KConfigGroup(&cfg, QString::number((int)containmentType()));
168
169 // qCDebug(LOG_PLASMA) << cfg.keyList();
170 if (cfg.exists()) {
171 const auto keyList = cfg.keyList();
172 for (const QString &key : keyList) {
173 // qCDebug(LOG_PLASMA) << "loading" << key;
174 setContainmentActions(key, cfg.readEntry(key, QString()));
175 }
176 } else { // shell defaults
177 KConfigGroup defaultActionsCfg;
178
179 switch (d->type) {
181 /* fall through*/
183 defaultActionsCfg = KConfigGroup(KSharedConfig::openConfig(corona()->kPackage().filePath("defaults")), QStringLiteral("Panel"));
184 break;
186 defaultActionsCfg = KConfigGroup(KSharedConfig::openConfig(corona()->kPackage().filePath("defaults")), QStringLiteral("Desktop"));
187 break;
188 default:
189 // for any other type of containment, there are no defaults
190 break;
191 }
192 if (defaultActionsCfg.isValid()) {
193 defaultActionsCfg = KConfigGroup(&defaultActionsCfg, QStringLiteral("ContainmentActions"));
194 const auto keyList = defaultActionsCfg.keyList();
195 for (const QString &key : keyList) {
196 setContainmentActions(key, defaultActionsCfg.readEntry(key, QString()));
197 }
198 }
199 }
200 }
201 Applet::restore(group);
202}
204void Containment::save(KConfigGroup &g) const
205{
206 if (Applet::d->transient) {
207 return;
208 }
209
210 KConfigGroup group = g;
211 if (!group.isValid()) {
212 group = config();
213 }
214
215 // locking is saved in Applet::save
216 Applet::save(group);
217
218 // group.writeEntry("screen", d->screen);
219 group.writeEntry("lastScreen", d->lastScreen);
220 group.writeEntry("formfactor", (int)d->formFactor);
221 group.writeEntry("location", (int)d->location);
222 group.writeEntry("activityId", d->activityId);
223
224 group.writeEntry("wallpaperplugin", d->wallpaperPlugin);
225
226 saveContents(group);
227}
230{
231 KConfigGroup applets(&group, QStringLiteral("Applets"));
232 for (const Applet *applet : std::as_const(d->applets)) {
233 KConfigGroup appletConfig(&applets, QString::number(applet->id()));
234 applet->save(appletConfig);
235 }
236}
239{
240 KConfigGroup applets(&group, QStringLiteral("Applets"));
241
242 // restore the applets ordered by id
243 QStringList groups = applets.groupList();
244 std::sort(groups.begin(), groups.end());
245
246 // Sort the applet configs in order of geometry to ensure that applets
247 // are added from left to right or top to bottom for a panel containment
248 QList<KConfigGroup> appletConfigs;
249 for (const QString &appletGroup : std::as_const(groups)) {
250 // qCDebug(LOG_PLASMA) << "reading from applet group" << appletGroup;
251 KConfigGroup appletConfig(&applets, appletGroup);
252 appletConfigs.append(appletConfig);
253 }
254 std::stable_sort(appletConfigs.begin(), appletConfigs.end(), appletConfigLessThan);
255
256 QMutableListIterator<KConfigGroup> it(appletConfigs);
257 while (it.hasNext()) {
258 KConfigGroup &appletConfig = it.next();
259 if (appletConfig.readEntry(QStringLiteral("transient"), false)) {
260 appletConfig.deleteGroup();
261 continue;
262 }
263 int appId = appletConfig.name().toUInt();
264 QString plugin = appletConfig.readEntry("plugin", QString());
265
266 if (plugin.isEmpty()) {
267 continue;
268 }
269
270 d->createApplet(plugin, QVariantList(), appId);
271 }
272
273 // if there are no applets, none of them is "loading"
274 if (Containment::applets().isEmpty()) {
275 d->appletsUiReady = true;
276 }
277 const auto lstApplets = Containment::applets();
278 for (Applet *applet : lstApplets) {
279 if (!applet->pluginMetaData().isValid()) {
280 applet->updateConstraints(UiReadyConstraint);
281 }
282 }
283}
286{
287 return d->type;
288}
291{
292 // We are not sure where the corona parent is in the hyerarchy, because of... the systray.
293 // We are iterating over the parent tree here rather than casting the parent
294 // to applet then asking ofr its containment and corona, as this might break during
295 // teardown, as this can be invoked during dtor of one of the ancestors,
296 // see https://bugs.kde.org/show_bug.cgi?id=477067 where it happens during destruction
297 // of the panel (containment of the applet that contains the systray containment)
298 for (auto candidate = parent(); candidate; candidate = candidate->parent()) {
299 if (auto c = qobject_cast<Corona *>(candidate)) {
300 return c;
301 }
302 }
303
304 return nullptr;
305}
308{
309 if (d->formFactor == formFactor) {
310 return;
311 }
312
313 // qCDebug(LOG_PLASMA) << "switching FF to " << formFactor;
314 d->formFactor = formFactor;
315
317
318 KConfigGroup c = config();
319 c.writeEntry("formfactor", (int)formFactor);
322}
325{
326 if (d->containmentDisplayHints == hints) {
327 return;
328 }
329
330 d->containmentDisplayHints = hints;
332}
335{
336 if (d->location == location) {
337 return;
338 }
339
340 d->location = location;
341
342 for (Applet *applet : std::as_const(d->applets)) {
343 applet->updateConstraints(LocationConstraint);
344 }
345
347
348 KConfigGroup c = config();
349 c.writeEntry("location", (int)location);
352}
354Applet *Containment::createApplet(const QString &name, const QVariantList &args, const QRectF &geometryHint)
355{
356 Plasma::Applet *applet = d->createApplet(name, args, 0, geometryHint);
357 if (applet) {
358 Q_EMIT appletCreated(applet, geometryHint);
359 }
360 return applet;
361}
363void Containment::addApplet(Applet *applet, const QRectF &geometryHint)
364{
365 if (!applet) {
366#ifndef NDEBUG
367 // qCDebug(LOG_PLASMA) << "adding null applet!?!";
368#endif
369 return;
370 }
371
372 if (immutability() != Types::Mutable && !applet->property("org.kde.plasma:force-create").toBool()) {
373 return;
374 }
375
376#ifndef NDEBUG
377 if (d->applets.contains(applet)) {
378 // qCDebug(LOG_PLASMA) << "already have this applet!";
379 }
380#endif
381
382 Containment *currentContainment = applet->containment();
383
384 if (currentContainment && currentContainment != this) {
385 Q_EMIT currentContainment->appletAboutToBeRemoved(applet);
386 Q_EMIT currentContainment->appletRemoved(applet);
388
389 disconnect(applet, nullptr, currentContainment, nullptr);
390 connect(currentContainment, nullptr, applet, nullptr);
391 KConfigGroup oldConfig = applet->config();
392 currentContainment->d->applets.removeAll(applet);
393 applet->setParent(this);
394
395 // now move the old config to the new location
396 // FIXME: this doesn't seem to get the actual main config group containing plugin=, etc
397 KConfigGroup c = config().group(QStringLiteral("Applets")).group(QString::number(applet->id()));
398 oldConfig.reparent(&c);
399 applet->d->resetConfigurationObject();
400
401 disconnect(applet, &Applet::activated, currentContainment, &Applet::activated);
402 // change the group to its configloader, if any
403 // FIXME: this is very, very brutal
404 if (applet->configScheme()) {
405 const QString oldGroupPrefix = QStringLiteral("Containments") + QString::number(currentContainment->id()) + QStringLiteral("Applets");
406 const QString newGroupPrefix = QStringLiteral("Containments") + QString::number(id()) + QStringLiteral("Applets");
407
408 applet->configScheme()->setCurrentGroup(applet->configScheme()->currentGroup().replace(0, oldGroupPrefix.length(), newGroupPrefix));
409
410 const auto items = applet->configScheme()->items();
411 for (KConfigSkeletonItem *item : items) {
412 item->setGroup(item->group().replace(0, oldGroupPrefix.length(), newGroupPrefix));
413 }
414 }
415 } else {
416 applet->setParent(this);
417 }
418
419 // make sure the applets are sorted by id
420 auto position = std::lower_bound(d->applets.begin(), d->applets.end(), applet, [](Plasma::Applet *a1, Plasma::Applet *a2) {
421 return a1->id() < a2->id();
422 });
423 Q_EMIT appletAboutToBeAdded(applet, geometryHint);
424 d->applets.insert(position, applet);
425
426 if (!d->uiReady) {
427 d->loadingApplets << applet;
428 }
429
431 connect(applet, SIGNAL(appletDeleted(Plasma::Applet *)), this, SLOT(appletDeleted(Plasma::Applet *)));
432 connect(applet, SIGNAL(statusChanged(Plasma::Types::ItemStatus)), this, SLOT(checkStatus(Plasma::Types::ItemStatus)));
433 connect(this, &Containment::containmentDisplayHintsChanged, applet, &Applet::containmentDisplayHintsChanged);
434
435 if (!currentContainment) {
436 const bool isNew = applet->d->mainConfigGroup()->entryMap().isEmpty();
437
438 if (!isNew) {
439 applet->restore(*applet->d->mainConfigGroup());
440 }
441
442 applet->init();
443
444 // FIXME: an on-appear animation would be nice to have again
445 }
446
447 applet->updateConstraints(AllConstraints);
449
450 Q_EMIT appletAdded(applet, geometryHint);
452 Q_EMIT applet->containmentChanged(this);
453
454 if (!currentContainment) {
457 }
458
459 applet->save(*applet->d->mainConfigGroup());
461}
464{
465 return d->applets;
466}
468int Containment::screen() const
469{
470 Q_ASSERT(corona());
471 if (Corona *c = corona()) {
472 return c->screenForContainment(this);
473 } else {
474 return -1;
475 }
476}
478int Containment::lastScreen() const
479{
480 return d->lastScreen;
481}
484{
485 if (!corona()) {
486 return {};
487 }
488
489 int screenId = screen();
490
491 // If corona returned an invalid screenId, try to use lastScreen value if it is valid
492 if (screenId == -1 && lastScreen() > -1) {
493 screenId = lastScreen();
494 // Is this a screen not actually valid?
495 if (screenId >= corona()->numScreens()) {
496 screenId = -1;
497 }
498 }
499
500 if (screenId > -1) {
501 QRectF rect = corona()->availableScreenRect(screenId);
502 // make it relative
503 QRectF geometry = corona()->screenGeometry(screenId);
504 rect.moveTo(rect.topLeft() - geometry.topLeft());
505 return rect;
506 }
507
508 return {};
509}
512{
513 QList<QRectF> regVal;
514
515 if (!containment() || !containment()->corona()) {
516 return regVal;
517 }
518
519 QRegion reg = QRect(QPoint(0, 0), screenGeometry().size().toSize());
520 int screenId = screen();
521 if (screenId < 0) {
522 return {};
523 }
524 reg = containment()->corona()->availableScreenRegion(screenId);
525
526 auto it = reg.begin();
527 const auto itEnd = reg.end();
528 QRect geometry = containment()->corona()->screenGeometry(screenId);
529 for (; it != itEnd; ++it) {
530 QRect rect = *it;
531 // make it relative
532 rect.moveTo(rect.topLeft() - geometry.topLeft());
533 regVal << QRectF(rect);
534 }
535 return regVal;
536}
539{
540 if (!corona() || screen() < 0) {
541 return {};
542 }
543
544 return corona()->screenGeometry(screen());
545}
547void Containment::setWallpaperPlugin(const QString &pluginName)
548{
549 if (pluginName != d->wallpaperPlugin) {
550 d->wallpaperPlugin = pluginName;
551
552 KConfigGroup cfg = config();
553 cfg.writeEntry("wallpaperplugin", d->wallpaperPlugin);
556 }
557}
559QString Containment::wallpaperPlugin() const
560{
561 return d->wallpaperPlugin;
562}
563
564QObject *Containment::wallpaperGraphicsObject() const
565{
566 return d->wallpaperGraphicsObject;
567}
568
569void Containment::setWallpaperGraphicsObject(QObject *object)
570{
571 if (d->wallpaperGraphicsObject == object) {
572 return;
573 }
574 d->wallpaperGraphicsObject = object;
576}
577
578QUrl Containment::compactApplet() const
579{
580 if (Applet::d->package.isValid()) {
581 return Applet::d->package.fileUrl("compactapplet");
582 }
583 return QUrl();
584}
586void Containment::setContainmentActions(const QString &trigger, const QString &pluginName)
587{
588 KConfigGroup cfg = d->containmentActionsConfig();
589 ContainmentActions *plugin = nullptr;
590
591 plugin = containmentActions().value(trigger);
592 if (plugin && plugin->metadata().pluginId() != pluginName) {
593 containmentActions().remove(trigger);
594 delete plugin;
595 plugin = nullptr;
596 }
597
598 if (pluginName.isEmpty()) {
599 cfg.deleteEntry(trigger);
600 } else if (plugin) {
601 // it already existed, just reload config
602 plugin->setContainment(this); // to be safe
603 // FIXME make a truly unique config group
604 KConfigGroup pluginConfig = KConfigGroup(&cfg, trigger);
605 plugin->restore(pluginConfig);
606
607 } else {
609
610 if (plugin) {
611 cfg.writeEntry(trigger, pluginName);
612 containmentActions().insert(trigger, plugin);
613 plugin->setContainment(this);
614 KConfigGroup pluginConfig = KConfigGroup(&cfg, trigger);
615 plugin->restore(pluginConfig);
616 } else {
617 // bad plugin... gets removed. is this a feature or a bug?
618 cfg.deleteEntry(trigger);
619 }
620 }
621
623}
626{
627 return d->localActionPlugins;
628}
630bool Containment::isUiReady() const
631{
632 return d->uiReady && d->appletsUiReady && Applet::d->started;
633}
635void Containment::setActivity(const QString &activityId)
636{
637 if (activityId.isEmpty() || d->activityId == activityId) {
638 return;
639 }
640
641 d->activityId = activityId;
642 KConfigGroup c = config();
643 c.writeEntry("activityId", activityId);
644
646 Q_EMIT activityChanged(activityId);
647}
650{
651 return d->activityId;
652}
655{
656 if (!d->activityInfo) {
657 return QString();
658 }
659 return d->activityInfo->name();
660}
661
662void Containment::reactToScreenChange()
663{
664 int newScreen = screen();
665
666 if (newScreen >= 0) {
667 d->lastScreen = newScreen;
668 KConfigGroup c = config();
669 c.writeEntry("lastScreen", d->lastScreen);
671 }
672
673 Q_EMIT screenChanged(newScreen);
674}
675
676} // Plasma namespace
677
678#include "moc_containment.cpp"
static Q_INVOKABLE bool authorize(const QString &action)
KConfigGroup group(const QString &group)
void reparent(KConfigBase *parent, WriteConfigFlags pFlags=Normal)
QString name() const
void deleteEntry(const char *key, WriteConfigFlags pFlags=Normal)
void writeEntry(const char *key, const char *value, WriteConfigFlags pFlags=Normal)
void deleteGroup(const QString &group, WriteConfigFlags flags=Normal)
bool isValid() const
QString readEntry(const char *key, const char *aDefault=nullptr) const
bool exists() const
QStringList keyList() const
QString currentGroup() const
KConfigSkeletonItem::List items() const
void setCurrentGroup(const QString &group)
QString pluginId() const
bool value(const QString &key, bool defaultValue) const
QString fileName() const
static KSharedConfig::Ptr openConfig(const QString &fileName=QString(), OpenFlags mode=FullConfig, QStandardPaths::StandardLocation type=QStandardPaths::GenericConfigLocation)
The base Applet class.
Definition applet.h:64
uint id
Applet id: is unique in the whole Plasma session and will never change across restarts.
Definition applet.h:69
void updateConstraints(Constraints constraints=AllConstraints)
Called when any of the geometry constraints have been updated.
Definition applet.cpp:269
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:107
void setHasConfigurationInterface(bool hasInterface)
Sets whether or not this applet provides a user interface for configuring the applet.
Definition applet.cpp:772
Plasma::Types::Location location
The location of the scene which is displaying applet.
Definition applet.h:95
Q_INVOKABLE QAction * internalAction(const QString &name) const
Definition applet.cpp:654
KConfigGroup config() const
Returns the KConfigGroup to access the applets configuration.
Definition applet.cpp:194
@ StartupCompletedConstraint
application startup has completed
Definition applet.h:219
@ UiReadyConstraint
The ui has been completely loaded.
Definition applet.h:220
@ FormFactorConstraint
The FormFactor for an object.
Definition applet.h:215
@ LocationConstraint
The Location of an object.
Definition applet.h:216
bool isContainment
True if this applet is a Containment and is acting as one, such as a desktop or a panel.
Definition applet.h:200
Plasma::Types::ImmutabilityType immutability
The immutability of the Corona.
Definition applet.h:106
void containmentChanged(Plasma::Containment *containment)
Emitted when the containment changes.
void configNeedsSaving()
Emitted when an applet has changed values in its configuration and wishes for them to be saved at the...
void activated()
Emitted when activation is requested due to, for example, a global keyboard shortcut.
void appletDeleted(Plasma::Applet *applet)
Emitted when the applet is deleted.
virtual void init()
This method is called once the applet is loaded and added to a Corona.
Definition applet.cpp:92
void statusChanged(Plasma::Types::ItemStatus status)
Emitted when the applet status changes.
Plasma::Types::FormFactor formFactor
The current form factor the applet is being displayed in.
Definition applet.h:88
Q_INVOKABLE void setInternalAction(const QString &name, QAction *action)
Add a new internal action.
Definition applet.cpp:632
QString pluginName
Plugin name for the applet.
Definition applet.h:205
QString title
User friendly title for the plasmoid: it's the localized applet name by default.
Definition applet.h:74
void setImmutability(const Types::ImmutabilityType immutable)
Sets the immutability type for this applet (not immutable, user immutable or system immutable)
Definition applet.cpp:441
Plasma::Containment * containment
The Containment managing this applet.
Definition applet.h:189
void flushPendingConstraintsEvents()
Sends all pending constraints updates to the applet.
Definition applet.cpp:536
KPluginMetaData pluginMetaData() const
Definition applet.cpp:394
KConfigLoader * configScheme() const
Returns the config skeleton object from this applet's package, if any.
Definition applet.cpp:243
virtual void restore(KConfigGroup &group)
Restores state information about this applet saved previously in save(KConfigGroup&).
Definition applet.cpp:140
The base ContainmentActions class.
KPluginMetaData metadata() const
virtual void restore(const KConfigGroup &config)
This method should be called once the plugin is loaded or settings are changed.
void setContainment(Containment *newContainment)
newContainment the containment the plugin should be associated with.
The base class for plugins that provide backgrounds and applet grouping containers.
Definition containment.h:47
Q_INVOKABLE void addApplet(Applet *applet, const QRectF &geometryHint=QRectF())
Add an existing applet to this Containment.
void save(KConfigGroup &group) const override
void setActivity(const QString &activityId)
Sets the current activity by id.
Plasma::Corona * corona
The corona for this contaiment.
Definition containment.h:59
void configureRequested(Plasma::Applet *applet)
Emitted when the user wants to configure/change the containment, or an applet inside it.
void containmentDisplayHintsChanged(Plasma::Types::ContainmentDisplayHints hints)
Emitted when the containment disaplay hints change.
void formFactorChanged(Plasma::Types::FormFactor formFactor)
Emitted when the formFactor has changed.
void setContainmentDisplayHints(Plasma::Types::ContainmentDisplayHints hints)
Set Display hints that come from the containment that suggest the applet how to look and behave.
Type
This enumeration describes the type of the Containment.
@ Panel
A desktop panel.
@ CustomPanel
A customized desktop panel.
@ Desktop
A desktop containment.
void appletCreated(Plasma::Applet *applet, const QRectF &geometryHint)
This signal is emitted when a new applet is created by the containment.
QString activity
Activity UID of this containment.
Definition containment.h:69
void activityChanged(const QString &activity)
Emitted when the activity id has changed.
QRectF screenGeometry
Provides access to the geometry of the applet is in.
void wallpaperPluginChanged()
Emitted when the wallpaper plugin is changed.
void availableRelativeScreenRegionChanged(const QList< QRectF > &region)
Emitted when the available screen rectangle has changed.
void setFormFactor(Plasma::Types::FormFactor formFactor)
Sets the form factor for this Containment.
QList< QRectF > availableRelativeScreenRegion() const
void appletRemoved(Plasma::Applet *applet)
This signal is emitted when an applet is destroyed.
void appletAboutToBeRemoved(Plasma::Applet *applet)
This signal is emitted right before appletRemoved, it can be used to do a preliminary setup on the ap...
void setContainmentActions(const QString &trigger, const QString &pluginName)
Sets a containmentactions plugin.
QHash< QString, ContainmentActions * > & containmentActions()
virtual void saveContents(KConfigGroup &group) const
Called when the contents of the containment should be saved.
void locationChanged(Plasma::Types::Location location)
Emitted when the location has changed.
void screenGeometryChanged(const QRectF &rect)
Emitted when the screen geometry has changed.
Applet * createApplet(const QString &name, const QVariantList &args=QVariantList(), const QRectF &geometryHint=QRectF(-1, -1, 0, 0))
Adds an applet to this Containment.
virtual void restoreContents(KConfigGroup &group)
Called when the contents of the containment should be loaded.
void wallpaperGraphicsObjectChanged()
Emitted when the root wallpaper item has changed.
void appletAboutToBeAdded(Plasma::Applet *applet, const QRectF &geometryHint)
This signal is emitted right before appletAdded, it can be used to do a preliminary setup on the appl...
void setLocation(Plasma::Types::Location location)
Informs the Corona as to what position it is in.
QString activityName
Activity name of this containment.
Definition containment.h:74
void appletsChanged()
Emitted when the list of applets has changed, either added or removed.
void setWallpaperPlugin(const QString &pluginName)
Sets wallpaper plugin.
int screen
The screen number this containment is serving as the desktop for, or -1 if none.
Definition containment.h:87
void init() override
Reimplemented from Applet.
Plasma::Containment::Type containmentType
Type of this containment.
Definition containment.h:64
void screenChanged(int newScreen)
This signal indicates that a containment has been associated (or dissociated) with a physical screen.
void appletAdded(Plasma::Applet *applet, const QRectF &geometryHint)
This signal is emitted when a new applet is added in the containment It may happen in the following s...
void availableRelativeScreenRectChanged(const QRectF &rect)
Emitted when the available screen rectangle has changed.
void restore(KConfigGroup &group) override
QRectF availableRelativeScreenRect() const
QList< Plasma::Applet * > applets
List of applets this containment has: the containments KF6: this should be AppletQuickItem *.
Definition containment.h:54
A bookkeeping Scene for Plasma::Applets.
Definition corona.h:28
Q_INVOKABLE QAction * action(const QString &name) const
Definition corona.cpp:397
virtual QRect screenGeometry(int id) const =0
Returns the geometry of a given screen.
virtual QRegion availableScreenRegion(int id) const
Returns the available region for a given screen.
Definition corona.cpp:267
void availableScreenRegionChanged(int id)
This signal indicates that a change in available screen geometry occurred.
virtual QRect availableScreenRect(int id) const
Returns the available rect for a given screen.
Definition corona.cpp:272
void screenGeometryChanged(int id)
This signal indicates that a change in geometry for the screen occurred.
void availableScreenRectChanged(int id)
This signal indicates that a change in available screen geometry occurred.
ContainmentActions * loadContainmentActions(Containment *parent, const QString &containmentActionsName, const QVariantList &args=QVariantList())
Load a ContainmentActions plugin.
static PluginLoader * self()
Return the active plugin loader.
ImmutabilityType
Defines the immutability of items like applets, corona and containments they can be free to modify,...
Definition plasma.h:99
@ SystemImmutable
the item is locked down by the system, the user can't unlock it
Definition plasma.h:103
@ Mutable
The item can be modified in any way.
Definition plasma.h:100
ItemStatus
Status of an applet.
Definition plasma.h:112
Location
The Location enumeration describes where on screen an element, such as an Applet or its managing cont...
Definition plasma.h:81
FormFactor
The FormFactor enumeration describes how a Plasma::Applet should arrange itself.
Definition plasma.h:40
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
Namespace for everything in libplasma.
void setEnabled(bool)
void setIcon(const QIcon &icon)
void setText(const QString &text)
void setVisible(bool)
QIcon fromTheme(const QString &name)
void append(QList< T > &&value)
iterator begin()
iterator end()
int keyToValue(const char *key, bool *ok) const const
bool hasNext() const const
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool disconnect(const QMetaObject::Connection &connection)
QObject * parent() const const
QVariant property(const char *name) const const
void setParent(QObject *parent)
void moveTo(const QPoint &position)
QPoint topLeft() const const
void moveTo(const QPointF &position)
QPointF topLeft() const const
const_iterator begin() const const
const_iterator end() const const
bool isEmpty() const const
qsizetype length() const const
QString number(double n, char format, int precision)
QString & replace(QChar before, QChar after, Qt::CaseSensitivity cs)
uint toUInt(bool *ok, int base) const const
bool toBool() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 3 2024 11:46:04 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.