Warning, /plasma/plasma-workspace/applets/systemtray/package/contents/ui/PlasmoidPopupsContainer.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2015 Marco Martin <mart@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 import QtQuick 2.15
0008 import QtQuick.Layouts 1.15
0009 import QtQuick.Controls 2.15
0010 import org.kde.plasma.components 3.0 as PlasmaComponents3
0011 import org.kde.kirigami 2.20 as Kirigami
0012 import org.kde.plasma.extras 2.0 as PlasmaExtras
0013 import org.kde.plasma.plasmoid 2.0
0014 
0015 StackView {
0016     id: mainStack
0017     focus: true
0018 
0019     Layout.minimumWidth: Kirigami.Units.gridUnit * 12
0020     Layout.minimumHeight: Kirigami.Units.gridUnit * 12
0021 
0022     readonly property Item activeApplet: systemTrayState.activeApplet
0023 
0024     /* Heading */
0025     property bool appletHasHeading: false
0026     property bool mergeHeadings: appletHasHeading && activeApplet.fullRepresentationItem.header.visible
0027     property int headingHeight: mergeHeadings ? activeApplet.fullRepresentationItem.header.height : 0
0028     /* Footer */
0029     property bool appletHasFooter: false
0030     property bool mergeFooters: appletHasFooter && activeApplet.fullRepresentationItem.footer.visible
0031     property int footerHeight: mergeFooters ? activeApplet.fullRepresentationItem.footer.height : 0
0032 
0033     onActiveAppletChanged: {
0034         mainStack.appletHasHeading = false
0035         mainStack.appletHasFooter = false
0036 
0037         if (activeApplet != null && activeApplet.fullRepresentationItem && !activeApplet.preferredRepresentation) {
0038             //reset any potential anchor
0039             activeApplet.fullRepresentationItem.anchors.left = undefined;
0040             activeApplet.fullRepresentationItem.anchors.top = undefined;
0041             activeApplet.fullRepresentationItem.anchors.right = undefined;
0042             activeApplet.fullRepresentationItem.anchors.bottom = undefined;
0043             activeApplet.fullRepresentationItem.anchors.centerIn = undefined;
0044             activeApplet.fullRepresentationItem.anchors.fill = undefined;
0045 
0046             if (activeApplet.fullRepresentationItem instanceof PlasmaComponents3.Page ||
0047                 activeApplet.fullRepresentationItem instanceof PlasmaExtras.Representation) {
0048                 if (activeApplet.fullRepresentationItem.header && activeApplet.fullRepresentationItem.header instanceof PlasmaExtras.PlasmoidHeading) {
0049                     mainStack.appletHasHeading = true
0050                     activeApplet.fullRepresentationItem.header.background.visible = false
0051                 }
0052                 if (activeApplet.fullRepresentationItem.footer && activeApplet.fullRepresentationItem.footer instanceof PlasmaExtras.PlasmoidHeading) {
0053                     mainStack.appletHasFooter = true
0054                     activeApplet.fullRepresentationItem.footer.background.visible = false
0055                 }
0056             }
0057 
0058             let unFlipped = systemTrayState.oldVisualIndex < systemTrayState.newVisualIndex;
0059             if (Qt.application.layoutDirection !== Qt.LeftToRight) {
0060                 unFlipped = !unFlipped;
0061             }
0062 
0063             const isTransitionEnabled = systemTrayState.expanded;
0064             (mainStack.empty ? mainStack.push : mainStack.replace)(activeApplet.fullRepresentationItem, {
0065                 "width": Qt.binding(() => mainStack.width),
0066                 "height": Qt.binding(() => mainStack.height),
0067                 "x": 0,
0068                 "focus": Qt.binding(() => !mainStack.busy), // QTBUG-44043: retrigger binding after StackView is ready to restore focus
0069                 "opacity": 1,
0070                 "KeyNavigation.up": mainStack.KeyNavigation.up,
0071                 "KeyNavigation.backtab": mainStack.KeyNavigation.backtab,
0072             }, isTransitionEnabled ? (unFlipped ? StackView.PushTransition : StackView.PopTransition) : StackView.Immediate);
0073         } else {
0074             mainStack.clear();
0075         }
0076     }
0077 
0078     onCurrentItemChanged: {
0079         if (currentItem !== null && root.expanded) {
0080             currentItem.forceActiveFocus();
0081         }
0082     }
0083 
0084     Connections {
0085         target: Plasmoid
0086         function onAppletRemoved(applet) {
0087             if (applet === systemTrayState.activeApplet) {
0088                 mainStack.clear();
0089             }
0090         }
0091     }
0092 }