From 4088c13eec49527b8997bf7cc72ac6c6dbcfaf1b Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Fri, 14 Nov 2025 13:27:54 +0100 Subject: [PATCH 1/8] AudioService: preserve input value (fixes 0% volume after suspend... hopefully) autoformat --- Services/Media/AudioService.qml | 8 ++++---- Services/Theming/TemplateProcessor.qml | 2 +- Services/Theming/TemplateRegistry.qml | 3 +-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Services/Media/AudioService.qml b/Services/Media/AudioService.qml index 60526eb3..9cb25a78 100644 --- a/Services/Media/AudioService.qml +++ b/Services/Media/AudioService.qml @@ -53,12 +53,12 @@ Singleton { var vol = source.audio.volume if (vol !== undefined && !isNaN(vol)) { root._inputVolume = vol - } else { - root._inputVolume = 0 } + // Don't reset to 0 if volume is undefined/NaN - preserve last known value root._inputMuted = !!source.audio.muted } else { - root._inputVolume = 0 + // Don't reset volume to 0 when source is unavailable - preserve last known value + // Only reset muted state root._inputMuted = true } } @@ -102,7 +102,7 @@ Singleton { function onVolumeChanged() { var vol = source?.audio?.volume if (vol === undefined || isNaN(vol)) { - root._inputVolume = 0 + // Don't reset to 0 if volume is undefined/NaN - preserve last known value return } // Only update if the value actually changed to prevent spurious signals diff --git a/Services/Theming/TemplateProcessor.qml b/Services/Theming/TemplateProcessor.qml index 9992bf1b..ba0400f1 100644 --- a/Services/Theming/TemplateProcessor.qml +++ b/Services/Theming/TemplateProcessor.qml @@ -235,7 +235,7 @@ Singleton { const templatePath = `${Quickshell.shellDir}/Assets/MatugenTemplates/${codeApp.input}` const outputPath = client.path.replace("~", homeDir) const outputDir = outputPath.substring(0, outputPath.lastIndexOf('/')) - + // Extract base config directory for checking var baseConfigDir = "" if (client.name === "code") { diff --git a/Services/Theming/TemplateRegistry.qml b/Services/Theming/TemplateRegistry.qml index 24da2974..2a9d2e6b 100644 --- a/Services/Theming/TemplateRegistry.qml +++ b/Services/Theming/TemplateRegistry.qml @@ -142,8 +142,7 @@ Singleton { "path": "~/.config/Vencord", "requiresThemesFolder": false }] - }, - { + }, { "id": "code", "name": "VSCode", "category": "applications", From 1573b5f128a5a3616b0d3c2c18d19a517a1783a9 Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Fri, 14 Nov 2025 13:31:41 +0100 Subject: [PATCH 2/8] OSD: fix initial input volume osd --- Modules/OSD/OSD.qml | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/Modules/OSD/OSD.qml b/Modules/OSD/OSD.qml index d444bdca..e54dc5a8 100644 --- a/Modules/OSD/OSD.qml +++ b/Modules/OSD/OSD.qml @@ -39,6 +39,7 @@ Variants { readonly property real currentInputVolume: AudioService.inputVolume readonly property bool isInputMuted: AudioService.inputMuted property bool inputAudioInitialized: false + property real lastKnownInputVolume: -1 // Track last known volume to detect actual changes // Brightness properties property real lastUpdatedBrightness: 0 @@ -509,20 +510,36 @@ Variants { } function onInputVolumeChanged() { - if (!inputAudioInitialized) { - return - } if (!AudioService.hasInput) { return } - showOSD("inputVolume") + // Capture initial volume on first change to avoid showing OSD on startup + if (lastKnownInputVolume < 0) { + lastKnownInputVolume = AudioService.inputVolume + inputAudioInitialized = true + return + } + if (!inputAudioInitialized) { + return + } + // Only show OSD if volume actually changed from last known value + if (Math.abs(AudioService.inputVolume - lastKnownInputVolume) > 0.001) { + lastKnownInputVolume = AudioService.inputVolume + showOSD("inputVolume") + } } function onInputMutedChanged() { - if (!inputAudioInitialized) { + if (!AudioService.hasInput) { return } - if (!AudioService.hasInput) { + // Capture initial state on first change to avoid showing OSD on startup + if (lastKnownInputVolume < 0) { + lastKnownInputVolume = AudioService.inputVolume + inputAudioInitialized = true + return + } + if (!inputAudioInitialized) { return } showOSD("inputVolume") @@ -537,7 +554,7 @@ Variants { onTriggered: { volumeInitialized = true muteInitialized = true - inputAudioInitialized = true + // Input volume initializes on first change to avoid showing OSD on startup // Brightness initializes on first change to avoid showing OSD on startup connectBrightnessMonitors() } From f64a2fae4e637b4aa797bf42df3f3976480f73f8 Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Fri, 14 Nov 2025 13:54:59 +0100 Subject: [PATCH 3/8] OSD: fix initial output volume osd --- Modules/OSD/OSD.qml | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/Modules/OSD/OSD.qml b/Modules/OSD/OSD.qml index e54dc5a8..b30122b2 100644 --- a/Modules/OSD/OSD.qml +++ b/Modules/OSD/OSD.qml @@ -34,6 +34,7 @@ Variants { readonly property bool isMuted: AudioService.muted property bool volumeInitialized: false property bool muteInitialized: false + property real lastKnownVolume: -1 // Track last known volume to detect actual changes // Input volume properties readonly property real currentInputVolume: AudioService.inputVolume @@ -498,15 +499,33 @@ Variants { target: AudioService function onVolumeChanged() { - if (volumeInitialized) { + // Capture initial volume on first change to avoid showing OSD on startup + if (lastKnownVolume < 0) { + lastKnownVolume = AudioService.volume + volumeInitialized = true + return + } + if (!volumeInitialized) { + return + } + // Only show OSD if volume actually changed from last known value + if (Math.abs(AudioService.volume - lastKnownVolume) > 0.001) { + lastKnownVolume = AudioService.volume showOSD("volume") } } function onMutedChanged() { - if (muteInitialized) { - showOSD("volume") + // Capture initial muted state on first change to avoid showing OSD on startup + if (lastKnownVolume < 0) { + lastKnownVolume = AudioService.volume + muteInitialized = true + return } + if (!muteInitialized) { + return + } + showOSD("volume") } function onInputVolumeChanged() { @@ -552,9 +571,7 @@ Variants { interval: 500 running: true onTriggered: { - volumeInitialized = true - muteInitialized = true - // Input volume initializes on first change to avoid showing OSD on startup + // Volume and input volume initialize on first change to avoid showing OSD on startup // Brightness initializes on first change to avoid showing OSD on startup connectBrightnessMonitors() } From 4129b4755940ca64666a391e833eec8c70941ff6 Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Fri, 14 Nov 2025 14:00:12 +0100 Subject: [PATCH 4/8] OSD: fix output OSD logic --- Modules/OSD/OSD.qml | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Modules/OSD/OSD.qml b/Modules/OSD/OSD.qml index b30122b2..6b5938de 100644 --- a/Modules/OSD/OSD.qml +++ b/Modules/OSD/OSD.qml @@ -499,7 +499,7 @@ Variants { target: AudioService function onVolumeChanged() { - // Capture initial volume on first change to avoid showing OSD on startup + // If not initialized yet, capture initial volume silently (fallback if timer hasn't fired) if (lastKnownVolume < 0) { lastKnownVolume = AudioService.volume volumeInitialized = true @@ -516,7 +516,7 @@ Variants { } function onMutedChanged() { - // Capture initial muted state on first change to avoid showing OSD on startup + // If not initialized yet, capture initial state silently (fallback if timer hasn't fired) if (lastKnownVolume < 0) { lastKnownVolume = AudioService.volume muteInitialized = true @@ -532,7 +532,7 @@ Variants { if (!AudioService.hasInput) { return } - // Capture initial volume on first change to avoid showing OSD on startup + // If not initialized yet, capture initial volume silently (fallback if timer hasn't fired) if (lastKnownInputVolume < 0) { lastKnownInputVolume = AudioService.inputVolume inputAudioInitialized = true @@ -552,7 +552,7 @@ Variants { if (!AudioService.hasInput) { return } - // Capture initial state on first change to avoid showing OSD on startup + // If not initialized yet, capture initial state silently (fallback if timer hasn't fired) if (lastKnownInputVolume < 0) { lastKnownInputVolume = AudioService.inputVolume inputAudioInitialized = true @@ -571,7 +571,16 @@ Variants { interval: 500 running: true onTriggered: { - // Volume and input volume initialize on first change to avoid showing OSD on startup + // Capture initial volume values to avoid showing OSD on startup + if (lastKnownVolume < 0 && AudioService.volume !== undefined) { + lastKnownVolume = AudioService.volume + volumeInitialized = true + } + if (lastKnownInputVolume < 0 && AudioService.hasInput && AudioService.inputVolume !== undefined) { + lastKnownInputVolume = AudioService.inputVolume + inputAudioInitialized = true + } + muteInitialized = true // Brightness initializes on first change to avoid showing OSD on startup connectBrightnessMonitors() } From a32d999e46a9b1ca78cf7389cf35ba1961d34593 Mon Sep 17 00:00:00 2001 From: ItsLemmy Date: Fri, 14 Nov 2025 09:26:17 -0500 Subject: [PATCH 5/8] SmartPaneWindow: unload when not in use --- Modules/MainScreen/SmartPanel.qml | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/Modules/MainScreen/SmartPanel.qml b/Modules/MainScreen/SmartPanel.qml index 7574beeb..fda4c738 100644 --- a/Modules/MainScreen/SmartPanel.qml +++ b/Modules/MainScreen/SmartPanel.qml @@ -43,8 +43,8 @@ Item { // Support close with escape property bool closeWithEscape: true - // Track if window has been created (for lazy loading) - property bool windowCreated: false + // Track if window should be active (for lazy loading and cleanup) + property bool windowActive: false // Expose panel state (from content window) readonly property bool isPanelOpen: windowLoader.item ? windowLoader.item.isPanelOpen : false @@ -77,8 +77,8 @@ Item { // Public control functions function toggle(buttonItem, buttonName) { // Ensure window is created before toggling - if (!windowCreated) { - windowCreated = true + if (!root.windowActive) { + root.windowActive = true Qt.callLater(function () { if (windowLoader.item) { windowLoader.item.toggle(buttonItem, buttonName) @@ -91,8 +91,8 @@ Item { function open(buttonItem, buttonName) { // Ensure window is created before opening - if (!windowCreated) { - windowCreated = true + if (!root.windowActive) { + root.windowActive = true Qt.callLater(function () { if (windowLoader.item) { windowLoader.item.open(buttonItem, buttonName) @@ -143,10 +143,10 @@ Item { parent: root.parent } - // Lazy-load the content window (only created on first open) + // Lazy-load the content window (only created when open, destroyed when closed) Loader { id: windowLoader - active: root.windowCreated + active: root.windowActive sourceComponent: SmartPanelWindow { placeholder: panelPlaceholder panelContent: root.panelContent @@ -156,7 +156,13 @@ Item { // Forward signals onPanelOpened: root.opened() - onPanelClosed: root.closed() + onPanelClosed: { + root.closed() + // Destroy the window after close animation completes + Qt.callLater(function () { + root.windowActive = false + }) + } } } From 717ea441b09c704cc61bc5ed7f49bce3c9ac0b9a Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Fri, 14 Nov 2025 15:40:26 +0100 Subject: [PATCH 6/8] Settings: cleanup --- Assets/settings-default.json | 8 +----- Commons/Settings.qml | 47 ++++++++++++++++++------------------ 2 files changed, 25 insertions(+), 30 deletions(-) diff --git a/Assets/settings-default.json b/Assets/settings-default.json index 320adebc..e8ca2ab8 100644 --- a/Assets/settings-default.json +++ b/Assets/settings-default.json @@ -297,13 +297,7 @@ "walker": false, "code": false, "spicetify": false, - "enableUserTemplates": false, - "discord_vesktop": false, - "discord_webcord": false, - "discord_armcord": false, - "discord_equibop": false, - "discord_lightcord": false, - "discord_dorion": false + "enableUserTemplates": false }, "nightLight": { "enabled": false, diff --git a/Commons/Settings.qml b/Commons/Settings.qml index d03d3a8b..56161540 100644 --- a/Commons/Settings.qml +++ b/Commons/Settings.qml @@ -438,17 +438,6 @@ Singleton { property bool code: false property bool spicetify: false property bool enableUserTemplates: false - - property bool code_code: false - property bool code_codium: false - - property bool discord_vesktop: false // To be deleted soon - property bool discord_webcord: false // To be deleted soon - property bool discord_armcord: false // To be deleted soon - property bool discord_equibop: false // To be deleted soon - property bool discord_lightcord: false // To be deleted soon - property bool discord_dorion: false // To be deleted soon - property bool discord_vencord: false // To be deleted soon } // night light @@ -658,22 +647,34 @@ Singleton { // 5th. Migrate Discord templates (version 20 → 21) // Consolidate individual discord_* properties into unified discord property if (adapter.settingsVersion < 21) { - var anyDiscordEnabled = false + // Read raw JSON file to access properties not in adapter schema + try { + var rawJson = settingsFileView.text() - // Check if any Discord client was enabled - const discordClients = ["discord_vesktop", "discord_webcord", "discord_armcord", "discord_equibop", "discord_lightcord", "discord_dorion", "discord_vencord"] + if (rawJson) { + var parsed = JSON.parse(rawJson) + var anyDiscordEnabled = false - for (var i = 0; i < discordClients.length; i++) { - if (adapter.templates[discordClients[i]]) { - anyDiscordEnabled = true - break + // Check if any Discord client was enabled + const discordClients = ["discord_vesktop", "discord_webcord", "discord_armcord", "discord_equibop", "discord_lightcord", "discord_dorion", "discord_vencord"] + + if (parsed.templates) { + for (var i = 0; i < discordClients.length; i++) { + if (parsed.templates[discordClients[i]]) { + anyDiscordEnabled = true + break + } + } + } + + // Set unified discord property + adapter.templates.discord = anyDiscordEnabled + + Logger.i("Settings", "Migrated Discord templates to unified 'discord' property (enabled:", anyDiscordEnabled + ")") } + } catch (error) { + Logger.w("Settings", "Failed to read raw JSON for Discord migration:", error) } - - // Set unified discord property - adapter.templates.discord = anyDiscordEnabled - - Logger.i("Settings", "Migrated Discord templates to unified 'discord' property (enabled:", anyDiscordEnabled + ")") } // ----------------- From 0eb82bce98faeebe5599fcd407c008599fcab61b Mon Sep 17 00:00:00 2001 From: ItsLemmy Date: Fri, 14 Nov 2025 10:00:20 -0500 Subject: [PATCH 7/8] SmartPanel: Tighter sizing by using the minimum size. --- Modules/MainScreen/PanelPlaceholder.qml | 42 ++++ Modules/MainScreen/SmartPanelWindow.qml | 282 +++++++++++++----------- 2 files changed, 200 insertions(+), 124 deletions(-) diff --git a/Modules/MainScreen/PanelPlaceholder.qml b/Modules/MainScreen/PanelPlaceholder.qml index af50d4c4..3cd68d85 100644 --- a/Modules/MainScreen/PanelPlaceholder.qml +++ b/Modules/MainScreen/PanelPlaceholder.qml @@ -56,6 +56,48 @@ Item { // Expose panelBackground as panelItem for AllBackgrounds readonly property var panelItem: panelBackground + // Primary anchor edge for window positioning + readonly property string primaryAnchorEdge: { + if (effectivePanelAnchorTop) + return "top" + if (effectivePanelAnchorBottom) + return "bottom" + if (effectivePanelAnchorLeft) + return "left" + if (effectivePanelAnchorRight) + return "right" + return "top" + // default + } + + // Calculate window margins for content-sized panel windows + function getWindowMargins() { + if (!root.width || !root.height) + return { + "top": 0, + "bottom": 0, + "left": 0, + "right": 0 + } + + // Determine which edges are anchored (matching SmartPanelWindow logic) + var isPrimaryVertical = primaryAnchorEdge === "top" || primaryAnchorEdge === "bottom" + var isPrimaryHorizontal = primaryAnchorEdge === "left" || primaryAnchorEdge === "right" + + // Anchor the primary edge + opposite edges of the other axis + var useTop = effectivePanelAnchorTop || primaryAnchorEdge === "top" || isPrimaryHorizontal + var useBottom = effectivePanelAnchorBottom || primaryAnchorEdge === "bottom" || isPrimaryHorizontal + var useLeft = effectivePanelAnchorLeft || primaryAnchorEdge === "left" || isPrimaryVertical + var useRight = effectivePanelAnchorRight || primaryAnchorEdge === "right" || isPrimaryVertical + + return { + "top": useTop ? panelBackground.targetY : 0, + "bottom": useBottom ? (root.height - panelBackground.targetY - panelBackground.targetHeight) : 0, + "left": useLeft ? panelBackground.targetX : 0, + "right": useRight ? (root.width - panelBackground.targetX - panelBackground.targetWidth) : 0 + } + } + // Bar configuration readonly property string barPosition: Settings.data.bar.position readonly property bool barIsVertical: barPosition === "left" || barPosition === "right" diff --git a/Modules/MainScreen/SmartPanelWindow.qml b/Modules/MainScreen/SmartPanelWindow.qml index 40a52a90..2023abdb 100644 --- a/Modules/MainScreen/SmartPanelWindow.qml +++ b/Modules/MainScreen/SmartPanelWindow.qml @@ -48,6 +48,10 @@ PanelWindow { property bool closeWatchdogActive: false property bool openWatchdogActive: false + // Cached window size (only update when content size changes, not during animation) + property real cachedWindowWidth: 0 + property real cachedWindowHeight: 0 + // Signals signal panelOpened signal panelClosed @@ -57,18 +61,44 @@ PanelWindow { mask: null // No mask - content window is rectangular visible: isPanelOpen - // Wayland layer shell configuration - fullscreen window + // Wayland layer shell configuration - content-sized window WlrLayershell.layer: WlrLayer.Top WlrLayershell.namespace: "noctalia-panel-content-" + placeholder.panelName + "-" + (placeholder.screen?.name || "unknown") WlrLayershell.exclusionMode: ExclusionMode.Ignore WlrLayershell.keyboardFocus: !root.isPanelOpen ? WlrKeyboardFocus.None : (exclusiveKeyboard ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.OnDemand) - // Anchor to all edges to make fullscreen - anchors { - top: true - bottom: true - left: true - right: true + // Dynamic anchoring based on panel position + // For correct positioning with Wayland layer shell: + // - Anchor the primary edge (top/bottom/left/right) + // - Also anchor the opposite edge of the OTHER axis (both horizontal edges if panel is vertical, both vertical edges if panel is horizontal) + // This prevents unwanted centering and allows margins to position the panel correctly + readonly property bool isPrimaryVertical: placeholder.primaryAnchorEdge === "top" || placeholder.primaryAnchorEdge === "bottom" + readonly property bool isPrimaryHorizontal: placeholder.primaryAnchorEdge === "left" || placeholder.primaryAnchorEdge === "right" + + anchors.top: placeholder.effectivePanelAnchorTop || placeholder.primaryAnchorEdge === "top" || isPrimaryHorizontal + anchors.bottom: placeholder.effectivePanelAnchorBottom || placeholder.primaryAnchorEdge === "bottom" || isPrimaryHorizontal + anchors.left: placeholder.effectivePanelAnchorLeft || placeholder.primaryAnchorEdge === "left" || isPrimaryVertical + anchors.right: placeholder.effectivePanelAnchorRight || placeholder.primaryAnchorEdge === "right" || isPrimaryVertical + + // Size to content (cached to avoid resizing during animations) + implicitWidth: cachedWindowWidth + implicitHeight: cachedWindowHeight + + // Position via margins (calculated from target position, not animated position) + readonly property var windowMargins: placeholder.getWindowMargins() + margins.top: windowMargins.top + margins.bottom: windowMargins.bottom + margins.left: windowMargins.left + margins.right: windowMargins.right + + // Debug logging for positioning + Component.onCompleted: { + Logger.d("SmartPanelWindow", "Panel positioning:", placeholder.panelName) + Logger.d("SmartPanelWindow", " primaryAnchorEdge:", placeholder.primaryAnchorEdge) + Logger.d("SmartPanelWindow", " isPrimaryVertical:", isPrimaryVertical, "isPrimaryHorizontal:", isPrimaryHorizontal) + Logger.d("SmartPanelWindow", " anchors:", anchors.top, anchors.bottom, anchors.left, anchors.right) + Logger.d("SmartPanelWindow", " margins (TLBR):", windowMargins.top, windowMargins.left, windowMargins.bottom, windowMargins.right) + Logger.d("SmartPanelWindow", " size:", cachedWindowWidth, "x", cachedWindowHeight) } // Sync state to placeholder @@ -82,6 +112,19 @@ PanelWindow { placeholder.opacityFadeComplete = opacityFadeComplete } + // Update cached window size (only when target size changes) + function updateWindowSize() { + var targetWidth = placeholder.panelItem.targetWidth + var targetHeight = placeholder.panelItem.targetHeight + + // Only update if size actually changed + if (cachedWindowWidth !== targetWidth || cachedWindowHeight !== targetHeight) { + cachedWindowWidth = targetWidth + cachedWindowHeight = targetHeight + Logger.d("SmartPanelWindow", "Window size updated:", targetWidth, "x", targetHeight, placeholder.panelName) + } + } + // Panel control functions function toggle(buttonItem, buttonName) { if (!isPanelOpen) { @@ -110,6 +153,9 @@ PanelWindow { placeholder.useButtonPosition = false } + // Initialize cached window size + updateWindowSize() + // Set isPanelOpen to trigger content loading isPanelOpen = true @@ -164,12 +210,13 @@ PanelWindow { Logger.d("SmartPanelWindow", "Panel close finalized", placeholder.panelName) } - // Fullscreen container for click-to-close and content + // Content wrapper with opacity animation (fills content-sized window) Item { + id: contentWrapper anchors.fill: parent - focus: true // Enable keyboard event handling + focus: true - // Handle keyboard events directly via Keys handler + // Keyboard event handling Keys.onPressed: event => { Logger.d("SmartPanelWindow", "Key pressed:", event.key, "for panel:", placeholder.panelName) if (event.key === Qt.Key_Escape) { @@ -228,143 +275,120 @@ PanelWindow { } } - // Background MouseArea for click-to-close (behind content) - MouseArea { - anchors.fill: parent - enabled: root.isPanelOpen && !root.isClosing - acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton - onClicked: mouse => { - root.close() - mouse.accepted = true - } - z: 0 + // Opacity animation + opacity: { + if (isClosing) + return 0.0 + if (isPanelVisible && sizeAnimationComplete) + return 1.0 + return 0.0 } - // Content wrapper with opacity animation - Item { - id: contentWrapper - // Position at placeholder location within fullscreen window - x: placeholder.panelItem.x - y: placeholder.panelItem.y - width: placeholder.panelItem.width - height: placeholder.panelItem.height - z: 1 // Above click-to-close MouseArea + Behavior on opacity { + NumberAnimation { + id: opacityAnimation + duration: root.isClosing ? Style.animationFaster : Style.animationFast + easing.type: Easing.OutQuad - // Opacity animation - opacity: { - if (isClosing) - return 0.0 - if (isPanelVisible && sizeAnimationComplete) - return 1.0 - return 0.0 - } - - Behavior on opacity { - NumberAnimation { - id: opacityAnimation - duration: root.isClosing ? Style.animationFaster : Style.animationFast - easing.type: Easing.OutQuad - - onRunningChanged: { - // Safety: Zero-duration animation handling - if (!running && duration === 0) { - if (root.isClosing && contentWrapper.opacity === 0.0) { - root.opacityFadeComplete = true - var shouldFinalizeNow = placeholder.panelItem && !placeholder.panelItem.shouldAnimateWidth && !placeholder.panelItem.shouldAnimateHeight - if (shouldFinalizeNow) { - Logger.d("SmartPanelWindow", "Zero-duration opacity + no size animation - finalizing", placeholder.panelName) - Qt.callLater(root.finalizeClose) - } - } else if (root.isPanelVisible && contentWrapper.opacity === 1.0) { - root.openWatchdogActive = false - openWatchdogTimer.stop() - } - return - } - - // When opacity fade completes during close, trigger size animation - if (!running && root.isClosing && contentWrapper.opacity === 0.0) { + onRunningChanged: { + // Safety: Zero-duration animation handling + if (!running && duration === 0) { + if (root.isClosing && contentWrapper.opacity === 0.0) { root.opacityFadeComplete = true var shouldFinalizeNow = placeholder.panelItem && !placeholder.panelItem.shouldAnimateWidth && !placeholder.panelItem.shouldAnimateHeight if (shouldFinalizeNow) { - Logger.d("SmartPanelWindow", "No animation - finalizing immediately", placeholder.panelName) + Logger.d("SmartPanelWindow", "Zero-duration opacity + no size animation - finalizing", placeholder.panelName) Qt.callLater(root.finalizeClose) - } else { - Logger.d("SmartPanelWindow", "Animation will run - waiting for size animation", placeholder.panelName) } - } // When opacity fade completes during open, stop watchdog - else if (!running && root.isPanelVisible && contentWrapper.opacity === 1.0) { + } else if (root.isPanelVisible && contentWrapper.opacity === 1.0) { root.openWatchdogActive = false openWatchdogTimer.stop() } + return } - } - } - // Panel content loader - Loader { - id: contentLoader - active: isPanelOpen - anchors.fill: parent - sourceComponent: root.panelContent - - // When content finishes loading, trigger positioning and visibility - onLoaded: { - // Capture initial content-driven size if available - if (contentLoader.item) { - var hasWidthProp = contentLoader.item.hasOwnProperty('contentPreferredWidth') - var hasHeightProp = contentLoader.item.hasOwnProperty('contentPreferredHeight') - - if (hasWidthProp || hasHeightProp) { - var initialWidth = hasWidthProp ? contentLoader.item.contentPreferredWidth : 0 - var initialHeight = hasHeightProp ? contentLoader.item.contentPreferredHeight : 0 - placeholder.updateContentSize(initialWidth, initialHeight) - Logger.d("SmartPanelWindow", "Initial content size:", initialWidth, "x", initialHeight, placeholder.panelName) + // When opacity fade completes during close, trigger size animation + if (!running && root.isClosing && contentWrapper.opacity === 0.0) { + root.opacityFadeComplete = true + var shouldFinalizeNow = placeholder.panelItem && !placeholder.panelItem.shouldAnimateWidth && !placeholder.panelItem.shouldAnimateHeight + if (shouldFinalizeNow) { + Logger.d("SmartPanelWindow", "No animation - finalizing immediately", placeholder.panelName) + Qt.callLater(root.finalizeClose) + } else { + Logger.d("SmartPanelWindow", "Animation will run - waiting for size animation", placeholder.panelName) } + } // When opacity fade completes during open, stop watchdog + else if (!running && root.isPanelVisible && contentWrapper.opacity === 1.0) { + root.openWatchdogActive = false + openWatchdogTimer.stop() } - - // Calculate position in placeholder - placeholder.setPosition() - - // Make panel visible on the next frame - Qt.callLater(function () { - root.isPanelVisible = true - opacityTrigger.start() - - // Start open watchdog timer - root.openWatchdogActive = true - openWatchdogTimer.start() - - panelOpened() - }) } } + } - // MouseArea to prevent clicks on panel content from closing it - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton - onClicked: mouse => { - mouse.accepted = true // Eat the click to prevent propagation to background - } - z: -1 // Behind content but above background click-to-close - } + // Panel content loader + Loader { + id: contentLoader + active: isPanelOpen + anchors.fill: parent + sourceComponent: root.panelContent - // Watch for changes in content-driven sizes - Connections { - target: contentLoader.item - ignoreUnknownSignals: true + // When content finishes loading, trigger positioning and visibility + onLoaded: { + // Capture initial content-driven size if available + if (contentLoader.item) { + var hasWidthProp = contentLoader.item.hasOwnProperty('contentPreferredWidth') + var hasHeightProp = contentLoader.item.hasOwnProperty('contentPreferredHeight') - function onContentPreferredWidthChanged() { - if (root.isPanelOpen && root.isPanelVisible && contentLoader.item) { - placeholder.updateContentSize(contentLoader.item.contentPreferredWidth, placeholder.contentPreferredHeight) + if (hasWidthProp || hasHeightProp) { + var initialWidth = hasWidthProp ? contentLoader.item.contentPreferredWidth : 0 + var initialHeight = hasHeightProp ? contentLoader.item.contentPreferredHeight : 0 + placeholder.updateContentSize(initialWidth, initialHeight) + Logger.d("SmartPanelWindow", "Initial content size:", initialWidth, "x", initialHeight, placeholder.panelName) } } - function onContentPreferredHeightChanged() { - if (root.isPanelOpen && root.isPanelVisible && contentLoader.item) { - placeholder.updateContentSize(placeholder.contentPreferredWidth, contentLoader.item.contentPreferredHeight) - } + // Calculate position in placeholder + placeholder.setPosition() + + // Make panel visible on the next frame + Qt.callLater(function () { + root.isPanelVisible = true + opacityTrigger.start() + + // Start open watchdog timer + root.openWatchdogActive = true + openWatchdogTimer.start() + + panelOpened() + }) + } + } + + // MouseArea to prevent clicks on panel content from closing it + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton + onClicked: mouse => { + mouse.accepted = true // Eat the click to prevent propagation to background + } + z: -1 // Behind content but above background click-to-close + } + + // Watch for changes in content-driven sizes + Connections { + target: contentLoader.item + ignoreUnknownSignals: true + + function onContentPreferredWidthChanged() { + if (root.isPanelOpen && root.isPanelVisible && contentLoader.item) { + placeholder.updateContentSize(contentLoader.item.contentPreferredWidth, placeholder.contentPreferredHeight) + } + } + + function onContentPreferredHeightChanged() { + if (root.isPanelOpen && root.isPanelVisible && contentLoader.item) { + placeholder.updateContentSize(placeholder.contentPreferredWidth, contentLoader.item.contentPreferredHeight) } } } @@ -416,6 +440,16 @@ PanelWindow { Connections { target: placeholder.panelItem + function onTargetWidthChanged() { + // Update cached window size when target changes (not during animation) + root.updateWindowSize() + } + + function onTargetHeightChanged() { + // Update cached window size when target changes (not during animation) + root.updateWindowSize() + } + function onWidthChanged() { // When width shrinks to 0 during close and we're animating width, finalize if (root.isClosing && placeholder.panelItem.width === 0 && placeholder.panelItem.shouldAnimateWidth) { From a0dcd97aa637489bdfed2c39e06b037c80dae43c Mon Sep 17 00:00:00 2001 From: ItsLemmy Date: Fri, 14 Nov 2025 10:11:57 -0500 Subject: [PATCH 8/8] TrayMenu: minimal fade-in animation when appearing. --- Modules/Bar/Extras/TrayMenu.qml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Modules/Bar/Extras/TrayMenu.qml b/Modules/Bar/Extras/TrayMenu.qml index f4e17e78..e0831f7a 100644 --- a/Modules/Bar/Extras/TrayMenu.qml +++ b/Modules/Bar/Extras/TrayMenu.qml @@ -122,6 +122,16 @@ PopupWindow { border.color: Color.mOutline border.width: Math.max(1, Style.borderS) radius: Style.radiusM + + // Fade-in animation + opacity: root.visible ? 1.0 : 0.0 + + Behavior on opacity { + NumberAnimation { + duration: Style.animationNormal + easing.type: Easing.OutQuad + } + } } Flickable { @@ -131,6 +141,16 @@ PopupWindow { contentHeight: columnLayout.implicitHeight interactive: true + // Fade-in animation + opacity: root.visible ? 1.0 : 0.0 + + Behavior on opacity { + NumberAnimation { + duration: Style.animationNormal + easing.type: Easing.OutQuad + } + } + // Use a ColumnLayout to handle menu item arrangement ColumnLayout { id: columnLayout