IPC/OSD: deprecate showText(withIcon) call.

This commit is contained in:
Lemmy
2026-01-07 12:07:32 -05:00
parent 016320846f
commit 5dfd76e568
3 changed files with 22 additions and 121 deletions
+19 -109
View File
@@ -19,8 +19,7 @@ Variants {
Volume,
InputVolume,
Brightness,
LockKey,
CustomText
LockKey
}
model: Quickshell.screens.filter(screen => (Settings.data.osd.monitors.includes(screen.name) || Settings.data.osd.monitors.length === 0) && Settings.data.osd.enabled)
@@ -36,8 +35,6 @@ Variants {
property int currentOSDType: -1 // OSD.Type enum value, -1 means none
property bool startupComplete: false
property real currentBrightness: 0
property string customText: ""
property string customIcon: ""
// Lock Key States
property string lastLockKeyChanged: "" // "caps", "num", "scroll", or ""
@@ -81,8 +78,6 @@ Variants {
return currentBrightness <= 0.5 ? "brightness-low" : "brightness-high";
case OSD.Type.LockKey:
return "keyboard";
case OSD.Type.CustomText:
return root.customIcon || "info-circle";
default:
return "";
}
@@ -98,8 +93,6 @@ Variants {
return currentBrightness;
case OSD.Type.LockKey:
return 1.0; // Always show 100% when showing lock key status
case OSD.Type.CustomText:
return 1.0;
default:
return 0;
}
@@ -117,9 +110,6 @@ Variants {
// For lock keys, return the pre-determined status text
return lastLockKeyChanged;
}
if (currentOSDType === OSD.Type.CustomText) {
return customText;
}
const value = getCurrentValue();
const max = getMaxValue();
@@ -154,9 +144,6 @@ Variants {
return LockKeysService.scrollLockOn ? Color.mPrimary : Color.mOnSurfaceVariant;
}
}
if (currentOSDType === OSD.Type.CustomText) {
return Color.mPrimary;
}
return Color.mPrimary;
}
@@ -241,25 +228,6 @@ Variants {
}
}
// Signal Connections
Connections {
target: OSDService
function onShowCustomText(text, icon) {
root.customText = text;
if (icon && root.validIcons.has(icon)) {
root.customIcon = icon;
} else {
if (icon) {
Logger.w("OSD", "Invalid custom icon name received: '" + icon + "'. Falling back to default.");
}
root.customIcon = "info-circle";
}
showOSD(OSD.Type.CustomText);
}
}
// AudioService monitoring
Connections {
target: AudioService
@@ -372,19 +340,8 @@ Variants {
wrapMode: Text.NoWrap
}
NText {
id: customTextMetrics
visible: false
text: root.customText
pointSize: Style.fontSizeM
family: Settings.data.ui.fontFixed
font.weight: Style.fontWeightMedium
elide: Text.ElideNone
wrapMode: Text.NoWrap
}
// Dimensions
readonly property bool isShortMode: root.currentOSDType === OSD.Type.LockKey || root.currentOSDType === OSD.Type.CustomText
readonly property bool isShortMode: root.currentOSDType === OSD.Type.LockKey
readonly property int longHWidth: Math.round(320 * Style.uiScaleRatio)
readonly property int longHHeight: Math.round(72 * Style.uiScaleRatio)
readonly property int shortHWidth: Math.round(180 * Style.uiScaleRatio)
@@ -392,25 +349,6 @@ Variants {
readonly property int longVHeight: Math.round(280 * Style.uiScaleRatio)
readonly property int shortVHeight: Math.round(180 * Style.uiScaleRatio)
// Dynamic width for horizontal custom text based on text length
readonly property int customTextHWidth: {
if (root.currentOSDType !== OSD.Type.CustomText || verticalMode) {
return shortHWidth;
}
const textWidth = Math.ceil(customTextMetrics.contentWidth || 0);
if (textWidth === 0) {
// Fallback if measurement not ready
return longHWidth;
}
const iconWidth = Style.fontSizeXL * Style.uiScaleRatio;
const margins = Style.marginL * 2; // Left and right content margins
const spacing = Style.marginM; // Spacing between icon and text
const bgMargins = Style.marginM * 1.5 * 2; // Background margins
const totalWidth = textWidth + iconWidth + margins + spacing + bgMargins;
// Ensure minimum width and add some buffer
return Math.max(shortHWidth, Math.round(totalWidth * 1.1));
}
// Dynamic width for horizontal lock keys based on text length
// Explicitly bind to contentWidth to ensure reactivity
readonly property int lockKeyHWidth: {
@@ -472,27 +410,6 @@ Variants {
return Math.max(shortVHeight, Math.round(totalHeight * 1.1));
}
readonly property int customTextVHeight: {
if (root.currentOSDType !== OSD.Type.CustomText || !verticalMode) {
return shortVHeight;
}
const text = root.customText;
const charCount = text ? text.length : 0;
if (charCount === 0) {
return shortVHeight;
}
const fontSize = Style.fontSizeM * Settings.data.ui.fontFixedScale * Style.uiScaleRatio;
const charHeight = fontSize * 1.3;
const textHeight = charCount * charHeight;
const bgMargins = Style.marginM * 1.5 * 2;
const contentMargins = Style.marginL * 2;
const iconSize = Style.fontSizeXL * Style.uiScaleRatio * 1.8;
const textIconSpacing = Style.marginM;
const buffer = Style.marginL;
const totalHeight = textHeight + bgMargins + contentMargins + iconSize + textIconSpacing + buffer;
return Math.max(shortVHeight, Math.round(totalHeight * 1.1));
}
readonly property int barThickness: {
const base = Math.max(8, Math.round(8 * Style.uiScaleRatio));
return base % 2 === 0 ? base : base + 1;
@@ -521,8 +438,8 @@ Variants {
margins.left: calculateMargin(anchors.left, "left")
margins.right: calculateMargin(anchors.right, "right")
implicitWidth: verticalMode ? longVWidth : (root.currentOSDType === OSD.Type.CustomText ? customTextHWidth : (isShortMode ? lockKeyHWidth : longHWidth))
implicitHeight: verticalMode ? (root.currentOSDType === OSD.Type.CustomText ? customTextVHeight : (isShortMode ? lockKeyVHeight : longVHeight)) : longHHeight
implicitWidth: verticalMode ? longVWidth : (isShortMode ? lockKeyHWidth : longHWidth)
implicitHeight: verticalMode ? (isShortMode ? lockKeyVHeight : longVHeight) : longHHeight
color: "transparent"
WlrLayershell.namespace: "noctalia-osd-" + (screen?.name || "unknown")
@@ -564,8 +481,6 @@ Variants {
osdItem.visible = false;
root.currentOSDType = -1;
root.lastLockKeyChanged = "";
root.customText = "";
root.customIcon = "";
root.active = false;
}
}
@@ -628,9 +543,9 @@ Variants {
}
}
// Lock Key or Custom Status Text (replaces progress bar)
// Lock Key Status Text (replaces progress bar)
NText {
visible: root.currentOSDType === OSD.Type.LockKey || root.currentOSDType === OSD.Type.CustomText
visible: root.currentOSDType === OSD.Type.LockKey
text: root.getDisplayPercentage()
color: root.getProgressColor()
pointSize: Style.fontSizeM
@@ -644,7 +559,7 @@ Variants {
// Progress Bar for Volume/Brightness
Rectangle {
visible: root.currentOSDType !== OSD.Type.LockKey && root.currentOSDType !== OSD.Type.CustomText
visible: root.currentOSDType !== OSD.Type.LockKey
Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter
height: panel.barThickness
@@ -676,7 +591,7 @@ Variants {
// Percentage Text for Volume/Brightness
NText {
visible: root.currentOSDType !== OSD.Type.LockKey && root.currentOSDType !== OSD.Type.CustomText
visible: root.currentOSDType !== OSD.Type.LockKey
text: root.getDisplayPercentage()
color: Color.mOnSurface
pointSize: Style.fontSizeS
@@ -698,12 +613,12 @@ Variants {
anchors.fill: parent
anchors.topMargin: Style.marginL
anchors.bottomMargin: Style.marginL
spacing: root.currentOSDType === OSD.Type.LockKey || root.currentOSDType === OSD.Type.CustomText ? Style.marginM : Style.marginS
clip: root.currentOSDType !== OSD.Type.LockKey && root.currentOSDType !== OSD.Type.CustomText
spacing: root.currentOSDType === OSD.Type.LockKey ? Style.marginM : Style.marginS
clip: root.currentOSDType !== OSD.Type.LockKey
ColumnLayout {
id: textVerticalLayout
visible: root.currentOSDType === OSD.Type.LockKey || root.currentOSDType === OSD.Type.CustomText
visible: root.currentOSDType === OSD.Type.LockKey
Layout.fillWidth: true
Layout.fillHeight: false
Layout.alignment: Qt.AlignHCenter
@@ -729,13 +644,8 @@ Variants {
textVerticalLayout.updateVerticalTextChars();
}
}
function onCustomTextChanged() {
if (root.currentOSDType === OSD.Type.CustomText) {
textVerticalLayout.updateVerticalTextChars();
}
}
function onCurrentOSDTypeChanged() {
if (root.currentOSDType === OSD.Type.LockKey || root.currentOSDType === OSD.Type.CustomText) {
if (root.currentOSDType === OSD.Type.LockKey) {
textVerticalLayout.updateVerticalTextChars();
}
}
@@ -763,7 +673,7 @@ Variants {
}
NText {
visible: root.currentOSDType !== OSD.Type.LockKey && root.currentOSDType !== OSD.Type.CustomText
visible: root.currentOSDType !== OSD.Type.LockKey
text: root.getDisplayPercentage()
color: Color.mOnSurface
pointSize: Style.fontSizeS
@@ -777,9 +687,9 @@ Variants {
}
Item {
visible: root.currentOSDType !== OSD.Type.LockKey && root.currentOSDType !== OSD.Type.CustomText
visible: root.currentOSDType !== OSD.Type.LockKey
Layout.fillWidth: true
Layout.fillHeight: root.currentOSDType !== OSD.Type.LockKey && root.currentOSDType !== OSD.Type.CustomText
Layout.fillHeight: root.currentOSDType !== OSD.Type.LockKey
Rectangle {
anchors.horizontalCenter: parent.horizontalCenter
@@ -816,10 +726,10 @@ Variants {
NIcon {
icon: root.getIcon()
color: root.getIconColor()
pointSize: root.currentOSDType === OSD.Type.LockKey || root.currentOSDType === OSD.Type.CustomText ? Style.fontSizeXL : Style.fontSizeL
Layout.alignment: root.currentOSDType === OSD.Type.LockKey || root.currentOSDType === OSD.Type.CustomText ? Qt.AlignHCenter : (Qt.AlignHCenter | Qt.AlignBottom)
Layout.preferredHeight: root.currentOSDType === OSD.Type.LockKey || root.currentOSDType === OSD.Type.CustomText ? (Style.fontSizeXL * Style.uiScaleRatio * 1.5) : -1
Layout.minimumHeight: root.currentOSDType === OSD.Type.LockKey || root.currentOSDType === OSD.Type.CustomText ? (Style.fontSizeXL * Style.uiScaleRatio) : 0
pointSize: root.currentOSDType === OSD.Type.LockKey ? Style.fontSizeXL : Style.fontSizeL
Layout.alignment: root.currentOSDType === OSD.Type.LockKey ? Qt.AlignHCenter : (Qt.AlignHCenter | Qt.AlignBottom)
Layout.preferredHeight: root.currentOSDType === OSD.Type.LockKey ? (Style.fontSizeXL * Style.uiScaleRatio * 1.5) : -1
Layout.minimumHeight: root.currentOSDType === OSD.Type.LockKey ? (Style.fontSizeXL * Style.uiScaleRatio) : 0
Behavior on color {
ColorAnimation {