From 33363c241d03995f2744ed9e6ae72b07759c4754 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Wed, 27 Feb 2019 17:36:39 +0200 Subject: [PATCH] Enable communication between Applets --applets can now use the LatteBridge in order to send/receive messages between them. A good example of this could be the window title and the window appmenu applets in order the hide and show themselves based on mouse hovering. --- .../ui/applet/communicator/Actions.qml | 45 +++++++++++++++ .../ui/applet/communicator/LatteBridge.qml | 56 ++++++------------- containment/package/contents/ui/main.qml | 2 + 3 files changed, 65 insertions(+), 38 deletions(-) diff --git a/containment/package/contents/ui/applet/communicator/Actions.qml b/containment/package/contents/ui/applet/communicator/Actions.qml index f1f79adf1..bd15dae23 100644 --- a/containment/package/contents/ui/applet/communicator/Actions.qml +++ b/containment/package/contents/ui/applet/communicator/Actions.qml @@ -20,6 +20,43 @@ import QtQuick 2.7 Item{ + // NAME: latteSideColoringEnabled + // TYPE: bool + // USAGE: writable through actions.setProperty + // EXPLANATION: when is FALSE, Latte is not painting/colorizing this applet + // in any case. In such case the applet can use 'palette' + // in order to access the color palette used at all cases from Latte + // USE CASE: when Latte is transparent and applets colors need to be adjusted in order + // to look consistent with the underlying desktop background OR the applet + // is not using monochromatic icons but rather colorful ones. + // @since: 0.9 + + + // NAME: latteIconOverlayEnabled + // TYPE: bool + // USAGE: writable through actions.setProperty + // EXPLANATION: when is FALSE, Latte is not overlaying any icons above + // the applet or alters the applet visual in any sense. + // That means that the applet is responsible to provide a coherent + // parabolic effect experience. + // @since: 0.9 + + // NAME: activeIndicatorEnabled + // TYPE: bool + // USAGE: writable through actions.setProperty + // EXPLANATION: when is TRUE, Latte can show its own Active Indicator + // when needed. For FALSE, the Latte Active Indicator is not drawn + // or used for that applet. + // @since: 0.9 + + // NAME: parabolicEffectEnabled + // TYPE: bool + // USAGE: writable through actions.setProperty + // EXPLANATION: when is TRUE, Latte can use Parabolic Effect in order + // to draw that applet. For FALSE, this applet is considered locked + // and can not be zoomed. + // @since: 0.9 + function setProperty(appletId, parameter, value) { if (parameter === "latteSideColoringEnabled") { mainCommunicator.latteSideColoringEnabled = value; @@ -46,4 +83,12 @@ Item{ return null; } + + //! USAGE: send message to , for command and set its property to + //! EXPLANATION: applets can send messages/commands to other applets + //! in order to communicate with each other + function broadcastToApplet(pluginName, action, value) { + root.broadcastedToApplet(pluginName, action, value); + } + } diff --git a/containment/package/contents/ui/applet/communicator/LatteBridge.qml b/containment/package/contents/ui/applet/communicator/LatteBridge.qml index 0174dc829..4b381f533 100644 --- a/containment/package/contents/ui/applet/communicator/LatteBridge.qml +++ b/containment/package/contents/ui/applet/communicator/LatteBridge.qml @@ -22,6 +22,16 @@ import QtQuick 2.7 Item{ id: settings + //! EXPOSED SIGNALS + + //! USAGE: signals from other applets, , + //! EXPLANATION: applets can receive signals from other applets + //! to catch signals from other applets in order to communicate with + //! each other + signal broadcasted(string action, variant value); + + //! EXPOSED PROPERTIES + // NAME: version // USAGE: read-only // EXPLANATION: Latte communication version in order for the applet to use only properties @@ -64,46 +74,16 @@ Item{ property Item actions: Actions{} - - // NAME: latteSideColoringEnabled - // TYPE: bool - // USAGE: writable through actions.setProperty - // EXPLANATION: when is FALSE, Latte is not painting/colorizing this applet - // in any case. In such case the applet can use 'palette' - // in order to access the color palette used at all cases from Latte - // USE CASE: when Latte is transparent and applets colors need to be adjusted in order - // to look consistent with the underlying desktop background OR the applet - // is not using monochromatic icons but rather colorful ones. - // @since: 0.9 - - - // NAME: latteIconOverlayEnabled - // TYPE: bool - // USAGE: writable through actions.setProperty - // EXPLANATION: when is FALSE, Latte is not overlaying any icons above - // the applet or alters the applet visual in any sense. - // That means that the applet is responsible to provide a coherent - // parabolic effect experience. - // @since: 0.9 - - // NAME: activeIndicatorEnabled - // TYPE: bool - // USAGE: writable through actions.setProperty - // EXPLANATION: when is TRUE, Latte can show its own Active Indicator - // when needed. For FALSE, the Latte Active Indicator is not drawn - // or used for that applet. - // @since: 0.9 - - // NAME: parabolicEffectEnabled - // TYPE: bool - // USAGE: writable through actions.setProperty - // EXPLANATION: when is TRUE, Latte can use Parabolic Effect in order - // to draw that applet. For FALSE, this applet is considered locked - // and can not be zoomed. - // @since: 0.9 + Connections { + target: root + onBroadcastedToApplet: { + if (appletItem.applet && appletItem.applet.pluginName === pluginName) { + settings.broadcasted(action, value); + } + } + } //! Initialize - Component.onCompleted: { appletRootItem.latteBridge = settings; } diff --git a/containment/package/contents/ui/main.qml b/containment/package/contents/ui/main.qml index 6cae6b98d..bf6cff881 100644 --- a/containment/package/contents/ui/main.qml +++ b/containment/package/contents/ui/main.qml @@ -51,6 +51,8 @@ DragDrop.DropArea { signal updateEffectsArea(); signal updateIndexes(); signal updateScale(int delegateIndex, real newScale, real step); + + signal broadcastedToApplet(string pluginName, string action, variant value); //// END SIGNALS ////BEGIN properties