Plasma-framework

applet.cpp
1/*
2 SPDX-FileCopyrightText: 2005 Aaron Seigo <aseigo@kde.org>
3 SPDX-FileCopyrightText: 2007 Riccardo Iaconelli <riccardo@kde.org>
4 SPDX-FileCopyrightText: 2008 Ménard Alexis <darktears31@gmail.com>
5 SPDX-FileCopyrightText: 2009 Chani Armitage <chani@kde.org>
6
7 SPDX-License-Identifier: LGPL-2.0-or-later
8*/
9
10#include "applet.h"
11#include "private/applet_p.h"
12
13#include "config-plasma.h"
14
15#include <QAbstractButton>
16#include <QActionGroup>
17#include <QDebug>
18#include <QFile>
19#include <QJSEngine>
20#include <QList>
21#include <QMessageBox>
22#include <QMetaEnum>
23
24#include <KAuthorized>
25#include <KColorScheme>
26#include <KConfigLoader>
27#include <KConfigPropertyMap>
28#include <KDesktopFile>
29#include <KGlobalAccel>
30#include <KLocalizedString>
31#include <KPackage/Package>
32
33#include "containment.h"
34#include "corona.h"
35#include "plasma.h"
36#include "pluginloader.h"
37
38#include "debug_p.h"
39#include "private/containment_p.h"
40
41#include <cmath>
42#include <limits>
43#include <qaction.h>
44
45namespace Plasma
46{
47Applet::Applet(QObject *parentObject, const KPluginMetaData &data, const QVariantList &args)
48 : QObject(parentObject)
49 , d(new AppletPrivate(data, args.count() > 1 ? args[1].toInt() : 0, this))
50{
51 if (!args.isEmpty()) {
52 const QVariant first = args.first();
53 if (first.canConvert<KPackage::Package>()) {
54 d->package = first.value<KPackage::Package>();
55 }
56 }
57 d->icon = d->appletDescription.iconName();
58
59 if (args.contains(QVariant::fromValue(QStringLiteral("org.kde.plasma:force-create")))) {
60 setProperty("org.kde.plasma:force-create", true);
61 }
62
63 // WARNING: do not access config() OR globalConfig() in this method!
64 // that requires a scene, which is not available at this point
65 d->init(args.mid(2));
66 d->setupPackage();
67}
68
69Applet::~Applet()
70{
71 for (QAction *a : d->actions.values()) {
72 disconnect(a, nullptr, this, nullptr);
73 }
74 for (QAction *a : d->contextualActions) {
75 disconnect(a, nullptr, this, nullptr);
76 }
77 if (d->transient) {
78 d->resetConfigurationObject();
79 }
80 // let people know that i will die
82
83 // ConfigLoader is deleted when AppletPrivate closes not Applet
84 // It saves on closure and emits a signal.
85 // disconnect early to avoid a crash. See 411221
86 if (d->configLoader) {
87 disconnect(d->configLoader, SIGNAL(configChanged()), this, SLOT(propagateConfigChanged()));
88 }
89 delete d;
90}
91
93{
94 // Don't implement anything here, it will be overridden by subclasses
95}
96
97uint Applet::id() const
98{
99 return d->appletId;
100}
101
102QVariantList Applet::startupArguments() const
103{
104 return d->startupArguments;
105}
106
108{
109 if (d->transient || !d->appletDescription.isValid()) {
110 return;
111 }
112
113 KConfigGroup group = g;
114 if (!group.isValid()) {
115 group = *d->mainConfigGroup();
116 }
117
118 // qCDebug(LOG_PLASMA) << "saving" << pluginName() << "to" << group.name();
119 // we call the dptr member directly for locked since isImmutable()
120 // also checks kiosk and parent containers
121 group.writeEntry("immutability", (int)d->immutability);
122 group.writeEntry("plugin", d->appletDescription.pluginId());
123
124 if (!d->started) {
125 return;
126 }
127
128 KConfigGroup appletConfigGroup(&group, QStringLiteral("Configuration"));
129 saveState(appletConfigGroup);
130
131 if (d->configLoader) {
132 // we're saving so we know its changed, we don't need or want the configChanged
133 // signal bubbling up at this point due to that
134 disconnect(d->configLoader, SIGNAL(configChanged()), this, SLOT(propagateConfigChanged()));
135 d->configLoader->save();
136 connect(d->configLoader, SIGNAL(configChanged()), this, SLOT(propagateConfigChanged()));
137 }
138}
139
141{
143
144 KConfigGroup shortcutConfig(&group, QStringLiteral("Shortcuts"));
145 QString shortcutText = shortcutConfig.readEntryUntranslated("global", QString());
146 if (!shortcutText.isEmpty()) {
147 setGlobalShortcut(QKeySequence(shortcutText));
148 /*
149 #ifndef NDEBUG
150 // qCDebug(LOG_PLASMA) << "got global shortcut for" << name() << "of" << QKeySequence(shortcutText);
151 #endif
152 #ifndef NDEBUG
153 // qCDebug(LOG_PLASMA) << "set to" << d->activationAction->objectName()
154 #endif
155 << d->activationAction->globalShortcut().primary();
156 */
157 }
158
159 // User background hints
160 // TODO support flags in the config
161 QByteArray hintsString = config().readEntry("UserBackgroundHints", QString()).toUtf8();
162 QMetaEnum hintEnum = QMetaEnum::fromType<Plasma::Types::BackgroundHints>();
163 bool ok;
164 int value = hintEnum.keyToValue(hintsString.constData(), &ok);
165 if (ok) {
166 d->userBackgroundHints = Plasma::Types::BackgroundHints(value);
167 d->userBackgroundHintsInitialized = true;
169 if (d->backgroundHints & Plasma::Types::ConfigurableBackground) {
171 }
172 }
173}
175void Applet::setLaunchErrorMessage(const QString &message)
176{
177 if (message == d->launchErrorMessage) {
178 return;
179 }
180
181 d->failed = true;
182 d->launchErrorMessage = message;
183}
185void Applet::saveState(KConfigGroup &group) const
186{
187 if (group.config()->name() != config().config()->name()) {
188 // we're being saved to a different file!
189 // let's just copy the current values in our configuration over
190 KConfigGroup c = config();
191 c.copyTo(&group);
192 }
193}
196{
197 if (d->transient) {
198 return KConfigGroup(KSharedConfig::openConfig(), QStringLiteral("PlasmaTransientsConfig"));
199 }
200
201 if (isContainment()) {
202 return *(d->mainConfigGroup());
203 }
204
205 return KConfigGroup(d->mainConfigGroup(), QStringLiteral("Configuration"));
206}
209{
210 KConfigGroup globalAppletConfig;
211 QString group = isContainment() ? QStringLiteral("ContainmentGlobals") : QStringLiteral("AppletGlobals");
212
213 Containment *cont = containment();
214 Corona *corona = nullptr;
215 if (cont) {
216 corona = cont->corona();
217 }
218 if (corona) {
219 KSharedConfig::Ptr coronaConfig = corona->config();
220 globalAppletConfig = KConfigGroup(coronaConfig, group);
221 } else {
222 globalAppletConfig = KConfigGroup(KSharedConfig::openConfig(), group);
223 }
224
225 return KConfigGroup(&globalAppletConfig, d->globalName());
226}
228void Applet::destroy()
229{
230 if (immutability() != Types::Mutable || d->transient || !d->started) {
231 return; // don't double delete
232 }
233
234 d->setDestroyed(true);
235 // FIXME: an animation on leave if !isContainment() would be good again .. which should be handled by the containment class
236 d->cleanUpAndDelete();
237}
239bool Applet::destroyed() const
240{
241 return d->transient;
242}
245{
246 if (!d->configLoader) {
247 const QString xmlPath = d->package.isValid() ? d->package.filePath("mainconfigxml") : QString();
248 KConfigGroup cfg = config();
249 if (xmlPath.isEmpty()) {
250 d->configLoader = new KConfigLoader(cfg, nullptr);
251 } else {
252 QFile file(xmlPath);
253 d->configLoader = new KConfigLoader(cfg, &file);
254 QObject::connect(d->configLoader, SIGNAL(configChanged()), this, SLOT(propagateConfigChanged()));
255 }
256 }
257
258 return d->configLoader;
259}
260
262{
263 if (!d->configPropertyMap) {
264 d->configPropertyMap = new KConfigPropertyMap(configScheme(), this);
266 }
267 return d->configPropertyMap;
268}
271{
272 d->scheduleConstraintsUpdate(constraints);
273}
274
275void Applet::constraintsEvent(Constraints constraints)
276{
277 // NOTE: do NOT put any code in here that reacts to constraints updates
278 // as it will not get called for any applet that reimplements constraintsEvent
279 // without calling the Applet:: version as well, which it shouldn't need to.
280 // INSTEAD put such code into flushPendingConstraintsEvents
281 Q_UNUSED(constraints)
282 // qCDebug(LOG_PLASMA) << constraints << "constraints are FormFactor: " << formFactor()
283 // << ", Location: " << location();
284}
287{
288 if (!d->customTitle.isEmpty()) {
289 return d->customTitle;
290 }
291
292 if (d->appletDescription.isValid()) {
293 return d->appletDescription.name();
294 }
295
296 return i18n("Unknown");
297}
299void Applet::setTitle(const QString &title)
300{
301 if (title == d->customTitle) {
302 return;
303 }
304
305 d->customTitle = title;
307}
309QString Applet::icon() const
310{
311 return d->icon;
312}
314void Applet::setIcon(const QString &icon)
315{
316 if (icon == d->icon) {
317 return;
318 }
319
320 d->icon = icon;
322}
324bool Applet::isBusy() const
325{
326 return d->busy;
327}
329void Applet::setBusy(bool busy)
330{
331 if (busy == d->busy) {
332 return;
333 }
334
335 d->busy = busy;
337}
340{
341 return d->backgroundHints;
342}
345{
346 if (d->backgroundHints == hint) {
347 return;
348 }
349
351
352 d->backgroundHints = hint;
354
355 if (oldeffectiveHints != effectiveBackgroundHints()) {
357 }
358}
361{
362 if (d->userBackgroundHintsInitialized && (d->backgroundHints & Plasma::Types::ConfigurableBackground)) {
363 return d->userBackgroundHints;
364 } else {
365 return d->backgroundHints;
366 }
367}
370{
371 return d->userBackgroundHints;
372}
375{
376 if (d->userBackgroundHints == hint && d->userBackgroundHintsInitialized) {
377 return;
378 }
379
380 d->userBackgroundHints = hint;
381 d->userBackgroundHintsInitialized = true;
382 QMetaEnum hintEnum = QMetaEnum::fromType<Plasma::Types::BackgroundHints>();
383 config().writeEntry("UserBackgroundHints", hintEnum.valueToKey(d->userBackgroundHints));
384 if (containment() && containment()->corona()) {
386 }
387
389
390 if (d->backgroundHints & Plasma::Types::ConfigurableBackground) {
392 }
393}
396{
397 return d->appletDescription;
398}
401{
402 return d->appletDescription.isValid() ? d->appletDescription.pluginId() : QString();
403}
406{
407 // if this object is itself system immutable, then just return that; it's the most
408 // restrictive setting possible and will override anything that might be happening above it
409 // in the Corona->Containment->Applet hierarchy
410 if (d->transient || (d->mainConfig && d->mainConfig->isImmutable())) {
412 }
413
414 // Returning the more strict immutability between the applet immutability, Containment and Corona
415 Types::ImmutabilityType upperImmutability = Types::Mutable;
416
417 if (isContainment()) {
418 Corona *cor = static_cast<Containment *>(const_cast<Applet *>(this))->corona();
419 if (cor) {
420 upperImmutability = cor->immutability();
421 }
422 } else {
423 const Containment *cont = containment();
424 if (cont) {
425 if (cont->corona()) {
426 upperImmutability = cont->corona()->immutability();
427 } else {
428 upperImmutability = cont->immutability();
429 }
430 }
431 }
432
433 if (upperImmutability != Types::Mutable) {
434 // it's either system or user immutable, and we already check for local system immutability,
435 // so upperImmutability is guaranteed to be as or more severe as this object's immutability
436 return upperImmutability;
437 } else {
438 return d->immutability;
439 }
440}
443{
444 if (d->immutability == immutable || immutable == Types::SystemImmutable) {
445 // we do not store system immutability in d->immutability since that gets saved
446 // out to the config file; instead, we check with
447 // the config group itself for this information at all times. this differs from
448 // corona, where SystemImmutability is stored in d->immutability.
449 return;
450 }
451
452 d->immutability = immutable;
454}
456bool Applet::immutable() const
457{
458 return immutability() != Types::Mutable;
459}
462{
463 return d->launchErrorMessage;
464}
466bool Applet::failedToLaunch() const
467{
468 return d->failed;
469}
472{
473 return d->needsConfig;
474}
477{
478 return d->configurationRequiredReason;
479}
481void Applet::setConfigurationRequired(bool needsConfig, const QString &reason)
482{
483 if (d->needsConfig == needsConfig && reason == d->configurationRequiredReason) {
484 return;
485 }
486
487 d->needsConfig = needsConfig;
488 d->configurationRequiredReason = reason;
489
490 Q_EMIT configurationRequiredChanged(needsConfig, reason);
491}
494{
495 if (d->constraintHints == constraintHints) {
496 return;
497 }
498
499 d->constraintHints = constraintHints;
501}
504{
505 return d->constraintHints;
506}
508bool Applet::isUserConfiguring() const
509{
510 return d->userConfiguring;
511}
513void Applet::setUserConfiguring(bool configuring)
514{
515 if (configuring == d->userConfiguring) {
516 return;
517 }
518
519 d->userConfiguring = configuring;
520 Q_EMIT userConfiguringChanged(configuring);
521}
524{
525 return d->itemStatus;
526}
529{
530 if (status == d->itemStatus) {
531 return;
532 }
533 d->itemStatus = status;
535}
538{
539 if (d->pendingConstraints == NoConstraint) {
540 return;
541 }
542
543 if (d->constraintsTimer.isActive()) {
544 d->constraintsTimer.stop();
545 }
546
547 // qCDebug(LOG_PLASMA) << "flushing constraints: " << d->pendingConstraints << "!!!!!!!!!!!!!!!!!!!!!!!!!!!";
548 Constraints c = d->pendingConstraints;
549 d->pendingConstraints = NoConstraint;
550
551 if (c & UiReadyConstraint) {
552 d->setUiReady();
553 }
554
556 // common actions
557 bool unlocked = immutability() == Types::Mutable;
558 QAction *closeApplet = d->actions.value(QStringLiteral("remove"));
559 if (closeApplet) {
560 closeApplet->setEnabled(unlocked);
561 closeApplet->setVisible(unlocked);
562 connect(closeApplet, SIGNAL(triggered(bool)), this, SLOT(askDestroy()), Qt::UniqueConnection);
563 }
564
565 QAction *configAction = d->actions.value(QStringLiteral("configure"));
566 if (configAction) {
567 if (d->hasConfigurationInterface) {
568 bool canConfig = unlocked || KAuthorized::authorize(QStringLiteral("plasma/allow_configure_when_locked"));
569 configAction->setVisible(canConfig);
570 configAction->setEnabled(canConfig);
571 }
572 }
573 }
574
575 if (c & ImmutableConstraint) {
576 bool unlocked = immutability() == Types::Mutable;
577 QAction *action = d->actions.value(QStringLiteral("remove"));
578 if (action) {
579 action->setVisible(unlocked);
580 action->setEnabled(unlocked);
581 }
582
583 action = d->actions.value(QStringLiteral("configure"));
584 if (action && d->hasConfigurationInterface) {
585 bool canConfig = unlocked || KAuthorized::authorize(QStringLiteral("plasma/allow_configure_when_locked"));
586 action->setVisible(canConfig);
587 action->setEnabled(canConfig);
588 }
589
590 // an immutable constraint will always happen at startup
591 // make sure don't emit a change signal for nothing
592 if (d->oldImmutability != immutability()) {
594 }
595 d->oldImmutability = immutability();
596 }
597
598 // now take care of constraints in special subclass: Containment
599 Containment *containment = qobject_cast<Plasma::Containment *>(this);
600 if (containment) {
601 containment->d->containmentConstraintsEvent(c);
602 }
603
604 // pass the constraint on to the actual subclass
605 constraintsEvent(c);
606
607 if (c & FormFactorConstraint) {
609 }
610
611 if (c & LocationConstraint) {
613 }
614}
615
617{
618 return d->contextualActions;
619}
620
621QQmlListProperty<QAction> Applet::qmlContextualActions()
622{
623 return QQmlListProperty<QAction>(this,
624 nullptr,
625 AppletPrivate::contextualActions_append,
626 AppletPrivate::contextualActions_count,
627 AppletPrivate::contextualActions_at,
628 AppletPrivate::contextualActions_clear,
629 AppletPrivate::contextualActions_replace,
630 AppletPrivate::contextualActions_removeLast);
631}
633void Applet::setInternalAction(const QString &name, QAction *action)
634{
635 if (name.isEmpty()) {
636 return;
637 }
638
639 action->setObjectName(name);
640 QAction *oldAction = d->actions.value(name);
641 if (oldAction && QJSEngine::objectOwnership(oldAction) == QJSEngine::CppOwnership) {
642 delete oldAction;
643 }
644
645 d->actions[name] = action;
646
647 QObject::connect(action, &QObject::destroyed, this, [this, name]() {
648 d->actions.remove(name);
649 Q_EMIT internalActionsChanged(d->actions.values());
650 });
651
652 Q_EMIT internalActionsChanged(d->actions.values());
653}
655QAction *Applet::internalAction(const QString &name) const
656{
657 return d->actions.value(name);
658}
661{
662 QAction *action = d->actions.value(name);
663
664 if (action && QJSEngine::objectOwnership(action) == QJSEngine::CppOwnership) {
665 disconnect(action, &QObject::destroyed, this, nullptr); // Avoid emitting signal again
666 delete action;
667 }
668
669 d->actions.remove(name);
670
671 Q_EMIT internalActionsChanged(d->actions.values());
672}
675{
676 return d->actions.values();
677}
680{
682 QObject *pw = qobject_cast<QObject *>(parent());
683 Plasma::Applet *parentApplet = qobject_cast<Plasma::Applet *>(pw);
684 // assumption: this loop is usually is -really- short or doesn't run at all
685 while (!parentApplet && pw && pw->parent()) {
686 pw = pw->parent();
687 parentApplet = qobject_cast<Plasma::Applet *>(pw);
688 }
689
690 return c ? c->d->formFactor : Plasma::Types::Planar;
691}
694{
696
697 return c ? c->d->containmentDisplayHints : Plasma::Types::NoContainmentDisplayHint;
698}
701{
702 Containment *c = qobject_cast<Containment *>(const_cast<Applet *>(this));
703 if (c && c->isContainment()) {
704 return c;
705 } else {
706 c = nullptr;
707 }
708
709 QObject *parent = this->parent();
710
711 while (parent) {
712 Containment *possibleC = qobject_cast<Containment *>(parent);
713
714 if (possibleC && possibleC->isContainment()) {
715 c = possibleC;
716 break;
717 }
718 parent = parent->parent();
719 }
720
721 return c;
722}
724void Applet::setGlobalShortcut(const QKeySequence &shortcut)
725{
726 if (!d->activationAction) {
727 d->activationAction = new QAction(this);
728 d->activationAction->setText(i18n("Activate %1 Widget", title()));
729 d->activationAction->setObjectName(QStringLiteral("activate widget %1").arg(id())); // NO I18N
730 connect(d->activationAction, &QAction::triggered, this, &Applet::activated);
731 connect(KGlobalAccel::self(), &KGlobalAccel::globalShortcutChanged, this, [this](QAction *action, const QKeySequence &shortcut) {
732 if (action == d->activationAction) {
733 d->activationAction->setShortcut(shortcut);
734 d->globalShortcutChanged();
735 }
736 });
737 } else if (d->activationAction->shortcut() == shortcut) {
738 return;
739 }
740
741 d->activationAction->setShortcut(shortcut);
742 d->globalShortcutEnabled = true;
743 QList<QKeySequence> seqs{shortcut};
744 KGlobalAccel::self()->setShortcut(d->activationAction, seqs, KGlobalAccel::NoAutoloading);
745 d->globalShortcutChanged();
746
748}
751{
752 if (d->activationAction) {
753 QList<QKeySequence> shortcuts = KGlobalAccel::self()->shortcut(d->activationAction);
754 if (!shortcuts.isEmpty()) {
755 return shortcuts.first();
756 }
757 }
758
759 return QKeySequence();
760}
763{
765 return c ? c->d->location : Plasma::Types::Desktop;
766}
769{
770 return d->hasConfigurationInterface;
771}
773void Applet::setHasConfigurationInterface(bool hasInterface)
774{
775 if (hasInterface == d->hasConfigurationInterface) {
776 return;
777 }
778
779 QAction *configAction = d->actions.value(QStringLiteral("configure"));
780 if (configAction) {
781 bool enable = hasInterface;
782 if (enable) {
783 const bool unlocked = immutability() == Types::Mutable;
784 enable = unlocked || KAuthorized::authorize(QStringLiteral("plasma/allow_configure_when_locked"));
785 }
786 configAction->setEnabled(enable);
787 }
788
789 d->hasConfigurationInterface = hasInterface;
791}
794{
795 if (d->configLoader) {
796 d->configLoader->load();
797 }
798}
799
800QUrl Applet::fileUrl(const QByteArray &key, const QString &filename) const
801{
802 if (d->package.isValid()) {
803 return d->package.fileUrl(key, filename);
804 }
805 return QUrl();
806}
807
808QUrl Applet::mainScript() const
809{
810 if (d->package.isValid()) {
811 return d->package.fileUrl("mainscript");
812 }
813 return QUrl();
814}
815
816QUrl Applet::configModel() const
817{
818 if (d->package.isValid()) {
819 return d->package.fileUrl("configmodel");
820 }
821
822 return QUrl();
823}
824
825bool Applet::sourceValid() const
826{
827 return d->package.isValid();
828}
831{
832 if (d->transient) {
833 d->constraintsTimer.stop();
834 return;
835 }
836
837 if (event->timerId() == d->constraintsTimer.timerId()) {
838 d->constraintsTimer.stop();
839
840 // Don't flushPendingConstraints if we're just starting up
841 // flushPendingConstraints will be called by Corona
842 if (!(d->pendingConstraints & StartupCompletedConstraint)) {
844 }
845 }
846}
848bool Applet::isContainment() const
849{
850 // HACK: this is a special case for the systray
851 // containment in an applet that is not a containment
852 Applet *pa = qobject_cast<Applet *>(parent());
853 if (pa && !pa->isContainment()) {
854 return true;
855 }
856 // normal "acting as a containment" condition
857 return qobject_cast<const Containment *>(this) && qobject_cast<Corona *>(parent());
858}
861{
862 const QString rootPath = d->appletDescription.value(QStringLiteral("X-Plasma-RootPath"));
863 if (!rootPath.isEmpty()) {
864 return QLatin1String("plasma_applet_") + rootPath;
865 } else {
866 return QLatin1String("plasma_applet_") + d->appletDescription.pluginId();
867 }
868}
869
870} // Plasma namespace
871
872#include "moc_applet.cpp"
static Q_INVOKABLE bool authorize(const QString &action)
QString readEntryUntranslated(const char *key, const QString &aDefault=QString()) const
void writeEntry(const char *key, const char *value, WriteConfigFlags pFlags=Normal)
bool isValid() const
KConfig * config()
QString readEntry(const char *key, const char *aDefault=nullptr) const
void copyTo(KConfigBase *other, WriteConfigFlags pFlags=Normal) const
QString name() const
static KGlobalAccel * self()
bool setShortcut(QAction *action, const QList< QKeySequence > &shortcut, GlobalShortcutLoading loadFlag=Autoloading)
QList< QKeySequence > shortcut(const QAction *action) const
void globalShortcutChanged(QAction *action, const QKeySequence &seq)
static KSharedConfig::Ptr openConfig(const QString &fileName=QString(), OpenFlags mode=FullConfig, QStandardPaths::StandardLocation type=QStandardPaths::GenericConfigLocation)
The base Applet class.
Definition applet.h:64
bool isUserConfiguring() const
Definition applet.cpp:507
uint id
Applet id: is unique in the whole Plasma session and will never change across restarts.
Definition applet.h:69
void updateConstraints(Constraints constraints=AllConstraints)
Called when any of the geometry constraints have been updated.
Definition applet.cpp:269
virtual void save(KConfigGroup &group) const
Saves state information about this applet that will be accessed when next instantiated in the restore...
Definition applet.cpp:107
Plasma::Types::ContainmentDisplayHints containmentDisplayHints
Display hints that come from the containment that suggest the applet how to look and behave.
Definition applet.h:119
QQmlListProperty< QAction > contextualActions
Actions to be added in the plasmoid context menu.
Definition applet.h:195
QKeySequence globalShortcut
The global shortcut to activate the plasmoid.
Definition applet.h:162
void setHasConfigurationInterface(bool hasInterface)
Sets whether or not this applet provides a user interface for configuring the applet.
Definition applet.cpp:772
Plasma::Types::Location location
The location of the scene which is displaying applet.
Definition applet.h:95
Q_INVOKABLE void removeInternalAction(const QString &name)
Removes an action from the internal actions.
Definition applet.cpp:659
void setStatus(const Types::ItemStatus stat)
sets the status for this applet
Definition applet.cpp:527
Q_INVOKABLE QAction * internalAction(const QString &name) const
Definition applet.cpp:654
KConfigGroup config() const
Returns the KConfigGroup to access the applets configuration.
Definition applet.cpp:194
bool failedToLaunch() const
If for some reason, the applet fails to get up on its feet (the library couldn't be loaded,...
Definition applet.cpp:465
void titleChanged(const QString &title)
Emitted when the title has changed.
Plasma::Types::BackgroundHints backgroundHints
How the applet wants its background to be drawn.
Definition applet.h:135
Plasma::Types::BackgroundHints userBackgroundHints
The containment (and/or the user) may decide to use another kind of background instead (if supported ...
Definition applet.h:140
void setUserBackgroundHints(Plasma::Types::BackgroundHints hint)
Sets the hints the user wished the background style for the applet to be.
Definition applet.cpp:373
void setConfigurationRequired(bool needsConfiguring, const QString &reason=QString())
When the applet needs to be configured before being usable, this method can be called to show a stand...
Definition applet.cpp:480
void internalActionsChanged(const QList< QAction * > &actions)
Emitted when the list of internal actions has changed.
@ NoConstraint
No constraint; never passed in to Applet::constraintsEvent on its own.
Definition applet.h:214
@ 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
@ FormFactorConstraint
The FormFactor for an object.
Definition applet.h:215
@ LocationConstraint
The Location of an object.
Definition applet.h:216
void destroy()
Destroys the applet; it will be removed nicely and deleted.
Definition applet.cpp:227
Applet::ConstraintHints constraintHints
The hints that the applet gives to its constraint, such as asking to fill all the available space ign...
Definition applet.h:179
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
QString translationDomain() const
The translation domain for this applet.
Definition applet.cpp:859
void globalShortcutChanged(const QKeySequence &sequence)
Emitted when the global shortcut to activate this applet has chanaged.
void effectiveBackgroundHintsChanged()
Emitted when the effective background hints have changed.
void setTitle(const QString &title)
Sets a custom title for this instance of the applet.
Definition applet.cpp:298
void configNeedsSaving()
Emitted when an applet has changed values in its configuration and wishes for them to be saved at the...
void activated()
Emitted when activation is requested due to, for example, a global keyboard shortcut.
void appletDeleted(Plasma::Applet *applet)
Emitted when the applet is deleted.
virtual void init()
This method is called once the applet is loaded and added to a Corona.
Definition applet.cpp:92
void setIcon(const QString &icon)
Sets an icon name for this applet.
Definition applet.cpp:313
virtual void configChanged()
Called when applet configuration values have changed.
Definition applet.cpp:792
void setUserConfiguring(bool configuring)
Tells the applet the user is configuring.
Definition applet.cpp:512
void hasConfigurationInterfaceChanged(bool hasConfiguration)
Emitted when the applet gains or loses the ability to show a configuration interface.
void setGlobalShortcut(const QKeySequence &shortcut=QKeySequence())
Sets the global shortcut to associate with this widget.
Definition applet.cpp:723
QString icon
Icon to represent the plasmoid.
Definition applet.h:79
void setConstraintHints(ConstraintHints constraintHints)
Sets the constraint hits which give a more granular control over sizing in constrained layouts such a...
Definition applet.cpp:492
void statusChanged(Plasma::Types::ItemStatus status)
Emitted when the applet status changes.
bool immutable
Whether the Corona is immutable.
Definition applet.h:113
void timerEvent(QTimerEvent *event) override
Reimplemented from QObject.
Definition applet.cpp:829
bool busy
True if the applet should show a busy status, for instance doing some network operation.
Definition applet.h:125
KConfigPropertyMap * configuration
A KConfigPropertyMap instance that represents the configuration which is usable from QML to read and ...
Definition applet.h:154
Plasma::Types::FormFactor formFactor
The current form factor the applet is being displayed in.
Definition applet.h:88
KConfigGroup globalConfig() const
Returns a KConfigGroup object to be shared by all applets of this type.
Definition applet.cpp:207
bool isBusy() const
Definition applet.cpp:323
void setLaunchErrorMessage(const QString &reason=QString())
Call this method when the applet fails to launch properly.
Definition applet.cpp:174
QString configurationRequiredReason() const
Definition applet.cpp:475
Q_INVOKABLE void setInternalAction(const QString &name, QAction *action)
Add a new internal action.
Definition applet.cpp:632
void iconChanged(const QString &icon)
Emitted when the icon name for the applet has changed.
QString pluginName
Plugin name for the applet.
Definition applet.h:205
void busyChanged(bool busy)
Emitted when the busy status has changed.
QList< QAction * > internalActions() const
Definition applet.cpp:673
bool destroyed() const
Definition applet.cpp:238
virtual void saveState(KConfigGroup &config) const
When called, the Applet should write any information needed as part of the Applet's running state to ...
Definition applet.cpp:184
Plasma::Types::ItemStatus status
Status of the plasmoid: useful to instruct the shell if this plasmoid is requesting attention,...
Definition applet.h:100
QString title
User friendly title for the plasmoid: it's the localized applet name by default.
Definition applet.h:74
void immutabilityChanged(Plasma::Types::ImmutabilityType immutable)
Emitted when the immutability changes.
void setBusy(bool busy)
Sets the Applet to have a busy status hint, for instance the applet doing some network operation.
Definition applet.cpp:328
void setImmutability(const Types::ImmutabilityType immutable)
Sets the immutability type for this applet (not immutable, user immutable or system immutable)
Definition applet.cpp:441
void setBackgroundHints(Plasma::Types::BackgroundHints hint)
Sets the applet background hints.
Definition applet.cpp:343
Plasma::Containment * containment
The Containment managing this applet.
Definition applet.h:189
void backgroundHintsChanged()
Emitted when the background hints have changed.
void configurationRequiredChanged(bool needsConfig, const QString &reason)
Emitted when setConfigurationRequired was called.
Plasma::Types::BackgroundHints effectiveBackgroundHints
The effective background hints the applet has, internally decided how to mix with userBackgroundHints...
Definition applet.h:145
void formFactorChanged(Plasma::Types::FormFactor formFactor)
Emitted when the formfactor changes.
QVariantList startupArguments() const
Definition applet.cpp:102
void flushPendingConstraintsEvents()
Sends all pending constraints updates to the applet.
Definition applet.cpp:536
Applet(QObject *parentObject, const KPluginMetaData &data, const QVariantList &args)
This constructor can be used with the KCoreAddons plugin loading system.
Definition applet.cpp:47
void locationChanged(Plasma::Types::Location location)
Emitted when the location changes.
void userConfiguringChanged(bool configuring)
emitted when the config ui appears or disappears
KPluginMetaData pluginMetaData() const
Definition applet.cpp:394
bool configurationRequired
If true the applet requires manual configuration from the user TODO KF6: having just a reson property...
Definition applet.h:168
KConfigLoader * configScheme() const
Returns the config skeleton object from this applet's package, if any.
Definition applet.cpp:243
bool hasConfigurationInterface
True if this applet will provide a UI for its configuration.
Definition applet.h:173
void constraintHintsChanged(ConstraintHints constraintHints)
Emitted when the constraint hints changed.
void userBackgroundHintsChanged()
Emitted when the user background hints have changed.
QString launchErrorMessage() const
If for some reason, the applet fails to get up on its feet (the library couldn't be loaded,...
Definition applet.cpp:460
virtual void restore(KConfigGroup &group)
Restores state information about this applet saved previously in save(KConfigGroup&).
Definition applet.cpp:140
The base class for plugins that provide backgrounds and applet grouping containers.
Definition containment.h:47
Plasma::Corona * corona
The corona for this contaiment.
Definition containment.h:59
A bookkeeping Scene for Plasma::Applets.
Definition corona.h:28
void requestConfigSync()
Schedules a flush-to-disk synchronization of the configuration state at the next convenient moment.
Definition corona.cpp:109
KSharedConfig::Ptr config() const
Returns the config file used to store the configuration for this Corona.
Definition corona.cpp:230
Types::ImmutabilityType immutability() const
Definition corona.cpp:282
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
BackgroundHints
Description on how draw a background for the applet.
Definition plasma.h:127
Location
The Location enumeration describes where on screen an element, such as an Applet or its managing cont...
Definition plasma.h:81
@ Desktop
On the planar desktop layer, extending across the full screen from edge to edge.
Definition plasma.h:84
FormFactor
The FormFactor enumeration describes how a Plasma::Applet should arrange itself.
Definition plasma.h:40
@ Planar
The applet lives in a plane and has two degrees of freedom to grow.
Definition plasma.h:41
Q_SCRIPTABLE CaptureState status()
QString i18n(const char *text, const TYPE &arg...)
Namespace for everything in libplasma.
void setEnabled(bool)
void triggered(bool checked)
void setVisible(bool)
const char * constData() const const
ObjectOwnership objectOwnership(QObject *object)
T & first()
bool isEmpty() const const
int keyToValue(const char *key, bool *ok) const const
const char * valueToKey(int value) const const
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
void destroyed(QObject *obj)
bool disconnect(const QMetaObject::Connection &connection)
virtual bool event(QEvent *e)
QObject * parent() const const
void setObjectName(QAnyStringView name)
bool setProperty(const char *name, QVariant &&value)
void valueChanged(const QString &key, const QVariant &value)
bool isEmpty() const const
QByteArray toUtf8() const const
UniqueConnection
bool canConvert() const const
QVariant fromValue(T &&value)
T value() const const
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.