Fix sizing of ComboBox and RadioButton
ClosedPublic

Authored by broulik on Mar 18 2020, 8:11 AM.

Details

Summary

KQuickStyleItem manages its implicit size internally. Overriding it on the QML side makes this non-deterministic which assignment wins and might cause unexpected re-evaluation of the size causing it to change.

Moreover, the CheckIndicator implicit size is based on sizeFromContents for CT_CheckBox, which in case of Breeze (but not the Qt built-in styles) already contains some extra padding on the side between checkbox and label. Instead of using that for layouting our full checkbox (indicator + label), do what qqc1 did and use PM_CheckBoxLabelSpacing for spacing and PM_IndicatorWidth as size hint for the indicator.

Also while at it for radio buttons use the appropriate (PM_RadioButtonLabelSpacing and PM_ExclusiveIndicatorWidth) hints.

This makes QQC2 CheckBox and RadioButton layouted pixel-perfect to their QWidget counterparts and also fixes it randomly changing size hints as you switch between pages as demonstrated by the bug report.

BUG: 418447

Test Plan

The only downside might be that using a CheckIndicator standalone now has a quite small size (just the checkbox you see basically) rather than a "nice delegate like height". But then I don't think this control is being used anywhere, and is probably centered vertically anway. When used in conjunction with ItemDelegate (checkable item delegate) I believe the entire delegate becomes clickable to toggle the CheckBox so it getting smaller should have no effect.

Also, using those invokables causes slight layout problems when switching between styles at runtime as they cannot be notified to have changed.

Before Breeze


After Breeze:

Before Oxygen:


After Oxygen:

Before Windows:


After Windows:

(I noticed that we use an incorrect palette somewhere since those checkboxes and comboboxes are meant to be white in Windows style but that's an issue unrelated to this patch)

Diff Detail

Repository
R858 Qt Quick Controls 2: Desktop Style
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
broulik created this revision.Mar 18 2020, 8:11 AM
Restricted Application added a project: Plasma. · View Herald TranscriptMar 18 2020, 8:11 AM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
broulik requested review of this revision.Mar 18 2020, 8:11 AM
broulik updated this revision to Diff 77882.Mar 18 2020, 8:42 AM
broulik edited the summary of this revision. (Show Details)
broulik edited the test plan for this revision. (Show Details)
broulik added reviewers: mart, hpereiradacosta.
  • Use pixel metric for checkbox/radio button size and use the spacing. Only use the size from contents for the (here unused) implicit size of the checkindicator.
mart accepted this revision.Mar 18 2020, 9:07 AM
This revision is now accepted and ready to land.Mar 18 2020, 9:07 AM
This revision was automatically updated to reflect the committed changes.