From d9fe9d438da2626cd7ff2b9bb8e0e0c569938507 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Fri, 22 Feb 2019 19:22:11 +0200 Subject: [PATCH] move Plasma/UnityIndicators into liblatte2 --- .../package/contents/ui/applet/AppletItem.qml | 30 ++- .../contents/ui/applet/HiddenSpacer.qml | 2 - .../ui/applet/indicators/LatteIndicator.qml | 194 ------------------ .../ui/applet/indicators/PlasmaIndicator.qml | 67 ------ .../ui/applet/indicators/UnityIndicator.qml | 56 ----- .../qml}/indicators/PlasmaIndicator.qml | 12 +- .../qml}/indicators/UnityIndicator.qml | 9 +- liblatte2/qmldir | 2 + .../package/contents/ui/task/TaskItem.qml | 11 +- plasmoid/package/contents/ui/task/Wrapper.qml | 3 + 10 files changed, 40 insertions(+), 346 deletions(-) delete mode 100644 containment/package/contents/ui/applet/indicators/LatteIndicator.qml delete mode 100644 containment/package/contents/ui/applet/indicators/PlasmaIndicator.qml delete mode 100644 containment/package/contents/ui/applet/indicators/UnityIndicator.qml rename {plasmoid/package/contents/ui/task => liblatte2/qml}/indicators/PlasmaIndicator.qml (90%) rename {plasmoid/package/contents/ui/task => liblatte2/qml}/indicators/UnityIndicator.qml (88%) diff --git a/containment/package/contents/ui/applet/AppletItem.qml b/containment/package/contents/ui/applet/AppletItem.qml index bff952bd4..c4c9f2111 100644 --- a/containment/package/contents/ui/applet/AppletItem.qml +++ b/containment/package/contents/ui/applet/AppletItem.qml @@ -496,6 +496,7 @@ Item { //! Active Indicator loader Loader{ + id: indicatorLoader anchors.fill: parent active: (root.activeIndicator === Latte.Types.AllIndicator @@ -504,8 +505,18 @@ Item { && !(root.indicatorStyle === Latte.Types.UnityIndicator && !communicator.overlayLatteIconIsActive) - sourceComponent: root.indicatorStyle===Latte.Types.LatteIndicator ? - latteStyleIndicator : (root.indicatorStyle===Latte.Types.PlasmaIndicator ? plasmaStyleIndicator : unityStyleIndicator) + sourceComponent: { + switch (root.indicatorStyle) { + case Latte.Types.LatteIndicator: + return latteStyleIndicator; + case Latte.Types.PlasmaIndicator: + return plasmaStyleIndicator; + case Latte.Types.UnityIndicator: + return unityStyleIndicator; + default: + return latteStyleIndicator; + }; + } /* Indicators Properties in order use them*/ readonly property bool isTask: false @@ -540,6 +551,10 @@ Item { readonly property real glowOpacity: root.glowOpacity readonly property bool glow3D: root.glow3D + //!icon colors + property color backgroundColor: wrapper.overlayIconLoader.backgroundColor + property color glowColor: wrapper.overlayIconLoader.glowColor + Component { id: latteStyleIndicator Latte.LatteIndicator{} @@ -547,19 +562,12 @@ Item { Component { id: plasmaStyleIndicator - - Indicators.PlasmaIndicator { - anchors.fill: parent - } + Latte.PlasmaIndicator{} } Component{ id:unityStyleIndicator - Indicators.UnityIndicator{ - anchors.fill: parent - backgroundColor: wrapper.overlayIconLoader.backgroundColor - glowColor: wrapper.overlayIconLoader.glowColor - } + Latte.UnityIndicator{} } } diff --git a/containment/package/contents/ui/applet/HiddenSpacer.qml b/containment/package/contents/ui/applet/HiddenSpacer.qml index 3ae3eca39..b1e3f84b3 100644 --- a/containment/package/contents/ui/applet/HiddenSpacer.qml +++ b/containment/package/contents/ui/applet/HiddenSpacer.qml @@ -1,5 +1,3 @@ - - /* * Copyright 2016 Smith AR * Michail Vourlakos diff --git a/containment/package/contents/ui/applet/indicators/LatteIndicator.qml b/containment/package/contents/ui/applet/indicators/LatteIndicator.qml deleted file mode 100644 index 04e687694..000000000 --- a/containment/package/contents/ui/applet/indicators/LatteIndicator.qml +++ /dev/null @@ -1,194 +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.plasmoid 2.0 -import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.plasma.components 2.0 as PlasmaComponents - -import org.kde.latte 0.2 as Latte - -Item{ - id:indicatorRoot - width: !root.isVertical ? parent.width : size - height: root.isVertical ? parent.height : size - - property int size: mimicPlasmaPanel ? 4 : 0.075*root.iconSize - - property bool mimicPlasmaPanel: !root.latteApplet && plasmoid.configuration.panelSize===100 ? - !plasmoid.configuration.reverseLinesPosition : false - - /*Rectangle{ - anchors.fill: parent - border.width: 1 - border.color: "yellow" - color: "transparent" - opacity:0.6 - }*/ - - Latte.GlowPoint{ - id:activePoint - anchors.centerIn: parent - - size: indicatorRoot.size - basicColor: theme.buttonFocusColor - roundCorners: true - showGlow: root.showGlow - glow3D: root.glow3D - animation: Math.max(1.65*3*units.longDuration,root.durationTime*3*units.longDuration) - location: plasmoid.location - glowOpacity: root.glowOpacity - contrastColor: root.appShadowColorSolid - - opacity:{ - if ( (!vertical && width <= indicatorRoot.size && !appletItem.isActive) - || (vertical && height <= indicatorRoot.size && !appletItem.isActive)) - return 0; - - return 1; - } - - property bool vertical: root.isVertical - - property int animationTime: root.durationTime * (1.2*units.longDuration) - property int stateWidth: root.activeIndicatorType === Latte.Types.DotIndicator ? indicatorRoot.size : indicatorRoot.width - property int stateHeight: root.activeIndicatorType === Latte.Types.DotIndicator ? indicatorRoot.size : indicatorRoot.height - - property real scaleFactor: wrapper.zoomScale - - function updateInitialSizes(){ - if(indicatorRoot){ - if(vertical) - width = indicatorRoot.size; - else - height = indicatorRoot.size; - - if(vertical && appletItem.isActive) - height = stateHeight; - else - height = indicatorRoot.size; - - if(!vertical && appletItem.isActive) - width = stateWidth; - else - width = indicatorRoot.size; - } - } - - Connections{ - target: appletItem - onIsActiveChanged: activeAndReverseAnimation.start(); - } - - onScaleFactorChanged: { - if ( root.activeIndicatorType === Latte.Types.LineIndicator ) { - if(!activeAndReverseAnimation.running && !root.vertical && appletItem.isActive){ - width = stateWidth; - } - else if (!activeAndReverseAnimation.running && root.vertical && appletItem.isActive){ - height = stateHeight; - } - } - } - - onStateWidthChanged:{ - if(!activeAndReverseAnimation.running && !vertical && appletItem.isActive && root.activeIndicatorType === Latte.Types.LineIndicator) - width = stateWidth; - } - - onStateHeightChanged:{ - if(!activeAndReverseAnimation.running && vertical && appletItem.isActive && root.activeIndicatorType === Latte.Types.LineIndicator) - height = stateHeight; - } - - onVerticalChanged: updateInitialSizes(); - - Component.onCompleted: { - updateInitialSizes(); - - root.onIconSizeChanged.connect(updateInitialSizes); - } - - Component.onDestruction: { - root.onIconSizeChanged.disconnect(updateInitialSizes); - } - - NumberAnimation{ - id: activeAndReverseAnimation - target: activePoint - property: root.isVertical ? "height" : "width" - to: !appletItem.isActive ? (root.isVertical ? activePoint.stateHeight : activePoint.stateWidth) : indicatorRoot.size - duration: activePoint.animationTime - easing.type: Easing.InQuad - - onStopped: activePoint.updateInitialSizes() - } - } - - states: [ - State { - name: "left" - when: ((plasmoid.location === PlasmaCore.Types.LeftEdge && !root.reverseLinesPosition) || - (plasmoid.location === PlasmaCore.Types.RightEdge && root.reverseLinesPosition)) - - AnchorChanges { - target: indicatorRoot - anchors{ verticalCenter:undefined; horizontalCenter:parent.horizontalCenter; - top:undefined; bottom:undefined; left:parent.left; right:undefined;} - } - }, - State { - name: "bottom" - when: ((plasmoid.location === PlasmaCore.Types.BottomEdge && !root.reverseLinesPosition) || - (plasmoid.location === PlasmaCore.Types.TopEdge && root.reverseLinesPosition)) - - AnchorChanges { - target: indicatorRoot - anchors{ verticalCenter:undefined; horizontalCenter:parent.horizontalCenter; - top:undefined; bottom:parent.bottom; left:undefined; right:undefined;} - } - }, - State { - name: "top" - when: ((plasmoid.location === PlasmaCore.Types.TopEdge && !root.reverseLinesPosition) || - (plasmoid.location === PlasmaCore.Types.BottomEdge && root.reverseLinesPosition)) - - AnchorChanges { - target: indicatorRoot - anchors{ verticalCenter:undefined; horizontalCenter:parent.horizontalCenter; - top:parent.top; bottom:undefined; left:undefined; right:undefined;} - } - }, - State { - name: "right" - when: ((plasmoid.location === PlasmaCore.Types.RightEdge && !root.reverseLinesPosition) || - (plasmoid.location === PlasmaCore.Types.LeftEdge && root.reverseLinesPosition)) - - AnchorChanges { - target: indicatorRoot - anchors{ verticalCenter:undefined; horizontalCenter:parent.horizontalCenter; - top:undefined; bottom:undefined; left:undefined; right:parent.right;} - } - } - ] -} - - diff --git a/containment/package/contents/ui/applet/indicators/PlasmaIndicator.qml b/containment/package/contents/ui/applet/indicators/PlasmaIndicator.qml deleted file mode 100644 index 62d808bec..000000000 --- a/containment/package/contents/ui/applet/indicators/PlasmaIndicator.qml +++ /dev/null @@ -1,67 +0,0 @@ -/* -* Copyright 2019 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.latte 0.2 as Latte - -PlasmaCore.FrameSvgItem { - id: expandedItem - anchors.fill: parent - imagePath: "widgets/tabbar" - visible: opacity > 0 - prefix: { - var prefix; - switch (plasmoid.location) { - case PlasmaCore.Types.LeftEdge: - prefix = "west-active-tab"; - break; - case PlasmaCore.Types.TopEdge: - prefix = "north-active-tab"; - break; - case PlasmaCore.Types.RightEdge: - prefix = "east-active-tab"; - break; - default: - prefix = "south-active-tab"; - } - if (!hasElementPrefix(prefix)) { - prefix = "active-tab"; - } - return prefix; - } - - opacity: isActive ? 1 : 0 - - property bool isActive: (appletItem.isExpanded - && communicator.overlayLatteIconIsActive - && !appletItem.isSystray - && applet.pluginName !== root.plasmoidName - && applet.pluginName !== "org.kde.activeWindowControl" - && applet.pluginName !== "org.kde.plasma.appmenu") - - Behavior on opacity { - NumberAnimation { - duration: units.shortDuration - easing.type: Easing.InOutQuad - } - } -} diff --git a/containment/package/contents/ui/applet/indicators/UnityIndicator.qml b/containment/package/contents/ui/applet/indicators/UnityIndicator.qml deleted file mode 100644 index de1473658..000000000 --- a/containment/package/contents/ui/applet/indicators/UnityIndicator.qml +++ /dev/null @@ -1,56 +0,0 @@ -/* -* Copyright 2019 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 QtGraphicalEffects 1.0 - -import org.kde.plasma.core 2.0 as PlasmaCore - -import org.kde.latte 0.2 as Latte - -Rectangle { - id: unityRect - anchors.bottom: parent.bottom - anchors.bottomMargin: 2 - anchors.horizontalCenter: parent.horizontalCenter - width: parent.width - 4 - height: parent.height - 4 - radius: 4 - //height: (root.iconSize + root.thickMargin)/6 - 4 - //radius: height/2 - color: backgroundColor - clip: true - - property color backgroundColor - property color glowColor - - RadialGradient{ - anchors.verticalCenter: parent.top - anchors.horizontalCenter: parent.horizontalCenter - width: parent.width - height: width - - gradient: Gradient { - GradientStop { position: 0.0; color: glowColor } - GradientStop { position: 0.6; color: "transparent" } - } - } - - visible: isActive -} diff --git a/plasmoid/package/contents/ui/task/indicators/PlasmaIndicator.qml b/liblatte2/qml/indicators/PlasmaIndicator.qml similarity index 90% rename from plasmoid/package/contents/ui/task/indicators/PlasmaIndicator.qml rename to liblatte2/qml/indicators/PlasmaIndicator.qml index 2bbbcba98..78ae6b5ad 100644 --- a/plasmoid/package/contents/ui/task/indicators/PlasmaIndicator.qml +++ b/liblatte2/qml/indicators/PlasmaIndicator.qml @@ -25,14 +25,14 @@ import org.kde.latte 0.2 as Latte PlasmaCore.FrameSvgItem { id: frame - anchors.fill: parent imagePath: "widgets/tasks" - property string basePrefix: "normal" prefix: taskPrefix(basePrefix) + property Item rootItem: parent + function taskPrefix(prefix) { var effectivePrefix; @@ -55,7 +55,7 @@ PlasmaCore.FrameSvgItem { states: [ State { name: "launcher" - when: taskItem.isLauncher + when: rootItem.isLauncher || (rootItem.isApplet && !rootItem.isActive) PropertyChanges { target: frame @@ -64,7 +64,7 @@ PlasmaCore.FrameSvgItem { }, State { name: "attention" - when: taskItem.isDemandingAttention + when: rootItem.inAttention PropertyChanges { target: frame @@ -73,7 +73,7 @@ PlasmaCore.FrameSvgItem { }, State { name: "minimized" - when: taskItem.isMinimized + when: rootItem.isMinimized PropertyChanges { target: frame @@ -82,7 +82,7 @@ PlasmaCore.FrameSvgItem { }, State { name: "active" - when: taskItem.isActive + when: rootItem.isActive PropertyChanges { target: frame diff --git a/plasmoid/package/contents/ui/task/indicators/UnityIndicator.qml b/liblatte2/qml/indicators/UnityIndicator.qml similarity index 88% rename from plasmoid/package/contents/ui/task/indicators/UnityIndicator.qml rename to liblatte2/qml/indicators/UnityIndicator.qml index ecb52c164..e475b1eac 100644 --- a/plasmoid/package/contents/ui/task/indicators/UnityIndicator.qml +++ b/liblatte2/qml/indicators/UnityIndicator.qml @@ -34,11 +34,10 @@ Rectangle { radius: 4 //height: (root.iconSize + root.thickMargin)/6 - 4 //radius: height/2 - color: backgroundColor + color: rootItem.backgroundColor clip: true - property color backgroundColor - property color glowColor + property Item rootItem: parent RadialGradient{ anchors.verticalCenter: parent.top @@ -47,10 +46,10 @@ Rectangle { height: width gradient: Gradient { - GradientStop { position: 0.0; color: glowColor } + GradientStop { position: 0.0; color: rootItem.glowColor } GradientStop { position: 0.6; color: "transparent" } } } - visible: isWindow + visible: rootItem.isActive || rootItem.hasShown } diff --git a/liblatte2/qmldir b/liblatte2/qmldir index dec1b83eb..84fed9c38 100644 --- a/liblatte2/qmldir +++ b/liblatte2/qmldir @@ -4,3 +4,5 @@ plugin latte2plugin GlowPoint 0.2 GlowPoint.qml BadgeText 0.2 BadgeText.qml LatteIndicator 0.2 indicators/LatteIndicator.qml +PlasmaIndicator 0.2 indicators/PlasmaIndicator.qml +UnityIndicator 0.2 indicators/UnityIndicator.qml diff --git a/plasmoid/package/contents/ui/task/TaskItem.qml b/plasmoid/package/contents/ui/task/TaskItem.qml index 56482f0a2..cd557c942 100644 --- a/plasmoid/package/contents/ui/task/TaskItem.qml +++ b/plasmoid/package/contents/ui/task/TaskItem.qml @@ -471,6 +471,10 @@ MouseArea{ readonly property real glowOpacity: root.glowOpacity readonly property bool glow3D: root.glow3D + //!icon colors + property color backgroundColor: wrapper.backgroundColor + property color glowColor: wrapper.glowColor + sourceComponent: { switch (root.indicatorStyle) { case Latte.Types.LatteIndicator: @@ -491,15 +495,12 @@ MouseArea{ Component{ id: plasmaIndicatorComponent - Indicators.PlasmaIndicator{} + Latte.PlasmaIndicator{} } Component{ id:unityIndicatorComponent - Indicators.UnityIndicator{ - // backgroundColor: taskIconItem.backgroundColor - // glowColor: taskIconItem.glowColor - } + Latte.UnityIndicator{} } } diff --git a/plasmoid/package/contents/ui/task/Wrapper.qml b/plasmoid/package/contents/ui/task/Wrapper.qml index 23ff006a3..345f55ebe 100644 --- a/plasmoid/package/contents/ui/task/Wrapper.qml +++ b/plasmoid/package/contents/ui/task/Wrapper.qml @@ -100,6 +100,9 @@ Item{ //property real center: (width + hiddenSpacerLeft.separatorSpace + hiddenSpacerRight.separatorSpace) / 2 property real center: (width + hiddenSpacerLeft.nHiddenSize + hiddenSpacerRight.nHiddenSize) / 2 + property color backgroundColor: taskIconItem.backgroundColor + property color glowColor: taskIconItem.glowColor + property Item titleTooltipVisualParent: taskIconItem.titleTooltipVisualParent property Item previewsTooltipVisualParent: taskIconItem.previewsTootipVisualParent