Use device pixel ratio for selection outline width
Instead of messing around with physical screen size, since that breaks when UI scaling gets involved. For example, on a 4K screen, you'd probably run Krita with a scale factor of 2, which causes the entire UI to be scaled, but the selection outline is impossible to make out because it's just one pixel wide. With this change, the outline just scales like the rest of the user interface.
There have been previous attempts in BUG:456364 which try to take the physical DPI of the screen into account, the current solution specifically includes code that undoes any logical UI scaling, which seems like the wrong thing to do to me, since the selection outline is a UI element like any other. A user can use the scaling options in their operating system or the QT_SCALE_FACTOR
environment variable to change the UI scaling employed by Qt, so if things are too small, they can make them bigger this way? But I don't have any MacOS computer to check how they behave with their 2.0 ratios by default, so maybe I'm thinking about this too naively.
Test Plan
Set the QT_SCALE_FACTOR
environment variable to 2
and run Krita. Observe that the UI is scaled 2x larger than normal. Create a new canvas and make some kind of selection. Observe that the marching ants are 2 pixels wide.
Same observations with other QT_SCALE_FACTOR
values (must be >= 1, can be fractional like 1.5 or something) and when using the operating system's scaling options (e.g. on Windows.)
Formalities Checklist
-
I confirmed this builds. -
I confirmed Krita ran and the relevant functions work. -
I tested the relevant unit tests and can confirm they are not broken. (If not possible, don't hesitate to ask for help!) -
I made sure my commits build individually and have good descriptions as per KDE guidelines. -
I made sure my code conforms to the standards set in the HACKING file. -
I can confirm the code is licensed and attributed appropriately, and that unattributed code is mine, as per KDE Licensing Policy.
Reminder: the reviewer is responsible for merging the patch, this is to ensure at the least two people can build the patch. In case a patch breaks the build, both the author and the reviewer should be contacted to fix the build. If this is not possible, the commits shall be reverted, and a notification with the reasoning and any relevant logs shall be sent to the mailing list, kimageshop@kde.org.