Libplasma

corona.cpp
1/*
2 SPDX-FileCopyrightText: 2007 Matt Broadstone <mbroadst@gmail.com>
3 SPDX-FileCopyrightText: 2007-2011 Aaron Seigo <aseigo@kde.org>
4 SPDX-FileCopyrightText: 2007 Riccardo Iaconelli <riccardo@kde.org>
5 SPDX-FileCopyrightText: 2009 Chani Armitage <chani@kde.org>
6
7 SPDX-License-Identifier: LGPL-2.0-or-later
8*/
9
10#include "corona.h"
11#include "private/corona_p.h"
12
13#include <QDebug>
14#include <QGuiApplication>
15#include <QJSEngine>
16#include <QMimeData>
17#include <QPainter>
18#include <QScreen>
19#include <QTimer>
20
21#include <KLocalizedString>
22
23#include <cmath>
24
25#include "containment.h"
26#include "debug_p.h"
27#include "pluginloader.h"
28#include "private/applet_p.h"
29#include "private/containment_p.h"
30
31using namespace Plasma;
32
33namespace Plasma
34{
35Corona::Corona(QObject *parent)
36 : QObject(parent)
37 , d(new CoronaPrivate(this))
38{
39 d->init();
40}
41
42Corona::~Corona()
43{
44 KConfigGroup trans(KSharedConfig::openConfig(), QStringLiteral("PlasmaTransientsConfig"));
45 trans.deleteGroup();
46
47 delete d;
48}
49
50KPackage::Package Corona::kPackage() const
51{
52 return d->package;
53}
54
56{
57 d->package = package;
58 Q_EMIT kPackageChanged(package);
59}
60
61void Corona::saveLayout(const QString &configName) const
62{
63 KSharedConfigPtr c;
64
65 if (configName.isEmpty() || configName == d->configName) {
66 c = config();
67 } else {
69 }
70
71 d->saveLayout(c);
72}
73
75{
76 const auto groupList = config.groupList();
77 for (const QString &group : groupList) {
78 KConfigGroup cg(&config, group);
79 cg.deleteGroup();
80 }
81
82 // temporarily unlock so that removal works
84 d->immutability = Types::Mutable;
85
86 KConfigGroup dest(&config, QStringLiteral("Containments"));
87 KConfigGroup dummy;
88 for (Plasma::Containment *c : std::as_const(containments)) {
89 c->save(dummy);
90 c->config().reparent(&dest);
91
92 // ensure the containment is unlocked
93 // this is done directly because we have to bypass any Types::SystemImmutable checks
94 c->Applet::d->immutability = Types::Mutable;
95 const auto lstApplet = c->applets();
96 for (Applet *a : lstApplet) {
97 a->d->immutability = Types::Mutable;
98 }
99
100 c->destroy();
101 }
102
103 // restore immutability
104 d->immutability = oldImm;
105
106 config.sync();
107}
108
110{
111 // constant controlling how long between requesting a configuration sync
112 // and one happening should occur. currently 10 seconds
113 static const int CONFIG_SYNC_TIMEOUT = 10000;
114
115 // TODO: should we check into our immutability before doing this?
116
117 // NOTE: this is a pretty simplistic model: we simply save no more than CONFIG_SYNC_TIMEOUT
118 // after the first time this is called. not much of a heuristic for save points, but
119 // it should at least compress these activities a bit and provide a way for applet
120 // authors to ween themselves from the sync() disease. A more interesting/dynamic
121 // algorithm for determining when to actually sync() to disk might be better, though.
122 if (!d->configSyncTimer->isActive()) {
123 d->configSyncTimer->start(CONFIG_SYNC_TIMEOUT);
124 }
125}
126
128{
129 d->syncConfig();
130}
131
132void Corona::loadLayout(const QString &configName)
133{
134 if (!configName.isEmpty() && configName != d->configName) {
135 // if we have a new config name passed in, then use that as the config file for this Corona
136 d->config = nullptr;
137 d->configName = configName;
138 }
139
140 KConfigGroup conf(config(), QString());
141 if (!config()->groupList().isEmpty()) {
142 d->importLayout(conf, false);
143 } else {
145 d->notifyContainmentsReady();
146 }
147
148 KConfigGroup cg(config(), QStringLiteral("General"));
150}
151
153{
154 return d->importLayout(conf, true);
155}
156
157Containment *Corona::containmentForScreen(int screen, const QString &activity, const QString &defaultPluginIfNonExistent, const QVariantList &defaultArgs)
158{
159 Containment *containment = nullptr;
160
161 for (Containment *cont : std::as_const(d->containments)) {
162 if (cont->lastScreen() == screen //
163 && ((cont->activity().isEmpty() || activity.isEmpty()) || cont->activity() == activity)
164 && (cont->containmentType() == Plasma::Containment::Type::Desktop //
165 || cont->containmentType() == Plasma::Containment::Type::Custom || cont->containmentType() == Plasma::Containment::Type::NoContainment)) {
166 containment = cont;
167 }
168 }
169
170 if (!containment && !defaultPluginIfNonExistent.isEmpty()) {
171 // screen requests are allowed to bypass immutability
172 if (screen >= 0) {
173 Plasma::Types::ImmutabilityType imm = d->immutability;
174 d->immutability = Types::Mutable;
175 containment = d->addContainment(defaultPluginIfNonExistent, defaultArgs, 0, screen, false);
176
177 d->immutability = imm;
178 }
179 }
180
181 if (containment) {
182 containment->setActivity(activity);
183 }
184 return containment;
185}
186
188{
190
191 if (activity.isEmpty()) {
192 return conts;
193 }
194
195 std::copy_if(d->containments.begin(), d->containments.end(), std::back_inserter(conts), [activity](Containment *cont) {
196 return cont->activity() == activity
197 && (cont->containmentType() == Plasma::Containment::Type::Desktop || cont->containmentType() == Plasma::Containment::Type::Custom);
198 });
199
200 return conts;
201}
202
204{
206
207 if (screen < 0) {
208 return conts;
209 }
210
211 std::copy_if(d->containments.begin(), d->containments.end(), std::back_inserter(conts), [screen](Containment *cont) {
212 return cont->lastScreen() == screen
213 && (cont->containmentType() == Plasma::Containment::Type::Desktop //
214 || cont->containmentType() == Plasma::Containment::Type::Custom);
215 });
216
217 return conts;
218}
219
221{
222 return d->containments;
223}
224
225bool Corona::isStartupCompleted() const
226{
227 return d->containmentsStarting <= 0;
228}
229
230KSharedConfigPtr Corona::config() const
231{
232 if (!d->config) {
233 d->config = KSharedConfig::openConfig(d->configName, KConfig::SimpleConfig);
234 }
235
236 return d->config;
237}
238
239Containment *Corona::createContainment(const QString &name, const QVariantList &args)
240{
241 if (d->immutability == Types::Mutable || args.contains(QVariant::fromValue(QStringLiteral("org.kde.plasma:force-create")))) {
242 return d->addContainment(name, args, 0, -1, false);
243 }
244
245 return nullptr;
246}
247
248Containment *Corona::createContainmentDelayed(const QString &name, const QVariantList &args)
249{
250 if (d->immutability == Types::Mutable) {
251 return d->addContainment(name, args, 0, -1, true);
252 }
253
254 return nullptr;
255}
256
258{
259 return -1;
260}
261
263{
264 return 1;
265}
266
268{
269 return QRegion(screenGeometry(id));
270}
271
273{
274 return screenGeometry(id);
275}
276
278{
279 // Default implementation does nothing
280}
281
283{
284 return d->immutability;
285}
286
288{
289 return d->immutability != Types::Mutable;
290}
291
293{
294 if (d->immutability == immutable || d->immutability == Types::SystemImmutable) {
295 return;
296 }
297
298#ifndef NDEBUG
299 // qCDebug(LOG_PLASMA) << "setting immutability to" << immutable;
300#endif
301 d->immutability = immutable;
302 d->updateContainmentImmutability();
303 // tell non-containments that might care (like plasmaapp or a custom corona)
305
306 // update our actions
307 QAction *action = d->actions.value(QStringLiteral("lock widgets"));
308 if (action) {
309 if (d->immutability == Types::SystemImmutable) {
310 action->setEnabled(false);
311 action->setVisible(false);
312 } else {
313 bool unlocked = d->immutability == Types::Mutable;
314 action->setText(unlocked ? i18n("Lock Widgets") : i18n("Unlock Widgets"));
315 action->setIcon(QIcon::fromTheme(unlocked ? QStringLiteral("object-locked") : QStringLiteral("object-unlocked")));
316 action->setEnabled(true);
317 action->setVisible(true);
318 }
319 }
320
321 action = d->actions.value(QStringLiteral("edit mode"));
322 if (action) {
323 switch (d->immutability) {
325 action->setEnabled(false);
326 action->setVisible(true);
327 break;
329 action->setEnabled(false);
330 action->setVisible(false);
331 break;
332 case Types::Mutable:
333 default:
334 action->setEnabled(true);
335 action->setVisible(true);
336 break;
337 }
338 }
339
340 if (d->immutability != Types::SystemImmutable) {
341 KConfigGroup cg(config(), QStringLiteral("General"));
342
343 // we call the dptr member directly for locked since isImmutable()
344 // also checks kiosk and parent containers
345 cg.writeEntry("immutability", (int)d->immutability);
347 }
348
349 if (d->immutability != Types::Mutable) {
350 setEditMode(false);
351 }
352}
353
354void Corona::setEditMode(bool edit)
355{
356 if (edit == d->editMode || (edit && d->immutability != Plasma::Types::Mutable)) {
357 return;
358 }
359
360 QAction *editAction = d->actions.value(QStringLiteral("edit mode"));
361 if (editAction) {
362 if (edit) {
363 editAction->setText(i18n("Exit Edit Mode"));
364 } else {
365 editAction->setText(i18n("Enter Edit Mode"));
366 }
367 }
368
369 if (!edit) {
371 }
372
373 d->editMode = edit;
375}
376
378{
379 return d->editMode;
380}
381
383{
385 /* clang-format off */
390 /* clang-format on */
391
392 const auto containments = this->containments();
393 for (Containment *containment : containments) {
394 if (containment->lastScreen() == screen && freeEdges.contains(containment->location())) {
395 freeEdges.removeAll(containment->location());
396 }
397 }
398
399 return freeEdges;
400}
401
402QAction *Corona::action(const QString &name) const
403{
404 return d->actions.value(name);
405}
406
408{
409 if (name.isEmpty()) {
410 return;
411 }
412 action->setObjectName(name);
413 QAction *oldAction = d->actions.value(name);
414 if (oldAction && QJSEngine::objectOwnership(oldAction) == QJSEngine::CppOwnership) {
415 delete oldAction;
416 }
417 connect(action, &QObject::destroyed, this, [this, name]() {
418 d->actions.remove(name);
419 });
420 d->actions[name] = action;
421}
422
424{
425 QAction *action = d->actions.value(name);
427 delete action;
428 }
429 d->actions.remove(name);
430}
431
433{
434 return d->actions.values();
435}
436
437CoronaPrivate::CoronaPrivate(Corona *corona)
438 : q(corona)
439 , immutability(Types::Mutable)
440 , config(nullptr)
441 , configSyncTimer(new QTimer(corona))
442 , containmentsStarting(0)
443{
444 // TODO: make Package path configurable
445
447 configName = QCoreApplication::instance()->applicationName() + QStringLiteral("-appletsrc");
448 } else {
449 configName = QStringLiteral("plasma-appletsrc");
450 }
451}
452
453CoronaPrivate::~CoronaPrivate()
454{
455 // Do not qDeleteAll. The list gets mutated as objects are destroyed because we are connected to the destroyed signal!
456 while (!containments.isEmpty()) {
457 delete containments.takeAt(0);
458 }
459}
460
461void CoronaPrivate::init()
462{
463 desktopDefaultsConfig = KConfigGroup(KSharedConfig::openConfig(package.filePath("defaults")), QStringLiteral("Desktop"));
464
465 configSyncTimer->setSingleShot(true);
466 QObject::connect(configSyncTimer, SIGNAL(timeout()), q, SLOT(syncConfig()));
467
468 QAction *lockAction = new QAction(q);
469 q->setAction(QStringLiteral("lock widgets"), lockAction);
470 QObject::connect(lockAction, SIGNAL(triggered(bool)), q, SLOT(toggleImmutability()));
471 lockAction->setText(i18n("Lock Widgets"));
472 lockAction->setAutoRepeat(true);
473 lockAction->setIcon(QIcon::fromTheme(QStringLiteral("object-locked")));
475
476 // fake containment/applet actions
477 auto containmentActions = AppletPrivate::defaultActions(q); // containment has to start with applet stuff
478 ContainmentPrivate::addDefaultActions(containmentActions, nullptr, q); // now it's really containment
479 actions.insert(containmentActions);
480
481 QAction *editAction = new QAction(q);
482 q->setAction(QStringLiteral("edit mode"), editAction);
483 QObject::connect(editAction, &QAction::triggered, q, [this]() {
484 q->setEditMode(!q->isEditMode());
485 });
486 editAction->setText(i18n("Enter Edit Mode"));
487 editAction->setAutoRepeat(true);
488 editAction->setIcon(QIcon::fromTheme(QStringLiteral("document-edit")));
490}
491
492void CoronaPrivate::toggleImmutability()
493{
494 if (immutability == Types::Mutable) {
495 q->setImmutability(Types::UserImmutable);
496 } else {
497 q->setImmutability(Types::Mutable);
498 }
499}
500
501void CoronaPrivate::saveLayout(KSharedConfigPtr cg) const
502{
503 KConfigGroup containmentsGroup(cg, QStringLiteral("Containments"));
504 for (const Containment *containment : containments) {
505 QString cid = QString::number(containment->id());
506 KConfigGroup containmentConfig(&containmentsGroup, cid);
507 containment->save(containmentConfig);
508 }
509}
510
511void CoronaPrivate::updateContainmentImmutability()
512{
513 for (Containment *c : std::as_const(containments)) {
514 // we need to tell each containment that immutability has been altered
515 c->updateConstraints(Applet::ImmutableConstraint);
516 }
517}
518
519void CoronaPrivate::containmentDestroyed(QObject *obj)
520{
521 // we do a static_cast here since it really isn't an Containment by this
522 // point anymore since we are in the qobject dtor. we don't actually
523 // try and do anything with it, we just need the value of the pointer
524 // so this unsafe looking code is actually just fine.
525 Containment *containment = static_cast<Plasma::Containment *>(obj);
526 int index = containments.indexOf(containment);
527
528 if (index > -1) {
529 containments.removeAt(index);
530 q->requestConfigSync();
531 }
532}
533
534void CoronaPrivate::syncConfig()
535{
536 q->config()->sync();
537 Q_EMIT q->configSynced();
538}
539
540Containment *CoronaPrivate::addContainment(const QString &name, const QVariantList &args, uint id, int lastScreen, bool delayedInit)
541{
542 QString pluginName = name;
543 Containment *containment = nullptr;
544 Applet *applet = nullptr;
545
546 // qCDebug(LOG_PLASMA) << "Loading" << name << args << id;
547
548 if (pluginName.isEmpty() || pluginName == QLatin1String("default")) {
549 // default to the desktop containment
550 pluginName = desktopDefaultsConfig.readEntry("Containment", "org.kde.desktopcontainment");
551 }
552
553 bool loadingNull = pluginName == QLatin1String("null");
554 if (!loadingNull) {
555 applet = PluginLoader::self()->loadApplet(pluginName, id, args);
556 containment = dynamic_cast<Containment *>(applet);
557 if (containment) {
558 containment->setParent(q);
559 }
560 }
561
562 if (!containment) {
563 if (!loadingNull) {
564#ifndef NDEBUG
565 // qCDebug(LOG_PLASMA) << "loading of containment" << name << "failed.";
566#endif
567 }
568 // in case we got a non-Containment from Applet::loadApplet or
569 // a null containment was requested
570 if (applet) {
571 // the applet probably doesn't know what's hit it, so let's pretend it can be
572 // initialized to make assumptions in the applet's dtor safer
573 applet->init();
574 delete applet;
575 }
576 applet = containment = new Containment(q, KPluginMetaData(), QVariantList{QVariant(), id});
577 if (lastScreen >= 0) {
578 containment->d->lastScreen = lastScreen;
579 }
580 // if it's a dummy containment, just say its ui is ready, not blocking the corona
582
583 // we want to provide something and don't care about the failure to launch
585 }
586
587 // if this is a new containment, we need to ensure that there are no stale
588 // configuration data around
589 if (id == 0) {
590 KConfigGroup conf(q->config(), QStringLiteral("Containments"));
591 conf = KConfigGroup(&conf, QString::number(containment->id()));
592 conf.deleteGroup();
593 }
594
595 // make sure the containments are sorted by id
596 const auto position = std::lower_bound(containments.begin(), containments.end(), containment, [](Plasma::Containment *c1, Plasma::Containment *c2) {
597 return c1->id() < c2->id();
598 });
599 containments.insert(position, containment);
600
601 QObject::connect(containment, SIGNAL(destroyed(QObject *)), q, SLOT(containmentDestroyed(QObject *)));
604
605 if (!delayedInit) {
606 containment->init();
607 KConfigGroup cg = containment->config();
608 containment->restore(cg);
610 containment->save(cg);
611 q->requestConfigSync();
612 containment->flushPendingConstraintsEvents();
613 Q_EMIT q->containmentAdded(containment);
614 // if id = 0 a new containment has been created, not restored
615 if (id == 0) {
616 Q_EMIT q->containmentCreated(containment);
617 }
618 }
619
620 return containment;
621}
622
623QList<Plasma::Containment *> CoronaPrivate::importLayout(const KConfigGroup &conf, bool mergeConfig)
624{
625 if (!conf.isValid()) {
626 return QList<Containment *>();
627 }
628
629 QList<Plasma::Containment *> newContainments;
630 QSet<uint> containmentsIds;
631
632 for (Containment *containment : std::as_const(containments)) {
633 containmentsIds.insert(containment->id());
634 }
635
636 KConfigGroup containmentsGroup(&conf, QStringLiteral("Containments"));
637 QStringList groups = containmentsGroup.groupList();
638 std::sort(groups.begin(), groups.end());
639
640 for (const QString &group : std::as_const(groups)) {
641 KConfigGroup containmentConfig(&containmentsGroup, group);
642
643 if (containmentConfig.entryMap().isEmpty()) {
644 continue;
645 } else if (containmentConfig.readEntry(QStringLiteral("transient"), false)) {
646 containmentConfig.deleteGroup();
647 continue;
648 }
649
650 uint cid = group.toUInt();
651 if (containmentsIds.contains(cid)) {
652 cid = ++AppletPrivate::s_maxAppletId;
653 } else if (cid > AppletPrivate::s_maxAppletId) {
654 AppletPrivate::s_maxAppletId = cid;
655 }
656
657 if (mergeConfig) {
658 KConfigGroup realConf(q->config(), QStringLiteral("Containments"));
659 realConf = KConfigGroup(&realConf, QString::number(cid));
660 // in case something was there before us
661 realConf.deleteGroup();
662 containmentConfig.copyTo(&realConf);
663 }
664
665 // qCDebug(LOG_PLASMA) << "got a containment in the config, trying to make a" << containmentConfig.readEntry("plugin", QString()) << "from" << group;
666#ifndef NDEBUG
667 // qCDebug(LOG_PLASMA) << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "Adding Containment" << containmentConfig.readEntry("plugin",
668 // QString());
669#endif
670 Containment *c = addContainment(containmentConfig.readEntry("plugin", QString()), QVariantList(), cid, -1);
671 if (!c) {
672 continue;
673 }
674
675 newContainments.append(c);
676 containmentsIds.insert(c->id());
677
678#ifndef NDEBUG
679// qCDebug(LOG_PLASMA) << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "Restored Containment" << c->pluginName();
680#endif
681 }
682
683 if (!mergeConfig) {
684 notifyContainmentsReady();
685 }
686
687 return newContainments;
688}
689
690void CoronaPrivate::notifyContainmentsReady()
691{
692 containmentsStarting = 0;
693 for (Containment *containment : std::as_const(containments)) {
694 if (!containment->isUiReady() && containment->screen() >= 0) {
695 ++containmentsStarting;
696 QObject::connect(containment, &Plasma::Containment::uiReadyChanged, q, [this](bool ready) {
697 containmentReady(ready);
698 });
699 }
700 }
701
702 if (containmentsStarting <= 0) {
703 Q_EMIT q->startupCompleted();
704 }
705}
706
707void CoronaPrivate::containmentReady(bool ready)
708{
709 if (!ready) {
710 return;
711 }
712 --containmentsStarting;
713 if (containmentsStarting <= 0) {
714 Q_EMIT q->startupCompleted();
715 }
716}
717
718} // namespace Plasma
719
720#include "moc_corona.cpp"
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 sync() override
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:276
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
@ ImmutableConstraint
the immutability (locked) nature of the applet changed
Definition applet.h:218
Plasma::Types::ImmutabilityType immutability
The immutability of the Corona.
Definition applet.h:106
void configNeedsSaving()
Emitted when an applet has changed values in its configuration and wishes for them to be saved at the...
virtual void init()
This method is called once the applet is loaded and added to a Corona.
Definition applet.cpp:87
void flushPendingConstraintsEvents()
Sends all pending constraints updates to the applet.
Definition applet.cpp:543
The base class for plugins that provide backgrounds and applet grouping containers.
Definition containment.h:47
void save(KConfigGroup &group) const override
void setActivity(const QString &activityId)
Sets the current activity by id.
void uiReadyChanged(bool uiReady)
Emitted when the ui has been fully loaded and is fully working.
@ Custom
A containment that is neither a desktop nor a panel but something application specific.
@ Desktop
A desktop containment.
void setFormFactor(Plasma::Types::FormFactor formFactor)
Sets the form factor for this Containment.
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.
void screenChanged(int newScreen)
This signal indicates that a containment has been associated (or dissociated) with a physical screen.
void restore(KConfigGroup &group) override
A bookkeeping Scene for Plasma::Applets.
Definition corona.h:28
virtual int numScreens() const
Returns the number of screens available to plasma.
Definition corona.cpp:262
QList< Plasma::Containment * > importLayout(const KConfigGroup &config)
Imports an applet layout from a config file.
Definition corona.cpp:152
void kPackageChanged(const KPackage::Package &package)
Emitted when the package for this corona has been changed.
QList< Plasma::Types::Location > freeEdges(int screen) const
This method is useful in order to retrieve the list of available screen edges for panel type containm...
Definition corona.cpp:382
virtual void loadDefaultLayout()
Loads the default (system wide) layout for this user.
Definition corona.cpp:277
Q_INVOKABLE QAction * action(const QString &name) const
Definition corona.cpp:402
void requestConfigSync()
Schedules a flush-to-disk synchronization of the configuration state at the next convenient moment.
Definition corona.cpp:109
void exportLayout(KConfigGroup &config, QList< Containment * > containments)
Exports a set of containments to a config file.
Definition corona.cpp:74
void immutabilityChanged(Plasma::Types::ImmutabilityType immutability)
emitted when immutability changes.
virtual int screenForContainment(const Containment *containment) const
Definition corona.cpp:257
virtual QRect screenGeometry(int id) const =0
Returns the geometry of a given screen.
void setEditMode(bool edit)
Set the Corona globally into "edit mode" Only when the corona is of mutable type can be set of edit m...
Definition corona.cpp:354
void loadLayout(const QString &config=QString())
Load applet layout from a config file.
Definition corona.cpp:132
QList< Containment * > containmentsForScreen(int screen)
Returns all containments which match a particular screen, for any activity.
Definition corona.cpp:203
void setAction(const QString &name, QAction *action)
Defines a new action with the given name in the internal collection.
Definition corona.cpp:407
void setKPackage(const KPackage::Package &package)
Setting the package for the corona.
Definition corona.cpp:55
bool immutable() const
Definition corona.cpp:287
virtual QRegion availableScreenRegion(int id) const
Returns the available region for a given screen.
Definition corona.cpp:267
void screenOwnerChanged(int isScreen)
This signal indicates that a containment has been newly associated (or dissociated) with a physical s...
QList< Containment * > containments() const
Definition corona.cpp:220
Containment * containmentForScreen(int screen, const QString &activity, const QString &defaultPluginIfNonExistent, const QVariantList &defaultArgs=QVariantList())
Returns the Containment for a given physical screen and desktop, creating one if none exists.
Definition corona.cpp:157
bool isEditMode() const
Definition corona.cpp:377
QList< QAction * > actions() const
Definition corona.cpp:432
void setImmutability(const Types::ImmutabilityType immutable)
Sets the immutability type for this Corona (not immutable, user immutable or system immutable)
Definition corona.cpp:292
KSharedConfig::Ptr config() const
Returns the config file used to store the configuration for this Corona.
Definition corona.cpp:230
void editModeChanged(bool edit)
emitted when the editMode state changes
Containment * createContainment(const QString &name, const QVariantList &args=QVariantList())
Adds a Containment to the Corona.
Definition corona.cpp:239
void requireConfigSync()
Schedules a time sensitive flush-to-disk synchronization of the configuration state.
Definition corona.cpp:127
virtual QRect availableScreenRect(int id) const
Returns the available rect for a given screen.
Definition corona.cpp:272
Containment * createContainmentDelayed(const QString &name, const QVariantList &args=QVariantList())
Loads a containment with delayed initialization, primarily useful for implementations of loadDefaultL...
Definition corona.cpp:248
void removeAction(const QString &name)
Remove the action with the given name, if exists.
Definition corona.cpp:423
Types::ImmutabilityType immutability() const
Definition corona.cpp:282
QList< Containment * > containmentsForActivity(const QString &activity)
Returns all containments which match a particular activity, for any screen.
Definition corona.cpp:187
void saveLayout(const QString &config=QString()) const
Save applets layout to file.
Definition corona.cpp:61
Applet * loadApplet(const QString &name, uint appletId=0, const QVariantList &args=QVariantList())
Load an Applet plugin.
static PluginLoader * self()
Return the active plugin loader.
Enums and constants used in Plasma.
Definition plasma.h:29
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
@ UserImmutable
The user has requested a lock down, and can undo the lock down at any time.
Definition plasma.h:101
@ RightEdge
Along the right side of the screen.
Definition plasma.h:90
@ TopEdge
Along the top of the screen.
Definition plasma.h:87
@ LeftEdge
Along the left side of the screen.
Definition plasma.h:89
@ BottomEdge
Along the bottom of the screen.
Definition plasma.h:88
@ Planar
The applet lives in a plane and has two degrees of freedom to grow.
Definition plasma.h:41
QString i18n(const char *text, const TYPE &arg...)
QString name(StandardAction id)
Namespace for everything in libplasma.
void setAutoRepeat(bool)
void setIcon(const QIcon &icon)
void setShortcutContext(Qt::ShortcutContext context)
void setText(const QString &text)
void triggered(bool checked)
QCoreApplication * instance()
QIcon fromTheme(const QString &name)
ObjectOwnership objectOwnership(QObject *object)
void append(QList< T > &&value)
iterator begin()
iterator end()
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
void destroyed(QObject *obj)
void setParent(QObject *parent)
bool contains(const QSet< T > &other) const const
iterator insert(const T &value)
bool isEmpty() const const
QString number(double n, char format, int precision)
ApplicationShortcut
QVariant fromValue(T &&value)
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Feb 28 2025 11:50:52 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.