From c39f0b4c8c1c0c6a8e495b10cb11925a2b0b2f96 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sun, 17 Mar 2019 01:52:45 +0200 Subject: [PATCH] add group indicator for Plasma style --- liblatte2/qml/indicators/PlasmaIndicator.qml | 291 +++++++++++++------ liblatte2/qml/indicators/UnityIndicator.qml | 4 +- 2 files changed, 197 insertions(+), 98 deletions(-) diff --git a/liblatte2/qml/indicators/PlasmaIndicator.qml b/liblatte2/qml/indicators/PlasmaIndicator.qml index e8b8bba29..c894af87c 100644 --- a/liblatte2/qml/indicators/PlasmaIndicator.qml +++ b/liblatte2/qml/indicators/PlasmaIndicator.qml @@ -23,117 +23,216 @@ import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.latte 0.2 as Latte -PlasmaCore.FrameSvgItem { - id: frame - +Item { readonly property Item parentItem: parent.manager - property string basePrefix: "normal" + readonly property Item rootItem: parent - imagePath: parentItem.usePlasmaTabsStyle ? "widgets/tabbar" : "widgets/tasks" + readonly property bool providesFrontLayer: true - prefix: { - if (parentItem.usePlasmaTabsStyle) { - if (!parentItem.isActive) { - return ""; + //! Background Layer + Loader{ + id: backLayer + anchors.fill: parent + active: rootItem.isBackLayer + + sourceComponent: PlasmaCore.FrameSvgItem { + id: frame + property string basePrefix: "normal" + + imagePath: parentItem.usePlasmaTabsStyle ? "widgets/tabbar" : "widgets/tasks" + + prefix: { + if (parentItem.usePlasmaTabsStyle) { + if (!parentItem.isActive) { + return ""; + } + + 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 && !parentItem.reversedEnabled) + || (plasmoid.location === PlasmaCore.Types.BottomEdge && parentItem.reversedEnabled)) { + return "north-active-tab"; + } + + 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 && !parentItem.reversedEnabled) + || (plasmoid.location === PlasmaCore.Types.TopEdge && parentItem.reversedEnabled)) { + return "south-active-tab"; + } + + return "south-active-tab"; + } else { + return taskPrefix(basePrefix); + } } - if ((plasmoid.location === PlasmaCore.Types.LeftEdge && !parentItem.reversedEnabled) - || (plasmoid.location === PlasmaCore.Types.RightEdge && parentItem.reversedEnabled)) { - return "west-active-tab"; + function taskPrefix(prefix) { + var effectivePrefix; + + if ((plasmoid.location === PlasmaCore.Types.LeftEdge && !parentItem.reversedEnabled) + || (plasmoid.location === PlasmaCore.Types.RightEdge && parentItem.reversedEnabled)) { + effectivePrefix = "west-" + prefix; + } + + if ((plasmoid.location === PlasmaCore.Types.TopEdge && !parentItem.reversedEnabled) + || (plasmoid.location === PlasmaCore.Types.BottomEdge && parentItem.reversedEnabled)) { + effectivePrefix = "north-" + prefix; + } + + if ((plasmoid.location === PlasmaCore.Types.RightEdge && !parentItem.reversedEnabled) + || (plasmoid.location === PlasmaCore.Types.LeftEdge && parentItem.reversedEnabled)) { + effectivePrefix = "east-" + prefix; + } + + if ((plasmoid.location === PlasmaCore.Types.BottomEdge && !parentItem.reversedEnabled) + || (plasmoid.location === PlasmaCore.Types.TopEdge && parentItem.reversedEnabled)) { + effectivePrefix = "south-" + prefix; + } + + return [effectivePrefix, prefix]; } - if ((plasmoid.location === PlasmaCore.Types.TopEdge && !parentItem.reversedEnabled) - || (plasmoid.location === PlasmaCore.Types.BottomEdge && parentItem.reversedEnabled)) { - return "north-active-tab"; - } + states: [ + State { + name: "launcher" + when: parentItem.isLauncher || (parentItem.isApplet && !parentItem.isActive) - if ((plasmoid.location === PlasmaCore.Types.RightEdge && !parentItem.reversedEnabled) - || (plasmoid.location === PlasmaCore.Types.LeftEdge && parentItem.reversedEnabled)) { - return "east-active-tab"; - } + PropertyChanges { + target: frame + basePrefix: "" + } + }, + State { + name: "hovered" + when: parentItem.isHovered && frame.hasElementPrefix("hover") - if ((plasmoid.location === PlasmaCore.Types.BottomEdge && !parentItem.reversedEnabled) - || (plasmoid.location === PlasmaCore.Types.TopEdge && parentItem.reversedEnabled)) { - return "south-active-tab"; - } + PropertyChanges { + target: frame + basePrefix: "hover" + } + }, + State { + name: "attention" + when: parentItem.inAttention - return "south-active-tab"; - } else { - return taskPrefix(basePrefix); + PropertyChanges { + target: frame + basePrefix: "attention" + } + }, + State { + name: "minimized" + when: parentItem.isMinimized + + PropertyChanges { + target: frame + basePrefix: "minimized" + } + }, + State { + name: "active" + when: parentItem.isActive + + PropertyChanges { + target: frame + basePrefix: "focus" + } + } + ] } } - function taskPrefix(prefix) { - var effectivePrefix; + //! Foreground Layer to draw arrows + Loader{ + id: frontLayer + anchors.fill: parent + active: !rootItem.isBackLayer && !parentItem.isApplet && parentItem.isGroup - if ((plasmoid.location === PlasmaCore.Types.LeftEdge && !parentItem.reversedEnabled) - || (plasmoid.location === PlasmaCore.Types.RightEdge && parentItem.reversedEnabled)) { - effectivePrefix = "west-" + prefix; + sourceComponent: Item { + anchors.fill: parent + + PlasmaCore.Svg { + id: taskSvg + imagePath: "widgets/tasks" + } + + Item { + id: iconBox + anchors.centerIn: parent + width: parentItem.currentIconSize + height: width + } + + PlasmaCore.SvgItem { + id: arrow + + implicitWidth: 0.25 * iconBox.width + implicitHeight: implicitWidth + + svg: taskSvg + elementId: elementForLocation(plasmoid.location) + + function elementForLocation(location) { + switch (location) { + case PlasmaCore.Types.LeftEdge: + return "group-expander-left"; + case PlasmaCore.Types.TopEdge: + return "group-expander-top"; + case PlasmaCore.Types.RightEdge: + return "group-expander-right"; + case PlasmaCore.Types.BottomEdge: + default: + return "group-expander-bottom"; + } + } + } + + states: [ + State { + name: "bottom" + when: plasmoid.location == PlasmaCore.Types.BottomEdge + AnchorChanges { + target: arrow + anchors.top: undefined; anchors.left: undefined; anchors.right: undefined; anchors.bottom: arrow.parent.bottom; + anchors.horizontalCenter: iconBox.horizontalCenter; anchors.verticalCenter: undefined; + } + }, + State { + name: "top" + when: plasmoid.location == PlasmaCore.Types.TopEdge + AnchorChanges { + target: arrow + anchors.top: arrow.parent.top; anchors.left: undefined; anchors.right: undefined; anchors.bottom: undefined; + anchors.horizontalCenter: iconBox.horizontalCenter; anchors.verticalCenter: undefined; + } + }, + State { + name: "left" + when: plasmoid.location == PlasmaCore.Types.LeftEdge + AnchorChanges { + target: arrow + anchors.top: undefined; anchors.left: arrow.parent.left; anchors.right: undefined; anchors.bottom: undefined; + anchors.horizontalCenter: undefined; anchors.verticalCenter: iconBox.verticalCenter; + } + }, + State { + name: "right" + when: plasmoid.location == PlasmaCore.Types.RightEdge + AnchorChanges { + target: arrow + anchors.top: undefined; anchors.left: undefined; anchors.right: arrow.parent.right; anchors.bottom: undefined; + anchors.horizontalCenter: undefined; anchors.verticalCenter: iconBox.verticalCenter; + } + } + ] } - - if ((plasmoid.location === PlasmaCore.Types.TopEdge && !parentItem.reversedEnabled) - || (plasmoid.location === PlasmaCore.Types.BottomEdge && parentItem.reversedEnabled)) { - effectivePrefix = "north-" + prefix; - } - - if ((plasmoid.location === PlasmaCore.Types.RightEdge && !parentItem.reversedEnabled) - || (plasmoid.location === PlasmaCore.Types.LeftEdge && parentItem.reversedEnabled)) { - effectivePrefix = "east-" + prefix; - } - - 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: parentItem.isLauncher || (parentItem.isApplet && !parentItem.isActive) - - PropertyChanges { - target: frame - basePrefix: "" - } - }, - State { - name: "hovered" - when: parentItem.isHovered && frame.hasElementPrefix("hover") - - PropertyChanges { - target: frame - basePrefix: "hover" - } - }, - State { - name: "attention" - when: parentItem.inAttention - - PropertyChanges { - target: frame - basePrefix: "attention" - } - }, - State { - name: "minimized" - when: parentItem.isMinimized - - PropertyChanges { - target: frame - basePrefix: "minimized" - } - }, - State { - name: "active" - when: parentItem.isActive - - PropertyChanges { - target: frame - basePrefix: "focus" - } - } - ] } diff --git a/liblatte2/qml/indicators/UnityIndicator.qml b/liblatte2/qml/indicators/UnityIndicator.qml index 0bfcd010b..d783e858b 100644 --- a/liblatte2/qml/indicators/UnityIndicator.qml +++ b/liblatte2/qml/indicators/UnityIndicator.qml @@ -29,8 +29,8 @@ import "../code/ColorizerTools.js" as ColorizerTools Item{ id: indicatorItem - property Item parentItem: parent.manager - property Item rootItem: parent + readonly property Item parentItem: parent.manager + readonly property Item rootItem: parent readonly property bool needsIconColors: true readonly property bool providesFrontLayer: true