Warning, /plasma/latte-dock/declarativeimports/abilities/client/ParabolicEffect.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2020 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 import org.kde.latte.abilities.definition 0.1 as AbilityDefinition 0012 0013 AbilityDefinition.ParabolicEffect { 0014 id: parabolic 0015 property Item bridge: null 0016 property Item indexer: null 0017 property Item layout: null 0018 0019 isEnabled: ref.parabolic.isEnabled 0020 factor: ref.parabolic.factor 0021 restoreZoomIsBlocked: bridge ? (bridge.parabolic.host.restoreZoomIsBlocked || local.restoreZoomIsBlocked) : local.restoreZoomIsBlocked 0022 currentParabolicItem: ref.parabolic.currentParabolicItem 0023 spread: ref.parabolic.spread 0024 0025 readonly property bool isActive: bridge !== null 0026 //! private properties can not go to definition because can not be made readonly in there 0027 //! special care must be taken in order to be redefined in local properties 0028 readonly property bool directRenderingEnabled: ref.parabolic._privates.directRenderingEnabled 0029 readonly property bool horizontal: plasmoid.formFactor === PlasmaCore.Types.Horizontal 0030 readonly property bool isHovered: { 0031 if (bridge && bridge.parabolic.host.currentParabolicItem) { 0032 return bridge.parabolic.host.currentParabolicItem.parent.parent.parent === layout; 0033 } 0034 0035 return false; 0036 } 0037 0038 readonly property AbilityDefinition.ParabolicEffect local: AbilityDefinition.ParabolicEffect { 0039 id: _localref 0040 readonly property bool directRenderingEnabled: _localref._privates.directRenderingEnabled 0041 spread: 3 0042 } 0043 0044 Item { 0045 id: ref 0046 readonly property Item parabolic: bridge ? bridge.parabolic.host : local 0047 } 0048 0049 onIsActiveChanged: { 0050 if (isActive) { 0051 bridge.parabolic.client = parabolic; 0052 } 0053 } 0054 0055 Component.onCompleted: { 0056 if (isActive) { 0057 bridge.parabolic.client = parabolic; 0058 } 0059 0060 parabolic.sglUpdateLowerItemScale.connect(sltTrackLowerItemScale); 0061 parabolic.sglUpdateHigherItemScale.connect(sltTrackHigherItemScale); 0062 } 0063 0064 Component.onDestruction: { 0065 if (isActive) { 0066 bridge.parabolic.client = null; 0067 } 0068 0069 parabolic.sglUpdateLowerItemScale.disconnect(sltTrackLowerItemScale); 0070 parabolic.sglUpdateHigherItemScale.disconnect(sltTrackHigherItemScale); 0071 } 0072 0073 Connections { 0074 target: parabolic 0075 onRestoreZoomIsBlockedChanged: { 0076 if (!(bridge || bridge.host)) { 0077 if (!parabolic.restoreZoomIsBlocked) { 0078 parabolic.startRestoreZoomTimer(); 0079 } else { 0080 parabolic.stopRestoreZoomTimer(); 0081 } 0082 } 0083 } 0084 0085 onCurrentParabolicItemChanged: { 0086 if (!parabolic.bridge || !parabolic.bridge.host) { 0087 if (!parabolic.currentParabolicItem) { 0088 parabolic.startRestoreZoomTimer(); 0089 } else { 0090 parabolic.stopRestoreZoomTimer(); 0091 } 0092 } 0093 } 0094 } 0095 0096 function startRestoreZoomTimer(){ 0097 if (restoreZoomIsBlocked) { 0098 return; 0099 } 0100 0101 if (bridge) { 0102 bridge.parabolic.host.startRestoreZoomTimer(); 0103 } else { 0104 restoreZoomTimer.start(); 0105 } 0106 } 0107 0108 function stopRestoreZoomTimer(){ 0109 if (bridge) { 0110 bridge.parabolic.host.stopRestoreZoomTimer(); 0111 } else { 0112 restoreZoomTimer.stop(); 0113 } 0114 } 0115 0116 function setDirectRenderingEnabled(value) { 0117 if (bridge) { 0118 bridge.parabolic.host.setDirectRenderingEnabled(value); 0119 } else { 0120 local._privates.directRenderingEnabled = value; 0121 } 0122 } 0123 0124 function setCurrentParabolicItem(item) { 0125 if (bridge) { 0126 bridge.parabolic.host.setCurrentParabolicItem(item); 0127 } else { 0128 local.currentParabolicItem = item; 0129 } 0130 } 0131 0132 function hostRequestUpdateLowerItemScale(newScales){ 0133 //! function called from host 0134 sglUpdateLowerItemScale(indexer.itemsCount-1, newScales); 0135 } 0136 0137 function hostRequestUpdateHigherItemScale(newScales){ 0138 //! function called from host 0139 sglUpdateHigherItemScale(0, newScales); 0140 } 0141 0142 function sltTrackLowerItemScale(delegateIndex, newScales){ 0143 //! send update signal to host 0144 if (bridge) { 0145 var clearrequestedfromlastacceptedsignal = (newScales.length===1) && (newScales[0]===1); 0146 if (delegateIndex === -1) { 0147 bridge.parabolic.clientRequestUpdateLowerItemScale(newScales); 0148 } else if (clearrequestedfromlastacceptedsignal && delegateIndex>=0) { 0149 bridge.parabolic.clientRequestUpdateLowerItemScale(newScales); 0150 } 0151 } 0152 } 0153 0154 function sltTrackHigherItemScale(delegateIndex, newScales) { 0155 //! send update signal to host 0156 if (bridge) { 0157 var clearrequestedfromlastacceptedsignal = (newScales.length===1) && (newScales[0]===1); 0158 if (delegateIndex >= indexer.itemsCount) { 0159 bridge.parabolic.clientRequestUpdateHigherItemScale(newScales); 0160 } else if (clearrequestedfromlastacceptedsignal && delegateIndex<indexer.itemsCount) { 0161 bridge.parabolic.clientRequestUpdateHigherItemScale(newScales); 0162 } 0163 } 0164 } 0165 0166 function setCurrentParabolicItemIndex(index) { 0167 if (bridge) { 0168 bridge.parabolic.host.setCurrentParabolicItemIndex(index); 0169 } 0170 } 0171 0172 function invkClearZoom() { 0173 if (parabolic.restoreZoomIsBlocked) { 0174 return 0175 } 0176 0177 if (bridge) { 0178 bridge.parabolic.host.sglClearZoom(); 0179 } else { 0180 parabolic.sglClearZoom(); 0181 } 0182 } 0183 0184 //! TIMERS 0185 0186 //! Timer to check if the mouse is outside the applet in order to restore items scales to 1.0 0187 //! IMPORTANT ::: This timer should be used only when the Latte plasmoid is not inside a Latte dock 0188 Timer{ 0189 id: restoreZoomTimer 0190 interval: 50 0191 0192 onTriggered: { 0193 if(parabolic.bridge) { 0194 console.log("Plasmoid, restoreZoomTimer was called, even though it shouldn't..."); 0195 } 0196 0197 setDirectRenderingEnabled(false); 0198 parabolic.invkClearZoom(); 0199 } 0200 } 0201 }