Do background contrast fallback at runtime
ClosedPublic

Authored by broulik on Jan 23 2019, 8:37 PM.

Details

Summary

When a theme doesn't supply background contrast values, we take an educated guess based on whether it's a dark or light theme. We didn't update the values when switching only color schemes at runtime (when theme follows it).
This lead to washed out Plasma popup and panel backgrounds. Instead, compute the fallback value at runtime
Also, while at it, update complimentary colorscheme as well, which was forgotten here.

BUG: 401142

Test Plan
  • Used Breeze Plasma theme (the one that follows system colors), switched from Breeze light color scheme to Breeze dark, popups immediately looked as they should have rather than only after a plasmashell restart

Diff Detail

Repository
R242 Plasma Framework (Library)
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
broulik created this revision.Jan 23 2019, 8:37 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptJan 23 2019, 8:37 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
broulik requested review of this revision.Jan 23 2019, 8:37 PM
broulik added inline comments.Jan 23 2019, 10:07 PM
src/plasma/private/theme_p.cpp
730–731

An alternative approach would be to store those values and then do the default fallback and qGray(color(Plasma::Theme::BackgroundColor).rgb()) < 127 stuff on the fly on demand.
It's runtime cpu cycles vs parsing a config file once on color change (with some awful copy paste)

Nice, it works great for me!

mart added a subscriber: mart.Feb 5 2019, 4:26 PM
mart added inline comments.
src/plasma/private/theme_p.cpp
730–731

but it wouldn't be guaranteed to be the same of the value stored in the config file no?

broulik added inline comments.Feb 5 2019, 6:19 PM
src/plasma/private/theme_p.cpp
730–731

If the theme does not supply background contrast values, they are auto-determined from the background color (dark or light), or what do you mean?

mart added inline comments.Feb 7 2019, 8:22 AM
src/plasma/private/theme_p.cpp
730–731

They can be supplied from the theme too (or used to be) even though most of the themes don't

mart added inline comments.Feb 7 2019, 8:41 AM
src/plasma/private/theme_p.cpp
730–731

err, forget everything i said, i misunderstood your comment :)
using qgray on the theme backgroundcolor instead of a magic 0.45 is an excellent idea

broulik updated this revision to Diff 51085.Feb 7 2019, 12:10 PM
broulik retitled this revision from Reparse background contrast settings when colors changed to Do background contrast fallback at runtime.
broulik edited the summary of this revision. (Show Details)
ngraham accepted this revision.Feb 7 2019, 2:59 PM

Works for me!

This revision is now accepted and ready to land.Feb 7 2019, 2:59 PM
mart accepted this revision.Feb 7 2019, 3:37 PM
This revision was automatically updated to reflect the committed changes.