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.
pull/5/head
Michail Vourlakos 6 years ago
parent f3be388c40
commit 33363c241d

@ -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 <pluginName>, for <action> command and set its property to <value>
//! 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);
}
}

@ -22,6 +22,16 @@ import QtQuick 2.7
Item{
id: settings
//! EXPOSED SIGNALS
//! USAGE: signals from other applets, <command>, <value>
//! 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;
}

@ -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

Loading…
Cancel
Save