1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-01-12 17:17:50 +03:00

add group indicator for Plasma style

This commit is contained in:
Michail Vourlakos 2019-03-17 01:52:45 +02:00
parent 10fbf41081
commit c39f0b4c8c
2 changed files with 197 additions and 98 deletions

View File

@ -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"
}
}
]
}

View File

@ -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