/* * Copyright 2016 Smith AR * Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * Latte-Dock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as Components import QtGraphicalEffects 1.0 Item{ // property string color id: glowItem property bool roundCorners: true property bool showAttention: false property bool showGlow: false property int animation: Math.max(1.65*3*units.longDuration,root.durationTime*3*units.longDuration) property color attentionColor: colorScopePalette.negativeTextColor // "#ffff1717" property color basicColor: "blue" property color animationColor property color currentColor: glowItem.showAttention ? animationColor : basicColor readonly property real glowOpacity: root.glowOpacity Item{ id: mainGlow anchors.fill: parent opacity: glowOpacity visible: glowItem.showGlow property int halfCorner: 3*glowFrame.size property int fullCorner: 6*glowFrame.size Item { id: firstGlowCorner width: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? mainGlow.halfCorner : mainGlow.fullCorner height: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? mainGlow.fullCorner : mainGlow.halfCorner clip: true Item { id: firstGlowCornerFull width: mainGlow.fullCorner height: mainGlow.fullCorner RadialGradient { anchors.fill: parent gradient: Gradient { GradientStop { position: 0.0; color: "transparent" } GradientStop { position: 0.07; color: "transparent" } GradientStop { position: 0.125; color: glowItem.currentColor } GradientStop { position: 0.4; color: "transparent" } GradientStop { position: 1; color: "transparent" } } } } } Item { id:mainGlowPart width: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? parent.width - glowFrame.size : mainGlow.fullCorner height: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? mainGlow.fullCorner : parent.height - glowFrame.size LinearGradient { anchors.fill: parent start: { if (plasmoid.location === PlasmaCore.Types.BottomEdge) return Qt.point(0, 0); else if (plasmoid.location === PlasmaCore.Types.TopEdge) return Qt.point(0, mainGlow.fullCorner); else if (plasmoid.location === PlasmaCore.Types.LeftEdge) return Qt.point(mainGlow.fullCorner, 0); else if (plasmoid.location === PlasmaCore.Types.RightEdge) return Qt.point(0, 0); return Qt.point(mainGlow.fullCorner, 0); } end: { if (plasmoid.location === PlasmaCore.Types.BottomEdge) return Qt.point(0, mainGlow.fullCorner); else if (plasmoid.location === PlasmaCore.Types.TopEdge) return Qt.point(0, 0); else if (plasmoid.location === PlasmaCore.Types.LeftEdge) return Qt.point(0,0); else if (plasmoid.location === PlasmaCore.Types.RightEdge) return Qt.point(mainGlow.fullCorner, 0); return Qt.point(0,0); } gradient: Gradient { GradientStop { position: 0.0; color: "transparent" } GradientStop { position: 0.08; color: "transparent" } GradientStop { position: 0.37; color: glowItem.currentColor } GradientStop { position: 0.49; color: "transparent" } } } } Item { id:lastGlowCorner width: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? mainGlow.halfCorner : mainGlow.fullCorner height: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? mainGlow.fullCorner : mainGlow.halfCorner clip: true Item { id: lastGlowCornerFull width: mainGlow.fullCorner height: mainGlow.fullCorner RadialGradient { anchors.fill: parent gradient: Gradient { GradientStop { position: 0.0; color: "transparent" } GradientStop { position: 0.07; color: "transparent" } GradientStop { position: 0.125; color: glowItem.currentColor } GradientStop { position: 0.4; color: "transparent" } GradientStop { position: 1; color: "transparent" } } } } } states: [ State{ name: "*" when: plasmoid.formFactor === PlasmaCore.Types.Horizontal AnchorChanges{ target:firstGlowCorner; anchors{ top:undefined; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:parent.verticalCenter} } AnchorChanges{ target:firstGlowCornerFull; anchors{ top:undefined; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:parent.verticalCenter} } AnchorChanges{ target:mainGlowPart; anchors{ top:undefined; bottom:undefined; left:firstGlowCorner.right; right:undefined; horizontalCenter:undefined; verticalCenter:parent.verticalCenter} } AnchorChanges{ target:lastGlowCorner; anchors{ top:undefined; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:parent.verticalCenter} } AnchorChanges{ target:lastGlowCornerFull; anchors{ top:undefined; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:parent.verticalCenter} } PropertyChanges{ target: firstGlowCorner; anchors.leftMargin: -2.5*glowFrame.size; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0 } PropertyChanges{ target: lastGlowCorner; anchors.leftMargin: 0; anchors.rightMargin:-2.5*glowFrame.size; anchors.topMargin:0; anchors.bottomMargin:0 } }, State{ name: "vertical" when: plasmoid.formFactor === PlasmaCore.Types.Vertical AnchorChanges{ target:firstGlowCorner; anchors{ top:parent.top; bottom:undefined; left:undefined; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:undefined} } AnchorChanges{ target:firstGlowCornerFull; anchors{ top:parent.top; bottom:undefined; left:undefined; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:undefined} } AnchorChanges{ target:mainGlowPart; anchors{ top:firstGlowCorner.bottom; bottom:undefined; left:undefined; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:undefined} } AnchorChanges{ target:lastGlowCorner; anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:undefined} } AnchorChanges{ target:lastGlowCornerFull; anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:undefined} } PropertyChanges{ target: firstGlowCorner; anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:-2.5*glowFrame.size; anchors.bottomMargin: 0 } PropertyChanges{ target: lastGlowCorner; anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin: -2.5*glowFrame.size } } ] } Item{ id:mainElement anchors.fill: parent Rectangle { id: smallCircle anchors.centerIn: parent anchors.fill: parent color: glowItem.basicColor radius: glowItem.roundCorners ? Math.min(width,height) / 2 : 0 } Loader{ anchors.centerIn: parent anchors.fill: parent active: glowItem.showAttention sourceComponent:Rectangle { id: smallCircleInAttention color: glowItem.animationColor radius: smallCircle.radius SequentialAnimation{ running: glowItem.showAttention loops: Animation.Infinite alwaysRunToEnd: true PropertyAnimation { target: glowItem property: "animationColor" to: glowItem.attentionColor duration: glowItem.animation easing.type: Easing.InOutQuad } PropertyAnimation { target: glowItem property: "animationColor" to: glowItem.basicColor duration: glowItem.animation easing.type: Easing.InOutQuad } } } } Rectangle { visible: glowItem.showGlow && root.glow3D anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenterOffset: { if (plasmoid.formFactor === PlasmaCore.Types.Horizontal) return 0; else if (plasmoid.location === PlasmaCore.Types.LeftEdge) return -glowItem.width / 7; else if (plasmoid.location === PlasmaCore.Types.RightEdge) return glowItem.width / 7; } anchors.verticalCenterOffset: { if (plasmoid.formFactor === PlasmaCore.Types.Vertical) return 0; else if (plasmoid.location === PlasmaCore.Types.BottomEdge) return glowItem.height / 7; else if (plasmoid.location === PlasmaCore.Types.TopEdge) return -glowItem.height / 7; } width: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? Math.max(mainGlowPart.width, shadow) : shadow height: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? shadow : Math.max(mainGlowPart.height, shadow) radius: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? height/2 : width/2 property int shadow: glowFrame.size / 3 color: root.appShadowColor opacity: 0.2 } } }