mirror of
https://github.com/tuxdotrs/tpanel.git
synced 2026-09-19 18:19:02 +05:30
Compare commits
2 Commits
77c56f9945
...
f2268f65e7
| Author | SHA1 | Date | |
|---|---|---|---|
|
f2268f65e7
|
|||
|
6357b949b3
|
@@ -39,7 +39,7 @@ Rectangle {
|
|||||||
radius: bar.width / 2
|
radius: bar.width / 2
|
||||||
color: Theme.colors.accent
|
color: Theme.colors.accent
|
||||||
antialiasing: true
|
antialiasing: true
|
||||||
opacity: 0.55 + 0.45 * bar.height / Math.max(1, barRow.height)
|
opacity: 0.45 + (bar.level * 0.55)
|
||||||
|
|
||||||
Behavior on height {
|
Behavior on height {
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
|
|||||||
@@ -4,57 +4,141 @@ import QtQuick
|
|||||||
import Quickshell.Hyprland
|
import Quickshell.Hyprland
|
||||||
import qs.config
|
import qs.config
|
||||||
|
|
||||||
Row {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property int count: 7
|
property int count: 7
|
||||||
|
|
||||||
spacing: Theme.spacing
|
implicitWidth: pillsRow.implicitWidth
|
||||||
|
implicitHeight: Theme.workspaces.height
|
||||||
|
Behavior on implicitWidth {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Theme.duration
|
||||||
|
easing.type: Easing.OutQuint
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Repeater {
|
Row {
|
||||||
model: root.count
|
id: pillsRow
|
||||||
|
|
||||||
Rectangle {
|
anchors.fill: parent
|
||||||
id: pill
|
spacing: Theme.spacing
|
||||||
|
|
||||||
required property int index
|
Repeater {
|
||||||
property var ws: Hyprland.workspaces.values.find(w => w.id === pill.index + 1)
|
model: root.count
|
||||||
property bool isActive: Hyprland.focusedWorkspace?.id === (pill.index + 1)
|
|
||||||
|
|
||||||
radius: Theme.workspaces.radius
|
Rectangle {
|
||||||
implicitHeight: Theme.workspaces.height
|
id: pill
|
||||||
implicitWidth: pill.isActive ? pill.implicitHeight * Theme.workspaces.activeWidthRatio : pill.implicitHeight
|
|
||||||
color: {
|
|
||||||
if (handler.hovered)
|
|
||||||
return Theme.colors.accent;
|
|
||||||
if (pill.isActive || pill.ws)
|
|
||||||
return Theme.colors.accent;
|
|
||||||
return Theme.colors.inActive;
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
required property int index
|
||||||
hoverEnabled: true
|
property var ws: Hyprland.workspaces.values.find(w => w.id === pill.index + 1)
|
||||||
anchors.fill: parent
|
property bool isActive: Hyprland.focusedWorkspace?.id === (pill.index + 1)
|
||||||
cursorShape: Qt.PointingHandCursor
|
|
||||||
onClicked: Hyprland.dispatch("workspace " + (pill.index + 1))
|
|
||||||
}
|
|
||||||
|
|
||||||
HoverHandler {
|
z: 1
|
||||||
id: handler
|
radius: Theme.workspaces.radius
|
||||||
}
|
implicitHeight: Theme.workspaces.height
|
||||||
|
implicitWidth: pill.isActive ? pill.implicitHeight * Theme.workspaces.activeWidthRatio : pill.implicitHeight
|
||||||
Behavior on color {
|
color: {
|
||||||
ColorAnimation {
|
if (pill.isActive)
|
||||||
duration: Theme.duration
|
return "transparent";
|
||||||
|
if (handler.hovered)
|
||||||
|
return Theme.colors.accent;
|
||||||
|
if (pill.ws)
|
||||||
|
return Theme.colors.secondaryForeground;
|
||||||
|
return Theme.colors.inActive;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Behavior on implicitWidth {
|
MouseArea {
|
||||||
NumberAnimation {
|
hoverEnabled: true
|
||||||
duration: Theme.duration
|
anchors.fill: parent
|
||||||
easing.type: Easing.OutQuad
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onClicked: Hyprland.dispatch("hl.dsp.focus({ workspace = " + (pill.index + 1) + " })")
|
||||||
|
}
|
||||||
|
|
||||||
|
HoverHandler {
|
||||||
|
id: handler
|
||||||
|
}
|
||||||
|
|
||||||
|
Behavior on color {
|
||||||
|
ColorAnimation {
|
||||||
|
duration: Theme.duration + 50
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Behavior on implicitWidth {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Theme.duration
|
||||||
|
easing.type: Easing.OutQuad
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: highlight
|
||||||
|
|
||||||
|
z: 2
|
||||||
|
radius: Theme.workspaces.radius
|
||||||
|
color: Theme.colors.accent
|
||||||
|
|
||||||
|
readonly property real activeW: Theme.workspaces.height * Theme.workspaces.activeWidthRatio
|
||||||
|
readonly property real inactiveW: Theme.workspaces.height
|
||||||
|
property int curIdx: Hyprland.focusedWorkspace ? Hyprland.focusedWorkspace.id - 1 : -1
|
||||||
|
property int prevIdx: 0
|
||||||
|
|
||||||
|
function getX(index, activeIndex) {
|
||||||
|
if (index < 0)
|
||||||
|
return 0;
|
||||||
|
let x = 0;
|
||||||
|
for (let i = 0; i < index; i++)
|
||||||
|
x += (i === activeIndex ? activeW : inactiveW) + pillsRow.spacing;
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
property real targetLeft: curIdx >= 0 ? getX(curIdx, curIdx) : 0
|
||||||
|
property real targetRight: curIdx >= 0 ? targetLeft + activeW : 0
|
||||||
|
property real actualLeft: targetLeft
|
||||||
|
property real actualRight: targetRight
|
||||||
|
|
||||||
|
Behavior on actualLeft {
|
||||||
|
NumberAnimation {
|
||||||
|
id: leftAnim
|
||||||
|
duration: Theme.duration
|
||||||
|
easing.type: Easing.OutQuint
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Behavior on actualRight {
|
||||||
|
NumberAnimation {
|
||||||
|
id: rightAnim
|
||||||
|
duration: Theme.duration
|
||||||
|
easing.type: Easing.OutQuint
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onCurIdxChanged: {
|
||||||
|
if (curIdx >= 0 && prevIdx >= 0) {
|
||||||
|
if (curIdx > prevIdx) {
|
||||||
|
leftAnim.duration = 400;
|
||||||
|
rightAnim.duration = 300;
|
||||||
|
} else if (curIdx < prevIdx) {
|
||||||
|
leftAnim.duration = 300;
|
||||||
|
rightAnim.duration = 400;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (curIdx >= 0)
|
||||||
|
prevIdx = curIdx;
|
||||||
|
}
|
||||||
|
|
||||||
|
x: actualLeft
|
||||||
|
width: actualRight - actualLeft
|
||||||
|
height: parent.height
|
||||||
|
opacity: curIdx >= 0 ? 1 : 0
|
||||||
|
Behavior on opacity {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: 180
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user