Libplasma

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 <QDebug>
16#include <QFile>
17#include <QJSEngine>
18#include <QList>
19#include <QMetaEnum>
20
21#include <KAuthorized>
22#include <KConfigLoader>
23#include <KConfigPropertyMap>
24#include <KGlobalAccel>
25#include <KLocalizedString>
26#include <KPackage/Package>
27
28#include "containment.h"
29#include "corona.h"
30#include "plasma.h"
31#include "pluginloader.h"
32
33#include "debug_p.h"
34#include "private/containment_p.h"
35
36#include <cmath>
37#include <limits>
38
39namespace Plasma
40{
41Applet::Applet(QObject *parentObject, const KPluginMetaData &data, const QVariantList &args)
42 : QObject(parentObject)
43 , d(new AppletPrivate(data, args.count() > 1 ? args[1].toInt() : 0, this))
44{
45 if (!args.isEmpty()) {
46 const QVariant first = args.first();
47 if (first.canConvert<KPackage::Package>()) {
48 d->package = first.value<KPackage::Package>();
49 }
50 }
51 d->icon = d->appletDescription.iconName();
52
53 if (args.contains(QVariant::fromValue(QStringLiteral("org.kde.plasma:force-create")))) {
54 setProperty("org.kde.plasma:force-create", true);
55 }
56
57 // WARNING: do not access config() OR globalConfig() in this method!
58 // that requires a scene, which is not available at this point
59 d->init(args.mid(2));
60}
61
62Applet::~Applet()
63{
64 for (QAction *a : d->actions.values()) {
65 disconnect(a, nullptr, this, nullptr);
66 }
67 for (QAction *a : d->contextualActions) {
68 disconnect(a, nullptr, this, nullptr);
69 }
70
71 // let people know that i will die
72 Q_EMIT appletDeleted(this);
73
74 if (d->transient) {
75 d->resetConfigurationObject();
76 }
77
78 // ConfigLoader is deleted when AppletPrivate closes not Applet
79 // It saves on closure and emits a signal.
80 // disconnect early to avoid a crash. See 411221
81 if (d->configLoader) {
82 disconnect(d->configLoader, SIGNAL(configChanged()), this, SLOT(propagateConfigChanged()));
83 }
84 delete d;
85}
86
88{
89 // Don't implement anything here, it will be overridden by subclasses
90}
91
92uint Applet::id() const
93{
94 return d->appletId;
95}
96
97QVariantList Applet::startupArguments() const
98{
99 return d->startupArguments;
100}
101
103{
104 if (d->transient || !d->appletDescription.isValid()) {
105 return;
106 }
107
108 KConfigGroup group = g;
109 if (!group.isValid()) {
110 group = *d->mainConfigGroup();
111 }
112
113 // qCDebug(LOG_PLASMA) << "saving" << pluginName() << "to" << group.name();
114 // we call the dptr member directly for locked since isImmutable()
115 // also checks kiosk and parent containers
116 group.writeEntry("immutability", (int)d->immutability);
117 group.writeEntry("plugin", d->appletDescription.pluginId());
118
119 if (!d->started) {
120 return;
121 }
122
123 KConfigGroup appletConfigGroup(&group, QStringLiteral("Configuration"));
124 saveState(appletConfigGroup);
125
126 if (d->configLoader) {
127 // we're saving so we know its changed, we don't need or want the configChanged
128 // signal bubbling up at this point due to that
129 disconnect(d->configLoader, SIGNAL(configChanged()), this, SLOT(propagateConfigChanged()));
130 d->configLoader->save();
131 connect(d->configLoader, SIGNAL(configChanged()), this, SLOT(propagateConfigChanged()));
132 }
133}
134
136{
138
139 KConfigGroup shortcutConfig(&group, QStringLiteral("Shortcuts"));
140 QString shortcutText = shortcutConfig.readEntryUntranslated("global", QString());
141 if (!shortcutText.isEmpty()) {
142 setGlobalShortcut(QKeySequence(shortcutText));
143 /*
144 #ifndef NDEBUG
145 // qCDebug(LOG_PLASMA) << "got global shortcut for" << name() << "of" << QKeySequence(shortcutText);
146 #endif
147 #ifndef NDEBUG
148 // qCDebug(LOG_PLASMA) << "set to" << d->activationAction->objectName()
149 #endif
150 << d->activationAction->globalShortcut().primary();
151 */
152 }
153
154 // User background hints
155 // TODO support flags in the config
156 QByteArray hintsString = config().readEntry("UserBackgroundHints", QString()).toUtf8();
158 bool ok;
159 int value = hintEnum.keyToValue(hintsString.constData(), &ok);
160 if (ok) {
161 d->userBackgroundHints = Plasma::Types::BackgroundHints(value);
162 d->userBackgroundHintsInitialized = true;
164 if (d->backgroundHints & Plasma::Types::ConfigurableBackground) {
166 }
167 }
168}
170void Applet::setLaunchErrorMessage(const QString &message)
171{
172 if (message == d->launchErrorMessage) {
173 return;
174 }
175
176 d->failed = true;
177 d->launchErrorMessage = message;
178}
180void Applet::saveState(KConfigGroup &group) const
181{
182 if (group.config()->name() != config().config()->name()) {
183 // we're being saved to a different file!
184 // let's just copy the current values in our configuration over
185 KConfigGroup c = config();
186 c.copyTo(&group);
187 }
188}
191{
192 if (d->transient) {
193 return KConfigGroup(KSharedConfig::openConfig(), QStringLiteral("PlasmaTransientsConfig"));
194 }
195
196 if (isContainment()) {
197 return *(d->mainConfigGroup());
198 }
199
200 return KConfigGroup(d->mainConfigGroup(), QStringLiteral("Configuration"));
201}
204{
205 KConfigGroup globalAppletConfig;
206 QString group = isContainment() ? QStringLiteral("ContainmentGlobals") : QStringLiteral("AppletGlobals");
207
208 Containment *cont = containment();
209 Corona *corona = nullptr;
210 if (cont) {
211 corona = cont->corona();
212 }
213 if (corona) {
214 KSharedConfig::Ptr coronaConfig = corona->config();
215 globalAppletConfig = KConfigGroup(coronaConfig, group);
216 } else {
217 globalAppletConfig = KConfigGroup(KSharedConfig::openConfig(), group);
218 }
219
220 return KConfigGroup(&globalAppletConfig, d->globalName());
221}
223void Applet::destroy()
224{
225 Corona *cor = nullptr;
226 Containment *cont = containment();
227 if (cont) {
228 cor = cont->corona();
229 }
230
231 if (d->transient) {
232 // If the applet is transient, we can delete it anyways, unless
233 // Corona itself is immutable
234 if (!d->started || (cor && cor->immutability() != Types::Mutable)) {
235 return;
236 }
237 }
238
239 d->setDestroyed(true);
240 // FIXME: an animation on leave if !isContainment() would be good again .. which should be handled by the containment class
241 d->cleanUpAndDelete();
242}
244bool Applet::destroyed() const
245{
246 return d->transient;
247}
250{
251 if (!d->configLoader) {
252 const QString xmlPath = d->package.isValid() ? d->package.filePath("mainconfigxml") : QString();
253 KConfigGroup cfg = config();
254 if (xmlPath.isEmpty()) {
255 d->configLoader = new KConfigLoader(cfg, nullptr);
256 } else {
257 QFile file(xmlPath);
258 d->configLoader = new KConfigLoader(cfg, &file);
259 QObject::connect(d->configLoader, SIGNAL(configChanged()), this, SLOT(propagateConfigChanged()));
260 }
261 }
262
263 return d->configLoader;
264}
265
267{
268 if (!d->configPropertyMap) {
269 d->configPropertyMap = new KConfigPropertyMap(configScheme(), this);
270 connect(d->configPropertyMap, &KConfigPropertyMap::valueChanged, this, [this]() {
271 d->scheduleModificationNotification();
272 });
273 }
274 return d->configPropertyMap;
275}
277void Applet::updateConstraints(Constraints constraints)
278{
279 d->scheduleConstraintsUpdate(constraints);
280}
281
282void Applet::constraintsEvent(Constraints constraints)
283{
284 // NOTE: do NOT put any code in here that reacts to constraints updates
285 // as it will not get called for any applet that reimplements constraintsEvent
286 // without calling the Applet:: version as well, which it shouldn't need to.
287 // INSTEAD put such code into flushPendingConstraintsEvents
288 Q_UNUSED(constraints)
289 // qCDebug(LOG_PLASMA) << constraints << "constraints are FormFactor: " << formFactor()
290 // << ", Location: " << location();
291}
294{
295 if (!d->customTitle.isEmpty()) {
296 return d->customTitle;
297 }
298
299 if (d->appletDescription.isValid()) {
300 return d->appletDescription.name();
301 }
302
303 return i18n("Unknown");
304}
306void Applet::setTitle(const QString &title)
307{
308 if (title == d->customTitle) {
309 return;
310 }
311
312 d->customTitle = title;
314}
316QString Applet::icon() const
317{
318 return d->icon;
319}
321void Applet::setIcon(const QString &icon)
322{
323 if (icon == d->icon) {
324 return;
325 }
326
327 d->icon = icon;
329}
331bool Applet::isBusy() const
332{
333 return d->busy;
334}
336void Applet::setBusy(bool busy)
337{
338 if (busy == d->busy) {
339 return;
340 }
341
342 d->busy = busy;
344}
347{
348 return d->backgroundHints;
349}
352{
353 if (d->backgroundHints == hint) {
354 return;
355 }
356
358
359 d->backgroundHints = hint;
361
362 if (oldeffectiveHints != effectiveBackgroundHints()) {
364 }
365}
368{
369 if (d->userBackgroundHintsInitialized && (d->backgroundHints & Plasma::Types::ConfigurableBackground)) {
370 return d->userBackgroundHints;
371 } else {
372 return d->backgroundHints;
373 }
374}
377{
378 return d->userBackgroundHints;
379}
382{
383 if (d->userBackgroundHints == hint && d->userBackgroundHintsInitialized) {
384 return;
385 }
386
387 d->userBackgroundHints = hint;
388 d->userBackgroundHintsInitialized = true;
390 config().writeEntry("UserBackgroundHints", hintEnum.valueToKey(d->userBackgroundHints));
391 if (containment() && containment()->corona()) {
392 containment()->corona()->requestConfigSync();
393 }
394
396
397 if (d->backgroundHints & Plasma::Types::ConfigurableBackground) {
399 }
400}
403{
404 return d->appletDescription;
405}
408{
409 return d->appletDescription.isValid() ? d->appletDescription.pluginId() : QString();
410}
413{
414 // if this object is itself system immutable, then just return that; it's the most
415 // restrictive setting possible and will override anything that might be happening above it
416 // in the Corona->Containment->Applet hierarchy
417 if (d->transient || (d->mainConfig && d->mainConfig->isImmutable())) {
419 }
420
421 // Returning the more strict immutability between the applet immutability, Containment and Corona
422 Types::ImmutabilityType upperImmutability = Types::Mutable;
423
424 if (isContainment()) {
425 Corona *cor = static_cast<Containment *>(const_cast<Applet *>(this))->corona();
426 if (cor) {
427 upperImmutability = cor->immutability();
428 }
429 } else {
430 const Containment *cont = containment();
431 if (cont) {
432 if (cont->corona()) {
433 upperImmutability = cont->corona()->immutability();
434 } else {
435 upperImmutability = cont->immutability();
436 }
437 }
438 }
439
440 if (upperImmutability != Types::Mutable) {
441 // it's either system or user immutable, and we already check for local system immutability,
442 // so upperImmutability is guaranteed to be as or more severe as this object's immutability
443 return upperImmutability;
444 } else {
445 return d->immutability;
446 }
447}
450{
451 if (d->immutability == immutable || immutable == Types::SystemImmutable) {
452 // we do not store system immutability in d->immutability since that gets saved
453 // out to the config file; instead, we check with
454 // the config group itself for this information at all times. this differs from
455 // corona, where SystemImmutability is stored in d->immutability.
456 return;
457 }
458
459 d->immutability = immutable;
461}
463bool Applet::immutable() const
464{
465 return immutability() != Types::Mutable;
466}
469{
470 return d->launchErrorMessage;
471}
473bool Applet::failedToLaunch() const
474{
475 return d->failed;
476}
479{
480 return d->needsConfig;
481}
484{
485 return d->configurationRequiredReason;
486}
488void Applet::setConfigurationRequired(bool needsConfig, const QString &reason)
489{
490 if (d->needsConfig == needsConfig && reason == d->configurationRequiredReason) {
491 return;
492 }
493
494 d->needsConfig = needsConfig;
495 d->configurationRequiredReason = reason;
496
497 Q_EMIT configurationRequiredChanged(needsConfig, reason);
498}
501{
502 if (d->constraintHints == constraintHints) {
503 return;
504 }
505
506 d->constraintHints = constraintHints;
508}
510Applet::ConstraintHints Applet::constraintHints() const
511{
512 return d->constraintHints;
513}
515bool Applet::isUserConfiguring() const
516{
517 return d->userConfiguring;
518}
520void Applet::setUserConfiguring(bool configuring)
521{
522 if (configuring == d->userConfiguring) {
523 return;
524 }
525
526 d->userConfiguring = configuring;
527 Q_EMIT userConfiguringChanged(configuring);
528}
531{
532 return d->itemStatus;
533}
536{
537 if (status == d->itemStatus) {
538 return;
539 }
540 d->itemStatus = status;
542}
545{
546 if (d->pendingConstraints == NoConstraint) {
547 return;
548 }
549
550 if (d->constraintsTimer.isActive()) {
551 d->constraintsTimer.stop();
552 }
553
554 // qCDebug(LOG_PLASMA) << "flushing constraints: " << d->pendingConstraints << "!!!!!!!!!!!!!!!!!!!!!!!!!!!";
555 Constraints c = d->pendingConstraints;
556 d->pendingConstraints = NoConstraint;
557
558 if (c & UiReadyConstraint) {
559 d->setUiReady();
560 }
561
563 // common actions
564 bool unlocked = immutability() == Types::Mutable;
565 QAction *closeApplet = d->actions.value(QStringLiteral("remove"));
566 if (closeApplet) {
567 closeApplet->setEnabled(unlocked);
568 closeApplet->setVisible(unlocked);
569 connect(closeApplet, SIGNAL(triggered(bool)), this, SLOT(askDestroy()), Qt::UniqueConnection);
570 }
571
572 QAction *configAction = d->actions.value(QStringLiteral("configure"));
573 if (configAction) {
574 if (d->hasConfigurationInterface) {
575 bool canConfig = unlocked || KAuthorized::authorize(QStringLiteral("plasma/allow_configure_when_locked"));
576 configAction->setVisible(canConfig);
577 configAction->setEnabled(canConfig);
578 }
579 }
580 }
581
582 if (c & ImmutableConstraint) {
583 bool unlocked = immutability() == Types::Mutable;
584 QAction *action = d->actions.value(QStringLiteral("remove"));
585 if (action) {
586 action->setVisible(unlocked);
587 action->setEnabled(unlocked);
588 }
589
590 action = d->actions.value(QStringLiteral("configure"));
591 if (action && d->hasConfigurationInterface) {
592 bool canConfig = unlocked || KAuthorized::authorize(QStringLiteral("plasma/allow_configure_when_locked"));
593 action->setVisible(canConfig);
594 action->setEnabled(canConfig);
595 }
596
597 // an immutable constraint will always happen at startup
598 // make sure don't emit a change signal for nothing
599 if (d->oldImmutability != immutability()) {
601 }
602 d->oldImmutability = immutability();
603 }
604
605 // now take care of constraints in special subclass: Containment
607 if (containment) {
608 containment->d->containmentConstraintsEvent(c);
609 }
610
611 // pass the constraint on to the actual subclass
612 constraintsEvent(c);
613
615 // start up is done, we can now go do a mod timer
616 if (d->modificationsTimer) {
617 if (d->modificationsTimer->isActive()) {
618 d->modificationsTimer->stop();
619 }
620 } else {
621 d->modificationsTimer = new QBasicTimer;
622 }
623 }
624
625 if (c & FormFactorConstraint) {
627 }
628
629 if (c & LocationConstraint) {
631 }
632}
633
635{
636 return d->contextualActions;
637}
638
639QQmlListProperty<QAction> Applet::qmlContextualActions()
640{
641 return QQmlListProperty<QAction>(this,
642 nullptr,
643 AppletPrivate::contextualActions_append,
644 AppletPrivate::contextualActions_count,
645 AppletPrivate::contextualActions_at,
646 AppletPrivate::contextualActions_clear,
647 AppletPrivate::contextualActions_replace,
648 AppletPrivate::contextualActions_removeLast);
649}
651void Applet::setInternalAction(const QString &name, QAction *action)
652{
653 if (name.isEmpty()) {
654 return;
655 }
656
657 action->setObjectName(name);
658 QAction *oldAction = d->actions.value(name);
659 if (oldAction && QJSEngine::objectOwnership(oldAction) == QJSEngine::CppOwnership) {
660 delete oldAction;
661 }
662
663 d->actions[name] = action;
664
665 QObject::connect(action, &QObject::destroyed, this, [this, name]() {
666 d->actions.remove(name);
667 Q_EMIT internalActionsChanged(d->actions.values());
668 });
669
670 Q_EMIT internalActionsChanged(d->actions.values());
671}
673QAction *Applet::internalAction(const QString &name) const
674{
675 return d->actions.value(name);
676}
679{
680 QAction *action = d->actions.value(name);
681
682 if (action && QJSEngine::objectOwnership(action) == QJSEngine::CppOwnership) {
683 disconnect(action, &QObject::destroyed, this, nullptr); // Avoid emitting signal again
684 delete action;
685 }
686
687 d->actions.remove(name);
688
689 Q_EMIT internalActionsChanged(d->actions.values());
690}
693{
694 return d->actions.values();
695}
698{
699 Containment *c = containment();
702 // assumption: this loop is usually is -really- short or doesn't run at all
703 while (!parentApplet && pw && pw->parent()) {
704 pw = pw->parent();
705 parentApplet = qobject_cast<Plasma::Applet *>(pw);
706 }
707
708 return c ? c->d->formFactor : Plasma::Types::Planar;
709}
711Types::ContainmentDisplayHints Applet::containmentDisplayHints() const
712{
713 Containment *c = containment();
714
715 return c ? c->d->containmentDisplayHints : Plasma::Types::NoContainmentDisplayHint;
716}
718Containment *Applet::containment() const
719{
720 Containment *c = qobject_cast<Containment *>(const_cast<Applet *>(this));
721 if (c && c->isContainment()) {
722 return c;
723 } else {
724 c = nullptr;
725 }
726
727 QObject *parent = this->parent();
728
729 while (parent) {
730 Containment *possibleC = qobject_cast<Containment *>(parent);
731
732 if (possibleC && possibleC->isContainment()) {
733 c = possibleC;
734 break;
735 }
736 parent = parent->parent();
737 }
738
739 return c;
740}
742void Applet::setGlobalShortcut(const QKeySequence &shortcut)
743{
744 if (!d->activationAction) {
745 d->activationAction = new QAction(this);
746 d->activationAction->setText(i18n("Activate %1 Widget", title()));
747 d->activationAction->setObjectName(QStringLiteral("activate widget %1").arg(id())); // NO I18N
748 connect(d->activationAction, &QAction::triggered, this, &Applet::activated);
749 connect(KGlobalAccel::self(), &KGlobalAccel::globalShortcutChanged, this, [this](QAction *action, const QKeySequence &shortcut) {
750 if (action == d->activationAction) {
751 d->activationAction->setShortcut(shortcut);
752 d->globalShortcutChanged();
753 }
754 });
755 } else if (d->activationAction->shortcut() == shortcut) {
756 return;
757 }
758
759 d->activationAction->setShortcut(shortcut);
760 d->globalShortcutEnabled = true;
761 QList<QKeySequence> seqs{shortcut};
762 KGlobalAccel::self()->setShortcut(d->activationAction, seqs, KGlobalAccel::NoAutoloading);
763 d->globalShortcutChanged();
764
766}
769{
770 if (d->activationAction) {
771 QList<QKeySequence> shortcuts = KGlobalAccel::self()->shortcut(d->activationAction);
772 if (!shortcuts.isEmpty()) {
773 return shortcuts.first();
774 }
775 }
776
777 return QKeySequence();
778}
781{
782 Containment *c = containment();
783 return c ? c->d->location : Plasma::Types::Desktop;
784}
787{
788 return d->hasConfigurationInterface;
789}
791void Applet::setHasConfigurationInterface(bool hasInterface)
792{
793 if (hasInterface == d->hasConfigurationInterface) {
794 return;
795 }
796
797 QAction *configAction = d->actions.value(QStringLiteral("configure"));
798 if (configAction) {
799 bool enable = hasInterface;
800 if (enable) {
801 const bool unlocked = immutability() == Types::Mutable;
802 enable = unlocked || KAuthorized::authorize(QStringLiteral("plasma/allow_configure_when_locked"));
803 }
804 configAction->setEnabled(enable);
805 }
806
807 d->hasConfigurationInterface = hasInterface;
809}
812{
813 if (d->configLoader) {
814 d->configLoader->load();
815 }
816}
817
818QUrl Applet::fileUrl(const QByteArray &key, const QString &filename) const
819{
820 if (d->package.isValid()) {
821 return d->package.fileUrl(key, filename);
822 }
823 return QUrl();
824}
825
826QUrl Applet::mainScript() const
827{
828 if (d->package.isValid()) {
829 return d->package.fileUrl("mainscript");
830 }
831 return QUrl();
832}
833
834QUrl Applet::configModel() const
835{
836 if (d->package.isValid()) {
837 return d->package.fileUrl("configmodel");
838 }
839
840 return QUrl();
841}
842
843bool Applet::sourceValid() const
844{
845 return d->package.isValid();
846}
849{
850 if (d->transient) {
851 d->constraintsTimer.stop();
852 if (d->modificationsTimer) {
853 d->modificationsTimer->stop();
854 }
855 return;
856 }
857
858 if (event->timerId() == d->constraintsTimer.timerId()) {
859 d->constraintsTimer.stop();
860
861 // Don't flushPendingConstraints if we're just starting up
862 // flushPendingConstraints will be called by Corona
863 if (!(d->pendingConstraints & StartupCompletedConstraint)) {
865 }
866 } else if (d->modificationsTimer && event->timerId() == d->modificationsTimer->timerId()) {
867 d->modificationsTimer->stop();
868 // invalid group, will result in save using the default group
869 KConfigGroup cg;
870
871 save(cg);
873 }
874}
876bool Applet::isContainment() const
877{
878 // HACK: this is a special case for the systray
879 // containment in an applet that is not a containment
881 if (pa && !pa->isContainment()) {
882 return true;
883 }
884 // normal "acting as a containment" condition
886}
889{
890 const QString rootPath = d->appletDescription.value(u"X-Plasma-RootPath");
891 if (!rootPath.isEmpty()) {
892 return QLatin1String("plasma_applet_") + rootPath;
893 } else {
894 return QLatin1String("plasma_applet_") + d->appletDescription.pluginId();
895 }
896}
897
898} // Plasma namespace
899
900#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:514
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
virtual void save(KConfigGroup &group) const
Saves state information about this applet that will be accessed when next instantiated in the restore...
Definition applet.cpp:102
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:790
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:677
void setStatus(const Types::ItemStatus stat)
sets the status for this applet
Definition applet.cpp:534
Q_INVOKABLE QAction * internalAction(const QString &name) const
Definition applet.cpp:672
KConfigGroup config() const
Returns the KConfigGroup to access the applets configuration.
Definition applet.cpp:189
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:472
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
void constraintHintsChanged(Plasma::Applet::ConstraintHints constraintHints)
Emitted when the constraint hints changed.
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:380
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:487
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:222
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:887
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:305
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.
virtual void init()
This method is called once the applet is loaded and added to a Corona.
Definition applet.cpp:87
void setIcon(const QString &icon)
Sets an icon name for this applet.
Definition applet.cpp:320
virtual void configChanged()
Called when applet configuration values have changed.
Definition applet.cpp:810
void setUserConfiguring(bool configuring)
Tells the applet the user is configuring.
Definition applet.cpp:519
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:741
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:499
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:847
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:202
bool isBusy() const
Definition applet.cpp:330
void setLaunchErrorMessage(const QString &reason=QString())
Call this method when the applet fails to launch properly.
Definition applet.cpp:169
QString configurationRequiredReason() const
Definition applet.cpp:482
Q_INVOKABLE void setInternalAction(const QString &name, QAction *action)
Add a new internal action.
Definition applet.cpp:650
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:691
bool destroyed() const
Definition applet.cpp:243
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:179
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:335
void setImmutability(const Types::ImmutabilityType immutable)
Sets the immutability type for this applet (not immutable, user immutable or system immutable)
Definition applet.cpp:448
void setBackgroundHints(Plasma::Types::BackgroundHints hint)
Sets the applet background hints.
Definition applet.cpp:350
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:97
void flushPendingConstraintsEvents()
Sends all pending constraints updates to the applet.
Definition applet.cpp:543
Applet(QObject *parentObject, const KPluginMetaData &data, const QVariantList &args)
This constructor can be used with the KCoreAddons plugin loading system.
Definition applet.cpp:41
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:401
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:248
bool hasConfigurationInterface
True if this applet will provide a UI for its configuration.
Definition applet.h:173
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:467
virtual void restore(KConfigGroup &group)
Restores state information about this applet saved previously in save(KConfigGroup&).
Definition applet.cpp:135
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
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
QMetaEnum fromType()
int keyToValue(const char *key, bool *ok) const const
const char * valueToKey(int value) const const
QObject(QObject *parent)
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
T qobject_cast(QObject *object)
void setObjectName(QAnyStringView name)
void valueChanged(const QString &key, const QVariant &value)
bool isEmpty() const const
UniqueConnection
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.