Libplasma

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(u"X-Plasma-ContainmentType");
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()) {
75 }
76 });
77 connect(corona(), &Plasma::Corona::availableScreenRegionChanged, this, [this](int screenId) {
78 if (screenId == screen()) {
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
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 const 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)));
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 if (isNew) {
445 applet->save(*applet->d->mainConfigGroup());
447 }
448 // FIXME: an on-appear animation would be nice to have again
449 }
450
451 applet->updateConstraints(AllConstraints);
453
454 Q_EMIT appletAdded(applet, geometryHint);
456 Q_EMIT applet->containmentChanged(this);
457
458 if (!currentContainment) {
461 }
462
463 applet->d->scheduleModificationNotification();
464}
467{
468 return d->applets;
469}
471int Containment::screen() const
472{
473 Q_ASSERT(corona());
474 if (Corona *c = corona()) {
475 return c->screenForContainment(this);
476 } else {
477 return -1;
478 }
479}
481int Containment::lastScreen() const
482{
483 return d->lastScreen;
484}
487{
488 if (!corona()) {
489 return {};
490 }
491
492 int screenId = screen();
493
494 // If corona returned an invalid screenId, try to use lastScreen value if it is valid
495 if (screenId == -1 && lastScreen() > -1) {
496 screenId = lastScreen();
497 // Is this a screen not actually valid?
498 if (screenId >= corona()->numScreens()) {
499 screenId = -1;
500 }
501 }
502
503 if (screenId > -1) {
504 QRectF rect = corona()->availableScreenRect(screenId);
505 // make it relative
506 QRectF geometry = corona()->screenGeometry(screenId);
507 rect.moveTo(rect.topLeft() - geometry.topLeft());
508 return rect;
509 }
510
511 return {};
512}
515{
516 QList<QRectF> regVal;
517
518 if (!containment() || !containment()->corona()) {
519 return regVal;
520 }
521
522 QRegion reg = QRect(QPoint(0, 0), screenGeometry().size().toSize());
523 int screenId = screen();
524 if (screenId < 0) {
525 return {};
526 }
527 reg = containment()->corona()->availableScreenRegion(screenId);
528
529 auto it = reg.begin();
530 const auto itEnd = reg.end();
531 QRect geometry = containment()->corona()->screenGeometry(screenId);
532 for (; it != itEnd; ++it) {
533 QRect rect = *it;
534 // make it relative
535 rect.moveTo(rect.topLeft() - geometry.topLeft());
536 regVal << QRectF(rect);
537 }
538 return regVal;
539}
542{
543 if (!corona() || screen() < 0) {
544 return {};
545 }
546
547 return corona()->screenGeometry(screen());
548}
550void Containment::setWallpaperPlugin(const QString &pluginName)
551{
552 if (pluginName != d->wallpaperPlugin) {
553 d->wallpaperPlugin = pluginName;
554
555 KConfigGroup cfg = config();
556 cfg.writeEntry("wallpaperplugin", d->wallpaperPlugin);
559 }
560}
562QString Containment::wallpaperPlugin() const
563{
564 return d->wallpaperPlugin;
565}
566
567QObject *Containment::wallpaperGraphicsObject() const
568{
569 return d->wallpaperGraphicsObject;
570}
571
572void Containment::setWallpaperGraphicsObject(QObject *object)
573{
574 if (d->wallpaperGraphicsObject == object) {
575 return;
576 }
577 d->wallpaperGraphicsObject = object;
579}
580
581QUrl Containment::compactApplet() const
582{
583 if (Applet::d->package.isValid()) {
584 return Applet::d->package.fileUrl("compactapplet");
585 }
586 return QUrl();
587}
589void Containment::setContainmentActions(const QString &trigger, const QString &pluginName)
590{
591 KConfigGroup cfg = d->containmentActionsConfig();
592 ContainmentActions *plugin = nullptr;
593
594 plugin = containmentActions().value(trigger);
595 if (plugin && plugin->metadata().pluginId() != pluginName) {
596 containmentActions().remove(trigger);
597 delete plugin;
598 plugin = nullptr;
599 }
600
601 if (pluginName.isEmpty()) {
602 cfg.deleteEntry(trigger);
603 } else if (plugin) {
604 // it already existed, just reload config
605 plugin->setContainment(this); // to be safe
606 // FIXME make a truly unique config group
607 KConfigGroup pluginConfig = KConfigGroup(&cfg, trigger);
608 plugin->restore(pluginConfig);
609
610 } else {
612
613 if (plugin) {
614 cfg.writeEntry(trigger, pluginName);
615 containmentActions().insert(trigger, plugin);
616 plugin->setContainment(this);
617 KConfigGroup pluginConfig = KConfigGroup(&cfg, trigger);
618 plugin->restore(pluginConfig);
619 } else {
620 // bad plugin... gets removed. is this a feature or a bug?
621 cfg.deleteEntry(trigger);
622 }
623 }
624
626}
629{
630 return d->localActionPlugins;
631}
633bool Containment::isUiReady() const
634{
635 return d->uiReady && d->appletsUiReady && Applet::d->started;
636}
638void Containment::setActivity(const QString &activityId)
639{
640 if (activityId.isEmpty() || d->activityId == activityId) {
641 return;
642 }
643
644 d->activityId = activityId;
645 KConfigGroup c = config();
646 c.writeEntry("activityId", activityId);
647
649 Q_EMIT activityChanged(activityId);
650}
653{
654 return d->activityId;
655}
658{
659 if (!d->activityInfo) {
660 return QString();
661 }
662 return d->activityInfo->name();
663}
664
665void Containment::reactToScreenChange()
666{
667 int newScreen = screen();
668
669 Q_EMIT screenChanged(newScreen);
670
671 if (newScreen >= 0) {
672 d->lastScreen = newScreen;
673 KConfigGroup c = config();
674 c.writeEntry("lastScreen", d->lastScreen);
676
680 }
681}
682
683} // Plasma namespace
684
685#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(QStringView 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:266
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:102
void setHasConfigurationInterface(bool hasInterface)
Sets whether or not this applet provides a user interface for configuring the applet.
Definition applet.cpp:780
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:662
KConfigGroup config() const
Returns the KConfigGroup to access the applets configuration.
Definition applet.cpp:189
@ 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:87
void statusChanged(Plasma::Types::ItemStatus status)
Emitted when the applet status changes.
void containmentDisplayHintsChanged(Plasma::Types::ContainmentDisplayHints hints)
Emitted when the containment display hints change.
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:640
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:438
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:533
KPluginMetaData pluginMetaData() const
Definition applet.cpp:391
KConfigLoader * configScheme() const
Returns the config skeleton object from this applet's package, if any.
Definition applet.cpp:238
virtual void restore(KConfigGroup &group)
Restores state information about this applet saved previously in save(KConfigGroup&).
Definition applet.cpp:135
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()
QMetaEnum fromType()
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
T qobject_cast(QObject *object)
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 Nov 29 2024 11:52:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.