Warning, /plasma/latte-dock/declarativeimports/components/GlowPoint.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 import QtGraphicalEffects 1.0 0008 0009 import org.kde.plasma.components 2.0 as Components 0010 import org.kde.plasma.core 2.0 as PlasmaCore 0011 import org.kde.plasma.plasmoid 2.0 0012 0013 Item{ 0014 // property string color 0015 id: glowItem 0016 0017 property bool glow3D: true 0018 property bool roundCorners: true 0019 property bool showBorder: false 0020 property bool showAttention: false 0021 property bool showGlow: false 0022 0023 property int animation: 250 0024 property int location: PlasmaCore.Types.BottomEdge 0025 property int size: 10 0026 0027 property real glowOpacity: 0.75 0028 0029 property color attentionColor: "red" 0030 property color basicColor: "blue" 0031 property color contrastColor: "#b0b0b0" 0032 property color currentColor: glowItem.showAttention ? animationColorAlpha : basicColorAlpha 0033 0034 property color animationColor: "red" // it is used only internally for the animation 0035 readonly property color basicColorAlpha: Qt.rgba(basicColor.r, basicColor.g, basicColor.b, glowOpacity) 0036 readonly property color animationColorAlpha: Qt.rgba(animationColor.r, animationColor.g, animationColor.b, glowOpacity) 0037 readonly property color contrastColorAlpha: Qt.rgba(contrastColor.r, contrastColor.g, contrastColor.b, Math.min(glowOpacity+0.25,1)) 0038 readonly property color contrastColorAlpha2: Qt.rgba(contrastColor.r, contrastColor.g, contrastColor.b, 0.3) 0039 0040 readonly property bool isVertical: (location === PlasmaCore.Types.LeftEdge) || (location === PlasmaCore.Types.RightEdge) 0041 readonly property bool isHorizontal: !isVertical 0042 0043 Grid{ 0044 id: mainGlow 0045 anchors.horizontalCenter: parent.horizontalCenter 0046 anchors.verticalCenter: parent.verticalCenter 0047 visible: glowItem.showGlow 0048 0049 rows: isHorizontal ? 1 : 0 0050 columns: isVertical ? 1 : 0 0051 0052 property int halfCorner: 3*glowItem.size 0053 property int fullCorner: 6*glowItem.size 0054 0055 Item { 0056 id: firstGlowCorner 0057 width: isHorizontal ? mainGlow.halfCorner : mainGlow.fullCorner 0058 height: isHorizontal ? mainGlow.fullCorner : mainGlow.halfCorner 0059 clip: true 0060 0061 Item { 0062 id: firstGlowCornerFull 0063 width: mainGlow.fullCorner 0064 height: mainGlow.fullCorner 0065 0066 RadialGradient { 0067 anchors.fill: parent 0068 gradient: Gradient { 0069 GradientStop { position: 0.0; color: "transparent" } 0070 GradientStop { position: 0.07; color: glowItem.contrastColorAlpha } 0071 GradientStop { position: 0.125; color: glowItem.currentColor } 0072 GradientStop { position: 0.4; color: "transparent" } 0073 GradientStop { position: 1; color: "transparent" } 0074 } 0075 } 0076 0077 states: [ 0078 State{ 0079 name: "*" 0080 when: isHorizontal 0081 0082 AnchorChanges{ 0083 target:firstGlowCornerFull; 0084 anchors{ bottom: undefined; left:parent.left;} 0085 } 0086 }, 0087 State{ 0088 name: "vertical" 0089 when: isVertical 0090 0091 AnchorChanges{ 0092 target:firstGlowCornerFull; 0093 anchors{ top: parent.top; left:undefined;} 0094 } 0095 } 0096 ] 0097 } 0098 } 0099 0100 Item { 0101 id:mainGlowPart 0102 width: isHorizontal ? glowItem.width - glowItem.size : mainGlow.fullCorner 0103 height: isHorizontal ? mainGlow.fullCorner : glowItem.height - glowItem.size 0104 0105 LinearGradient { 0106 anchors.fill: parent 0107 start: { 0108 if (location === PlasmaCore.Types.BottomEdge || location === PlasmaCore.Types.Floating) 0109 return Qt.point(0, 0); 0110 else if (location === PlasmaCore.Types.TopEdge) 0111 return Qt.point(0, mainGlow.fullCorner); 0112 else if (location === PlasmaCore.Types.LeftEdge) 0113 return Qt.point(mainGlow.fullCorner, 0); 0114 else if (location === PlasmaCore.Types.RightEdge) 0115 return Qt.point(0, 0); 0116 0117 return Qt.point(mainGlow.fullCorner, 0); 0118 } 0119 end: { 0120 if (location === PlasmaCore.Types.BottomEdge || location === PlasmaCore.Types.Floating) 0121 return Qt.point(0, mainGlow.fullCorner); 0122 else if (location === PlasmaCore.Types.TopEdge) 0123 return Qt.point(0, 0); 0124 else if (location === PlasmaCore.Types.LeftEdge) 0125 return Qt.point(0,0); 0126 else if (location === PlasmaCore.Types.RightEdge) 0127 return Qt.point(mainGlow.fullCorner, 0); 0128 0129 return Qt.point(0,0); 0130 } 0131 0132 gradient: Gradient { 0133 GradientStop { position: 0.0; color: "transparent" } 0134 GradientStop { position: 0.08; color: "transparent" } 0135 GradientStop { position: 0.37; color: glowItem.currentColor } 0136 GradientStop { position: 0.43; color: glowItem.contrastColorAlpha } 0137 GradientStop { position: 0.57; color: glowItem.contrastColorAlpha } 0138 GradientStop { position: 0.63; color: glowItem.currentColor } 0139 GradientStop { position: 0.92; color: "transparent" } 0140 GradientStop { position: 1; color: "transparent" } 0141 } 0142 } 0143 } 0144 0145 Item { 0146 id:lastGlowCorner 0147 width: isHorizontal ? mainGlow.halfCorner : mainGlow.fullCorner 0148 height: isHorizontal ? mainGlow.fullCorner : mainGlow.halfCorner 0149 clip: true 0150 0151 Item { 0152 id: lastGlowCornerFull 0153 width: mainGlow.fullCorner 0154 height: mainGlow.fullCorner 0155 0156 RadialGradient { 0157 anchors.fill: parent 0158 gradient: Gradient { 0159 GradientStop { position: 0.0; color: "transparent" } 0160 GradientStop { position: 0.07; color: glowItem.contrastColorAlpha } 0161 GradientStop { position: 0.125; color: glowItem.currentColor } 0162 GradientStop { position: 0.4; color: "transparent"} 0163 GradientStop { position: 1; color: "transparent" } 0164 } 0165 } 0166 0167 states: [ 0168 State{ 0169 name: "*" 0170 when: isHorizontal 0171 0172 AnchorChanges{ 0173 target:lastGlowCornerFull; 0174 anchors{ bottom: undefined; right:parent.right;} 0175 } 0176 }, 0177 State{ 0178 name: "vertical" 0179 when: isVertical 0180 0181 AnchorChanges{ 0182 target:lastGlowCornerFull; 0183 anchors{ bottom: parent.bottom; right:undefined;} 0184 } 0185 } 0186 ] 0187 } 0188 } 0189 } 0190 0191 //! add border around indicator without reducing its size 0192 Loader{ 0193 anchors.centerIn: mainElement 0194 active: glowItem.showBorder 0195 0196 sourceComponent:Rectangle { 0197 width: mainElement.width + size 0198 height: mainElement.height + size 0199 anchors.centerIn: parent 0200 0201 color: contrastColorAlpha2 0202 radius: glowItem.roundCorners ? Math.min(width,height) / 2 : 0 0203 0204 property int size: Math.min(2*Math.max(1,mainElement.width/5 ), 0205 2*Math.max(1,mainElement.height/5 )) 0206 } 0207 } 0208 0209 Item{ 0210 id:mainElement 0211 0212 width: Math.max(glowItem.size, parent.width) 0213 height: Math.max(glowItem.size, parent.height) 0214 anchors.centerIn: parent 0215 0216 Rectangle { 0217 id: smallCircle 0218 anchors.centerIn: parent 0219 anchors.fill: parent 0220 0221 color: glowItem.basicColor 0222 radius: glowItem.roundCorners ? Math.min(width,height) / 2 : 0 0223 visible: !glowItem.showAttention 0224 } 0225 0226 Loader{ 0227 anchors.centerIn: parent 0228 anchors.fill: parent 0229 0230 active: glowItem.showAttention 0231 0232 sourceComponent:Rectangle { 0233 id: smallCircleInAttention 0234 0235 color: glowItem.animationColor 0236 radius: smallCircle.radius 0237 0238 SequentialAnimation{ 0239 running: glowItem.showAttention 0240 loops: Animation.Infinite 0241 alwaysRunToEnd: true 0242 0243 PropertyAnimation { 0244 target: glowItem 0245 property: "animationColor" 0246 to: glowItem.animationColor 0247 duration: glowItem.animation 0248 easing.type: Easing.InOutQuad 0249 } 0250 0251 PropertyAnimation { 0252 target: glowItem 0253 property: "animationColor" 0254 to: glowItem.basicColor 0255 duration: glowItem.animation 0256 easing.type: Easing.InOutQuad 0257 } 0258 } 0259 } 0260 } 0261 0262 Rectangle { 0263 visible: glowItem.showGlow && glowItem.glow3D 0264 anchors.horizontalCenter: parent.horizontalCenter 0265 anchors.verticalCenter: parent.verticalCenter 0266 0267 anchors.horizontalCenterOffset: { 0268 if (isHorizontal) 0269 return 0; 0270 else if (location === PlasmaCore.Types.LeftEdge) 0271 return -glowItem.width / 7; 0272 else if (location === PlasmaCore.Types.RightEdge) 0273 return glowItem.width / 7; 0274 0275 return 0; 0276 } 0277 anchors.verticalCenterOffset: { 0278 if (isVertical) 0279 return 0; 0280 else if (location === PlasmaCore.Types.BottomEdge) 0281 return glowItem.height / 7; 0282 else if (location === PlasmaCore.Types.TopEdge) 0283 return -glowItem.height / 7; 0284 0285 return 0; 0286 } 0287 0288 width: isHorizontal ? Math.max(mainGlowPart.width, shadow) : shadow 0289 height: isHorizontal ? shadow : Math.max(mainGlowPart.height, shadow) 0290 radius: isHorizontal ? height/2 : width/2 0291 0292 property int shadow: glowItem.size / 3 0293 0294 color: glowItem.contrastColorAlpha 0295 opacity: 0.2 0296 } 0297 } 0298 }