refactor: bar workspaces move workspace into file
This commit is contained in:
parent
3108a7d75e
commit
0b48cc5ff6
4 changed files with 35 additions and 21 deletions
|
|
@ -40,6 +40,10 @@ Variants {
|
||||||
|
|
||||||
OsIcon {}
|
OsIcon {}
|
||||||
|
|
||||||
|
Workspaces {
|
||||||
|
vertical: win.vertical
|
||||||
|
}
|
||||||
|
|
||||||
Clock {
|
Clock {
|
||||||
vertical: win.vertical
|
vertical: win.vertical
|
||||||
}
|
}
|
||||||
|
|
@ -47,10 +51,6 @@ Variants {
|
||||||
ActiveWindow {
|
ActiveWindow {
|
||||||
vertical: win.vertical
|
vertical: win.vertical
|
||||||
}
|
}
|
||||||
|
|
||||||
Workspaces {
|
|
||||||
vertical: win.vertical
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,9 @@ BoxLayout {
|
||||||
|
|
||||||
required property bool vertical
|
required property bool vertical
|
||||||
required property list<Label> workspaces
|
required property list<Label> workspaces
|
||||||
|
required property var occupied
|
||||||
required property BoxLayout layout
|
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
|
anchors.centerIn: parent
|
||||||
spacing: 0
|
spacing: 0
|
||||||
z: -1
|
z: -1
|
||||||
|
|
|
||||||
18
modules/bar/workspaces/Workspace.qml
Normal file
18
modules/bar/workspaces/Workspace.qml
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
import "root:/widgets"
|
||||||
|
import "root:/services"
|
||||||
|
import "root:/config"
|
||||||
|
import QtQuick.Layouts
|
||||||
|
|
||||||
|
Label {
|
||||||
|
required property int index
|
||||||
|
required property BoxLayout layout
|
||||||
|
required property var occupied
|
||||||
|
readonly property bool isWorkspace: true
|
||||||
|
|
||||||
|
text: index + 1
|
||||||
|
color: BarConfig.workspaces.occupiedBg || occupied[index + 1] ? Appearance.colours.text : Appearance.colours.subtext0
|
||||||
|
horizontalAlignment: Label.AlignHCenter
|
||||||
|
|
||||||
|
Layout.preferredWidth: layout.homogenous && !layout.vertical ? layout.height : -1
|
||||||
|
Layout.preferredHeight: layout.homogenous && layout.vertical ? layout.width : -1
|
||||||
|
}
|
||||||
|
|
@ -12,7 +12,15 @@ Item {
|
||||||
|
|
||||||
property alias vertical: layout.vertical
|
property alias vertical: layout.vertical
|
||||||
readonly property color colour: Appearance.colours.mauve
|
readonly property color colour: Appearance.colours.mauve
|
||||||
|
property int shown: 10
|
||||||
|
property bool occupiedBg: false
|
||||||
|
property bool showWindows: false
|
||||||
|
|
||||||
readonly property list<Label> workspaces: layout.children.filter(c => c.isWorkspace)
|
readonly property list<Label> workspaces: layout.children.filter(c => c.isWorkspace)
|
||||||
|
readonly property var occupied: Hyprland.workspaces.values.reduce((acc, curr) => {
|
||||||
|
acc[curr.id] = curr.lastIpcObject.windows > 0;
|
||||||
|
return acc;
|
||||||
|
}, {})
|
||||||
|
|
||||||
implicitWidth: layout.implicitWidth
|
implicitWidth: layout.implicitWidth
|
||||||
implicitHeight: layout.implicitHeight
|
implicitHeight: layout.implicitHeight
|
||||||
|
|
@ -28,26 +36,18 @@ Item {
|
||||||
Repeater {
|
Repeater {
|
||||||
model: BarConfig.workspaces.shown
|
model: BarConfig.workspaces.shown
|
||||||
|
|
||||||
Label {
|
Workspace {
|
||||||
required property int index
|
layout: layout
|
||||||
readonly property bool isWorkspace: true
|
occupied: root.occupied
|
||||||
|
|
||||||
text: index + 1
|
|
||||||
color: BarConfig.workspaces.occupiedBg || occupied.occupied[index + 1] ? Appearance.colours.text : Appearance.colours.subtext0
|
|
||||||
horizontalAlignment: Label.AlignHCenter
|
|
||||||
|
|
||||||
Layout.preferredWidth: layout.homogenous && !layout.vertical ? layout.height : -1
|
|
||||||
Layout.preferredHeight: layout.homogenous && layout.vertical ? layout.width : -1
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OccupiedBg {
|
OccupiedBg {
|
||||||
id: occupied
|
|
||||||
|
|
||||||
opacity: BarConfig.workspaces.occupiedBg ? 1 : 0
|
opacity: BarConfig.workspaces.occupiedBg ? 1 : 0
|
||||||
vertical: root.vertical
|
vertical: root.vertical
|
||||||
workspaces: root.workspaces
|
workspaces: root.workspaces
|
||||||
|
occupied: root.occupied
|
||||||
layout: layout
|
layout: layout
|
||||||
|
|
||||||
Behavior on opacity {
|
Behavior on opacity {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue