fix(battery): apply panel settings from the widget that opened it#2517
Open
cyril-marpaud wants to merge 1 commit intonoctalia-dev:mainfrom
Open
fix(battery): apply panel settings from the widget that opened it#2517cyril-marpaud wants to merge 1 commit intonoctalia-dev:mainfrom
cyril-marpaud wants to merge 1 commit intonoctalia-dev:mainfrom
Conversation
When two Battery widgets were configured simultaneously, the panelID (which controls showPowerProfiles and showNoctaliaPerformance in the panel) was being overwritten by reactive QML bindings on both widget instances whenever isPanelOpen changed. This caused one widget's settings to consistently override the other's. Move the panelID write out of getBatteryPanel() (which was called from a reactive tooltipText binding) and into toggleBatteryPanel(), guarded by !panel.isPanelOpen so it only fires when actually opening the panel. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When two Battery widgets are configured simultaneously (e.g. one for the laptop battery, one for a Bluetooth headset), the Show power profile controls and Show Noctalia Performance toggle settings from the second widget were being ignored — the first widget's settings always won.
Root cause
getBatteryPanel()was writingpanelID(which controlsshowPowerProfilesandshowNoctaliaPerformancein the panel) as a side effect on every call. This function was also called from a reactive QMLtooltipTextbinding on each widget instance:Because this binding depends on
isPanelOpen, it re-evaluates on every panel open/close. With two widget instances, both bindings fire and the last one to run overwritespanelID— consistently producing the first widget's settings.Fix
getBatteryPanel()now only returns the panel, with no side effectspanelIDis written intoggleBatteryPanel(), guarded by!panel.isPanelOpenso it only fires when actually opening the panel — not when closing itThis ensures the panel always reflects the settings of the widget that opened it, for its entire open → close lifecycle.
Testing
Reproduced with two Battery widgets (laptop + Bluetooth headset) with different
showPowerProfiles/showNoctaliaPerformancevalues. Confirmed fix resolves the issue.