1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-07 14:05:38 -05:00

Add 3 workspace indicators by default

This commit is contained in:
purian23
2025-07-21 01:20:10 -04:00
parent 92908b6e0e
commit 5189a34d40

View File

@@ -1,4 +1,5 @@
import QtQuick import QtQuick
import QtQuick.Controls
import Quickshell import Quickshell
import qs.Common import qs.Common
import qs.Services import qs.Services
@@ -8,7 +9,15 @@ Rectangle {
property string screenName: "" property string screenName: ""
property int currentWorkspace: getDisplayActiveWorkspace() property int currentWorkspace: getDisplayActiveWorkspace()
property var workspaceList: getDisplayWorkspaces() property var workspaceList: padWorkspaces(getDisplayWorkspaces())
function padWorkspaces(list) {
var padded = list.slice();
while (padded.length < 3) {
padded.push(-1); // Use -1 as a placeholder
}
return padded;
}
function getDisplayWorkspaces() { function getDisplayWorkspaces() {
if (!NiriWorkspaceService.niriAvailable || NiriWorkspaceService.allWorkspaces.length === 0) if (!NiriWorkspaceService.niriAvailable || NiriWorkspaceService.allWorkspaces.length === 0)
@@ -51,7 +60,7 @@ Rectangle {
Connections { Connections {
function onAllWorkspacesChanged() { function onAllWorkspacesChanged() {
root.workspaceList = root.getDisplayWorkspaces(); root.workspaceList = padWorkspaces(root.getDisplayWorkspaces());
root.currentWorkspace = root.getDisplayActiveWorkspace(); root.currentWorkspace = root.getDisplayActiveWorkspace();
} }
@@ -61,7 +70,7 @@ Rectangle {
function onNiriAvailableChanged() { function onNiriAvailableChanged() {
if (NiriWorkspaceService.niriAvailable) { if (NiriWorkspaceService.niriAvailable) {
root.workspaceList = root.getDisplayWorkspaces(); root.workspaceList = padWorkspaces(root.getDisplayWorkspaces());
root.currentWorkspace = root.getDisplayActiveWorkspace(); root.currentWorkspace = root.getDisplayActiveWorkspace();
} }
} }
@@ -80,33 +89,46 @@ Rectangle {
Rectangle { Rectangle {
property bool isActive: modelData === root.currentWorkspace property bool isActive: modelData === root.currentWorkspace
property bool isPlaceholder: modelData === -1
property bool isHovered: mouseArea.containsMouse property bool isHovered: mouseArea.containsMouse
property int sequentialNumber: index + 1 property int sequentialNumber: index + 1
width: isActive ? Theme.spacingXL + Theme.spacingM : Theme.spacingL + Theme.spacingXS width: isActive ? Theme.spacingXL + Theme.spacingM : Theme.spacingL + Theme.spacingXS
height: Theme.spacingL height: Theme.spacingL
radius: height / 2 radius: height / 2
color: isActive ? Theme.primary : isHovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.5) : Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.3) color: isActive ? Theme.primary : isPlaceholder ? Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.12) : isHovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.5) : Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.3)
MouseArea { MouseArea {
id: mouseArea id: mouseArea
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
enabled: !isPlaceholder
onClicked: { onClicked: {
if (!isPlaceholder) {
Quickshell.execDetached(["niri", "msg", "action", "focus-workspace", (modelData - 1).toString()]); Quickshell.execDetached(["niri", "msg", "action", "focus-workspace", (modelData - 1).toString()]);
} }
} }
}
// Only show index if enabled in preferences // Show index for placeholders if Prefs.showWorkspaceIndex is true, otherwise show a subtle dot
Text { Text {
visible: Prefs.showWorkspaceIndex visible: Prefs.showWorkspaceIndex
anchors.centerIn: parent anchors.centerIn: parent
text: sequentialNumber text: isPlaceholder ? sequentialNumber : sequentialNumber
color: Theme.surfaceText color: isPlaceholder ? Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.3) : Theme.surfaceText
font.pixelSize: Theme.fontSizeMedium font.pixelSize: Theme.fontSizeMedium
font.bold: isActive font.bold: isActive && !isPlaceholder
}
// If not showing index, show a subtle dot for placeholders
Rectangle {
visible: isPlaceholder && !Prefs.showWorkspaceIndex
anchors.centerIn: parent
width: Theme.spacingXS
height: Theme.spacingXS
radius: Theme.spacingXS / 2
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.18)
} }
Behavior on width { Behavior on width {
@@ -114,7 +136,6 @@ Rectangle {
duration: Theme.mediumDuration duration: Theme.mediumDuration
easing.type: Theme.emphasizedEasing easing.type: Theme.emphasizedEasing
} }
} }
Behavior on color { Behavior on color {
@@ -122,11 +143,8 @@ Rectangle {
duration: Theme.mediumDuration duration: Theme.mediumDuration
easing.type: Theme.emphasizedEasing easing.type: Theme.emphasizedEasing
} }
}
} }
}
} }
} }