Modified distance function to keep aspect ratio as close as possible

Authored by antlarr on Nov 2 2016, 12:01 PM.

Description

Modified distance function to keep aspect ratio as close as possible

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