Modified distance function to keep aspect ratio as close as possible
ClosedPublic

Authored by antlarr on Oct 28 2016, 11:36 AM.

Details

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.

Diff Detail

Repository
R120 Plasma Workspace
Branch
Plasma/5.8
Lint
No Linters Available
Unit
No Unit Test Coverage
antlarr updated this revision to Diff 7719.Oct 28 2016, 11:36 AM
antlarr retitled this revision from to Modified distance function to keep aspect ratio as close as possible.
antlarr updated this object.
antlarr edited the test plan for this revision. (Show Details)
antlarr added a reviewer: Plasma.
Restricted Application added a project: Plasma. · View Herald TranscriptOct 28 2016, 11:36 AM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
antlarr added inline comments.Oct 28 2016, 11:43 AM
wallpapers/image/testfindpreferredimage.cpp
92

I'll fix indentation around all the file in the next commit. But I'll wait to see if there's any other change to make

mart added a subscriber: mart.Oct 28 2016, 2:24 PM
mart added inline comments.
wallpapers/image/image.cpp
186–187

remove dead code

196

dead code

wallpapers/image/testfindpreferredimage.cpp
91

good that a test has been added!
but instead of doing all of this manually, couldn't it use qt autotest stuff, qcompare, qtest etc?

mart requested changes to this revision.Oct 28 2016, 2:24 PM
mart added a reviewer: mart.
This revision now requires changes to proceed.Oct 28 2016, 2:24 PM
antlarr added inline comments.Oct 28 2016, 2:54 PM
wallpapers/image/image.cpp
196

The commented out qDebug a couple of lines below shows that variable (when uncommented). Should I remove it from the qDebug line below? or just keep both?
(the same for the case above)

wallpapers/image/testfindpreferredimage.cpp
91

I never used QTest before and I thought about that but preferred to do it as fast as possible. I guess I'll have to write it anyway :)

antlarr updated this revision to Diff 7737.Oct 28 2016, 4:10 PM
antlarr edited edge metadata.
  • Converted the test to use QTest
antlarr marked 3 inline comments as done.Oct 28 2016, 4:12 PM

Converted the test to use QTest

antlarr updated this revision to Diff 7764.Oct 31 2016, 8:53 AM
antlarr edited edge metadata.
  • Adjust the distance method to work with QUAD HD resolutions
mart added a comment.Nov 2 2016, 11:47 AM

almost perfect :)

last thing, can the test be moved in a subfolder called autotests? (just a convention)

antlarr updated this revision to Diff 7823.Nov 2 2016, 12:04 PM
  • Moved testfindpreferredimage to an autotests directory
mart accepted this revision.Nov 2 2016, 12:06 PM
mart edited edge metadata.
This revision is now accepted and ready to land.Nov 2 2016, 12:06 PM
This revision was automatically updated to reflect the committed changes.