Merge pull request #1963 from tmarti2/use-ncolorchoice-in-workspace-settings

Use NColorCoice for workspace widget settings
This commit is contained in:
Lemmy
2026-02-25 08:47:06 -05:00
committed by GitHub
3 changed files with 17 additions and 107 deletions
+6 -23
View File
@@ -29,23 +29,6 @@ Item {
// Fixed dimension (cross-axis) for visual pill
readonly property real fixedDimension: Style.toOdd(capsuleHeight * baseDimensionRatio)
// Helper to safely get colors with proper reactivity
// Accesses Color singleton directly to ensure fresh values
function getColorPair(colorKey) {
switch (colorKey) {
case "primary":
return [Color.mPrimary, Color.mOnPrimary];
case "secondary":
return [Color.mSecondary, Color.mOnSecondary];
case "tertiary":
return [Color.mTertiary, Color.mOnTertiary];
case "onSurface":
return [Color.mOnSurface, Color.mSurface];
default:
return [Color.mPrimary, Color.mOnPrimary];
}
}
// Animated pill dimensions (for visual pill, not container)
property real pillWidth: isVertical ? fixedDimension : getWorkspaceWidth(workspace, false)
property real pillHeight: isVertical ? getWorkspaceHeight(workspace, false) : fixedDimension
@@ -102,12 +85,12 @@ Item {
if (pillMouseArea.containsMouse)
return Color.mHover;
if (workspace.isFocused)
return getColorPair(focusedColor)[0];
return Color.resolveColorKey(focusedColor);
if (workspace.isUrgent)
return Color.mError;
if (workspace.isOccupied)
return getColorPair(occupiedColor)[0];
return Qt.alpha(getColorPair(emptyColor)[0], 0.3);
return Color.resolveColorKey(occupiedColor);
return Qt.alpha(Color.resolveColorKey(emptyColor), 0.3);
}
Loader {
@@ -144,12 +127,12 @@ Item {
if (pillMouseArea.containsMouse)
return Color.mOnHover;
if (workspace.isFocused)
return getColorPair(focusedColor)[1];
return Color.resolveOnColorKey(focusedColor);
if (workspace.isUrgent)
return Color.mOnError;
if (workspace.isOccupied)
return getColorPair(occupiedColor)[1];
return getColorPair(emptyColor)[1];
return Color.resolveOnColorKey(occupiedColor);
return Color.resolveOnColorKey(emptyColor);
}
Behavior on color {
+6 -21
View File
@@ -68,21 +68,6 @@ Item {
readonly property string emptyColor: (widgetSettings.emptyColor !== undefined) ? widgetSettings.emptyColor : widgetMetadata.emptyColor
readonly property bool showBadge: (widgetSettings.showBadge !== undefined) ? widgetSettings.showBadge : widgetMetadata.showBadge
// Helper to safely get colors with proper reactivity
// Accesses Color singleton directly to ensure fresh values
function getColorPair(colorKey) {
switch (colorKey) {
case "primary":
return [Color.mPrimary, Color.mOnPrimary];
case "secondary":
return [Color.mSecondary, Color.mOnSecondary];
case "tertiary":
return [Color.mTertiary, Color.mOnTertiary];
default:
return [Color.mOnSurface, Color.mSurface];
}
}
// Only for grouped mode / show apps
readonly property int baseItemSize: Style.toOdd(capsuleHeight * 0.8)
readonly property int iconSize: Style.toOdd(baseItemSize * iconScale)
@@ -804,13 +789,13 @@ Item {
color: {
if (groupedContainer.workspaceModel.isFocused)
return root.getColorPair(root.focusedColor)[0];
return Color.resolveColorKey(root.focusedColor);
if (groupedContainer.workspaceModel.isUrgent)
return Color.mError;
if (groupedContainer.hasWindows)
return root.getColorPair(root.occupiedColor)[0];
return Color.resolveColorKey(root.occupiedColor);
return root.getColorPair(root.emptyColor)[0];
return Color.resolveColorKey(root.emptyColor);
}
scale: groupedContainer.workspaceModel.isActive ? 1.0 : 0.8
@@ -873,13 +858,13 @@ Item {
color: {
if (groupedContainer.workspaceModel.isFocused)
return root.getColorPair(root.focusedColor)[1];
return Color.resolveOnColorKey(root.focusedColor);
if (groupedContainer.workspaceModel.isUrgent)
return Color.mOnError;
if (groupedContainer.hasWindows)
return root.getColorPair(root.occupiedColor)[1];
return Color.resolveOnColorKey(root.occupiedColor);
return root.getColorPair(root.emptyColor)[1];
return Color.resolveOnColorKey(root.emptyColor);
}
Behavior on opacity {
@@ -105,6 +105,8 @@ ColumnLayout {
to: 1.0
stepSize: 0.01
value: valuePillSize
defaultValue: widgetMetadata.pillSize
showReset: true
onMoved: value => {
valuePillSize = value;
saveSettings();
@@ -238,93 +240,33 @@ ColumnLayout {
Layout.fillWidth: true
}
NComboBox {
id: focusedColorCombo
NColorChoice {
label: I18n.tr("bar.workspace.focused-color-label")
description: I18n.tr("bar.workspace.focused-color-description")
model: [
{
"key": "none",
"name": I18n.tr("common.none")
},
{
"key": "primary",
"name": I18n.tr("common.primary")
},
{
"key": "secondary",
"name": I18n.tr("common.secondary")
},
{
"key": "tertiary",
"name": I18n.tr("common.tertiary")
}
]
currentKey: valueFocusedColor
onSelected: key => {
valueFocusedColor = key;
saveSettings();
}
minimumWidth: 200
}
NComboBox {
id: occupiedColorCombo
NColorChoice {
label: I18n.tr("bar.workspace.occupied-color-label")
description: I18n.tr("bar.workspace.occupied-color-description")
model: [
{
"key": "none",
"name": I18n.tr("common.none")
},
{
"key": "primary",
"name": I18n.tr("common.primary")
},
{
"key": "secondary",
"name": I18n.tr("common.secondary")
},
{
"key": "tertiary",
"name": I18n.tr("common.tertiary")
}
]
currentKey: valueOccupiedColor
onSelected: key => {
valueOccupiedColor = key;
saveSettings();
}
minimumWidth: 200
}
NComboBox {
id: emptyColorCombo
NColorChoice {
label: I18n.tr("bar.workspace.empty-color-label")
description: I18n.tr("bar.workspace.empty-color-description")
model: [
{
"key": "none",
"name": I18n.tr("common.none")
},
{
"key": "primary",
"name": I18n.tr("common.primary")
},
{
"key": "secondary",
"name": I18n.tr("common.secondary")
},
{
"key": "tertiary",
"name": I18n.tr("common.tertiary")
}
]
currentKey: valueEmptyColor
onSelected: key => {
valueEmptyColor = key;
saveSettings();
}
minimumWidth: 200
}
}