/*SPDX-FileCopyrightText: 2013 Marco Martin <mart@kde.org>SPDX-License-Identifier: GPL-2.0-or-later*/pragma ComponentBehavior: Boundimport QtQuickimport QtQuick.Layoutsimport org.kde.plasma.core as PlasmaCoreimport org.kde.plasma.plasmoidimport org.kde.plasma.workspace.components as WorkspaceComponentsimport org.kde.kirigami as KirigamiKirigami.Icon {id: defaultCompactRepresentationproperty PlasmoidItem plasmoidItemreadonly property bool inPanel: [PlasmaCore.Types.TopEdge, PlasmaCore.Types.RightEdge, PlasmaCore.Types.BottomEdge, PlasmaCore.Types.LeftEdge].includes(Plasmoid.location)Layout.minimumWidth: {switch (Plasmoid.formFactor) {case PlasmaCore.Types.Vertical:return 0;case PlasmaCore.Types.Horizontal:return height;default:return Kirigami.Units.gridUnit * 3;}}Layout.minimumHeight: {switch (Plasmoid.formFactor) {case PlasmaCore.Types.Vertical:return width;case PlasmaCore.Types.Horizontal:return 0;default:return Kirigami.Units.gridUnit * 3;}}source: Plasmoid.icon || "plasma"active: mouseArea.containsMouseactiveFocusOnTab: trueKeys.onPressed: event => {switch (event.key) {case Qt.Key_Space:case Qt.Key_Enter:case Qt.Key_Return:case Qt.Key_Select:Plasmoid.activated();event.accepted = true; // BUG 481393: Prevent system tray from receiving the eventbreak;}}Accessible.name: Plasmoid.titleAccessible.description: plasmoidItem.toolTipSubText ?? ""Accessible.role: Accessible.ButtonMouseArea {id: mouseAreaproperty bool wasExpanded: falseanchors.fill: parenthoverEnabled: trueonPressed: wasExpanded = defaultCompactRepresentation.plasmoidItem.expandedonClicked: mouse => {if (mouse.button === Qt.MiddleButton) {Plasmoid.secondaryActivated();} else {defaultCompactRepresentation.plasmoidItem.expanded = !wasExpanded;}}}// Open the FullRepresentation on drag-hover if the applet wants itLoader {anchors.fill: parentactive: defaultCompactRepresentation.plasmoidItem.expandedOnDragHoversourceComponent: DropArea {anchors.fill: parentonEntered: dropTimer.restart()onExited: dropTimer.stop()Timer {id: dropTimerinterval: 250 // matches taskmanager delayonTriggered: {defaultCompactRepresentation.plasmoidItem.expanded = true;mouseArea.wasExpanded = true;}}}}Loader {id: badgeLoaderanchors.bottom: defaultCompactRepresentation.bottomanchors.right: defaultCompactRepresentation.rightactive: defaultCompactRepresentation.plasmoidItem.badgeText.length != 0sourceComponent: WorkspaceComponents.BadgeOverlay {text: defaultCompactRepresentation.plasmoidItem.badgeTexticon: defaultCompactRepresentation}// Non-default state to center if the badge is wider than the iconstates: [State {when: badgeLoader.width >= defaultCompactRepresentation.widthAnchorChanges {target: badgeLoaderanchors.right: undefinedanchors.horizontalCenter: defaultCompactRepresentation.horizontalCenter}}]}}