Merge pull request #777 from MrDowntempo/fix/BetterWorkspaceWidget

Fix/better workspace widget and TaskbarGrouped
This commit is contained in:
Lemmy
2025-11-16 20:50:32 -05:00
committed by GitHub
4 changed files with 41 additions and 18 deletions
+3 -2
View File
@@ -329,7 +329,8 @@ Item {
topMargin: -Style.fontSizeXS * 0.5
}
width: Math.max(workspaceNumber.implicitWidth + Style.marginXS, Style.fontSizeXXS * 2)
// Doube width margin necessary here for Name or Name+Index, but double height not needed.
width: Math.max(workspaceNumber.implicitWidth + (Style.marginXS * 2), Style.fontSizeXXS * 2)
height: Math.max(workspaceNumber.implicitHeight + Style.marginXS, Style.fontSizeXXS * 2)
Rectangle {
@@ -392,7 +393,7 @@ Item {
return workspaceModel.name.substring(0, root.characterCount)
}
if (root.labelMode === "index+name") {
return (workspaceModel.idx.toString() + " " + workspaceModel.name.substring(0, root.characterCount))
return (workspaceModel.idx.toString() + workspaceModel.name.substring(0, 1))
}
}
return workspaceModel.idx.toString()
+32 -15
View File
@@ -71,15 +71,24 @@ Item {
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);
// Don't calculate text width if labels are off
if (labelMode === "none") {
return d * factor;
}
return d * factor;
var displayText = ws.idx.toString();
if (ws.name && ws.name.length > 0) {
if (root.labelMode === "name") {
displayText = ws.name.substring(0, characterCount);
} else if (root.labelMode === "index+name") {
displayText = ws.idx.toString() + " " + ws.name.substring(0, characterCount);
}
}
const textWidth = displayText.length * (d * 0.4); // Approximate width per character
const padding = d * 0.6;
return Math.max(d * factor, textWidth + padding);
}
function getWorkspaceHeight(ws) {
@@ -289,11 +298,15 @@ Item {
x: (pill.width - width) / 2
y: (pill.height - height) / 2 + (height - contentHeight) / 2
text: {
if (labelMode === "name" && model.name && model.name.length > 0) {
return model.name.substring(0, characterCount);
} else {
return model.idx.toString();
if (model.name && model.name.length > 0) {
if (root.labelMode === "name") {
return model.name.substring(0, characterCount);
}
if (root.labelMode === "index+name") {
return (model.idx.toString() + " " + model.name.substring(0, characterCount))
}
}
return model.idx.toString();
}
family: Settings.data.ui.fontFixed
pointSize: model.isActive ? workspacePillContainer.height * 0.45 : workspacePillContainer.height * 0.42
@@ -434,11 +447,15 @@ Item {
x: (pillVertical.width - width) / 2
y: (pillVertical.height - height) / 2 + (height - contentHeight) / 2
text: {
if (labelMode === "name" && model.name && model.name.length > 0) {
return model.name.substring(0, characterCount);
} else {
return model.idx.toString();
if (model.name && model.name.length > 0) {
if (root.labelMode === "name") {
return model.name.substring(0, characterCount);
}
if (root.labelMode === "index+name") {
return (model.idx.toString() + model.name.substring(0, 1))
}
}
return model.idx.toString();
}
family: Settings.data.ui.fontFixed
pointSize: model.isActive ? workspacePillContainerVertical.width * 0.45 : workspacePillContainerVertical.width * 0.42
@@ -44,7 +44,8 @@ ColumnLayout {
{
"key": "name",
"name": I18n.tr("options.workspace-labels.name")
}, {
},
{
"key": "index+name",
"name": I18n.tr("options.workspace-labels.index+name")
}]
@@ -40,6 +40,10 @@ ColumnLayout {
{
"key": "name",
"name": I18n.tr("options.workspace-labels.name")
},
{
"key": "index+name",
"name": I18n.tr("options.workspace-labels.index+name")
}
]
currentKey: widgetData.labelMode || widgetMetadata.labelMode