89 lines
1.8 KiB
QML
89 lines
1.8 KiB
QML
pragma ComponentBehavior: Bound
|
|
import QtQuick
|
|
import QtQuick.Layouts
|
|
import Quickshell
|
|
import Quickshell.Hyprland
|
|
|
|
import "../Color.js" as Colors
|
|
import "../Components/"
|
|
import "../Services/"
|
|
|
|
Container {
|
|
id: root
|
|
|
|
property double barHeight: 25
|
|
required property HyprlandMonitor monitor
|
|
property double rowLeftMargin: 5
|
|
property double workspaceButtonSpacing: 4
|
|
property double workspaceCount: WorkspaceManager.getNumberOfWorkspaces(monitor)
|
|
property double workspaceWidth: 17
|
|
|
|
boxHeight: barHeight
|
|
boxRadius: 8
|
|
boxWidth: (2 * rowLeftMargin) + (workspaceCount * workspaceWidth) + ((workspaceCount - 1)
|
|
* workspaceButtonSpacing)
|
|
exclusiveMonitor: monitor
|
|
|
|
states: [
|
|
State {
|
|
name: "hovered"
|
|
when: root.hovered
|
|
|
|
PropertyChanges {
|
|
root.barHeight: 30
|
|
root.workspaceWidth: 25
|
|
}
|
|
}
|
|
]
|
|
|
|
RowLayout {
|
|
spacing: root.workspaceButtonSpacing
|
|
|
|
anchors {
|
|
bottom: parent.bottom
|
|
left: parent.left
|
|
leftMargin: root.rowLeftMargin
|
|
top: parent.top
|
|
}
|
|
|
|
Repeater {
|
|
delegate: workspaceButton
|
|
delegateModelAccess: DelegateModel.ReadOnly
|
|
model: WorkspaceManager.getWorkspacesForMonitor(root.exclusiveMonitor)
|
|
}
|
|
|
|
Component {
|
|
id: workspaceButton
|
|
|
|
Item {
|
|
id: buttonRoot
|
|
|
|
required property var modelData
|
|
property double stateInt: WorkspaceManager.getWorkspaceStateIndex(modelData)
|
|
property variant workspaceColors: [Colors.lavender, Colors.overlay2, Colors.surface2]
|
|
property string workspaceId: modelData.id
|
|
|
|
Layout.alignment: Qt.AlignLeft
|
|
height: root.barHeight - 7
|
|
implicitWidth: root.workspaceWidth
|
|
|
|
TapHandler {
|
|
id: tapHandler
|
|
|
|
onTapped: WorkspaceManager.activateWorkspaceById(buttonRoot.modelData.id)
|
|
}
|
|
|
|
Rectangle {
|
|
anchors.fill: parent
|
|
color: buttonRoot.workspaceColors[buttonRoot.stateInt]
|
|
radius: 4
|
|
|
|
CenteredText {
|
|
text: buttonRoot.modelData.id
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|