Warning, /plasma/plasma-mobile/shell/contents/views/Desktop.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *   SPDX-FileCopyrightText: 2014 Aaron Seigo <aseigo@kde.org>
0003  *   SPDX-FileCopyrightText: 2012 Marco Martin <notmart@gmail.com>
0004  *
0005  *   SPDX-License-Identifier: LGPL-2.0-or-later
0006  */
0007 
0008 import QtQuick 2.15
0009 
0010 import org.kde.plasma.core as PlasmaCore
0011 import org.kde.plasma.shell 2.0 as Shell
0012 
0013 import org.kde.kquickcontrolsaddons 2.0
0014 import org.kde.kirigami 2.20 as Kirigami
0015 
0016 Rectangle {
0017     id: root
0018 
0019     property Item containment
0020 
0021     color: (containment && containment.backgroundHints == PlasmaCore.Types.NoBackground) ? "transparent" : Kirigami.Theme.textColor
0022 
0023     function toggleWidgetExplorer(containment) {
0024         console.log("Widget Explorer toggled");
0025         if (widgetExplorerStack.source != "") {
0026             widgetExplorerStack.source = "";
0027         } else {
0028             widgetExplorerStack.setSource(desktop.fileFromPackage("explorer", "WidgetExplorer.qml"), {"containment": containment, "containmentInterface": root.containment})
0029         }
0030     }
0031 
0032     onContainmentChanged: {
0033         if (containment == null) {
0034             return;
0035         }
0036 
0037         containment.parent = root;
0038         containment.visible = true;
0039         containment.anchors.fill = root;
0040     }
0041 
0042     // This is taken from plasma-desktop's shell package, try to keep it in sync
0043     // Handles taking accent color from wallpaper
0044     Loader {
0045         id: wallpaperColors
0046 
0047         active: desktop.usedInAccentColor && root.containment && root.containment.wallpaper
0048         asynchronous: true
0049 
0050         sourceComponent: Kirigami.ImageColors {
0051             id: imageColors
0052             source: root.containment.wallpaper
0053 
0054             readonly property color backgroundColor: Kirigami.Theme.backgroundColor
0055             readonly property color textColor: Kirigami.Theme.textColor
0056             property color colorFromPlugin: "transparent"
0057 
0058             Kirigami.Theme.inherit: false
0059             Kirigami.Theme.backgroundColor: backgroundColor
0060             Kirigami.Theme.textColor: textColor
0061 
0062             onBackgroundColorChanged: Qt.callLater(update)
0063             onTextColorChanged: Qt.callLater(update)
0064 
0065             property Binding colorBinding: Binding {
0066                 target: desktop
0067                 property: "accentColor"
0068                 value: {
0069                     if (!Qt.colorEqual(imageColors.colorFromPlugin, "transparent")) {
0070                         return imageColors.colorFromPlugin;
0071                     }
0072                     if (imageColors.palette.length === 0) {
0073                         return "transparent";
0074                     }
0075                     return imageColors.dominant;
0076                 }
0077                 when: desktop.usedInAccentColor // Without this, accentColor may still be updated after usedInAccentColor becomes false
0078             }
0079 
0080             property Connections repaintConnection: Connections {
0081                 target: root.containment.wallpaper
0082                 function onRepaintNeeded(color) {
0083                     imageColors.colorFromPlugin = color;
0084 
0085                     if (Qt.colorEqual(color, "transparent")) {
0086                         imageColors.update();
0087                     }
0088                 }
0089             }
0090         }
0091 
0092         onLoaded: item.update()
0093     }
0094 
0095     Loader {
0096         id: widgetExplorerStack
0097         z: 99
0098         asynchronous: true
0099         y: containment ? containment.availableScreenRect.y : 0
0100         height: containment ? containment.availableScreenRect.height : parent.height
0101         width: parent.width
0102 
0103         onLoaded: {
0104             if (widgetExplorerStack.item) {
0105                 item.closed.connect(function() {
0106                     widgetExplorerStack.source = ""
0107                 });
0108 
0109                 item.topPanelHeight = containment.availableScreenRect.y
0110                 item.bottomPanelHeight = root.height - (containment.availableScreenRect.height + containment.availableScreenRect.y)
0111 
0112                 item.leftPanelWidth = containment.availableScreenRect.x
0113                 item.rightPanelWidth = root.width - (containment.availableScreenRect.width + containment.availableScreenRect.x)
0114             }
0115         }
0116     }
0117 }