Summary:
This new version of the distance function simplifies the
findPreferredImageInPackage method by using the aspect ratio in the
calculation. Now, it won't only search for a wallpaper with the same
aspect ratio, but will also choose one with the closest possible
aspect ratio when a perfect match is not found.
Also, I separated the method that chooses the preferred image
to not use KPackage in order to use it from a test application
that tests the distance algorithm with all possible resolutions.
Test application that tests the Image::findPreferredImage method
The test initializes a list of available wallpaper image sizes,
then a list of screen resolutions, and then executes
Image::findPreferredImage to find out which is the preferred image
in each case.
Test Plan:
I tested with different screen resolutions on a virtual machine with
openSUSE Leap 42.2 RC1 and also included a commit that adds a test
application (not built by default) that tests all possible resolutions.
Reviewers: #plasma, mart
Reviewed By: mart
Subscribers: mart, plasma-devel
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D3188
Summary:
The default wallpaper method is to scale the wallpaper, and the previous
algorithm in plasma choosed the wallpaper with closest area to the screen
area (w*h) giving a bit of preference to downscaling over upscaling.
The result was that in widescreens like 1280x720, a 1280x1024 wallpaper
was preferred to be scaled down, instead of scaling down the also
available 1920x1080 wallpaper, which had the same aspect ratio and so,
was not distorted.
This patch changes the Image::findPreferedImageInPackage method to do the
same closest-area algorithm first on wallpapers with the same
aspect ratio and if no wallpaper with same aspect ratio is found, then
fallback to the previous algorithm. Note I added some variables so both
happen in the same loop and we don't have to iterate twice
over the wallpapers.
This fixes https://bugzilla.opensuse.org/show_bug.cgi?id=990257
Test Plan:
Make sure the wallpaper mode is in Scale. Choose a wallpaper with
1920x1080 and 1280x1024 resolutions which shows a perfect circle,
a recognizable object or a face. Then change the screen resolution to
1280x720. The wallpaper should appear with correct aspect ratio.
Reviewers: #plasma, davidedmundson
Reviewed By: #plasma, davidedmundson
Subscribers: plasma-devel
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D2834
BackgroundFinder::suffixes(), despite its name, actually returns a list
of glob patterns. The extension of the image file is checked against
this list to ensure that it is supported, which needs to take
account of that. Do the check in a new function
BackgroundFinder::isAcceptableSuffix(const QString &suffix).
Reviewers: davidedmundson, #plasma
Reviewed By: davidedmundson, #plasma
Subscribers: plasma-devel
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D2722
Update the targetSize when it changes to ensure we update the image when
resolution changes. Also, since the view has an initial size of 1024x768, it would
just load that image and never use the full resolution leaving you with an ugly
blurry image. Additionally, don't bother looking up the image until everything has
settled, potentially improving startup performance slightly by saving a bit of IO.
REVIEW: 124311
* when dropped w/out a url scheme, check if it is an abs path
* set the preferred file in the package itself for single files
* don't try and find a best fit in the wallpaper plugin if the package
has already set a prefrred image
this will allow it to be shared by other plugins out there. it does mean
sacrificing the generic "find best paper size" functionality which was
tightly bound to the image wallpaper (in plasma4, this was Plasma::Wallpaper,
so acceptable). Finding the best image is now left up to the plugin,
though I imagine that other plugins will want this eventually as well
and it will find its way into a library somewhere or else just be
copy-and-pasted a lot.
This is the beginning of revision history for this module. If you
want to look at revision history older than this, please refer to the
techbase wiki for how to use Git history grafting. At the time of
writing, this wiki is located here:
http://community.kde.org/Frameworks/GitOldHistory
If you have already performed the grafting and you don't see any
history beyond this commit, try running "git log" with the "--follow"
argument.
Branched from the monolithic repo kde-workspace, frameworks branch, at commit
049113e719dd2fc4446d054fa1a3aada330094f0