From fa1ef2f17dd937cdd9d8fcc2eb135342d7b0ab31 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Wed, 3 Jan 2018 12:48:26 +0200 Subject: [PATCH] move GlowPoint to latte library --this way we can use the same code between plasmoid and containment --- .../contents/ui/applet/ActiveIndicator.qml | 2 +- liblattedock/CMakeLists.txt | 3 + .../applet => liblattedock/qml}/GlowPoint.qml | 0 liblattedock/qmldir | 2 + .../package/contents/ui/task/GlowPoint.qml | 252 ------------------ .../contents/ui/task/TaskGroupItem.qml | 4 +- 6 files changed, 8 insertions(+), 255 deletions(-) rename {containment/package/contents/ui/applet => liblattedock/qml}/GlowPoint.qml (100%) delete mode 100644 plasmoid/package/contents/ui/task/GlowPoint.qml diff --git a/containment/package/contents/ui/applet/ActiveIndicator.qml b/containment/package/contents/ui/applet/ActiveIndicator.qml index 013d313c0..5d4e043dc 100644 --- a/containment/package/contents/ui/applet/ActiveIndicator.qml +++ b/containment/package/contents/ui/applet/ActiveIndicator.qml @@ -44,7 +44,7 @@ Item{ opacity:0.6 }*/ - GlowPoint{ + Latte.GlowPoint{ id:activePoint anchors.centerIn: parent diff --git a/liblattedock/CMakeLists.txt b/liblattedock/CMakeLists.txt index 45e6cafbc..052872591 100644 --- a/liblattedock/CMakeLists.txt +++ b/liblattedock/CMakeLists.txt @@ -24,4 +24,7 @@ if(HAVE_X11) endif() install(TARGETS lattedockplugin DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/latte) + +install(DIRECTORY qml/ DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/latte) + install(FILES qmldir DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/latte) diff --git a/containment/package/contents/ui/applet/GlowPoint.qml b/liblattedock/qml/GlowPoint.qml similarity index 100% rename from containment/package/contents/ui/applet/GlowPoint.qml rename to liblattedock/qml/GlowPoint.qml diff --git a/liblattedock/qmldir b/liblattedock/qmldir index 737db9ed6..a8be0516d 100644 --- a/liblattedock/qmldir +++ b/liblattedock/qmldir @@ -1,2 +1,4 @@ module org.kde.latte plugin lattedockplugin + +GlowPoint 0.1 GlowPoint.qml diff --git a/plasmoid/package/contents/ui/task/GlowPoint.qml b/plasmoid/package/contents/ui/task/GlowPoint.qml deleted file mode 100644 index 07e65c2dc..000000000 --- a/plasmoid/package/contents/ui/task/GlowPoint.qml +++ /dev/null @@ -1,252 +0,0 @@ -/* -* 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 - - Grid{ - id: mainGlow - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - opacity: glowOpacity - visible: glowItem.showGlow - - rows: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? 1 : 0 - columns: plasmoid.formFactor === PlasmaCore.Types.Vertical ? 1 : 0 - - 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 ? glowItem.width - glowFrame.size : mainGlow.fullCorner - height: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? mainGlow.fullCorner : glowItem.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 - anchors.right: parent.right - 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:lastGlowCornerFull; - anchors{ bottom: undefined; right:parent.right;} - } - }, - State{ - name: "vertical" - when: plasmoid.formFactor === PlasmaCore.Types.Vertical - - AnchorChanges{ - target:lastGlowCornerFull; - anchors{ bottom: parent.bottom; right:undefined;} - } - } - ] - } - } - } - - 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 - visible: !glowItem.showAttention - } - - 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 - } - } -} diff --git a/plasmoid/package/contents/ui/task/TaskGroupItem.qml b/plasmoid/package/contents/ui/task/TaskGroupItem.qml index fa015a90f..761fa93b8 100644 --- a/plasmoid/package/contents/ui/task/TaskGroupItem.qml +++ b/plasmoid/package/contents/ui/task/TaskGroupItem.qml @@ -59,7 +59,7 @@ Item{ id: flowItem flow: ( icList.orientation === Qt.Vertical ) ? Flow.TopToBottom : Flow.LeftToRight - GlowPoint{ + Latte.GlowPoint{ id:firstPoint visible: ( !IsLauncher ) ? true: false @@ -169,7 +169,7 @@ Item{ height: secondPoint.visible ? 0.5*glowFrame.size : 0 } - GlowPoint{ + Latte.GlowPoint{ id:secondPoint width: visible ? glowFrame.size : 0 height: width