Warning, /plasma/latte-dock/declarativeimports/abilities/items/basicitem/ParabolicItem.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2016 Smith AR <audoban@openmailbox.org> 0003 SPDX-FileCopyrightText: 2016 Michail Vourlakos <mvourlakos@gmail.com> 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 2.0 0008 import QtGraphicalEffects 1.0 0009 0010 import org.kde.plasma.plasmoid 2.0 0011 import org.kde.plasma.core 2.0 as PlasmaCore 0012 0013 import org.kde.latte.core 0.2 as LatteCore 0014 0015 Item{ 0016 id: parabolicItem 0017 width: abilityItem.isHorizontal ? length : thickness 0018 height: abilityItem.isHorizontal ? thickness : length 0019 0020 readonly property real length: (!abilityItem.visible || abilityItem.isSeparator) ? 0 : basicScalingLength 0021 0022 readonly property real thickness: (!abilityItem.visible ? 0 : (abilityItem.isSeparator ? 0023 abilityItem.abilities.metrics.mask.thickness.normalForItems : 0024 basicScalingThickness + abilityItem.abilities.metrics.margin.screenEdge)) 0025 0026 property bool isParabolicEventBlocked: false 0027 property bool isUpdatingOnlySpacers: false 0028 property bool isZoomed: false 0029 0030 //scales which are used mainly for activating InLauncher 0031 ////Scalers/////// 0032 property bool hasZoomPerAxis: ((zoomLength !== 1.0) || (zoomThickness !== 1.0) ) 0033 0034 property real zoom: 1.0 0035 property real zoomLength: 1.0 0036 property real zoomThickness: 1.0 0037 0038 property real scaleLength: hasZoomPerAxis ? zoomLength : zoom 0039 property real scaleThickness: hasZoomPerAxis ? zoomThickness : zoom 0040 0041 readonly property real marginZoom: 1 + ((zoom-1) * abilityItem.abilities.parabolic.factor.marginThicknessZoomInPercentage) 0042 readonly property real marginScaleThickness: 1 + ((scaleThickness-1) * abilityItem.abilities.parabolic.factor.marginThicknessZoomInPercentage) 0043 0044 property real cleanScalingLength: abilityItem.abilities.metrics.totals.length * zoom 0045 property real cleanScalingThickness: (abilityItem.abilities.metrics.iconSize * zoom) + (abilityItem.abilities.metrics.totals.thicknessEdges * marginZoom) 0046 0047 property real basicScalingLength: hasZoomPerAxis ? abilityItem.abilities.metrics.totals.length * scaleLength : cleanScalingLength 0048 property real basicScalingThickness: hasZoomPerAxis ? (abilityItem.abilities.metrics.iconSize * scaleThickness) + (abilityItem.abilities.metrics.totals.thicknessEdges * marginScaleThickness) : 0049 cleanScalingThickness 0050 0051 property real regulatorLength: abilityItem.isSeparator ? (abilityItem.isHorizontal ? width : height) : basicScalingLength 0052 property real regulatorThickness: abilityItem.isSeparator ? (abilityItem.isHorizontal ? height : width) : basicScalingThickness 0053 0054 property real visualScaledLength: (abilityItem.abilities.metrics.iconSize + abilityItem.abilities.metrics.totals.lengthPaddings) * zoom 0055 property real visualScaledThickness: cleanScalingThickness 0056 /// end of Scalers/////// 0057 0058 readonly property alias contentItemContainer: _contentItemContainer 0059 readonly property alias titleTooltipVisualParent: _titleTooltipVisualParent 0060 0061 readonly property string bothAxisZoomEvent: parabolicItem + "_zoom" 0062 /* Rectangle{ 0063 anchors.fill: parent 0064 border.width: 1 0065 border.color: "green" 0066 color: "transparent" 0067 }*/ 0068 0069 Behavior on zoom { 0070 id: animatedBehavior 0071 enabled: !abilityItem.abilities.parabolic.directRenderingEnabled || restoreAnimation.running 0072 NumberAnimation{ 0073 duration: 3 * abilityItem.animationTime 0074 easing.type: Easing.OutCubic 0075 } 0076 } 0077 0078 Behavior on zoom { 0079 enabled: !animatedBehavior.enabled 0080 NumberAnimation { duration: 0 } 0081 } 0082 0083 Item{ 0084 anchors.bottom: (abilityItem.location === PlasmaCore.Types.BottomEdge) ? parent.bottom : undefined 0085 anchors.top: (abilityItem.location === PlasmaCore.Types.TopEdge) ? parent.top : undefined 0086 anchors.left: (abilityItem.location === PlasmaCore.Types.LeftEdge) ? parent.left : undefined 0087 anchors.right: (abilityItem.location === PlasmaCore.Types.RightEdge) ? parent.right : undefined 0088 0089 anchors.horizontalCenter: abilityItem.isHorizontal ? parent.horizontalCenter : undefined 0090 anchors.verticalCenter: abilityItem.isHorizontal ? undefined : parent.verticalCenter 0091 0092 anchors.bottomMargin: (abilityItem.location === PlasmaCore.Types.BottomEdge) ? abilityItem.abilities.metrics.margin.screenEdge : 0 0093 anchors.topMargin: (abilityItem.location === PlasmaCore.Types.TopEdge) ? abilityItem.abilities.metrics.margin.screenEdge : 0 0094 anchors.leftMargin: (abilityItem.location === PlasmaCore.Types.LeftEdge) ? abilityItem.abilities.metrics.margin.screenEdge : 0 0095 anchors.rightMargin: (abilityItem.location === PlasmaCore.Types.RightEdge) ? abilityItem.abilities.metrics.margin.screenEdge : 0 0096 0097 width: abilityItem.isHorizontal ? parabolicItem.regulatorLength : parabolicItem.regulatorThickness 0098 height: abilityItem.isHorizontal ? parabolicItem.regulatorThickness : parabolicItem.regulatorLength 0099 0100 TitleTooltipParent{ 0101 id: _titleTooltipVisualParent 0102 thickness: abilityItem.abilities.metrics.mask.thickness.zoomedForItems - abilityItem.abilities.metrics.margin.screenEdge 0103 } 0104 0105 //fix bug #478, when changing form factor sometimes the tasks are not positioned 0106 //correctly, in such case we make a fast reinitialization for the sizes 0107 Connections { 0108 target: plasmoid 0109 onFormFactorChanged:{ 0110 parabolicItem.zoom = 1.01; 0111 parabolicItem.zoomLength = 1.01; 0112 parabolicItem.zoomThickness = 1.01; 0113 0114 parabolicItem.zoom = 1; 0115 parabolicItem.zoomLength = 1; 0116 parabolicItem.zoomThickness = 1; 0117 } 0118 } 0119 0120 //! Shadows 0121 Loader{ 0122 anchors.fill: _contentItemContainer 0123 active: abilityItem.abilities.myView.itemShadow.isEnabled 0124 && !abilityItem.isSeparator 0125 && abilityItem.abilities.environment.isGraphicsSystemAccelerated 0126 0127 sourceComponent: DropShadow{ 0128 anchors.fill: parent 0129 transformOrigin: abilityItem.iconTransformOrigin 0130 opacity: abilityItem.iconOpacity 0131 rotation: abilityItem.iconRotation 0132 scale: abilityItem.iconScale 0133 color: abilityItem.abilities.myView.itemShadow.shadowColor 0134 fast: true 0135 samples: 2 * radius 0136 source: _contentItemContainer 0137 radius: abilityItem.abilities.myView.itemShadow.size 0138 verticalOffset: 2 0139 } 0140 } 0141 0142 //! Main contented item 0143 Item { 0144 id: _contentItemContainer 0145 anchors.bottom: (abilityItem.location === PlasmaCore.Types.BottomEdge) ? parent.bottom : undefined 0146 anchors.top: (abilityItem.location === PlasmaCore.Types.TopEdge) ? parent.top : undefined 0147 anchors.left: (abilityItem.location === PlasmaCore.Types.LeftEdge) ? parent.left : undefined 0148 anchors.right: (abilityItem.location === PlasmaCore.Types.RightEdge) ? parent.right : undefined 0149 0150 anchors.horizontalCenter: abilityItem.isHorizontal ? parent.horizontalCenter : undefined 0151 anchors.verticalCenter: abilityItem.isHorizontal ? undefined : parent.verticalCenter 0152 0153 anchors.bottomMargin: (abilityItem.location === PlasmaCore.Types.BottomEdge) ? tailMargin + abilityItem.iconOffsetY : 0 0154 anchors.topMargin: (abilityItem.location === PlasmaCore.Types.TopEdge) ? tailMargin + abilityItem.iconOffsetY : 0 0155 anchors.leftMargin: (abilityItem.location === PlasmaCore.Types.LeftEdge) ? tailMargin + abilityItem.iconOffsetX : 0 0156 anchors.rightMargin: (abilityItem.location === PlasmaCore.Types.RightEdge) ? tailMargin + abilityItem.iconOffsetX : 0 0157 0158 anchors.horizontalCenterOffset: abilityItem.isHorizontal ? abilityItem.iconOffsetX : 0 0159 anchors.verticalCenterOffset: abilityItem.isVertical ? abilityItem.iconOffsetY : 0 0160 0161 transformOrigin: abilityItem.iconTransformOrigin 0162 opacity: abilityItem.iconOpacity 0163 rotation: abilityItem.iconRotation 0164 scale: abilityItem.iconScale 0165 0166 width: newTempSize 0167 height: width 0168 visible: !abilityItem.isSeparator 0169 0170 property int zoomedSize: abilityItem.abilities.parabolic.factor.zoom * abilityItem.abilities.metrics.iconSize 0171 property real basicScalingLength: abilityItem.abilities.metrics.iconSize * (parabolicItem.hasZoomPerAxis ? parabolicItem.scaleLength : parabolicItem.zoom) 0172 property real basicScalingThickness: proposedItemThickness * appliedZoom 0173 0174 readonly property real appliedZoom: (parabolicItem.hasZoomPerAxis ? parabolicItem.scaleThickness : parabolicItem.zoom) 0175 readonly property real marginAppliedZoom: 1 + ((appliedZoom-1) * abilityItem.abilities.parabolic.factor.marginThicknessZoomInPercentage) 0176 0177 readonly property int proposedItemThickness: abilityItem.abilities.indexer.inMarginsArea ? 0178 Math.max(16, abilityItem.abilities.metrics.marginsArea.iconSize) : 0179 abilityItem.abilities.metrics.iconSize 0180 0181 readonly property int itemNormalTailMargin: abilityItem.abilities.indexer.inMarginsArea ? abilityItem.abilities.metrics.marginsArea.tailThickness : abilityItem.abilities.metrics.margin.tailThickness 0182 readonly property real tailMargin: Math.round(itemNormalTailMargin * marginAppliedZoom) 0183 0184 property real newTempSize: { 0185 if (parabolicItem.opacity === 1 ) { 0186 return Math.min(basicScalingLength, basicScalingThickness); 0187 } else { 0188 return Math.max(basicScalingLength, basicScalingThickness); 0189 } 0190 } 0191 0192 readonly property Item contentItem: children.length > 0 ? children[0] : null 0193 0194 Component.onCompleted: { 0195 if (abilityItem.contentItem && abilityItem.contentItem.parent !== _contentItemContainer) { 0196 abilityItem.contentItem.parent = _contentItemContainer; 0197 } 0198 } 0199 0200 Connections { 0201 target: abilityItem 0202 onContentItemChanged: { 0203 if (abilityItem.contentItem && abilityItem.contentItem.parent !== _contentItemContainer) { 0204 abilityItem.contentItem.parent = _contentItemContainer; 0205 } 0206 } 0207 } 0208 } //_contentItemContainer 0209 0210 //! Latte Side Painting-style if the user chose it 0211 Loader{ 0212 anchors.fill: _contentItemContainer 0213 active: abilityItem.isMonochromaticForcedContentItem && abilityItem.monochromizedItem 0214 0215 sourceComponent: ColorOverlay { 0216 anchors.fill: parent 0217 color: latteBridge ? latteBridge.palette.textColor : "transparent" 0218 source: abilityItem.monochromizedItem 0219 } 0220 } 0221 //! Latte Side Painting-style if the user chose it 0222 0223 ShortcutBadge{ 0224 id: shortcutBadge 0225 anchors.centerIn: parent 0226 width: abilityItem.abilities.metrics.iconSize * (parabolicItem.hasZoomPerAxis ? parabolicItem.scaleThickness : parabolicItem.zoom) 0227 height: width 0228 } 0229 0230 Loader{ 0231 anchors.fill: _contentItemContainer 0232 active: abilityItem.abilities.debug.graphicsEnabled 0233 0234 sourceComponent: Rectangle{ 0235 anchors.fill: parent 0236 color: "transparent" 0237 border.color: "yellow" 0238 border.width: 1 0239 } 0240 } 0241 } 0242 0243 function sendEndOfNeedBothAxisAnimation(){ 0244 if (isZoomed) { 0245 isZoomed = false; 0246 abilityItem.abilities.animations.needBothAxis.removeEvent(bothAxisZoomEvent); 0247 } 0248 } 0249 0250 onZoomChanged: { 0251 if ((zoom === abilityItem.abilities.parabolic.factor.zoom) && !abilityItem.abilities.parabolic.directRenderingEnabled) { 0252 abilityItem.abilities.parabolic.setDirectRenderingEnabled(true); 0253 } 0254 0255 if ((zoom > 1) && !isZoomed) { 0256 isZoomed = true; 0257 abilityItem.abilities.animations.needBothAxis.addEvent(bothAxisZoomEvent); 0258 } else if ((zoom == 1) && isZoomed) { 0259 sendEndOfNeedBothAxisAnimation(); 0260 } 0261 } 0262 0263 Connections { 0264 target: abilityItem 0265 onVisibleChanged: { 0266 if (!abilityItem.visible) { 0267 //! is mostly used when the user destroys tasks applet from the context menu and both 0268 //! axis animations should be released in that case 0269 parabolicItem.sendEndOfNeedBothAxisAnimation(); 0270 } 0271 } 0272 } 0273 0274 Component.onCompleted: { 0275 if (!LatteCore.WindowSystem.compositingActive) { 0276 opacity = 1; 0277 } 0278 } 0279 }//parabolicItem