Warning, /plasma/latte-dock/indicators/org.kde.latte.plasma/package/ui/FrontLayer.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.7
0007 
0008 import org.kde.plasma.plasmoid 2.0
0009 import org.kde.plasma.core 2.0 as PlasmaCore
0010 
0011 Item {
0012     anchors.fill: parent
0013 
0014     Item {
0015         id: relevantItem
0016         anchors.fill: parent
0017         clip: true
0018 
0019         Item{
0020             id: clickedCenter
0021 
0022             readonly property int center: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? parent.width/2 : parent.height/2
0023 
0024             states:[
0025                 State {
0026                     name: "bottom"
0027                     when: (plasmoid.location === PlasmaCore.Types.BottomEdge)
0028 
0029                     AnchorChanges {
0030                         target: clickedCenter
0031                         anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:undefined;
0032                             horizontalCenter:parent.horizontalCenter; verticalCenter:undefined}
0033                     }
0034                 },
0035                 State {
0036                     name: "left"
0037                     when: (plasmoid.location === PlasmaCore.Types.LeftEdge)
0038 
0039                     AnchorChanges {
0040                         target: clickedCenter
0041                         anchors{ top:undefined; bottom:undefined; left:parent.left; right:undefined;
0042                             horizontalCenter:undefined; verticalCenter:parent.verticalCenter}
0043                     }
0044                 },
0045                 State {
0046                     name: "right"
0047                     when: (plasmoid.location === PlasmaCore.Types.RightEdge)
0048 
0049                     AnchorChanges {
0050                         target: clickedCenter
0051                         anchors{ top:undefined; bottom:undefined; left:undefined; right:parent.right;
0052                             horizontalCenter:undefined; verticalCenter:parent.verticalCenter}
0053                     }
0054                 },
0055                 State {
0056                     name: "top"
0057                     when: (plasmoid.location === PlasmaCore.Types.TopEdge)
0058 
0059                     AnchorChanges {
0060                         target: clickedCenter
0061                         anchors{ top:parent.top; bottom:undefined; left:undefined; right:undefined;
0062                             horizontalCenter:parent.horizontalCenter; verticalCenter:undefined}
0063                     }
0064                 }
0065             ]
0066         }
0067 
0068         Rectangle {
0069             id: clickedRectangle
0070             anchors.centerIn: clickedCenter
0071             opacity: 0
0072             radius: width/2
0073             height: width
0074 
0075             color: theme.highlightColor
0076         }
0077     }
0078     
0079     SequentialAnimation {
0080         id: clickedAnimation
0081         ScriptAction{
0082             script: {
0083                 clickedRectangle.width = 0;
0084                 clickedRectangle.opacity = 0.75;
0085                 clickedRectangle.anchors.rightMargin = 0;
0086                 clickedRectangle.anchors.leftMargin = 0;
0087                 clickedRectangle.anchors.topMargin = 0;
0088                 clickedRectangle.anchors.bottomMargin = 0;
0089                 clickedRectangle.anchors.horizontalCenterOffset = 0;
0090                 clickedRectangle.anchors.verticalCenterOffset = 0;
0091             }
0092         }
0093 
0094         ParallelAnimation{
0095             PropertyAnimation {
0096                 target: clickedRectangle
0097                 property: "width"
0098                 //! Don't animate above for length
0099                 to: maxLength * multiplier
0100                 duration: 700
0101                 easing.type: Easing.Linear
0102 
0103                 readonly property int multiplier: indicator.scaleFactor * 2
0104                 readonly property int maxLength: Math.min(indicator.currentIconSize*10, Math.max(relevantItem.width, relevantItem.height))
0105             }
0106             PropertyAnimation {
0107                 target: clickedRectangle
0108                 property: "opacity"
0109                 to: 0
0110                 duration: 700
0111                 easing.type: Easing.Linear
0112             }
0113         }
0114     }
0115 
0116     Connections {
0117         target: level
0118         enabled: root.clickedAnimationEnabled
0119         onMousePressed: {
0120             var fixedX = 0;
0121             var fixedY = 0;
0122 
0123             if (plasmoid.formFactor === PlasmaCore.Types.Horizontal) {
0124                 fixedX = x - clickedCenter.center;
0125             } else {
0126                 if (plasmoid.location === PlasmaCore.Types.RightEdge) {
0127                    fixedX = relevantItem.width - x;
0128                 } else {
0129                    fixedX = x;
0130                 }
0131             }
0132 
0133             if (plasmoid.formFactor === PlasmaCore.Types.Vertical) {
0134                 fixedY = y - clickedCenter.center;
0135             } else {
0136                  if (plasmoid.location === PlasmaCore.Types.BottomEdge) {
0137                     fixedY = relevantItem.height - y;
0138                  } else {
0139                     fixedY = y;
0140                  }
0141             }
0142 
0143             if (plasmoid.formFactor === PlasmaCore.Types.Horizontal) {
0144                 clickedCenter.anchors.horizontalCenterOffset = fixedX;
0145             } else {
0146                 if (plasmoid.location === PlasmaCore.Types.LeftEdge) {
0147                     clickedCenter.anchors.leftMargin = fixedX;
0148                 } else if (plasmoid.location === PlasmaCore.Types.RightEdge) {
0149                     clickedCenter.anchors.rightMargin = fixedX;
0150                 }
0151             }
0152 
0153             if (plasmoid.formFactor === PlasmaCore.Types.Vertical) {
0154                 clickedCenter.anchors.verticalCenterOffset = fixedY;
0155             } else {
0156                 if (plasmoid.location === PlasmaCore.Types.BottomEdge) {
0157                     clickedCenter.anchors.bottomMargin = fixedY;
0158                 } else if (plasmoid.location === PlasmaCore.Types.TopEdge) {
0159                     clickedCenter.anchors.topMargin = fixedY;
0160                 }
0161             }
0162 
0163             clickedCenter.anchors.verticalCenterOffset = fixedY;
0164 
0165             clickedAnimation.start();
0166         }
0167     }
0168     
0169 
0170     Loader {
0171         anchors.fill: parent
0172         anchors.topMargin: plasmoid.location === PlasmaCore.Types.TopEdge ? indicator.screenEdgeMargin : 0
0173         anchors.bottomMargin: plasmoid.location === PlasmaCore.Types.BottomEdge ? indicator.screenEdgeMargin : 0
0174         anchors.leftMargin: plasmoid.location === PlasmaCore.Types.LeftEdge ? indicator.screenEdgeMargin : 0
0175         anchors.rightMargin: plasmoid.location === PlasmaCore.Types.RightEdge ? indicator.screenEdgeMargin : 0
0176 
0177         visible: !indicator.isApplet && indicator.isGroup
0178         sourceComponent: Item{
0179             anchors.fill: parent
0180 
0181             Item {
0182                 id: iconBox
0183                 anchors.centerIn: parent
0184                 width: indicator.currentIconSize
0185                 height: width
0186             }
0187 
0188             PlasmaCore.SvgItem {
0189                 id: arrow
0190 
0191                 implicitWidth: 0.25 * iconBox.width
0192                 implicitHeight: implicitWidth
0193 
0194                 svg: groupSvg
0195                 elementId: elementForLocation(plasmoid.location)
0196 
0197                 readonly property QtObject groupSvg: indicator.resources && indicator.resources.svgs.length > 0 ? indicator.resources.svgs[0] : null
0198 
0199                 function elementForLocation(location) {
0200                     switch (location) {
0201                     case PlasmaCore.Types.LeftEdge:
0202                         return "group-expander-left";
0203                     case PlasmaCore.Types.TopEdge:
0204                         return "group-expander-top";
0205                     case PlasmaCore.Types.RightEdge:
0206                         return "group-expander-right";
0207                     case PlasmaCore.Types.BottomEdge:
0208                     default:
0209                         return "group-expander-bottom";
0210                     }
0211                 }
0212             }
0213 
0214             states: [
0215                 State {
0216                     name: "bottom"
0217                     when: plasmoid.location === PlasmaCore.Types.BottomEdge
0218                     AnchorChanges {
0219                         target: arrow
0220                         anchors.top: undefined; anchors.left: undefined; anchors.right: undefined; anchors.bottom: arrow.parent.bottom;
0221                         anchors.horizontalCenter: iconBox.horizontalCenter; anchors.verticalCenter: undefined;
0222                     }
0223                 },
0224                 State {
0225                     name: "top"
0226                     when: plasmoid.location === PlasmaCore.Types.TopEdge
0227                     AnchorChanges {
0228                         target: arrow
0229                         anchors.top: arrow.parent.top; anchors.left: undefined; anchors.right: undefined; anchors.bottom: undefined;
0230                         anchors.horizontalCenter: iconBox.horizontalCenter; anchors.verticalCenter: undefined;
0231                     }
0232                 },
0233                 State {
0234                     name: "left"
0235                     when: plasmoid.location === PlasmaCore.Types.LeftEdge
0236                     AnchorChanges {
0237                         target: arrow
0238                         anchors.top: undefined; anchors.left: arrow.parent.left; anchors.right: undefined; anchors.bottom: undefined;
0239                         anchors.horizontalCenter: undefined; anchors.verticalCenter: iconBox.verticalCenter;
0240                     }
0241                 },
0242                 State {
0243                     name: "right"
0244                     when: plasmoid.location === PlasmaCore.Types.RightEdge
0245                     AnchorChanges {
0246                         target: arrow
0247                         anchors.top: undefined; anchors.left: undefined; anchors.right: arrow.parent.right; anchors.bottom: undefined;
0248                         anchors.horizontalCenter: undefined; anchors.verticalCenter: iconBox.verticalCenter;
0249                     }
0250                 }
0251             ]
0252         }
0253     }
0254 }