make dwm-like setup with 10 workspaces per monitor
This commit is contained in:
parent
0f6bc633a5
commit
6fc103cf24
4 changed files with 142 additions and 65 deletions
|
|
@ -9,54 +9,67 @@ import qs.widgets
|
|||
import qs.settings
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
required property ShellScreen barScreen
|
||||
required property double moduleHeight
|
||||
property HyprlandMonitor hyprBarScreen: Hyprland.monitorFor(root.barScreen)
|
||||
radius: Config.rounding
|
||||
color: 'transparent'
|
||||
implicitWidth: wsLayout.implicitWidth
|
||||
implicitHeight: moduleHeight
|
||||
id: root
|
||||
required property ShellScreen barScreen
|
||||
required property double moduleHeight
|
||||
property HyprlandMonitor hyprBarScreen: Hyprland.monitorFor(root.barScreen)
|
||||
|
||||
RowLayout {
|
||||
id: wsLayout
|
||||
anchors.centerIn: root
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
spacing: 0
|
||||
Repeater {
|
||||
id: wsRepeater
|
||||
model: Hyprland.workspaces
|
||||
delegate: Rectangle {
|
||||
id: wsWrapper
|
||||
implicitHeight: root.moduleHeight
|
||||
implicitWidth: 16
|
||||
parent: wsLayout
|
||||
color: 'transparent'
|
||||
radius: Config.rounding
|
||||
visible: modelData.monitor == root.hyprBarScreen
|
||||
required property var modelData
|
||||
StyledText {
|
||||
anchors.centerIn: parent
|
||||
text: wsWrapper.modelData.id
|
||||
color: parent.modelData.active ? Colors.base0D : Colors.base04
|
||||
opacity: parent.modelData.active ? 1.0 : 0.5
|
||||
// split-monitor-workspaces numbering: each monitor owns `count` (10)
|
||||
// workspaces. eDP-1 -> ids 1..10, DP-2 -> ids 11..20. The offset is the
|
||||
// first id on this monitor, minus 1.
|
||||
property int wsIdOffset: root.barScreen.name != Config.primaryMon ? 10 : 0
|
||||
|
||||
radius: Config.rounding
|
||||
color: 'transparent'
|
||||
implicitWidth: wsLayout.implicitWidth
|
||||
implicitHeight: moduleHeight
|
||||
|
||||
RowLayout {
|
||||
id: wsLayout
|
||||
anchors.centerIn: root
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
spacing: 0
|
||||
Repeater {
|
||||
id: wsRepeater
|
||||
model: 10
|
||||
delegate: Rectangle {
|
||||
id: wsWrapper
|
||||
required property var modelData
|
||||
|
||||
property int wsId: root.wsIdOffset + modelData + 1
|
||||
|
||||
property var ws: {
|
||||
const vals = Hyprland.workspaces.values;
|
||||
for (let i = 0; i < vals.length; ++i) {
|
||||
if (vals[i].id === wsWrapper.wsId)
|
||||
return vals[i];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
property bool active: wsWrapper.ws ? wsWrapper.ws.active : false
|
||||
property bool vacant: !wsWrapper.ws || wsWrapper.ws.toplevels.values.length === 0
|
||||
|
||||
implicitHeight: root.moduleHeight
|
||||
implicitWidth: 16
|
||||
parent: wsLayout
|
||||
color: 'transparent'
|
||||
radius: Config.rounding
|
||||
|
||||
StyledText {
|
||||
anchors.centerIn: parent
|
||||
text: wsWrapper.modelData + 1
|
||||
color: wsWrapper.active ? Colors.base0D : Colors.base05
|
||||
opacity: wsWrapper.vacant ? wsWrapper.active ? 1.0 : 0.4 : 1.0
|
||||
}
|
||||
MouseArea {
|
||||
id: clickHandler
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.LeftButton
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: Hyprland.dispatch("workspace " + wsWrapper.wsId)
|
||||
}
|
||||
}
|
||||
}
|
||||
Behavior on implicitWidth {
|
||||
NumberAnimation {
|
||||
easing.type: Easing.InOutBack
|
||||
easing.amplitude: 2
|
||||
duration: 400
|
||||
easing.overshoot: 2
|
||||
}
|
||||
}
|
||||
MouseArea {
|
||||
id: clickHandler
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.LeftButton
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: parent.modelData.activate()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue