From ea500a8ec0086dbece17999cbf246bfbed295ba0 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sun, 24 Oct 2021 00:33:31 +0300 Subject: [PATCH] indicators:expose iconOffsetX/Y to applets --expose iconed applets indicator iconOffsetX/Y setting and this way animate applet icons if the indicator would like to do so --- .../package/contents/ui/applet/AppletItem.qml | 8 ++-- .../package/contents/applet/CompactApplet.qml | 37 ++++++++++++++++--- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/containment/package/contents/ui/applet/AppletItem.qml b/containment/package/contents/ui/applet/AppletItem.qml index 91bcfd557..43623dfdb 100644 --- a/containment/package/contents/ui/applet/AppletItem.qml +++ b/containment/package/contents/ui/applet/AppletItem.qml @@ -94,6 +94,7 @@ Item { && ((applet && applet.status === PlasmaCore.Types.HiddenStatus ) || isInternalViewSplitter) property bool isInternalViewSplitter: (internalSplitterId > 0) property bool isZoomed: false + property bool isPressed: viewSignalsConnector.pressed property bool isSeparator: applet && (applet.pluginName === "audoban.applet.separator" || applet.pluginName === "org.kde.latte.separator") property bool isSpacer: applet && (applet.pluginName === "org.kde.latte.spacer") @@ -678,10 +679,10 @@ Item { target: root.latteView ? root.latteView.extendedInterface : null enabled: !appletItem.indexerIsSupported && !appletItem.isSeparator && !appletItem.isSpacer && !appletItem.isHidden - onExpandedAppletStateChanged: { + onHasExpandedAppletChanged: { if (latteView.extendedInterface.hasExpandedApplet && appletItem.applet) { appletItem.isExpanded = latteView.extendedInterface.appletIsExpandable(appletItem.applet.id) - && latteView.extendedInterface.appletIsExpanded(appletItem.applet.id); + && latteView.extendedInterface.appletIsExpanded(appletItem.applet.id); } else { appletItem.isExpanded = false; } @@ -727,9 +728,10 @@ Item { isActive: appletItem.isActive isHovered: appletItem.containsMouse + isPressed: appletItem.isPressed isSquare: appletItem.isSquare - hasActive: isActive + hasActive: appletItem.isActive scaleFactor: appletItem.wrapper.zoomScale panelOpacity: root.background.currentOpacity diff --git a/shell/package/contents/applet/CompactApplet.qml b/shell/package/contents/applet/CompactApplet.qml index d646012db..024516d67 100644 --- a/shell/package/contents/applet/CompactApplet.qml +++ b/shell/package/contents/applet/CompactApplet.qml @@ -26,10 +26,10 @@ PlasmaCore.ToolTipArea { textFormat: plasmoid.toolTipTextFormat mainItem: plasmoid.toolTipItem ? plasmoid.toolTipItem : null - property Item fullRepresentation - property Item compactRepresentation + property Item fullRepresentation: null + property Item compactRepresentation: null /*Discover real visual parent - the following code points to Applet::ItemWrapper*/ - property Item originalCompactRepresenationParent + property Item originalCompactRepresenationParent: null property Item compactRepresentationVisualParent: originalCompactRepresenationParent && originalCompactRepresenationParent.parent ? originalCompactRepresenationParent.parent.parent : null @@ -42,7 +42,15 @@ PlasmaCore.ToolTipArea { originalCompactRepresenationParent = compactRepresentation.parent; compactRepresentation.parent = root; - compactRepresentation.anchors.fill = root; + compactRepresentation.anchors.centerIn = root; + compactRepresentation.width = Qt.binding(function() { + return root.width; + }); + + compactRepresentation.height = Qt.binding(function() { + return root.height; + }); + compactRepresentation.visible = true; } root.visible = true; @@ -203,11 +211,30 @@ PlasmaCore.ToolTipArea { } } + ////Indicators API //// + Binding { + target: compactRepresentation ? compactRepresentation.anchors : null + property: "horizontalCenterOffset" + when: compactRepresentation + value: appletItem ? appletItem.iconOffsetX : 0 + } + + Binding { + target: compactRepresentation ? compactRepresentation.anchors : null + property: "verticalCenterOffset" + when: compactRepresentation + value: appletItem ? appletItem.iconOffsetY : 0 + } + ////Clicked Effect //// BrightnessContrast { id: _clickedEffect - anchors.fill: parent + anchors.centerIn: parent + anchors.horizontalCenterOffset: compactRepresentation ? compactRepresentation.anchors.horizontalCenterOffset : 0 + anchors.verticalCenterOffset: compactRepresentation ? compactRepresentation.anchors.verticalCenterOffset : 0 source: compactRepresentation + width: root.width + height: root.height visible: appletItem && clickedAnimation.running && !appletItem.indicators.info.providesClickedAnimation z:1000 }