66 lines
2.1 KiB
QML
66 lines
2.1 KiB
QML
import Quickshell
|
|
import Quickshell.Io
|
|
import Quickshell.Hyprland
|
|
import QtQuick
|
|
import QtQuick.Layouts
|
|
|
|
// Mirrors eww workspaces-widget / workspace-btn
|
|
Item {
|
|
id: root
|
|
property var workspaces: []
|
|
|
|
implicitHeight: row.implicitHeight
|
|
implicitWidth: row.implicitWidth
|
|
|
|
RowLayout {
|
|
id: row
|
|
spacing: 10
|
|
|
|
Repeater {
|
|
model: root.workspaces
|
|
|
|
// workspace-btn equivalent
|
|
Rectangle {
|
|
id: wsBtn
|
|
required property var modelData
|
|
|
|
readonly property bool active: modelData.active ?? false
|
|
readonly property bool urgent: modelData.urgent ?? false
|
|
readonly property bool empty: modelData.empty ?? false
|
|
|
|
implicitWidth: Math.max(label.implicitWidth + 16,
|
|
modelData.pxwidth ?? 28)
|
|
implicitHeight: 22
|
|
radius: 4
|
|
|
|
color: active ? "#89b4fa" // blue active
|
|
: urgent ? "#f38ba8" // red urgent
|
|
: empty ? "transparent" // ghost empty
|
|
: "#313244" // normal
|
|
|
|
border.color: empty && !active ? "#585b70" : "transparent"
|
|
border.width: empty && !active ? 1 : 0
|
|
|
|
Text {
|
|
id: label
|
|
anchors.centerIn: parent
|
|
text: wsBtn.modelData.label ?? ""
|
|
color: wsBtn.active ? "#1e1e2e" : "#cdd6f4"
|
|
font.pixelSize: 12
|
|
font.family: "monospace"
|
|
}
|
|
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
onClicked: {
|
|
var proc = Qt.createQmlObject(
|
|
'import Quickshell.Io; Process { command: ["hyprctl","dispatch","workspace","' +
|
|
wsBtn.modelData.id + '"]; running: true }',
|
|
wsBtn)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|