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 {}
|
||||
|
||||
Workspaces {
|
||||
vertical: win.vertical
|
||||
}
|
||||
|
||||
Clock {
|
||||
vertical: win.vertical
|
||||
}
|
||||
|
|
@ -47,10 +51,6 @@ Variants {
|
|||
ActiveWindow {
|
||||
vertical: win.vertical
|
||||
}
|
||||
|
||||
Workspaces {
|
||||
vertical: win.vertical
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,13 +10,9 @@ BoxLayout {
|
|||
|
||||
required property bool vertical
|
||||
required property list<Label> workspaces
|
||||
required property var occupied
|
||||
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
|
||||
|
|
|
|||
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
|
||||
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 var occupied: Hyprland.workspaces.values.reduce((acc, curr) => {
|
||||
acc[curr.id] = curr.lastIpcObject.windows > 0;
|
||||
return acc;
|
||||
}, {})
|
||||
|
||||
implicitWidth: layout.implicitWidth
|
||||
implicitHeight: layout.implicitHeight
|
||||
|
|
@ -28,26 +36,18 @@ Item {
|
|||
Repeater {
|
||||
model: BarConfig.workspaces.shown
|
||||
|
||||
Label {
|
||||
required property int index
|
||||
readonly property bool isWorkspace: true
|
||||
|
||||
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
|
||||
Workspace {
|
||||
layout: layout
|
||||
occupied: root.occupied
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OccupiedBg {
|
||||
id: occupied
|
||||
|
||||
opacity: BarConfig.workspaces.occupiedBg ? 1 : 0
|
||||
vertical: root.vertical
|
||||
workspaces: root.workspaces
|
||||
occupied: root.occupied
|
||||
layout: layout
|
||||
|
||||
Behavior on opacity {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue