Warning, /plasma/latte-dock/indicators/org.kde.latte.plasma/package/ui/main.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2019 Michail Vourlakos <mvourlakos@gmail.com>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 import QtQuick 2.0
0007 
0008 import org.kde.plasma.core 2.0 as PlasmaCore
0009 
0010 import org.kde.latte.components 1.0 as LatteComponents
0011 
0012 LatteComponents.IndicatorItem {
0013     id: root
0014 
0015     needsMouseEventCoordinates: true
0016     providesClickedAnimation: clickedAnimationEnabled
0017     //providesHoveredAnimation: true
0018     providesFrontLayer: true
0019     svgImagePaths: ["widgets/tasks"]
0020 
0021     enabledForApplets: true
0022     /*enabledForApplets: configurationIsReady && indicator.configuration.clickedAnimationEnabled !== undefined ?
0023                            indicator.configuration.enabledForApplets : true*/
0024     lengthPadding: configurationIsReady && indicator.configuration.clickedAnimationEnabled !== undefined ?
0025                        indicator.configuration.lengthPadding : 0.08
0026 
0027     backgroundCornerMargin: configurationIsReady && indicator.configuration.backgroundCornerMargin !== undefined ?
0028                                 indicator.configuration.backgroundCornerMargin : 1.00
0029 
0030     //! config options
0031     readonly property bool clickedAnimationEnabled: configurationIsReady
0032                                                     && indicator.configuration.clickedAnimationEnabled !== undefined
0033                                                     && indicator.configuration.clickedAnimationEnabled
0034 
0035     /*readonly property bool reversedEnabled: configurationIsReady
0036                                             && indicator.configuration.reversed !== undefined
0037                                             && indicator.configuration.reversed*/
0038 
0039 
0040     readonly property bool configurationIsReady: indicator && indicator.configuration
0041 
0042     //! Background Layer
0043     Loader{
0044         id: backLayer
0045         anchors.fill: parent
0046         anchors.topMargin: plasmoid.location === PlasmaCore.Types.TopEdge ? indicator.screenEdgeMargin : 0
0047         anchors.bottomMargin: plasmoid.location === PlasmaCore.Types.BottomEdge ? indicator.screenEdgeMargin : 0
0048         anchors.leftMargin: plasmoid.location === PlasmaCore.Types.LeftEdge ? indicator.screenEdgeMargin : 0
0049         anchors.rightMargin: plasmoid.location === PlasmaCore.Types.RightEdge ? indicator.screenEdgeMargin : 0
0050 
0051         active: level.isBackground && indicator.isTask && !indicator.isEmptySpace
0052         sourceComponent: TaskBackLayer{}
0053     }
0054 
0055     //! Applet Background Layer
0056     Loader{
0057         id: appletBackLayer
0058         anchors.fill: parent
0059         anchors.topMargin: plasmoid.location === PlasmaCore.Types.TopEdge ? indicator.screenEdgeMargin : 0
0060         anchors.bottomMargin: plasmoid.location === PlasmaCore.Types.BottomEdge ? indicator.screenEdgeMargin : 0
0061         anchors.leftMargin: plasmoid.location === PlasmaCore.Types.LeftEdge ? indicator.screenEdgeMargin : 0
0062         anchors.rightMargin: plasmoid.location === PlasmaCore.Types.RightEdge ? indicator.screenEdgeMargin : 0
0063 
0064         active: level.isBackground && indicator.isApplet && !indicator.isEmptySpace
0065         sourceComponent: AppletBackLayer{}
0066     }
0067 
0068     /* progress overlay for BackLayer*/
0069     /* it is not added in the BackLayer because the BackLayer is rotated in some cases*/
0070     Loader {
0071         anchors.fill: backLayer
0072         asynchronous: true
0073         active: level.isBackground && indicator.progressVisible
0074         sourceComponent: Item {
0075             id: background
0076 
0077             Item {
0078                 anchors {
0079                     top: parent.top
0080                     left: parent.left
0081                     bottom: parent.bottom
0082                 }
0083 
0084                 width: parent.width * (Math.min(indicator.progress, 100) / 100)
0085                 clip: true
0086 
0087                 PlasmaCore.FrameSvgItem {
0088                     id: progressFrame
0089                     width: background.width
0090                     height: background.height
0091 
0092                     imagePath: "widgets/tasks"
0093                     prefix: root.taskPrefix("progress").concat(root.taskPrefix("hover"))
0094                 }
0095             }
0096         }
0097     }
0098 
0099     //! Foreground Layer to draw arrows
0100     Loader{
0101         id: frontLayer
0102         anchors.fill: parent
0103         active: (level.isForeground && !indicator.isApplet && indicator.isGroup) || providesClickedAnimation
0104 
0105         sourceComponent: FrontLayer{}
0106     }
0107 
0108 
0109     function taskPrefix(prefix) {
0110         var effectivePrefix;
0111 
0112         if (plasmoid.location === PlasmaCore.Types.LeftEdge) {
0113             effectivePrefix = "west-" + prefix;
0114         }
0115 
0116         if (plasmoid.location === PlasmaCore.Types.TopEdge) {
0117             effectivePrefix = "north-" + prefix;
0118         }
0119 
0120         if (plasmoid.location === PlasmaCore.Types.RightEdge) {
0121             effectivePrefix = "east-" + prefix;
0122         }
0123 
0124         if (plasmoid.location === PlasmaCore.Types.BottomEdge) {
0125             effectivePrefix = "south-" + prefix;
0126         }
0127 
0128         return [effectivePrefix, prefix];
0129     }
0130 
0131     function taskPrefixHovered(prefix) {
0132         var effectivePrefix = taskPrefix(prefix);
0133 
0134         if ("" !== prefix)
0135             effectivePrefix = [
0136                 ...taskPrefix(prefix + "-hover"),
0137                 ...taskPrefix("hover"),
0138                 ...effectivePrefix
0139             ];
0140 
0141         return effectivePrefix;
0142     }
0143 }