Warning, /plasma/latte-dock/containment/package/contents/ui/applet/communicator/LatteBridge.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2018 Michail Vourlakos <mvourlakos@gmail.com>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 import QtQuick 2.7
0007 
0008 import org.kde.latte.abilities.host 0.1 as AbilityHost
0009 import org.kde.latte.abilities.bridge 0.1 as AbilityBridge
0010 
0011 Item{
0012     id: settings
0013 
0014     //! EXPOSED SIGNALS
0015 
0016     //!   USAGE: signals from other applets, <command>, <value>
0017     //!   EXPLANATION: applets can receive signals from other applets
0018     //!       to catch signals from other applets in order to communicate with
0019     //!       each other
0020     signal broadcasted(string action, variant value);
0021 
0022     //! EXPOSED PROPERTIES
0023 
0024     // NAME: version
0025     //   USAGE: read-only
0026     //   EXPLANATION: Latte communication version in order for the applet to use only properties
0027     //       and parameters that are valid
0028     // @since: 0.9
0029     readonly property int version: root.version
0030 
0031     // NAME: inEditMode
0032     //   USAGE: read-only
0033     //   EXPLANATION: Latte sets it to true when this applet is in a Latte containment and Latte
0034     //       is also in EditMode, that means when the user is altering applets and Latte latteView settings
0035     // @since: 0.9
0036     readonly property bool inEditMode: appletItem.isLattePlasmoid ? root.editMode : root.inConfigureAppletsMode
0037 
0038     // NAME: inPlasmaPanelStyle
0039     //   USAGE: read-only
0040     //   EXPLANATION: Latte sets it to true when this view behaves as Plasma panel concerning
0041     //       drawing background shadows externally and applets can take this into account in order
0042     //       to adjust their appearance and behavior
0043     // @since: 0.9
0044     readonly property bool inPlasmaPanelStyle: root.behaveAsPlasmaPanel
0045 
0046     // NAME: palette
0047     //   USAGE: read-only
0048     //   EXPLANATION: Latte updates it to its coloring palette in order for the applet
0049     //       to take responsibility of its coloring.
0050     //   USE CASE: when Latte is transparent and applets colors need to be adjusted in order
0051     //       to look consistent with the underlying desktop background
0052     // @since: 0.9
0053     readonly property QtObject palette: !applet.latteSideColoringEnabled ? colorizerManager : null
0054 
0055     // NAME: applyPalette
0056     //   USAGE: read-only
0057     //   EXPLANATION: Latte updates it to TRUE when the applet must use the provided
0058     //       Latte "palette" and FALSE otherwise
0059     //   USE CASE: when Latte is transparent and applets colors need to be adjusted in order
0060     //       to look consistent with the underlying desktop background
0061     // @since: 0.9
0062     readonly property bool applyPalette: !applet.latteSideColoringEnabled ? colorizerManager.mustBeShown : false
0063 
0064     // NAME: parabolicEffectEnabled
0065     //   USAGE: read-only
0066     //   EXPLANATION: Parabolic Effect is enabled or not for this Latte View
0067     //   USE CASE: it can be used from applets that want to be adjusted based
0068     //       on the parabolic Effect or not
0069     // @since: 0.9
0070     readonly property bool parabolicEffectEnabled: appletItem.parabolic.isEnabled && !appletItem.originalAppletBehavior
0071 
0072     // NAME: iconSize
0073     //   USAGE: read-only
0074     //   EXPLANATION: The current icon size used in the Latte View
0075     //   USE CASE: it can be used from applets that want their size to be always
0076     //       relevant to the view icon size
0077     // @since: 0.9
0078     readonly property int iconSize: appletItem.metrics.iconSize
0079 
0080     // NAME: screenEdgeMargin
0081     //   USAGE: read-only
0082     //   EXPLANATION: The screen edge margin applied in pixels
0083     //   USE CASE: it can be used from applets that want to be informed what is the screen edge margin
0084     //       currently applied
0085     // @since: 0.10
0086     readonly property int screenEdgeMargin: appletItem.metrics.margin.screenEdge
0087 
0088     // NAME: thicknessPadding
0089     //   USAGE: read-only
0090     //   EXPLANATION: The thickness padding around applet in pixels
0091     //   USE CASE: it can be used from applets that want to be informed what is the thickness padding
0092     //       currently applied
0093     // @since: 0.10
0094     readonly property int thicknessPadding: appletItem.metrics.margin.tailThickness
0095 
0096     // NAME: lengthMargin
0097     //   USAGE: read-only
0098     //   EXPLANATION: The length margin around applet in pixels
0099     //   USE CASE: it can be used from applets that want to be informed what is the length margin
0100     //       currently applied
0101     // @since: 0.10
0102     readonly property int lengthMargin: appletItem.metrics.margin.length
0103 
0104     // NAME: lengthPadding
0105     //   USAGE: read-only
0106     //   EXPLANATION: The length padding around applet in pixels
0107     //   USE CASE: it can be used from applets that want to be informed what is the length padding
0108     //       currently applied
0109     // @since: 0.10
0110     readonly property int lengthPadding: appletItem.lengthAppletPadding
0111 
0112     // NAME: maxZoomFactor
0113     //   USAGE: read-only
0114     //   EXPLANATION: The maximum zoom factor currently used
0115     //   USE CASE: it can be used from applets that want to be informed what is the maximum
0116     //       zoom factor currently used
0117     // @since: 0.9
0118     readonly property real maxZoomFactor: appletItem.parabolic.factor.zoom
0119 
0120     // NAME: windowsTracker
0121     //   USAGE: read-only
0122     //   EXPLANATION: windows tracking based on the view this applet is present
0123     //   USE CASE: it can be used from applets that want windows tracking in order
0124     //       to update their appearance or their behavior accordingly
0125     // @since: 0.9
0126     readonly property QtObject windowsTracker: applet.windowsTrackingEnabled && latteView && latteView.windowsTracker ?
0127                                                    latteView.windowsTracker : null
0128 
0129     readonly property Item actions: Actions{}
0130     readonly property Item applet: mainCommunicator.requires
0131     readonly property alias containment: _containment.publicApi
0132     readonly property Item environment: appletItem.environment.publicApi
0133     readonly property Item debug: appletItem.debug.publicApi
0134     readonly property Item indicators: appletItem.indicators.publicApi
0135     readonly property Item metrics: appletItem.metrics.publicApi
0136     readonly property Item userRequests: appletItem.userRequests
0137 
0138     readonly property AbilityBridge.Animations animations: AbilityBridge.Animations {
0139         host: appletItem.animations.publicApi
0140         appletIndex: index
0141     }
0142 
0143     readonly property AbilityBridge.Indexer indexer: AbilityBridge.Indexer {
0144         host: appletItem.indexer
0145         appletIndex: index
0146         inMarginsArea: appletItem.inMarginsArea
0147         headAppletIsSeparator: appletItem.headAppletIsSeparator
0148         tailAppletIsSeparator: appletItem.tailAppletIsSeparator
0149     }
0150 
0151     readonly property AbilityBridge.Launchers launchers: AbilityBridge.Launchers {
0152         host: appletItem.launchers
0153         appletIndex: index
0154     }
0155 
0156     readonly property AbilityBridge.MyView myView: AbilityBridge.MyView {
0157         host: appletItem.myView.publicApi
0158         appletIndex: index
0159     }
0160 
0161     readonly property AbilityBridge.ParabolicEffect parabolic: AbilityBridge.ParabolicEffect {
0162         host: appletItem.parabolic
0163         appletIndex: index
0164     }
0165 
0166     readonly property AbilityBridge.ThinTooltip thinTooltip: AbilityBridge.ThinTooltip {
0167         host: appletItem.thinTooltip.publicApi
0168         appletIndex: index
0169     }
0170 
0171     readonly property AbilityBridge.PositionShortcuts shortcuts: AbilityBridge.PositionShortcuts {
0172         host: appletItem.shortcuts
0173         appletIndex: index
0174     }
0175 
0176     Connections {
0177         target: root
0178         onBroadcastedToApplet: {
0179             if (appletItem.applet && appletItem.applet.pluginName === pluginName) {
0180                 settings.broadcasted(action, value);
0181             }
0182         }
0183     }
0184 
0185     AbilityHost.Containment {
0186         id: _containment
0187         appletIndex: index
0188         myView: appletItem.myView
0189 
0190         isFirstAppletInContainment: appletItem.firstAppletInContainer
0191         isLastAppletInContainment: appletItem.lastAppletInContainer
0192     }
0193 
0194     //! Initialize
0195     Component.onCompleted: {
0196         if (appletContainsLatteBridge) {
0197             appletRootItem.latteBridge = settings;
0198         }
0199     }
0200 
0201     Component.onDestruction: {
0202         if (appletContainsLatteBridge) {
0203             appletRootItem.latteBridge = null;
0204         }
0205     }
0206 }