bar: workspaces different styles for occupied
This commit is contained in:
parent
e878949858
commit
3108a7d75e
4 changed files with 72 additions and 49 deletions
|
|
@ -9,5 +9,6 @@ Singleton {
|
||||||
readonly property QtObject workspaces: QtObject {
|
readonly property QtObject workspaces: QtObject {
|
||||||
property int shown: 10
|
property int shown: 10
|
||||||
property string style: ""
|
property string style: ""
|
||||||
|
property bool occupiedBg: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import "root:/widgets"
|
import "root:/widgets"
|
||||||
import "root:/config"
|
import "root:/config"
|
||||||
|
import "workspaces"
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Wayland
|
import Quickshell.Wayland
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
|
|
||||||
52
modules/bar/workspaces/OccupiedBg.qml
Normal file
52
modules/bar/workspaces/OccupiedBg.qml
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
import "root:/widgets"
|
||||||
|
import "root:/services"
|
||||||
|
import "root:/config"
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Layouts
|
||||||
|
import Qt5Compat.GraphicalEffects
|
||||||
|
|
||||||
|
BoxLayout {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
required property bool vertical
|
||||||
|
required property list<Label> workspaces
|
||||||
|
required property BoxLayout layout
|
||||||
|
|
||||||
|
readonly property var occupied: Hyprland.workspaces.values.reduce((acc, curr) => {
|
||||||
|
acc[curr.id] = curr.lastIpcObject.windows > 0;
|
||||||
|
return acc;
|
||||||
|
}, {})
|
||||||
|
|
||||||
|
anchors.centerIn: parent
|
||||||
|
spacing: 0
|
||||||
|
z: -1
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: BarConfig.workspaces.shown
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
required property int index
|
||||||
|
readonly property int roundLeft: index === 0 || !root.occupied[index] ? Appearance.rounding.full : 0
|
||||||
|
readonly property int roundRight: index === BarConfig.workspaces.shown - 1 || !root.occupied[index + 2] ? Appearance.rounding.full : 0
|
||||||
|
|
||||||
|
color: Appearance.alpha(Appearance.colours.surface2, true)
|
||||||
|
opacity: root.occupied[index + 1] ? 1 : 0
|
||||||
|
topLeftRadius: roundLeft
|
||||||
|
bottomLeftRadius: roundLeft
|
||||||
|
topRightRadius: roundRight
|
||||||
|
bottomRightRadius: roundRight
|
||||||
|
|
||||||
|
// Ugh stupid size errors on reload
|
||||||
|
Layout.preferredWidth: root.vertical ? layout.width : root.workspaces[index]?.width ?? 1
|
||||||
|
Layout.preferredHeight: root.vertical ? root.workspaces[index]?.height ?? 1 : layout.height
|
||||||
|
|
||||||
|
Behavior on opacity {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Appearance.anim.durations.normal
|
||||||
|
easing.type: Easing.BezierSpline
|
||||||
|
easing.bezierCurve: Appearance.anim.curves.standard
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -33,7 +33,7 @@ Item {
|
||||||
readonly property bool isWorkspace: true
|
readonly property bool isWorkspace: true
|
||||||
|
|
||||||
text: index + 1
|
text: index + 1
|
||||||
color: Appearance.colours.text
|
color: BarConfig.workspaces.occupiedBg || occupied.occupied[index + 1] ? Appearance.colours.text : Appearance.colours.subtext0
|
||||||
horizontalAlignment: Label.AlignHCenter
|
horizontalAlignment: Label.AlignHCenter
|
||||||
|
|
||||||
Layout.preferredWidth: layout.homogenous && !layout.vertical ? layout.height : -1
|
Layout.preferredWidth: layout.homogenous && !layout.vertical ? layout.height : -1
|
||||||
|
|
@ -42,47 +42,20 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BoxLayout {
|
OccupiedBg {
|
||||||
id: occupied
|
id: occupied
|
||||||
|
|
||||||
readonly property var occupied: Hyprland.workspaces.values.reduce((acc, curr) => {
|
opacity: BarConfig.workspaces.occupiedBg ? 1 : 0
|
||||||
acc[curr.id] = curr.lastIpcObject.windows > 0;
|
vertical: root.vertical
|
||||||
return acc;
|
workspaces: root.workspaces
|
||||||
}, {})
|
layout: layout
|
||||||
|
|
||||||
anchors.centerIn: parent
|
|
||||||
spacing: 0
|
|
||||||
z: -1
|
|
||||||
|
|
||||||
Repeater {
|
|
||||||
model: BarConfig.workspaces.shown
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
required property int index
|
|
||||||
readonly property int roundLeft: index === 0 || !occupied.occupied[index] ? Appearance.rounding.full : 0
|
|
||||||
readonly property int roundRight: index === BarConfig.workspaces.shown - 1 || !occupied.occupied[index + 2] ? Appearance.rounding.full : 0
|
|
||||||
|
|
||||||
color: Appearance.alpha(Appearance.colours.surface2, true)
|
|
||||||
opacity: occupied.occupied[index + 1] ? 1 : 0
|
|
||||||
topLeftRadius: roundLeft
|
|
||||||
bottomLeftRadius: roundLeft
|
|
||||||
topRightRadius: roundRight
|
|
||||||
bottomRightRadius: roundRight
|
|
||||||
|
|
||||||
// Ugh stupid size errors on reload
|
|
||||||
Layout.preferredWidth: root.vertical ? layout.width : root.workspaces[index]?.width ?? 1
|
|
||||||
Layout.preferredHeight: root.vertical ? root.workspaces[index]?.height ?? 1 : layout.height
|
|
||||||
|
|
||||||
Behavior on opacity {
|
Behavior on opacity {
|
||||||
NumberAnimation {
|
Anim {
|
||||||
duration: Appearance.anim.durations.normal
|
|
||||||
easing.type: Easing.BezierSpline
|
|
||||||
easing.bezierCurve: Appearance.anim.curves.standard
|
easing.bezierCurve: Appearance.anim.curves.standard
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
@ -143,27 +116,23 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
Behavior on leading {
|
Behavior on leading {
|
||||||
NumberAnimation {
|
Anim {}
|
||||||
duration: Appearance.anim.durations.normal
|
|
||||||
easing.type: Easing.BezierSpline
|
|
||||||
easing.bezierCurve: Appearance.anim.curves.emphasized
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Behavior on trailing {
|
Behavior on trailing {
|
||||||
NumberAnimation {
|
Anim {
|
||||||
duration: Appearance.anim.durations.normal * 2
|
duration: Appearance.anim.durations.normal * 2
|
||||||
easing.type: Easing.BezierSpline
|
|
||||||
easing.bezierCurve: Appearance.anim.curves.emphasized
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Behavior on currentSize {
|
Behavior on currentSize {
|
||||||
NumberAnimation {
|
Anim {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
component Anim: NumberAnimation {
|
||||||
duration: Appearance.anim.durations.normal
|
duration: Appearance.anim.durations.normal
|
||||||
easing.type: Easing.BezierSpline
|
easing.type: Easing.BezierSpline
|
||||||
easing.bezierCurve: Appearance.anim.curves.emphasized
|
easing.bezierCurve: Appearance.anim.curves.emphasized
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Reference in a new issue