singletons: Initialize singletons in shell desktop, not panel

We have some singletons (ex. for notification popups, volume, dbus) that
need to be initialized somewhere in plasmashell. Currently they are done
from the panel containment, which is a bit of a strange location. There isn't really
any offical way it seems to do this, so move it to the shell package
which feels more central.
This commit is contained in:
Devin Lin 2025-06-25 12:20:12 -04:00
parent 7c07dc0122
commit 46578fde73
3 changed files with 30 additions and 12 deletions

View file

@ -20,9 +20,15 @@ Item {
// WARNING: only call this load from within the plasmashell process, because
// multiple bindings of the shortcut may break it entirely (hardware volume keys)
function load() {
volumeOSD.active = true;
notifications.active = true;
actionButtons.active = true;
if (!volumeOSD.active) {
volumeOSD.active = true;
}
if (!notifications.active) {
notifications.active = true;
}
if (!actionButtons.active) {
actionButtons.active = true;
}
}
Loader {

View file

@ -136,15 +136,6 @@ ContainmentItem {
Component.onCompleted: {
root.setWindowProperties();
// register dbus
MobileShellState.ShellDBusObject.registerObject();
// HACK: we need to initialize the DBus server somewhere, it might as well be here...
// Initialize the volume osd, and volume keys.
// Initialize notification popups.
// Initialize action popup buttons.
MobileShell.PopupProviderLoader.load();
}
MobileShell.StartupFeedbackPanelFill {

View file

@ -13,6 +13,9 @@ import org.kde.plasma.shell 2.0 as Shell
import org.kde.kquickcontrolsaddons 2.0
import org.kde.kirigami 2.20 as Kirigami
import org.kde.plasma.private.mobileshell as MobileShell
import org.kde.plasma.private.mobileshell.state as MobileShellState
Rectangle {
id: root
@ -20,6 +23,24 @@ Rectangle {
color: (containment && containment.backgroundHints == PlasmaCore.Types.NoBackground) ? "transparent" : Kirigami.Theme.textColor
Component.onCompleted: {
initializeShellSingletons();
}
function initializeShellSingletons() {
console.log('Initializing DBus objects and popup providers...');
// Note: The calls here must be idempotent (support being called multiple times)
// - this is called every time there is a new desktop containment
// HACK: we need to initialize the DBus server somewhere in plasmashell, it might as well be here...
MobileShellState.ShellDBusObject.registerObject();
// Initialize the volume osd, and volume keys.
// Initialize notification popups.
// Initialize action popup buttons.
MobileShell.PopupProviderLoader.load();
}
function toggleWidgetExplorer(containment) {
console.log("Widget Explorer toggled");
if (widgetExplorerStack.source != "") {