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 if (d->immutability == immutable || d->immutability == Types::SystemImmutable) {
290 return;
291 }
292
293#ifndef NDEBUG
294 // qCDebug(LOG_PLASMA) << "setting immutability to" << immutable;
295#endif
296 d->immutability = immutable;
297 d->updateContainmentImmutability();
298 // tell non-containments that might care (like plasmaapp or a custom corona)
299 Q_EMIT immutabilityChanged(immutable);
300
301 // update our actions
302 QAction *action = d->actions.value(QStringLiteral("lock widgets"));
303 if (action) {
304 if (d->immutability == Types::SystemImmutable) {
305 action->setEnabled(false);
306 action->setVisible(false);
307 } else {
308 bool unlocked = d->immutability == Types::Mutable;
309 action->setText(unlocked ? i18n("Lock Widgets") : i18n("Unlock Widgets"));
310 action->setIcon(QIcon::fromTheme(unlocked ? QStringLiteral("object-locked") : QStringLiteral("object-unlocked")));
311 action->setEnabled(true);
312 action->setVisible(true);
313 }
314 }
315
316 action = d->actions.value(QStringLiteral("edit mode"));
317 if (action) {
318 switch (d->immutability) {
320 action->setEnabled(false);
321 action->setVisible(true);
322 break;
324 action->setEnabled(false);
325 action->setVisible(false);
326 break;
327 case Types::Mutable:
328 default:
329 action->setEnabled(true);
330 action->setVisible(true);
331 break;
332 }
333 }
334
335 if (d->immutability != Types::SystemImmutable) {
336 KConfigGroup cg(config(), QStringLiteral("General"));
337
338 // we call the dptr member directly for locked since isImmutable()
339 // also checks kiosk and parent containers
340 cg.writeEntry("immutability", (int)d->immutability);
342 }
343
344 if (d->immutability != Types::Mutable) {
345 setEditMode(false);
346 }
347}
348
349void Corona::setEditMode(bool edit)
350{
351 if (edit == d->editMode || (edit && d->immutability != Plasma::Types::Mutable)) {
352 return;
353 }
354
355 QAction *editAction = d->actions.value(QStringLiteral("edit mode"));
356 if (editAction) {
357 if (edit) {
358 editAction->setText(i18n("Exit Edit Mode"));
359 } else {
360 editAction->setText(i18n("Enter Edit Mode"));
361 }
362 }
363
364 if (!edit) {
366 }
367
368 d->editMode = edit;
370}
371
373{
374 return d->editMode;
375}
376
378{
380 /* clang-format off */
385 /* clang-format on */
386
387 const auto containments = this->containments();
388 for (Containment *containment : containments) {
389 if (containment->lastScreen() == screen && freeEdges.contains(containment->location())) {
390 freeEdges.removeAll(containment->location());
391 }
392 }
393
394 return freeEdges;
395}
396
397QAction *Corona::action(const QString &name) const
398{
399 return d->actions.value(name);
400}
401
402void Corona::setAction(const QString &name, QAction *action)
403{
404 if (name.isEmpty()) {
405 return;
406 }
407 action->setObjectName(name);
408 QAction *oldAction = d->actions.value(name);
409 if (oldAction && QJSEngine::objectOwnership(oldAction) == QJSEngine::CppOwnership) {
410 delete oldAction;
411 }
412 connect(action, &QObject::destroyed, this, [this, name]() {
413 d->actions.remove(name);
414 });
415 d->actions[name] = action;
416}
417
419{
420 QAction *action = d->actions.value(name);
422 delete action;
423 }
424 d->actions.remove(name);
425}
426
428{
429 return d->actions.values();
430}
431
432CoronaPrivate::CoronaPrivate(Corona *corona)
433 : q(corona)
434 , immutability(Types::Mutable)
435 , config(nullptr)
436 , configSyncTimer(new QTimer(corona))
437 , containmentsStarting(0)
438{
439 // TODO: make Package path configurable
440
442 configName = QCoreApplication::instance()->applicationName() + QStringLiteral("-appletsrc");
443 } else {
444 configName = QStringLiteral("plasma-appletsrc");
445 }
446}
447
448CoronaPrivate::~CoronaPrivate()
449{
450 // Do not qDeleteAll. The list gets mutated as objects are destroyed because we are connected to the destroyed signal!
451 while (!containments.isEmpty()) {
452 delete containments.takeAt(0);
453 }
454}
455
456void CoronaPrivate::init()
457{
458 desktopDefaultsConfig = KConfigGroup(KSharedConfig::openConfig(package.filePath("defaults")), QStringLiteral("Desktop"));
459
460 configSyncTimer->setSingleShot(true);
461 QObject::connect(configSyncTimer, SIGNAL(timeout()), q, SLOT(syncConfig()));
462
463 QAction *lockAction = new QAction(q);
464 q->setAction(QStringLiteral("lock widgets"), lockAction);
465 QObject::connect(lockAction, SIGNAL(triggered(bool)), q, SLOT(toggleImmutability()));
466 lockAction->setText(i18n("Lock Widgets"));
467 lockAction->setAutoRepeat(true);
468 lockAction->setIcon(QIcon::fromTheme(QStringLiteral("object-locked")));
470
471 // fake containment/applet actions
472 auto containmentActions = AppletPrivate::defaultActions(q); // containment has to start with applet stuff
473 ContainmentPrivate::addDefaultActions(containmentActions, nullptr, q); // now it's really containment
474 actions.insert(containmentActions);
475
476 QAction *editAction = new QAction(q);
477 q->setAction(QStringLiteral("edit mode"), editAction);
478 QObject::connect(editAction, &QAction::triggered, q, [this]() {
479 q->setEditMode(!q->isEditMode());
480 });
481 editAction->setText(i18n("Enter Edit Mode"));
482 editAction->setAutoRepeat(true);
483 editAction->setIcon(QIcon::fromTheme(QStringLiteral("document-edit")));
484 editAction->setShortcut(QKeySequence(QStringLiteral("alt+d, e")));
486}
487
488void CoronaPrivate::toggleImmutability()
489{
490 if (immutability == Types::Mutable) {
491 q->setImmutability(Types::UserImmutable);
492 } else {
493 q->setImmutability(Types::Mutable);
494 }
495}
496
497void CoronaPrivate::saveLayout(KSharedConfigPtr cg) const
498{
499 KConfigGroup containmentsGroup(cg, QStringLiteral("Containments"));
500 for (const Containment *containment : containments) {
501 QString cid = QString::number(containment->id());
502 KConfigGroup containmentConfig(&containmentsGroup, cid);
503 containment->save(containmentConfig);
504 }
505}
506
507void CoronaPrivate::updateContainmentImmutability()
508{
509 for (Containment *c : std::as_const(containments)) {
510 // we need to tell each containment that immutability has been altered
511 c->updateConstraints(Applet::ImmutableConstraint);
512 }
513}
514
515void CoronaPrivate::containmentDestroyed(QObject *obj)
516{
517 // we do a static_cast here since it really isn't an Containment by this
518 // point anymore since we are in the qobject dtor. we don't actually
519 // try and do anything with it, we just need the value of the pointer
520 // so this unsafe looking code is actually just fine.
521 Containment *containment = static_cast<Plasma::Containment *>(obj);
522 int index = containments.indexOf(containment);
523
524 if (index > -1) {
525 containments.removeAt(index);
526 q->requestConfigSync();
527 }
528}
529
530void CoronaPrivate::syncConfig()
531{
532 q->config()->sync();
533 Q_EMIT q->configSynced();
534}
535
536Containment *CoronaPrivate::addContainment(const QString &name, const QVariantList &args, uint id, int lastScreen, bool delayedInit)
537{
538 QString pluginName = name;
539 Containment *containment = nullptr;
540 Applet *applet = nullptr;
541
542 // qCDebug(LOG_PLASMA) << "Loading" << name << args << id;
543
544 if (pluginName.isEmpty() || pluginName == QLatin1String("default")) {
545 // default to the desktop containment
546 pluginName = desktopDefaultsConfig.readEntry("Containment", "org.kde.desktopcontainment");
547 }
548
549 bool loadingNull = pluginName == QLatin1String("null");
550 if (!loadingNull) {
551 applet = PluginLoader::self()->loadApplet(pluginName, id, args);
552 containment = dynamic_cast<Containment *>(applet);
553 if (containment) {
554 containment->setParent(q);
555 }
556 }
557
558 if (!containment) {
559 if (!loadingNull) {
560#ifndef NDEBUG
561 // qCDebug(LOG_PLASMA) << "loading of containment" << name << "failed.";
562#endif
563 }
564 // in case we got a non-Containment from Applet::loadApplet or
565 // a null containment was requested
566 if (applet) {
567 // the applet probably doesn't know what's hit it, so let's pretend it can be
568 // initialized to make assumptions in the applet's dtor safer
569 applet->init();
570 delete applet;
571 }
572 applet = containment = new Containment(q, KPluginMetaData(), QVariantList{QVariant(), id});
573 if (lastScreen >= 0) {
574 containment->d->lastScreen = lastScreen;
575 }
576 // if it's a dummy containment, just say its ui is ready, not blocking the corona
578
579 // we want to provide something and don't care about the failure to launch
581 }
582
583 // if this is a new containment, we need to ensure that there are no stale
584 // configuration data around
585 if (id == 0) {
586 KConfigGroup conf(q->config(), QStringLiteral("Containments"));
587 conf = KConfigGroup(&conf, QString::number(containment->id()));
588 conf.deleteGroup();
589 }
590
591 // make sure the containments are sorted by id
592 const auto position = std::lower_bound(containments.begin(), containments.end(), containment, [](Plasma::Containment *c1, Plasma::Containment *c2) {
593 return c1->id() < c2->id();
594 });
595 containments.insert(position, containment);
596
597 QObject::connect(containment, SIGNAL(destroyed(QObject *)), q, SLOT(containmentDestroyed(QObject *)));
600
601 if (!delayedInit) {
602 containment->init();
603 KConfigGroup cg = containment->config();
604 containment->restore(cg);
606 containment->save(cg);
607 q->requestConfigSync();
608 containment->flushPendingConstraintsEvents();
609 Q_EMIT q->containmentAdded(containment);
610 // if id = 0 a new containment has been created, not restored
611 if (id == 0) {
612 Q_EMIT q->containmentCreated(containment);
613 }
614 }
615
616 return containment;
617}
618
619QList<Plasma::Containment *> CoronaPrivate::importLayout(const KConfigGroup &conf, bool mergeConfig)
620{
621 if (!conf.isValid()) {
622 return QList<Containment *>();
623 }
624
625 QList<Plasma::Containment *> newContainments;
626 QSet<uint> containmentsIds;
627
628 for (Containment *containment : std::as_const(containments)) {
629 containmentsIds.insert(containment->id());
630 }
631
632 KConfigGroup containmentsGroup(&conf, QStringLiteral("Containments"));
633 QStringList groups = containmentsGroup.groupList();
634 std::sort(groups.begin(), groups.end());
635
636 for (const QString &group : std::as_const(groups)) {
637 KConfigGroup containmentConfig(&containmentsGroup, group);
638
639 if (containmentConfig.entryMap().isEmpty()) {
640 continue;
641 } else if (containmentConfig.readEntry(QStringLiteral("transient"), false)) {
642 containmentConfig.deleteGroup();
643 continue;
644 }
645
646 uint cid = group.toUInt();
647 if (containmentsIds.contains(cid)) {
648 cid = ++AppletPrivate::s_maxAppletId;
649 } else if (cid > AppletPrivate::s_maxAppletId) {
650 AppletPrivate::s_maxAppletId = cid;
651 }
652
653 if (mergeConfig) {
654 KConfigGroup realConf(q->config(), QStringLiteral("Containments"));
655 realConf = KConfigGroup(&realConf, QString::number(cid));
656 // in case something was there before us
657 realConf.deleteGroup();
658 containmentConfig.copyTo(&realConf);
659 }
660
661 // qCDebug(LOG_PLASMA) << "got a containment in the config, trying to make a" << containmentConfig.readEntry("plugin", QString()) << "from" << group;
662#ifndef NDEBUG
663 // qCDebug(LOG_PLASMA) << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "Adding Containment" << containmentConfig.readEntry("plugin",
664 // QString());
665#endif
666 Containment *c = addContainment(containmentConfig.readEntry("plugin", QString()), QVariantList(), cid, -1);
667 if (!c) {
668 continue;
669 }
670
671 newContainments.append(c);
672 containmentsIds.insert(c->id());
673
674#ifndef NDEBUG
675// qCDebug(LOG_PLASMA) << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "Restored Containment" << c->pluginName();
676#endif
677 }
678
679 if (!mergeConfig) {
680 notifyContainmentsReady();
681 }
682
683 return newContainments;
684}
685
686void CoronaPrivate::notifyContainmentsReady()
687{
688 containmentsStarting = 0;
689 for (Containment *containment : std::as_const(containments)) {
690 if (!containment->isUiReady() && containment->screen() >= 0) {
691 ++containmentsStarting;
692 QObject::connect(containment, &Plasma::Containment::uiReadyChanged, q, [this](bool ready) {
693 containmentReady(ready);
694 });
695 }
696 }
697
698 if (containmentsStarting <= 0) {
699 Q_EMIT q->startupCompleted();
700 }
701}
702
703void CoronaPrivate::containmentReady(bool ready)
704{
705 if (!ready) {
706 return;
707 }
708 --containmentsStarting;
709 if (containmentsStarting <= 0) {
710 Q_EMIT q->startupCompleted();
711 }
712}
713
714} // namespace Plasma
715
716#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:266
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
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:533
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:377
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:397
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:349
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:402
void setKPackage(const KPackage::Package &package)
Setting the package for the corona.
Definition corona.cpp:55
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:372
QList< QAction * > actions() const
Definition corona.cpp:427
void setImmutability(const Types::ImmutabilityType immutable)
Sets the immutability type for this Corona (not immutable, user immutable or system immutable)
Definition corona.cpp:287
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:418
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(GameStandardAction id)
Namespace for everything in libplasma.
void setAutoRepeat(bool)
void setEnabled(bool)
void setIcon(const QIcon &icon)
void setShortcut(const QKeySequence &shortcut)
void setShortcutContext(Qt::ShortcutContext context)
void setText(const QString &text)
void triggered(bool checked)
void setVisible(bool)
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 setObjectName(QAnyStringView name)
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-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:34:35 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.