Use separate config group for each wallpaper plugin
ClosedPublic

Authored by aleksejshilin on Mar 9 2018, 10:04 PM.

Details

Summary

Wallpaper plugins were storing their configurations in the same config
group, overwriting each other's values.

Test Plan
0. Apply revision D11194 (plasma-desktop).
1. Right-click the desktop and click Configure Desktop.
2. Select Wallpaper Type -> Plain Color. Click the chooser button
   and select green. Hit Apply.
3. Select Wallpaper Type -> Picture of the Day. Click Background
   Color button and select red. Hit Apply.
4. Select Plain Color type again. The color should still be green.

Diff Detail

Repository
R120 Plasma Workspace
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
aleksejshilin created this revision.Mar 9 2018, 10:04 PM
Restricted Application added a project: Plasma. · View Herald TranscriptMar 9 2018, 10:04 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
aleksejshilin requested review of this revision.Mar 9 2018, 10:04 PM
davidedmundson requested changes to this revision.Mar 10 2018, 1:08 AM
davidedmundson added a subscriber: davidedmundson.

One could argue keeping the colour persist across wallpapers is a feature, what problems does it cause?

shell/containmentconfigview.cpp
180–181

why do this line still?

181

when a user with a current config upgrades, what's going to happen?

This revision now requires changes to proceed.Mar 10 2018, 1:08 AM

One could argue keeping the colour persist across wallpapers is a feature, what problems does it cause?

It's not limited to colors, that's just a testcase. And unless there is a well-defined key naming convention I haven't found, that keys have the same name doesn't imply they have the same meaning. For example, 'Provider' key may have totally different acceptable values across different wallpaper plugins, 'Color' may mean 'background color', 'skin color' (imagine dynamic emoji wallpaper :) ) and so on.

But that's not the main point. I've played with different wallpaper types, and that's what ended up in ~/.config/plasma-org.kde.plasma.desktop-appletsrc:

[Containments][1][Wallpaper][General]
Blur=true
Color=170,0,0
FillMode=2
Image=file:///usr/share/wallpapers/Next/contents/images/1366x768.png
Provider=bing
SlidePaths=/home/aleksej/Изображения

[Containments][1][Wallpaper][org.kde.color][General]
Color=255,0,0

[Containments][1][Wallpaper][org.kde.image][General]
Blur=true
Color=170,0,0
FillMode=2
Image=file:///usr/share/wallpapers/Next/contents/images/1366x768.png
SlidePaths=/home/aleksej/Изображения

[Containments][1][Wallpaper][org.kde.potd][General]
Color=170,0,0
FillMode=1
Provider=bing

[Containments][1][Wallpaper][org.kde.slideshow][General]
Color=170,0,0
FillMode=6
SlidePaths=/home/aleksej/Изображения

As you see, separate config groups are used by the plugins anyway. More importantly, they are the ones plasmashell actually reads at startup. It's just ContainmentConfigView is using the wrong group for these settings. And it starts doing that only after one changes Wallpaper Type for the first time in the dialog. Try this:

  1. Right-click the desktop and click Configure Desktop.
  2. Select Wallpaper Type -> Plain Color. If it's already selected, select a different one first.
  3. Click the chooser button and select green, then hit OK.
  4. Open the dialog again. Don't switch wallpaper types. Change the color to red and click Apply.
  5. Select Picture of the Day as Wallpaper Type. The selected color is still green.

So, wallpaper plugins "share" configuration only accidentally due to ContainmentConfigView::setCurrentWallpaper() bug.

I see, thanks for the explanation.

Fix setting cfg twice, and then I'll approve it

Fix setting cfg twice

It's not setting twice, it's creating a nested config group.

Or did you mean to use a separate variable each time instead of reusing cfg?

davidedmundson accepted this revision.Mar 10 2018, 11:50 AM

Urgh, I can't read. Sorry.

typically we'd do cfg = cfg.group("") which IMHO is easier to read, but this is fine too

Thanks

This revision is now accepted and ready to land.Mar 10 2018, 11:50 AM

typically we'd do cfg = cfg.group("") which IMHO is easier to read

Yeah, I like it more, too, but I saw the same styling almost everywhere in shell/ and therefore decided to follow rather than stand out.

Thanks!

This revision was automatically updated to reflect the committed changes.