WorkspaceSettings: add setting to change the amount of characters displayed for name workspaces

Workspace: change pill width depending on characterCount
This commit is contained in:
lysec
2025-10-24 14:16:02 +02:00
parent c9d3aedf39
commit 612dc58ad8
10 changed files with 59 additions and 4 deletions
+4
View File
@@ -1057,6 +1057,10 @@
"hide-unoccupied": {
"label": "Unbesetzte ausblenden",
"description": "Arbeitsbereiche ohne Fenster nicht anzeigen."
},
"character-count": {
"label": "Zeichenanzahl",
"description": "Anzahl der Zeichen, die von Arbeitsbereichsnamen angezeigt werden (1-10)."
}
},
"microphone": {
+4
View File
@@ -1040,6 +1040,10 @@
"hide-unoccupied": {
"label": "Hide unoccupied",
"description": "Don't display workspaces without windows."
},
"character-count": {
"label": "Character count",
"description": "Number of characters to display from workspace names (1-10)."
}
},
"microphone": {
+4
View File
@@ -1040,6 +1040,10 @@
"hide-unoccupied": {
"label": "Ocultar desocupados",
"description": "No mostrar espacios de trabajo sin ventanas."
},
"character-count": {
"label": "Número de caracteres",
"description": "Número de caracteres a mostrar de los nombres de espacios de trabajo (1-10)."
}
},
"microphone": {
+4
View File
@@ -1040,6 +1040,10 @@
"hide-unoccupied": {
"label": "Masquer les inoccupés",
"description": "Ne pas afficher les espaces de travail sans fenêtres."
},
"character-count": {
"label": "Nombre de caractères",
"description": "Nombre de caractères à afficher des noms d'espaces de travail (1-10)."
}
},
"microphone": {
+4
View File
@@ -1040,6 +1040,10 @@
"hide-unoccupied": {
"label": "Ocultar desocupados",
"description": "Não exibir áreas de trabalho sem janelas."
},
"character-count": {
"label": "Número de caracteres",
"description": "Número de caracteres a exibir dos nomes de espaços de trabalho (1-10)."
}
},
"microphone": {
+4
View File
@@ -1040,6 +1040,10 @@
"hide-unoccupied": {
"label": "隐藏未占用",
"description": "不显示没有窗口的工作区。"
},
"character-count": {
"label": "字符数量",
"description": "显示工作区名称的字符数量(1-10)。"
}
},
"microphone": {
+2 -1
View File
@@ -24,7 +24,8 @@
],
"center": [
{
"id": "Workspace"
"id": "Workspace",
"characterCount": 2
}
],
"right": [
+12 -2
View File
@@ -44,6 +44,7 @@ Item {
readonly property string labelMode: (widgetSettings.labelMode !== undefined) ? widgetSettings.labelMode : widgetMetadata.labelMode
readonly property bool hideUnoccupied: (widgetSettings.hideUnoccupied !== undefined) ? widgetSettings.hideUnoccupied : widgetMetadata.hideUnoccupied
readonly property int characterCount: (widgetSettings.characterCount !== undefined) ? widgetSettings.characterCount : widgetMetadata.characterCount
property bool isDestroying: false
property bool hovered: false
@@ -68,6 +69,15 @@ Item {
function getWorkspaceWidth(ws) {
const d = Style.capsuleHeight * root.baseDimensionRatio
const factor = ws.isActive ? 2.2 : 1
// For name mode, calculate width based on actual text content
if (labelMode === "name" && ws.name && ws.name.length > 0) {
const displayText = ws.name.substring(0, characterCount)
const textWidth = displayText.length * (d * 0.4) // Approximate width per character
const padding = d * 0.6 // Padding on both sides
return Math.max(d * factor, textWidth + padding)
}
return d * factor
}
@@ -279,7 +289,7 @@ Item {
y: (pill.height - height) / 2 + (height - contentHeight) / 2
text: {
if (labelMode === "name" && model.name && model.name.length > 0) {
return model.name.substring(0, 2)
return model.name.substring(0, characterCount)
} else {
return model.idx.toString()
}
@@ -424,7 +434,7 @@ Item {
y: (pillVertical.height - height) / 2 + (height - contentHeight) / 2
text: {
if (labelMode === "name" && model.name && model.name.length > 0) {
return model.name.substring(0, 2)
return model.name.substring(0, characterCount)
} else {
return model.idx.toString()
}
@@ -17,6 +17,7 @@ ColumnLayout {
var settings = Object.assign({}, widgetData || {})
settings.labelMode = labelModeCombo.currentKey
settings.hideUnoccupied = hideUnoccupiedToggle.checked
settings.characterCount = characterCountSpinBox.value
return settings
}
@@ -47,4 +48,22 @@ ColumnLayout {
checked: widgetData.hideUnoccupied
onToggled: checked => hideUnoccupiedToggle.checked = checked
}
NSpinBox {
id: characterCountSpinBox
label: I18n.tr("bar.widget-settings.workspace.character-count.label")
description: I18n.tr("bar.widget-settings.workspace.character-count.description")
from: 1
to: 10
value: {
if (widgetData && widgetData.characterCount !== undefined) {
return widgetData.characterCount
}
if (widgetMetadata && widgetMetadata.characterCount !== undefined) {
return widgetMetadata.characterCount
}
return 2
}
visible: labelModeCombo.currentKey === "name"
}
}
+2 -1
View File
@@ -146,7 +146,8 @@ Singleton {
"Workspace": {
"allowUserSettings": true,
"labelMode": "index",
"hideUnoccupied": false
"hideUnoccupied": false,
"characterCount": 2
},
"Volume": {
"allowUserSettings": true,