Mouse KCM: Align spin boxes, port to Qt5
ClosedPublic

Authored by marten on Sep 25 2016, 11:55 AM.

Details

Summary

The "Advanced" and "Keyboard Navigation" tabs of the mouse control panel (kcmshell5 mouse) contain a number of spin boxes, all of which were originally at their natural widths (see "before" screen shots):

This change improves the appearance by aligning them all to have the same width:

In addition to this, the spin boxes are ported from the deprecated KNumInput to QSpinBox/QDoubleSpinBox as appropriate, and some cruft (including unneeded include files) is removed.

Test Plan

Built mouse KCM with these changes, checked appearance and operation.

Diff Detail

Repository
R119 Plasma Desktop
Lint
Lint Skipped
Unit
Unit Tests Skipped
marten updated this revision to Diff 6916.Sep 25 2016, 11:55 AM
marten retitled this revision from to Mouse KCM: Align spin boxes, port to Qt5.
marten updated this object.
marten edited the test plan for this revision. (Show Details)
marten added a reviewer: Plasma.
marten set the repository for this revision to R119 Plasma Desktop.
marten added a project: Plasma.
Restricted Application added a subscriber: plasma-devel. · View Herald TranscriptSep 25 2016, 11:55 AM
mart added a subscriber: mart.Sep 26 2016, 9:06 AM
mart added inline comments.
kcms/input/mouse.cpp
796

not sure about this manual resize.
couldn't the kcm just have used a gridlayout instead?

A grid layout would fix it, but I assume that the point of using a form layout is that it would automatically pick up the platform and style policy (field and label alignment, stretch policy etc).

marten updated this revision to Diff 7032.Oct 1 2016, 9:12 PM

Implemented using a grid layout. It looks the same, not needing the event filter but at the cost of more code to generate the layout (getting the required label alignment, setting label buddies, keeping track of rows...) which QFormLayout does automatically.

davidedmundson accepted this revision.Oct 2 2016, 6:31 PM
davidedmundson added a reviewer: davidedmundson.
This revision is now accepted and ready to land.Oct 2 2016, 6:31 PM

Also, I just looked over your first patch.

That event filter was weird, but there wasn't any reason to move away from a formLayout.

you could have set a setFieldGrowthPolicy on the form layout to ExpandingFieldsGrow
Then set the spinboxes to horizontalSizeHint to minimumExpanding.

should have worked.

But the grid thing works too now you've done it.

marten added a comment.Oct 2 2016, 7:17 PM

Thanks for the hint David... I thought that I'd tried the approach of setting the fieldGrowthPolicy and the sizePolicy of the fields, and the problem with that was that the spinboxes were then extended to the full width of the form - not looking good, as well as putting the numeric values a long way away from their labels. So I remembered seeing the event filter technique used somewhere else, and did that. I'll take another look at the QFormLayout approach, though, and see if it can be made to give the right appearance.

marten added a comment.Oct 3 2016, 7:16 AM

This is what happens with a QFormLayout with fieldGrowthPolicy=ExpandingFieldsGrow and fields' sizePolicy=MinimumExpanding/Fixed. The effect is not good - it moves the spin box controls a long way away. Shall I stick with the grid layout?

Weird, with your patch I get

which looks spot on.

mart added a comment.Oct 3 2016, 10:41 AM

Weird, with your patch I get

which looks spot on.

latest version (that uses a grid) or formlayout version with hints changed?

Urgh, I got confused. I assumed had Marten had uploaded a patch when he uploaded a screenshot. Well deduced :)

@marten can you upload your form based patch that looks wrong and I'll take a look.
I think you just need to wrap it in a hboxlayout with the form layout and a spacer.

marten updated this revision to Diff 7049.Oct 3 2016, 11:07 AM
marten edited edge metadata.

Apologies for the confusion... this patch corresponds to the last screen shot, with ExpandingFieldsGrow and MinimumExpanding (currently only for the "Advanced" tab).

Adding an outer layout with a stretch to the right seem to be the way to go, I'll work on that.

thanks @marten for this update. If you are interested into some system setting changes let me know.

marten updated this revision to Diff 7051.Oct 3 2016, 11:32 AM

Using a form layout wrapped in an outer layout with stretch added to the right. Gives the intended effect, with all spin boxes the same size and lining up on both tabs. The boxes for the "Keyboard Navigation" tab are wider than they should be, because the check box makes the form layout wider - probably not worth the complexity of fixing, the appearance is at least better than before.

The indentation here is awful, especially the "Keyboard Navigation" block enclosed in spurious braces and then indented outwards... I've kept that which exists at the moment, and will fix in a separate commit so as not to mix code and whitespace changes.

mart added a comment.Oct 3 2016, 11:52 AM

looks fine here with latest version of the patch

Ship it!

I can't click approve again apparently.

I really appreciate that you put in the extra time finding the neatest solution. Good stuff.

mart accepted this revision.Oct 3 2016, 2:03 PM
mart added a reviewer: mart.
This revision was automatically updated to reflect the committed changes.