diff --git a/liblatte2/qml/indicators/LatteIndicator.qml b/liblatte2/qml/indicators/LatteIndicator.qml index 857b11cd..b32aa5a8 100644 --- a/liblatte2/qml/indicators/LatteIndicator.qml +++ b/liblatte2/qml/indicators/LatteIndicator.qml @@ -1,266 +1,266 @@ /* * 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 QtQuick.Layouts 1.1 import QtGraphicalEffects 1.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 import "../code/ColorizerTools.js" as ColorizerTools Item{ id: indicatorRoot readonly property real factor: 0.08 - readonly property int size: factor * rootItem.currentIconSize - readonly property int extraMaskThickness: rootItem.reversedEnabled && rootItem.glowEnabled ? 1.7 * (factor * rootItem.maxIconSize) : 0 - readonly property Item rootItem: parent + readonly property int size: factor * parentItem.currentIconSize + readonly property int extraMaskThickness: parentItem.reversedEnabled && parentItem.glowEnabled ? 1.7 * (factor * parentItem.maxIconSize) : 0 + readonly property Item parentItem: parent.manager property real textColorBrightness: ColorizerTools.colorBrightness(theme.textColor) property color isActiveColor: theme.buttonFocusColor property color minimizedColor: { - if (rootItem.multiColorEnabled) { + if (parentItem.multiColorEnabled) { return (textColorBrightness > 127.5 ? Qt.darker(theme.textColor, 1.7) : Qt.lighter(theme.textColor, 7)); } return isActiveColor; } - property color notActiveColor: rootItem.isMinimized ? minimizedColor : isActiveColor + property color notActiveColor: parentItem.isMinimized ? minimizedColor : isActiveColor /*Rectangle{ anchors.fill: parent border.width: 1 border.color: "yellow" color: "transparent" opacity:0.6 }*/ Item{ id: mainIndicatorElement width: flowItem.width height: flowItem.height Flow{ id: flowItem flow: plasmoid.formFactor === PlasmaCore.Types.Vertical ? Flow.TopToBottom : Flow.LeftToRight Latte.GlowPoint{ id:firstPoint opacity: { - if (rootItem.isTask) { - return rootItem.isLauncher || (rootItem.inRemoving && !activeAndReverseAnimation.running) ? 0 : 1 + if (parentItem.isTask) { + return parentItem.isLauncher || (parentItem.inRemoving && !activeAndReverseAnimation.running) ? 0 : 1 } - if (rootItem.isApplet) { - return (rootItem.isActive || activeAndReverseAnimation.running) ? 1 : 0 + if (parentItem.isApplet) { + return (parentItem.isActive || activeAndReverseAnimation.running) ? 1 : 0 } } - basicColor: rootItem.isActive || (rootItem.isGroup && rootItem.hasShown) ? indicatorRoot.isActiveColor : indicatorRoot.notActiveColor + basicColor: parentItem.isActive || (parentItem.isGroup && parentItem.hasShown) ? indicatorRoot.isActiveColor : indicatorRoot.notActiveColor size: indicatorRoot.size - glow3D: rootItem.glow3D - animation: Math.max(1.65*3*units.longDuration,rootItem.durationTime*3*units.longDuration) + glow3D: parentItem.glow3D + animation: Math.max(1.65*3*units.longDuration,parentItem.durationTime*3*units.longDuration) location: plasmoid.location - glowOpacity: rootItem.glowOpacity - contrastColor: rootItem.shadowColor + glowOpacity: parentItem.glowOpacity + contrastColor: parentItem.shadowColor attentionColor: theme.negativeTextColor roundCorners: true - showAttention: rootItem.inAttention + showAttention: parentItem.inAttention showGlow: { - if (rootItem.glowEnabled && (rootItem.glowOption === Latte.Types.GlowAll || showAttention )) + if (parentItem.glowEnabled && (parentItem.glowOption === Latte.Types.GlowAll || showAttention )) return true; - else if (rootItem.glowEnabled && rootItem.glowOption === Latte.Types.GlowOnlyOnActive && rootItem.hasActive) + else if (parentItem.glowEnabled && parentItem.glowOption === Latte.Types.GlowOnlyOnActive && parentItem.hasActive) return true; else return false; } - showBorder: rootItem.glowEnabled && rootItem.glow3D + showBorder: parentItem.glowEnabled && parentItem.glow3D - property int stateWidth: rootItem.isGroup ? indicatorRoot.width - secondPoint.width : indicatorRoot.width - spacer.width - property int stateHeight: rootItem.isGroup ? indicatorRoot.height - secondPoint.height : indicatorRoot.width - spacer.height + property int stateWidth: parentItem.isGroup ? indicatorRoot.width - secondPoint.width : indicatorRoot.width - spacer.width + property int stateHeight: parentItem.isGroup ? indicatorRoot.height - secondPoint.height : indicatorRoot.width - spacer.height - property int animationTime: rootItem.durationTime* (0.7*units.longDuration) + property int animationTime: parentItem.durationTime* (0.7*units.longDuration) - property bool isActive: rootItem.hasActive || rootItem.isActive + property bool isActive: parentItem.hasActive || parentItem.isActive property bool vertical: plasmoid.formFactor === PlasmaCore.Types.Vertical - property real scaleFactor: rootItem.scaleFactor + property real scaleFactor: parentItem.scaleFactor function updateInitialSizes(){ if(indicatorRoot){ if(vertical) width = indicatorRoot.size; else height = indicatorRoot.size; - if(vertical && isActive && rootItem.activeIndicatorType === Latte.Types.LineIndicator) + if(vertical && isActive && parentItem.activeIndicatorType === Latte.Types.LineIndicator) height = stateHeight; else height = indicatorRoot.size; - if(!vertical && isActive && rootItem.activeIndicatorType === Latte.Types.LineIndicator) + if(!vertical && isActive && parentItem.activeIndicatorType === Latte.Types.LineIndicator) width = stateWidth; else width = indicatorRoot.size; } } onIsActiveChanged: { - if (rootItem.activeIndicatorType === Latte.Types.LineIndicator) + if (parentItem.activeIndicatorType === Latte.Types.LineIndicator) activeAndReverseAnimation.start(); } onScaleFactorChanged: { - if(!activeAndReverseAnimation.running && !vertical && isActive && rootItem.activeIndicatorType === Latte.Types.LineIndicator){ + if(!activeAndReverseAnimation.running && !vertical && isActive && parentItem.activeIndicatorType === Latte.Types.LineIndicator){ width = stateWidth; } - else if (!activeAndReverseAnimation.running && vertical && isActive && rootItem.activeIndicatorType === Latte.Types.LineIndicator){ + else if (!activeAndReverseAnimation.running && vertical && isActive && parentItem.activeIndicatorType === Latte.Types.LineIndicator){ height = stateHeight; } } onStateWidthChanged:{ - if(!activeAndReverseAnimation.running && !vertical && isActive && rootItem.activeIndicatorType === Latte.Types.LineIndicator) + if(!activeAndReverseAnimation.running && !vertical && isActive && parentItem.activeIndicatorType === Latte.Types.LineIndicator) width = stateWidth; } onStateHeightChanged:{ - if(!activeAndReverseAnimation.running && vertical && isActive && rootItem.activeIndicatorType === Latte.Types.LineIndicator) + if(!activeAndReverseAnimation.running && vertical && isActive && parentItem.activeIndicatorType === Latte.Types.LineIndicator) height = stateHeight; } onVerticalChanged: updateInitialSizes(); Component.onCompleted: { updateInitialSizes(); - rootItem.onCurrentIconSizeChanged.connect(updateInitialSizes); + parentItem.onCurrentIconSizeChanged.connect(updateInitialSizes); } Component.onDestruction: { - rootItem.onCurrentIconSizeChanged.disconnect(updateInitialSizes); + parentItem.onCurrentIconSizeChanged.disconnect(updateInitialSizes); } NumberAnimation{ id: activeAndReverseAnimation target: firstPoint property: plasmoid.formFactor === PlasmaCore.Types.Vertical ? "height" : "width" - to: rootItem.hasActive && rootItem.activeIndicatorType === Latte.Types.LineIndicator + to: parentItem.hasActive && parentItem.activeIndicatorType === Latte.Types.LineIndicator ? (plasmoid.formFactor === PlasmaCore.Types.Vertical ? firstPoint.stateHeight : firstPoint.stateWidth) : indicatorRoot.size duration: firstPoint.animationTime easing.type: Easing.InQuad onStopped: firstPoint.updateInitialSizes() } } Item{ id:spacer width: secondPoint.visible ? 0.5*indicatorRoot.size : 0 height: secondPoint.visible ? 0.5*indicatorRoot.size : 0 } Latte.GlowPoint{ id:secondPoint width: visible ? indicatorRoot.size : 0 height: width size: indicatorRoot.size - glow3D: rootItem.glow3D - animation: Math.max(1.65*3*units.longDuration,rootItem.durationTime*3*units.longDuration) + glow3D: parentItem.glow3D + animation: Math.max(1.65*3*units.longDuration,parentItem.durationTime*3*units.longDuration) location: plasmoid.location - glowOpacity: rootItem.glowOpacity - contrastColor: rootItem.shadowColor - showBorder: rootItem.glowEnabled && rootItem.glow3D + glowOpacity: parentItem.glowOpacity + contrastColor: parentItem.shadowColor + showBorder: parentItem.glowEnabled && parentItem.glow3D basicColor: state2Color roundCorners: true - showGlow: rootItem.glowEnabled && rootItem.glowOption === Latte.Types.GlowAll - visible: ( rootItem.isGroup && ((rootItem.dotsOnActive && rootItem.activeIndicatorType === Latte.Types.LineIndicator) - || rootItem.activeIndicatorType === Latte.Types.DotIndicator - || !rootItem.hasActive) )? true: false + showGlow: parentItem.glowEnabled && parentItem.glowOption === Latte.Types.GlowAll + visible: ( parentItem.isGroup && ((parentItem.dotsOnActive && parentItem.activeIndicatorType === Latte.Types.LineIndicator) + || parentItem.activeIndicatorType === Latte.Types.DotIndicator + || !parentItem.hasActive) )? true: false //when there is no active window - property color state1Color: rootItem.hasShown ? indicatorRoot.isActiveColor : indicatorRoot.minimizedColor + property color state1Color: parentItem.hasShown ? indicatorRoot.isActiveColor : indicatorRoot.minimizedColor //when there is active window - property color state2Color: rootItem.hasMinimized ? indicatorRoot.minimizedColor : indicatorRoot.isActiveColor + property color state2Color: parentItem.hasMinimized ? indicatorRoot.minimizedColor : indicatorRoot.isActiveColor } } states: [ State { name: "left" - when: ((plasmoid.location === PlasmaCore.Types.LeftEdge && !rootItem.reversedEnabled) || - (plasmoid.location === PlasmaCore.Types.RightEdge && rootItem.reversedEnabled)) + when: ((plasmoid.location === PlasmaCore.Types.LeftEdge && !parentItem.reversedEnabled) || + (plasmoid.location === PlasmaCore.Types.RightEdge && parentItem.reversedEnabled)) AnchorChanges { target: mainIndicatorElement anchors{ verticalCenter:parent.verticalCenter; horizontalCenter:undefined; top:undefined; bottom:undefined; left:parent.left; right:undefined;} } }, State { name: "bottom" - when: ((plasmoid.location === PlasmaCore.Types.BottomEdge && !rootItem.reversedEnabled) || - (plasmoid.location === PlasmaCore.Types.TopEdge && rootItem.reversedEnabled)) + when: ((plasmoid.location === PlasmaCore.Types.BottomEdge && !parentItem.reversedEnabled) || + (plasmoid.location === PlasmaCore.Types.TopEdge && parentItem.reversedEnabled)) AnchorChanges { target: mainIndicatorElement anchors{ verticalCenter:undefined; horizontalCenter:parent.horizontalCenter; top:undefined; bottom:parent.bottom; left:undefined; right:undefined;} } }, State { name: "top" - when: ((plasmoid.location === PlasmaCore.Types.TopEdge && !rootItem.reversedEnabled) || - (plasmoid.location === PlasmaCore.Types.BottomEdge && rootItem.reversedEnabled)) + when: ((plasmoid.location === PlasmaCore.Types.TopEdge && !parentItem.reversedEnabled) || + (plasmoid.location === PlasmaCore.Types.BottomEdge && parentItem.reversedEnabled)) AnchorChanges { target: mainIndicatorElement anchors{ verticalCenter:undefined; horizontalCenter:parent.horizontalCenter; top:parent.top; bottom:undefined; left:undefined; right:undefined;} } }, State { name: "right" - when: ((plasmoid.location === PlasmaCore.Types.RightEdge && !rootItem.reversedEnabled) || - (plasmoid.location === PlasmaCore.Types.LeftEdge && rootItem.reversedEnabled)) + when: ((plasmoid.location === PlasmaCore.Types.RightEdge && !parentItem.reversedEnabled) || + (plasmoid.location === PlasmaCore.Types.LeftEdge && parentItem.reversedEnabled)) AnchorChanges { target: mainIndicatorElement anchors{ verticalCenter:parent.verticalCenter; horizontalCenter:undefined; top:undefined; bottom:undefined; left:undefined; right:parent.right;} } } ] } }// number of windows indicator diff --git a/liblatte2/qml/indicators/PlasmaIndicator.qml b/liblatte2/qml/indicators/PlasmaIndicator.qml index bd1baaf7..351d46fb 100644 --- a/liblatte2/qml/indicators/PlasmaIndicator.qml +++ b/liblatte2/qml/indicators/PlasmaIndicator.qml @@ -1,130 +1,130 @@ /* * 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: frame - readonly property Item rootItem: parent + readonly property Item parentItem: parent.manager property string basePrefix: "normal" - imagePath: rootItem.usePlasmaTabsStyle ? "widgets/tabbar" : "widgets/tasks" + imagePath: parentItem.usePlasmaTabsStyle ? "widgets/tabbar" : "widgets/tasks" prefix: { - if (rootItem.usePlasmaTabsStyle) { - if (!rootItem.isActive) { + if (parentItem.usePlasmaTabsStyle) { + if (!parentItem.isActive) { return ""; } - if ((plasmoid.location === PlasmaCore.Types.LeftEdge && !rootItem.reversedEnabled) - || (plasmoid.location === PlasmaCore.Types.RightEdge && rootItem.reversedEnabled)) { + if ((plasmoid.location === PlasmaCore.Types.LeftEdge && !parentItem.reversedEnabled) + || (plasmoid.location === PlasmaCore.Types.RightEdge && parentItem.reversedEnabled)) { return "west-active-tab"; } - if ((plasmoid.location === PlasmaCore.Types.TopEdge && !rootItem.reversedEnabled) - || (plasmoid.location === PlasmaCore.Types.BottomEdge && rootItem.reversedEnabled)) { + if ((plasmoid.location === PlasmaCore.Types.TopEdge && !parentItem.reversedEnabled) + || (plasmoid.location === PlasmaCore.Types.BottomEdge && parentItem.reversedEnabled)) { return "north-active-tab"; } - if ((plasmoid.location === PlasmaCore.Types.RightEdge && !rootItem.reversedEnabled) - || (plasmoid.location === PlasmaCore.Types.LeftEdge && rootItem.reversedEnabled)) { + if ((plasmoid.location === PlasmaCore.Types.RightEdge && !parentItem.reversedEnabled) + || (plasmoid.location === PlasmaCore.Types.LeftEdge && parentItem.reversedEnabled)) { return "east-active-tab"; } - if ((plasmoid.location === PlasmaCore.Types.BottomEdge && !rootItem.reversedEnabled) - || (plasmoid.location === PlasmaCore.Types.TopEdge && rootItem.reversedEnabled)) { + if ((plasmoid.location === PlasmaCore.Types.BottomEdge && !parentItem.reversedEnabled) + || (plasmoid.location === PlasmaCore.Types.TopEdge && parentItem.reversedEnabled)) { return "south-active-tab"; } return "south-active-tab"; } else { return taskPrefix(basePrefix); } } function taskPrefix(prefix) { var effectivePrefix; - if ((plasmoid.location === PlasmaCore.Types.LeftEdge && !rootItem.reversedEnabled) - || (plasmoid.location === PlasmaCore.Types.RightEdge && rootItem.reversedEnabled)) { + if ((plasmoid.location === PlasmaCore.Types.LeftEdge && !parentItem.reversedEnabled) + || (plasmoid.location === PlasmaCore.Types.RightEdge && parentItem.reversedEnabled)) { effectivePrefix = "west-" + prefix; } - if ((plasmoid.location === PlasmaCore.Types.TopEdge && !rootItem.reversedEnabled) - || (plasmoid.location === PlasmaCore.Types.BottomEdge && rootItem.reversedEnabled)) { + if ((plasmoid.location === PlasmaCore.Types.TopEdge && !parentItem.reversedEnabled) + || (plasmoid.location === PlasmaCore.Types.BottomEdge && parentItem.reversedEnabled)) { effectivePrefix = "north-" + prefix; } - if ((plasmoid.location === PlasmaCore.Types.RightEdge && !rootItem.reversedEnabled) - || (plasmoid.location === PlasmaCore.Types.LeftEdge && rootItem.reversedEnabled)) { + if ((plasmoid.location === PlasmaCore.Types.RightEdge && !parentItem.reversedEnabled) + || (plasmoid.location === PlasmaCore.Types.LeftEdge && parentItem.reversedEnabled)) { effectivePrefix = "east-" + prefix; } - if ((plasmoid.location === PlasmaCore.Types.BottomEdge && !rootItem.reversedEnabled) - || (plasmoid.location === PlasmaCore.Types.TopEdge && rootItem.reversedEnabled)) { + if ((plasmoid.location === PlasmaCore.Types.BottomEdge && !parentItem.reversedEnabled) + || (plasmoid.location === PlasmaCore.Types.TopEdge && parentItem.reversedEnabled)) { effectivePrefix = "south-" + prefix; } return [effectivePrefix, prefix]; } states: [ State { name: "launcher" - when: rootItem.isLauncher || (rootItem.isApplet && !rootItem.isActive) + when: parentItem.isLauncher || (parentItem.isApplet && !parentItem.isActive) PropertyChanges { target: frame basePrefix: "" } }, State { name: "attention" - when: rootItem.inAttention + when: parentItem.inAttention PropertyChanges { target: frame basePrefix: "attention" } }, State { name: "minimized" - when: rootItem.isMinimized + when: parentItem.isMinimized PropertyChanges { target: frame basePrefix: "minimized" } }, State { name: "active" - when: rootItem.isActive + when: parentItem.isActive PropertyChanges { target: frame basePrefix: "focus" } } ] }