antlarr created this revision. antlarr added a reviewer: Plasma. Restricted Application added a project: Plasma. Restricted Application added a subscriber: plasma-devel.
REVISION 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. REPOSITORY rPLASMAWORKSPACE Plasma Workspace BRANCH Plasma/5.8 REVISION DETAIL https://phabricator.kde.org/D3188 AFFECTED FILES wallpapers/image/CMakeLists.txt wallpapers/image/image.cpp wallpapers/image/image.h wallpapers/image/testfindpreferredimage.cpp EMAIL PREFERENCES https://phabricator.kde.org/settings/panel/emailpreferences/ To: antlarr, #plasma Cc: plasma-devel, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas