Warning, /plasma/plasma-desktop/desktoppackage/contents/applet/DefaultCompactRepresentation.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2013 Marco Martin <mart@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 import QtQuick 2.15
0008 import QtQuick.Layouts 1.15
0009 
0010 import org.kde.plasma.core as PlasmaCore
0011 import org.kde.plasma.plasmoid 2.0
0012 import org.kde.kirigami 2.20 as Kirigami
0013 
0014 Kirigami.Icon {
0015     property PlasmoidItem plasmoidItem
0016     readonly property bool inPanel: [PlasmaCore.Types.TopEdge, PlasmaCore.Types.RightEdge, PlasmaCore.Types.BottomEdge, PlasmaCore.Types.LeftEdge]
0017         .includes(Plasmoid.location)
0018 
0019     Layout.minimumWidth: {
0020         switch (Plasmoid.formFactor) {
0021         case PlasmaCore.Types.Vertical:
0022             return 0;
0023         case PlasmaCore.Types.Horizontal:
0024             return height;
0025         default:
0026             return Kirigami.Units.gridUnit * 3;
0027         }
0028     }
0029 
0030     Layout.minimumHeight: {
0031         switch (Plasmoid.formFactor) {
0032         case PlasmaCore.Types.Vertical:
0033             return width;
0034         case PlasmaCore.Types.Horizontal:
0035             return 0;
0036         default:
0037             return Kirigami.Units.gridUnit * 3;
0038         }
0039     }
0040 
0041     source: Plasmoid.icon || "plasma"
0042     active: mouseArea.containsMouse
0043 
0044     activeFocusOnTab: true
0045 
0046     Keys.onPressed: event => {
0047         switch (event.key) {
0048         case Qt.Key_Space:
0049         case Qt.Key_Enter:
0050         case Qt.Key_Return:
0051         case Qt.Key_Select:
0052             Plasmoid.activated();
0053             break;
0054         }
0055     }
0056 
0057     Accessible.name: Plasmoid.title
0058     Accessible.description: plasmoidItem.toolTipSubText ?? ""
0059     Accessible.role: Accessible.Button
0060 
0061     MouseArea {
0062         id: mouseArea
0063 
0064         property bool wasExpanded: false
0065 
0066         anchors.fill: parent
0067         hoverEnabled: true
0068         onPressed: wasExpanded = plasmoidItem.expanded
0069         onClicked: plasmoidItem.expanded = !wasExpanded
0070     }
0071 }