Skip to content

High-DPI toolbar icon rendering

Tuomas Nurmi requested to merge nurmi/amarok:hidpi_toolbar_icon_rendering into master

Expanding further on the topic introduced in MR#19, this merge request alters the main toolbar components to use higher-resolution svg renders and icons, producing clearly better-looking results in scaled high-DPI UIs.

Before-after comparison with normal (100%) scaling shows no visible differences, as it shouldn't (or actually, the track action button might be a pixel or two smaller, I'll have to check that later). normiskaalausilman

normiskaalausmuutoksilla

Before-after comparison with 200% UI scaling shows very clear difference between original and the UI drawn with these changes (the latter screenshot also includes most of the MR#19 changes, the difference is also visible in the MR#19 screenshots). The track action button rendering is actually broken in scaled UIs, this MR fixes also that. tuplaskaalausilman

tuplaskaalausmuutoksilla

As these changes are a bit more intrusive than the one-liners in the previous MR, I'm adding this as a draft for now. I've added target widths and heights to drawPixmap calls, fixed the IconButton's adjusted() function (which by itself would supposedly fix the broken track action buttons) and added a multiplier '2' in various places. Originally I was wondering if this should be done somehow more elegantly, however, the code involved is pretty much contained in a couple of files, so this seems to have been more manageable than I anticipated, and no changes are needed to any general icon loading/svg rendering part, either. At least works nicely on my 150% scaled 4k display, and I haven't (at least yet) found any regressions.

The brokennes of TrackActionButton visuals on high DPI is probably because src/widgets/TrackActionButton.cpp:69, icon is loaded from QIcon with "m_icon.image[2] = m_icon.icon.pixmap( sz ).toImage();", and according to QIcon::pixmap documentation, "Setting the Qt::AA_UseHighDpiPixmaps application attribute enables this function to return pixmaps that are larger than the requested size." Thus the size of pixmap is bigger than the requested size [of IconButton] and gets cropped.

Edit: One more set of before-afters, now with increased TrackActionButton base sizes also included 100200prosbeforeafterset

Edited by Tuomas Nurmi

Merge request reports