Plasma-framework

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->screen() == 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 qDeleteAll(containments);
451}
452
453void CoronaPrivate::init()
454{
455 desktopDefaultsConfig = KConfigGroup(KSharedConfig::openConfig(package.filePath("defaults")), QStringLiteral("Desktop"));
456
457 configSyncTimer->setSingleShot(true);
458 QObject::connect(configSyncTimer, SIGNAL(timeout()), q, SLOT(syncConfig()));
459
460 QAction *lockAction = new QAction(q);
461 q->setAction(QStringLiteral("lock widgets"), lockAction);
462 QObject::connect(lockAction, SIGNAL(triggered(bool)), q, SLOT(toggleImmutability()));
463 lockAction->setText(i18n("Lock Widgets"));
464 lockAction->setAutoRepeat(true);
465 lockAction->setIcon(QIcon::fromTheme(QStringLiteral("object-locked")));
467
468 // fake containment/applet actions
469 auto containmentActions = AppletPrivate::defaultActions(q); // containment has to start with applet stuff
470 ContainmentPrivate::addDefaultActions(containmentActions, nullptr, q); // now it's really containment
471 actions.insert(containmentActions);
472
473 QAction *editAction = new QAction(q);
474 q->setAction(QStringLiteral("edit mode"), editAction);
475 QObject::connect(editAction, &QAction::triggered, q, [this]() {
476 q->setEditMode(!q->isEditMode());
477 });
478 editAction->setText(i18n("Enter Edit Mode"));
479 editAction->setAutoRepeat(true);
480 editAction->setIcon(QIcon::fromTheme(QStringLiteral("document-edit")));
481 editAction->setShortcut(QKeySequence(QStringLiteral("alt+d, e")));
483}
484
485void CoronaPrivate::toggleImmutability()
486{
487 if (immutability == Types::Mutable) {
488 q->setImmutability(Types::UserImmutable);
489 } else {
490 q->setImmutability(Types::Mutable);
491 }
492}
493
494void CoronaPrivate::saveLayout(KSharedConfigPtr cg) const
495{
496 KConfigGroup containmentsGroup(cg, QStringLiteral("Containments"));
497 for (const Containment *containment : containments) {
498 QString cid = QString::number(containment->id());
499 KConfigGroup containmentConfig(&containmentsGroup, cid);
500 containment->save(containmentConfig);
501 }
502}
503
504void CoronaPrivate::updateContainmentImmutability()
505{
506 for (Containment *c : std::as_const(containments)) {
507 // we need to tell each containment that immutability has been altered
508 c->updateConstraints(Applet::ImmutableConstraint);
509 }
510}
511
512void CoronaPrivate::containmentDestroyed(QObject *obj)
513{
514 // we do a static_cast here since it really isn't an Containment by this
515 // point anymore since we are in the qobject dtor. we don't actually
516 // try and do anything with it, we just need the value of the pointer
517 // so this unsafe looking code is actually just fine.
518 Containment *containment = static_cast<Plasma::Containment *>(obj);
519 int index = containments.indexOf(containment);
520
521 if (index > -1) {
522 containments.removeAt(index);
523 q->requestConfigSync();
524 }
525}
526
527void CoronaPrivate::syncConfig()
528{
529 q->config()->sync();
530 Q_EMIT q->configSynced();
531}
532
533Containment *CoronaPrivate::addContainment(const QString &name, const QVariantList &args, uint id, int lastScreen, bool delayedInit)
534{
535 QString pluginName = name;
536 Containment *containment = nullptr;
537 Applet *applet = nullptr;
538
539 // qCDebug(LOG_PLASMA) << "Loading" << name << args << id;
540
541 if (pluginName.isEmpty() || pluginName == QLatin1String("default")) {
542 // default to the desktop containment
543 pluginName = desktopDefaultsConfig.readEntry("Containment", "org.kde.desktopcontainment");
544 }
545
546 bool loadingNull = pluginName == QLatin1String("null");
547 if (!loadingNull) {
548 applet = PluginLoader::self()->loadApplet(pluginName, id, args);
549 containment = dynamic_cast<Containment *>(applet);
550 if (containment) {
551 containment->setParent(q);
552 }
553 }
554
555 if (!containment) {
556 if (!loadingNull) {
557#ifndef NDEBUG
558 // qCDebug(LOG_PLASMA) << "loading of containment" << name << "failed.";
559#endif
560 }
561 // in case we got a non-Containment from Applet::loadApplet or
562 // a null containment was requested
563 if (applet) {
564 // the applet probably doesn't know what's hit it, so let's pretend it can be
565 // initialized to make assumptions in the applet's dtor safer
566 applet->init();
567 delete applet;
568 }
569 applet = containment = new Containment(q, KPluginMetaData(), QVariantList{QVariant(), id});
570 if (lastScreen >= 0) {
571 containment->d->lastScreen = lastScreen;
572 }
573 // if it's a dummy containment, just say its ui is ready, not blocking the corona
575
576 // we want to provide something and don't care about the failure to launch
578 }
579
580 // if this is a new containment, we need to ensure that there are no stale
581 // configuration data around
582 if (id == 0) {
583 KConfigGroup conf(q->config(), QStringLiteral("Containments"));
584 conf = KConfigGroup(&conf, QString::number(containment->id()));
585 conf.deleteGroup();
586 }
587
588 // make sure the containments are sorted by id
589 auto position = std::lower_bound(containments.begin(), containments.end(), containment, [](Plasma::Containment *c1, Plasma::Containment *c2) {
590 return c1->id() < c2->id();
591 });
592 containments.insert(position, containment);
593
594 QObject::connect(containment, SIGNAL(destroyed(QObject *)), q, SLOT(containmentDestroyed(QObject *)));
597
598 if (!delayedInit) {
599 containment->init();
600 KConfigGroup cg = containment->config();
601 containment->restore(cg);
603 containment->save(cg);
604 q->requestConfigSync();
605 containment->flushPendingConstraintsEvents();
606 Q_EMIT q->containmentAdded(containment);
607 // if id = 0 a new containment has been created, not restored
608 if (id == 0) {
609 Q_EMIT q->containmentCreated(containment);
610 }
611 }
612
613 return containment;
614}
615
616QList<Plasma::Containment *> CoronaPrivate::importLayout(const KConfigGroup &conf, bool mergeConfig)
617{
618 if (!conf.isValid()) {
619 return QList<Containment *>();
620 }
621
622 QList<Plasma::Containment *> newContainments;
623 QSet<uint> containmentsIds;
624
625 for (Containment *containment : std::as_const(containments)) {
626 containmentsIds.insert(containment->id());
627 }
628
629 KConfigGroup containmentsGroup(&conf, QStringLiteral("Containments"));
630 QStringList groups = containmentsGroup.groupList();
631 std::sort(groups.begin(), groups.end());
632
633 for (const QString &group : std::as_const(groups)) {
634 KConfigGroup containmentConfig(&containmentsGroup, group);
635
636 if (containmentConfig.entryMap().isEmpty()) {
637 continue;
638 } else if (containmentConfig.readEntry(QStringLiteral("transient"), false)) {
639 containmentConfig.deleteGroup();
640 continue;
641 }
642
643 uint cid = group.toUInt();
644 if (containmentsIds.contains(cid)) {
645 cid = ++AppletPrivate::s_maxAppletId;
646 } else if (cid > AppletPrivate::s_maxAppletId) {
647 AppletPrivate::s_maxAppletId = cid;
648 }
649
650 if (mergeConfig) {
651 KConfigGroup realConf(q->config(), QStringLiteral("Containments"));
652 realConf = KConfigGroup(&realConf, QString::number(cid));
653 // in case something was there before us
654 realConf.deleteGroup();
655 containmentConfig.copyTo(&realConf);
656 }
657
658 // qCDebug(LOG_PLASMA) << "got a containment in the config, trying to make a" << containmentConfig.readEntry("plugin", QString()) << "from" << group;
659#ifndef NDEBUG
660 // qCDebug(LOG_PLASMA) << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "Adding Containment" << containmentConfig.readEntry("plugin",
661 // QString());
662#endif
663 Containment *c = addContainment(containmentConfig.readEntry("plugin", QString()), QVariantList(), cid, -1);
664 if (!c) {
665 continue;
666 }
667
668 newContainments.append(c);
669 containmentsIds.insert(c->id());
670
671#ifndef NDEBUG
672// qCDebug(LOG_PLASMA) << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "Restored Containment" << c->pluginName();
673#endif
674 }
675
676 if (!mergeConfig) {
677 notifyContainmentsReady();
678 }
679
680 return newContainments;
681}
682
683void CoronaPrivate::notifyContainmentsReady()
684{
685 containmentsStarting = 0;
686 for (Containment *containment : std::as_const(containments)) {
687 if (!containment->isUiReady() && containment->screen() >= 0) {
688 ++containmentsStarting;
689 QObject::connect(containment, &Plasma::Containment::uiReadyChanged, q, [this](bool ready) {
690 containmentReady(ready);
691 });
692 }
693 }
694
695 if (containmentsStarting <= 0) {
696 Q_EMIT q->startupCompleted();
697 }
698}
699
700void CoronaPrivate::containmentReady(bool ready)
701{
702 if (!ready) {
703 return;
704 }
705 --containmentsStarting;
706 if (containmentsStarting <= 0) {
707 Q_EMIT q->startupCompleted();
708 }
709}
710
711} // namespace Plasma
712
713#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
KConfig * config()
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:269
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
@ 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:92
void flushPendingConstraintsEvents()
Sends all pending constraints updates to the applet.
Definition applet.cpp:536
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(StandardAction 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 Fri May 17 2024 11:54:11 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.