From 0f888fd734775c7d218c745af29b4dcddff7c9eb Mon Sep 17 00:00:00 2001 From: ItsLemmy Date: Thu, 25 Sep 2025 08:49:01 -0400 Subject: [PATCH] MediaMini: autoHide --- Assets/Translations/en.json | 3 ++- Modules/Bar/Widgets/MediaMini.qml | 15 +++++++++--- .../Bar/WidgetSettings/MediaMiniSettings.qml | 9 +++++++ Services/BarWidgetRegistry.qml | 5 ++-- Widgets/NDateTimeTokens.qml | 24 +++++++------------ 5 files changed, 33 insertions(+), 23 deletions(-) diff --git a/Assets/Translations/en.json b/Assets/Translations/en.json index 74ee7cbe..8a84e472 100644 --- a/Assets/Translations/en.json +++ b/Assets/Translations/en.json @@ -774,8 +774,8 @@ "search-placeholder": "Search widgets..." }, "active-window": { - "show-app-icon": "Show app icon", "auto-hide": "Hide automatically", + "show-app-icon": "Show app icon", "scrolling-mode": "Scrolling mode" }, "system-monitor": { @@ -867,6 +867,7 @@ } }, "media-mini": { + "auto-hide": "Hide automatically", "show-album-art": "Show album art", "show-visualizer": "Show visualizer", "visualizer-type": "Visualizer type", diff --git a/Modules/Bar/Widgets/MediaMini.qml b/Modules/Bar/Widgets/MediaMini.qml index ec64b654..002fc67c 100644 --- a/Modules/Bar/Widgets/MediaMini.qml +++ b/Modules/Bar/Widgets/MediaMini.qml @@ -33,6 +33,7 @@ Item { readonly property string barPosition: Settings.data.bar.position readonly property bool compact: (Settings.data.bar.density === "compact") + readonly property bool autoHide: (widgetSettings.autoHide !== undefined) ? widgetSettings.autoHide : widgetMetadata.autoHide readonly property bool showAlbumArt: (widgetSettings.showAlbumArt !== undefined) ? widgetSettings.showAlbumArt : widgetMetadata.showAlbumArt readonly property bool showVisualizer: (widgetSettings.showVisualizer !== undefined) ? widgetSettings.showVisualizer : widgetMetadata.showVisualizer readonly property string visualizerType: (widgetSettings.visualizerType !== undefined && widgetSettings.visualizerType !== "") ? widgetSettings.visualizerType : widgetMetadata.visualizerType @@ -41,6 +42,17 @@ Item { // Fixed width - no expansion readonly property real widgetWidth: Math.max(1, screen.width * 0.06) + implicitHeight: visible ? ((barPosition === "left" || barPosition === "right") ? calculatedVerticalHeight() : Math.round(Style.barHeight * scaling)) : 0 + implicitWidth: visible ? ((barPosition === "left" || barPosition === "right") ? Math.round(Style.baseWidgetSize * 0.8 * scaling) : (widgetWidth * scaling)) : 0 + + opacity: !autoHide || getTitle() !== "" ? 1.0 : 0 + Behavior on opacity { + NumberAnimation { + duration: Style.animationNormal + easing.type: Easing.OutCubic + } + } + function getTitle() { return MediaService.trackTitle + (MediaService.trackArtist !== "" ? ` - ${MediaService.trackArtist}` : "") } @@ -49,9 +61,6 @@ Item { return Math.round(Style.baseWidgetSize * 0.8 * scaling) } - implicitHeight: visible ? ((barPosition === "left" || barPosition === "right") ? calculatedVerticalHeight() : Math.round(Style.barHeight * scaling)) : 0 - implicitWidth: visible ? ((barPosition === "left" || barPosition === "right") ? Math.round(Style.baseWidgetSize * 0.8 * scaling) : (widgetWidth * scaling)) : 0 - // A hidden text element to safely measure the full title width NText { id: fullTitleMetrics diff --git a/Modules/Settings/Bar/WidgetSettings/MediaMiniSettings.qml b/Modules/Settings/Bar/WidgetSettings/MediaMiniSettings.qml index c5b68456..d2391434 100644 --- a/Modules/Settings/Bar/WidgetSettings/MediaMiniSettings.qml +++ b/Modules/Settings/Bar/WidgetSettings/MediaMiniSettings.qml @@ -14,6 +14,7 @@ ColumnLayout { property var widgetMetadata: null // Local state + property bool valueAutoHide: widgetData.autoHide !== undefined ? widgetData.autoHide : widgetMetadata.autoHide property bool valueShowAlbumArt: widgetData.showAlbumArt !== undefined ? widgetData.showAlbumArt : widgetMetadata.showAlbumArt property bool valueShowVisualizer: widgetData.showVisualizer !== undefined ? widgetData.showVisualizer : widgetMetadata.showVisualizer property string valueVisualizerType: widgetData.visualizerType || widgetMetadata.visualizerType @@ -21,6 +22,7 @@ ColumnLayout { function saveSettings() { var settings = Object.assign({}, widgetData || {}) + settings.autoHide = valueAutoHide settings.showAlbumArt = valueShowAlbumArt settings.showVisualizer = valueShowVisualizer settings.visualizerType = valueVisualizerType @@ -28,6 +30,13 @@ ColumnLayout { return settings } + NToggle { + Layout.fillWidth: true + label: I18n.tr("bar.widget-settings.media-mini.auto-hide") + checked: root.valueAutoHide + onToggled: checked => root.valueAutoHide = checked + } + NToggle { label: I18n.tr("bar.widget-settings.media-mini.show-album-art") checked: valueShowAlbumArt diff --git a/Services/BarWidgetRegistry.qml b/Services/BarWidgetRegistry.qml index 3073f570..d9fa14e4 100644 --- a/Services/BarWidgetRegistry.qml +++ b/Services/BarWidgetRegistry.qml @@ -81,12 +81,11 @@ Singleton { }, "MediaMini": { "allowUserSettings": true, - "hideAutomatically": false, + "autoHide": true, "scrollingMode": "hover", "showAlbumArt": false, "showVisualizer": false, - "visualizerType": "linear", - "autoHide": false + "visualizerType": "linear" }, "Microphone": { "allowUserSettings": true, diff --git a/Widgets/NDateTimeTokens.qml b/Widgets/NDateTimeTokens.qml index 89fe8961..523e74f0 100644 --- a/Widgets/NDateTimeTokens.qml +++ b/Widgets/NDateTimeTokens.qml @@ -66,8 +66,7 @@ Rectangle { "token": "ddd, MMM dd", "description": I18n.tr("widgets.datetime-tokens.common.weekday-date"), "example": "Fri, Dec 12" - }, - // Hour tokens + }, // Hour tokens { "category": "Hour", "token": "H", @@ -78,8 +77,7 @@ Rectangle { "token": "HH", "description": I18n.tr("widgets.datetime-tokens.hour.leading-zero"), "example": "14" - }, - // Minute tokens + }, // Minute tokens { "category": "Minute", "token": "m", @@ -90,8 +88,7 @@ Rectangle { "token": "mm", "description": I18n.tr("widgets.datetime-tokens.minute.leading-zero"), "example": "30" - }, - // Second tokens + }, // Second tokens { "category": "Second", "token": "s", @@ -102,8 +99,7 @@ Rectangle { "token": "ss", "description": I18n.tr("widgets.datetime-tokens.second.leading-zero"), "example": "45" - }, - // AM/PM tokens + }, // AM/PM tokens { "category": "AM/PM", "token": "AP", @@ -114,15 +110,13 @@ Rectangle { "token": "ap", "description": I18n.tr("widgets.datetime-tokens.ampm.lowercase"), "example": "pm" - }, - // Timezone tokens + }, // Timezone tokens { "category": "Timezone", "token": "t", "description": I18n.tr("widgets.datetime-tokens.timezone.abbreviation"), "example": "UTC" - }, - // Year tokens + }, // Year tokens { "category": "Year", "token": "yy", @@ -133,8 +127,7 @@ Rectangle { "token": "yyyy", "description": I18n.tr("widgets.datetime-tokens.year.four-digit"), "example": "2023" - }, - // Month tokens + }, // Month tokens { "category": "Month", "token": "M", @@ -155,8 +148,7 @@ Rectangle { "token": "MMMM", "description": I18n.tr("widgets.datetime-tokens.month.full"), "example": "December" - }, - // Day tokens + }, // Day tokens { "category": "Day", "token": "d",