Support per-display brightness changes in OSD service (plasma-workspace part)
Reason for the change
Per-display brightness controls in powerdevil!361 (merged) is currently blocked on brightness OSD indicators being confusing. There are a number of ways that brightness changes for multiple screens at once could be represented, but at a basic level we need three things:
- A new API to allow providing changed brightness info for multiple different screens
- A generic way to represent multi-screen brightness changes if we can't associate adjusted brightness to Plasma's QScreen list
- A specialized way to represent single-screen brightness changes in a simple, non-confusing way
This MR is a first stab at something workable, but it does contain all the basic ingredients and hopefully can be further built upon in the future without breaking the (newly introduced) API.
CC: @zamundaaa, @nclarius, @ngraham
Original commit message(s)
shell: First stab at an OSD screenBrightnessChanged method
The old brightnessChanged method with its lone percentage argument isn't sufficient in a per-screen brightness world. The new addition adds several arguments to identify and present brightness for different displays.
Each method call receives information about a single screen, which will be combined with information from subsequent calls. Brightness info about all known displays will be retained until the OSD disappears.
As a first stab, we use a multi-line text OSD indicator when more
than one screen sees a brightness change. This is specialized to use
showProgress()
when it's only a single screen, using a progress
indicator with the newly unbroken osdAdditionalText
property for
the QML Osd
item to show which screen is involved.
As a further specialization, the original progress indicator without
additional text is used when only one screen changed brightness and
could be associated to the only screen used by the ShellCorona
.
With all this in place, we can keep basic single-screen changes simple and straightforward, while being able to present relevant changes for a larger number of screens. Eventually, we should probably create multiple OSD popups on associated screens whenever it's possible to determine the correct QScreen for each call and place OSD dialogs accordingly.
lookandfeel: Support the "osdAdditionalText" property in fallback OsdItem
This is currently only used by the mediaPlayerVolumeChanged method,
where playerName
is relayed to the OSD as additional text.
We can make use of this also for an upcoming screenBrightnessChanged
method addition.
In the QML, the label item is pulled upwards in the code so it can appear on top of the progress bar, instead of being mutually exclusive. Preferred height is adjusted to also take implicitHeight into account, rather than only the size of the icon.
(For future reference, follow the guidelines at https://cbea.ms/git-commit/#seven-rules) -->
Test plan
- Apply the corresponding plasma-desktop MR, because the
Osd
QML item in this MR is just the fallback and won't be used in most cases. - Make sure that existing OSD use cases continue looking like they used to.
- Also apply powerdevil!361 (merged) and libkscreen!196 (merged). Having this, try brightness keys (up/down) or brightness applet icon scrolling to invoke the OSD. Try with one screen (active or secondary) and with multiple screens, presentation changes as per commit message.
Screenshots
Before | After |
---|---|
OSDs without additional text requested in addition to the progress percentage will still look the same as before.