[Icon Item] Support non-square icons
ClosedPublic

Authored by broulik on Dec 31 2016, 5:08 PM.

Details

Summary

BUG: 355592

Test Plan

Tests still pass, added a test for paintedWidth/paintedHeight


Now getting non-square thumbs in FolderView (will make a patch for FolderView to let IconItem span the full delegate width to make better use of available space for wide thumbs)
Everything else looks as normal, icons still rounded to icon sizes and square usually, verified that paintedWidth/paintedHeight is always updated and correct

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 updated this revision to Diff 9561.Dec 31 2016, 5:08 PM
broulik retitled this revision from to [Icon Item] Support non-square icons.
broulik updated this object.
broulik edited the test plan for this revision. (Show Details)
broulik added reviewers: Plasma, hein.
broulik set the repository for this revision to R242 Plasma Framework (Library).
Restricted Application added projects: Plasma, Frameworks. · View Herald TranscriptDec 31 2016, 5:08 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
broulik updated this revision to Diff 9577.Jan 1 2017, 1:19 PM
davidedmundson added inline comments.
src/declarativeimports/core/iconitem.cpp
325

This makes no sense.
You can't round it to icon sizes *after* scaling, it means the shorter size is always just wrong.

If we do merge this patch, you want:

m_iconPixmap.size().scaled(QSize(Units.roundtoIconSize(actualContainerSize.width), Units.roundToIconSize(actualContainerSize.height)

377

You're using references a lot in a few patches that don't make any sense.

paintedSize returns a new QSize object; you're keeping a reference to a value that would just be immediately discarded. This doesn't result in an optimisation but instead doing something that would crash if it wasn't for a magic C++ feature where it lengthens the lifespan of the object.

mart added a subscriber: mart.Jan 2 2017, 10:11 AM
mart added inline comments.
src/declarativeimports/core/iconitem.cpp
325

the final size should be:
the *biggest* between width and height should be rounded to icon size
the other dimension should be scaled accordingly keeping the same proportions, so for example, if the original is
200*100 pixels, and you paint of a 32x32 icon canvas, the final image should be 32x16 (possibly painted centered)

davidedmundson added inline comments.Jan 3 2017, 1:24 PM
src/declarativeimports/core/iconitem.cpp
325

Copying a better explanation of the bug here from on IRC:

‎[13:09] ‎<‎d_ed‎>‎ kbroulik: assuming the standard icon sizes are 16,32,48 if I have an icon that is 48x45 your paintedSize will return 48x32

‎[13:12] ‎<‎d_ed‎>‎and your unit test currently only passes because roundToIcon size has a code path of if size > KIconLoader::SizeHuge return size

broulik updated this revision to Diff 9658.Jan 3 2017, 2:21 PM
  • Don't blindly round both sizes, instead round one and then scale the other accordingly
  • Adjust unit test
Restricted Application added a subscriber: Frameworks. · View Herald TranscriptJan 3 2017, 2:21 PM
mart added a comment.Jan 3 2017, 4:09 PM

+1 from me

davidedmundson accepted this revision.Jan 5 2017, 1:45 PM
davidedmundson added a reviewer: davidedmundson.
This revision is now accepted and ready to land.Jan 5 2017, 1:45 PM
This revision was automatically updated to reflect the committed changes.