From 3809f290ed5a7ccfa6dbe5a33a4024ba6068e163 Mon Sep 17 00:00:00 2001 From: ItsLemmy Date: Thu, 25 Sep 2025 08:42:10 -0400 Subject: [PATCH] ActiveWindow: better autohide --- Assets/Translations/en.json | 4 +- Modules/Bar/Widgets/ActiveWindow.qml | 15 ++++++-- .../WidgetSettings/ActiveWindowSettings.qml | 12 +++++- Services/BarWidgetRegistry.qml | 37 ++++++++++--------- 4 files changed, 46 insertions(+), 22 deletions(-) diff --git a/Assets/Translations/en.json b/Assets/Translations/en.json index d3adfd85..74ee7cbe 100644 --- a/Assets/Translations/en.json +++ b/Assets/Translations/en.json @@ -774,7 +774,9 @@ "search-placeholder": "Search widgets..." }, "active-window": { - "show-app-icon": "Show app icon" + "show-app-icon": "Show app icon", + "auto-hide": "Hide automatically", + "scrolling-mode": "Scrolling mode" }, "system-monitor": { "cpu-usage": "CPU usage", diff --git a/Modules/Bar/Widgets/ActiveWindow.qml b/Modules/Bar/Widgets/ActiveWindow.qml index a7890135..8a43014f 100644 --- a/Modules/Bar/Widgets/ActiveWindow.qml +++ b/Modules/Bar/Widgets/ActiveWindow.qml @@ -39,18 +39,27 @@ Item { // Widget settings - matching MediaMini pattern readonly property bool showIcon: (widgetSettings.showIcon !== undefined) ? widgetSettings.showIcon : widgetMetadata.showIcon + readonly property bool autoHide: (widgetSettings.autoHide !== undefined) ? widgetSettings.autoHide : widgetMetadata.autoHide readonly property string scrollingMode: (widgetSettings.scrollingMode !== undefined) ? widgetSettings.scrollingMode : (widgetMetadata.scrollingMode !== undefined ? widgetMetadata.scrollingMode : "hover") // Fixed width 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 || hasActiveWindow ? 1.0 : 0 + Behavior on opacity { + NumberAnimation { + duration: Style.animationNormal + easing.type: Easing.OutCubic + } + } + function calculatedVerticalHeight() { 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 - function getAppIcon() { try { // Try CompositorService first diff --git a/Modules/Settings/Bar/WidgetSettings/ActiveWindowSettings.qml b/Modules/Settings/Bar/WidgetSettings/ActiveWindowSettings.qml index 4f9fc6c0..c2ef8983 100644 --- a/Modules/Settings/Bar/WidgetSettings/ActiveWindowSettings.qml +++ b/Modules/Settings/Bar/WidgetSettings/ActiveWindowSettings.qml @@ -15,22 +15,32 @@ ColumnLayout { // Local state property bool valueShowIcon: widgetData.showIcon !== undefined ? widgetData.showIcon : widgetMetadata.showIcon + property bool valueAutoHide: widgetData.autoHide !== undefined ? widgetData.autoHide : widgetMetadata.autoHide property string valueScrollingMode: widgetData.scrollingMode || widgetMetadata.scrollingMode function saveSettings() { var settings = Object.assign({}, widgetData || {}) + settings.autoHide = valueAutoHide settings.showIcon = valueShowIcon settings.scrollingMode = valueScrollingMode + console.log(JSON.stringify(settings)) return settings } NToggle { - id: showIcon + Layout.fillWidth: true + label: I18n.tr("bar.widget-settings.active-window.auto-hide") + checked: root.valueAutoHide + onToggled: checked => root.valueAutoHide = checked + } + + NToggle { Layout.fillWidth: true label: I18n.tr("bar.widget-settings.active-window.show-app-icon") checked: root.valueShowIcon onToggled: checked => root.valueShowIcon = checked } + NComboBox { label: I18n.tr("bar.widget-settings.active-window.scrolling-mode") model: [{ diff --git a/Services/BarWidgetRegistry.qml b/Services/BarWidgetRegistry.qml index a0e0e765..3073f570 100644 --- a/Services/BarWidgetRegistry.qml +++ b/Services/BarWidgetRegistry.qml @@ -41,6 +41,7 @@ Singleton { "ActiveWindow": { "allowUserSettings": true, "showIcon": true, + "autoHide": true, "scrollingMode": "hover" }, "Battery": { @@ -59,6 +60,12 @@ Singleton { "formatHorizontal": "HH:mm ddd, MMM dd", "formatVertical": "HH mm - dd MM" }, + "ControlCenter": { + "allowUserSettings": true, + "useDistroLogo": false, + "icon": "noctalia", + "customIconPath": "" + }, "CustomButton": { "allowUserSettings": true, "icon": "heart", @@ -68,6 +75,19 @@ Singleton { "textCommand": "", "textIntervalMs": 3000 }, + "KeyboardLayout": { + "allowUserSettings": true, + "displayMode": "onhover" + }, + "MediaMini": { + "allowUserSettings": true, + "hideAutomatically": false, + "scrollingMode": "hover", + "showAlbumArt": false, + "showVisualizer": false, + "visualizerType": "linear", + "autoHide": false + }, "Microphone": { "allowUserSettings": true, "displayMode": "onhover" @@ -95,26 +115,9 @@ Singleton { "labelMode": "index", "hideUnoccupied": false }, - "MediaMini": { - "allowUserSettings": true, - "showAlbumArt": false, - "showVisualizer": false, - "visualizerType": "linear", - "scrollingMode": "hover" - }, - "ControlCenter": { - "allowUserSettings": true, - "useDistroLogo": false, - "icon": "noctalia", - "customIconPath": "" - }, "Volume": { "allowUserSettings": true, "displayMode": "onhover" - }, - "KeyboardLayout": { - "allowUserSettings": true, - "displayMode": "onhover" } })