126 lines
3.9 KiB
QML
126 lines
3.9 KiB
QML
import QtQuick
|
|
import Quickshell
|
|
import QtQuick.Layouts
|
|
|
|
Item {
|
|
id: root
|
|
|
|
required property Theme theme
|
|
required property string workspaceName
|
|
required property int workspaceIndex
|
|
required property bool selected
|
|
required property bool current
|
|
required property var windows
|
|
|
|
signal activated
|
|
|
|
// Windows that fit before the "+N more" overflow.
|
|
readonly property var displayWindows: root.windows.slice(0, root.theme.maxWindowRows)
|
|
readonly property int hiddenCount: Math.max(0, root.windows.length - root.theme.maxWindowRows)
|
|
|
|
width: root.theme.cardWidth
|
|
height: root.theme.cardHeight
|
|
|
|
Glass {
|
|
anchors.fill: parent
|
|
theme: root.theme
|
|
radius: root.theme.cardRadius
|
|
tint: root.theme.cardBg
|
|
selected: root.selected
|
|
shadow: true
|
|
}
|
|
|
|
Column {
|
|
anchors.fill: parent
|
|
anchors.margins: root.theme.fieldPadding
|
|
spacing: 6
|
|
clip: true
|
|
|
|
// Top row: workspace name + index + current badge
|
|
RowLayout {
|
|
width: parent.width
|
|
spacing: 6
|
|
|
|
Text {
|
|
Layout.fillWidth: true
|
|
elide: Text.ElideRight
|
|
color: root.theme.textColor
|
|
font.pixelSize: root.theme.fontSize
|
|
text: root.workspaceName.length > 0 ? root.workspaceName : String(root.workspaceIndex)
|
|
}
|
|
|
|
Text {
|
|
visible: root.workspaceName.length > 0
|
|
color: root.theme.labelColor
|
|
font.pixelSize: root.theme.monitorLabelSize
|
|
text: String(root.workspaceIndex)
|
|
}
|
|
|
|
// A small yellow badge.
|
|
Rectangle {
|
|
visible: root.current
|
|
implicitWidth: currentText.implicitWidth + root.theme.pillPadding * 2
|
|
implicitHeight: currentText.implicitHeight + root.theme.pillPadding / 2
|
|
radius: height / 2
|
|
color: root.theme.accentColor
|
|
|
|
Text {
|
|
id: currentText
|
|
anchors.centerIn: parent
|
|
color: root.theme.accentText
|
|
font.pixelSize: root.theme.pillFontSize
|
|
font.bold: true
|
|
text: "current"
|
|
}
|
|
}
|
|
}
|
|
|
|
// Window bubbles
|
|
Column {
|
|
width: parent.width
|
|
spacing: root.theme.windowRowSpacing
|
|
|
|
Repeater {
|
|
model: root.displayWindows
|
|
|
|
Row {
|
|
width: parent.width
|
|
spacing: 6
|
|
|
|
Image {
|
|
width: root.theme.windowIconSize
|
|
height: root.theme.windowIconSize
|
|
source: Quickshell.iconPath(modelData.app.length > 0 ? modelData.app : "window")
|
|
sourceSize.width: root.theme.windowIconSize * 2
|
|
sourceSize.height: root.theme.windowIconSize * 2
|
|
fillMode: Image.PreserveAspectFit
|
|
smooth: true
|
|
}
|
|
|
|
Text {
|
|
width: parent.width - root.theme.windowIconSize - parent.spacing
|
|
height: root.theme.windowIconSize
|
|
verticalAlignment: Text.AlignVCenter
|
|
elide: Text.ElideRight
|
|
color: root.theme.labelColor
|
|
font.pixelSize: root.theme.windowFontSize
|
|
text: modelData.title.length > 0 ? modelData.title : "Untitled"
|
|
}
|
|
}
|
|
}
|
|
|
|
Text {
|
|
visible: root.hiddenCount > 0
|
|
color: root.theme.labelColor
|
|
font.pixelSize: root.theme.windowFontSize
|
|
text: "+" + root.hiddenCount + " more"
|
|
}
|
|
}
|
|
}
|
|
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
onClicked: root.activated()
|
|
}
|
|
}
|