shift-shell/shell/contents/views/Desktop.qml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

139 lines
4.8 KiB
QML
Raw Normal View History

2014-09-29 14:40:58 +00:00
/*
2021-03-01 20:03:25 +00:00
* SPDX-FileCopyrightText: 2014 Aaron Seigo <aseigo@kde.org>
* SPDX-FileCopyrightText: 2012 Marco Martin <notmart@gmail.com>
2014-09-29 14:40:58 +00:00
*
2021-03-01 20:03:25 +00:00
* SPDX-License-Identifier: LGPL-2.0-or-later
2014-09-29 14:40:58 +00:00
*/
import QtQuick 2.15
import org.kde.plasma.core as PlasmaCore
import org.kde.kquickcontrolsaddons 2.0
import org.kde.kirigami as Kirigami
import org.kde.plasma.private.mobileshell as MobileShell
import org.kde.plasma.private.mobileshell.state as MobileShellState
Rectangle {
id: root
2018-02-13 13:16:48 +00:00
property Item containment
2018-02-13 13:16:48 +00:00
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();
MobileShellState.PanelSettingsDBusObjectManager.registerObjects();
// 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 != "") {
widgetExplorerStack.source = "";
} else {
2020-07-16 11:48:53 +00:00
widgetExplorerStack.setSource(desktop.fileFromPackage("explorer", "WidgetExplorer.qml"), {"containment": containment, "containmentInterface": root.containment})
}
}
onContainmentChanged: {
2023-03-05 02:52:41 +00:00
if (containment == null) {
return;
}
containment.parent = root;
containment.visible = true;
containment.anchors.fill = root;
2018-02-13 13:16:48 +00:00
}
// This is taken from plasma-desktop's shell package, try to keep it in sync
// Handles taking accent color from wallpaper
Loader {
id: wallpaperColors
active: desktop.usedInAccentColor && root.containment && root.containment.wallpaper
asynchronous: true
sourceComponent: Kirigami.ImageColors {
id: imageColors
source: root.containment.wallpaper
readonly property color backgroundColor: Kirigami.Theme.backgroundColor
readonly property color textColor: Kirigami.Theme.textColor
property color colorFromPlugin: "transparent"
Kirigami.Theme.inherit: false
Kirigami.Theme.backgroundColor: backgroundColor
Kirigami.Theme.textColor: textColor
onBackgroundColorChanged: Qt.callLater(update)
onTextColorChanged: Qt.callLater(update)
property Binding colorBinding: Binding {
target: desktop
property: "accentColor"
value: {
if (!Qt.colorEqual(imageColors.colorFromPlugin, "transparent")) {
return imageColors.colorFromPlugin;
}
if (imageColors.palette.length === 0) {
return "transparent";
}
return imageColors.dominant;
}
when: desktop.usedInAccentColor // Without this, accentColor may still be updated after usedInAccentColor becomes false
}
property Connections repaintConnection: Connections {
target: root.containment.wallpaper
function onRepaintNeeded(color) {
imageColors.colorFromPlugin = color;
if (Qt.colorEqual(color, "transparent")) {
imageColors.update();
}
}
}
}
onLoaded: item.update()
}
Loader {
id: widgetExplorerStack
z: 99
asynchronous: true
y: containment ? containment.availableScreenRect.y : 0
height: containment ? containment.availableScreenRect.height : parent.height
width: parent.width
onLoaded: {
if (widgetExplorerStack.item) {
item.closed.connect(function() {
widgetExplorerStack.source = ""
});
item.topPanelHeight = containment.availableScreenRect.y
item.bottomPanelHeight = root.height - (containment.availableScreenRect.height + containment.availableScreenRect.y)
item.leftPanelWidth = containment.availableScreenRect.x
item.rightPanelWidth = root.width - (containment.availableScreenRect.width + containment.availableScreenRect.x)
}
}
}
}