Bug 453146 - KisIntegerParseSpinBox and KisDoubleParseSpinBox's sizeHint().height() sometimes returns 26 and sometimes 25 based on the parent element
Summary: KisIntegerParseSpinBox and KisDoubleParseSpinBox's sizeHint().height() someti...
Status: RESOLVED INTENTIONAL
Alias: None
Product: krita
Classification: Applications
Component: Dockers (show other bugs)
Version: git master (please specify the git hash!)
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Deif Lou
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-28 14:42 UTC by littlelightlittlefire
Modified: 2022-04-29 12:07 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description littlelightlittlefire 2022-04-28 14:42:58 UTC
Hash: e53f968 (currrent master), bug filed at the request of amyspark on IRC

SUMMARY

While working on the HSV color selector (https://invent.kde.org/graphics/krita/-/merge_requests/1434)
I've noticed that `Kis{Integer,Double}ParseSpinBox` `sizeHint().height()` returns different sizes.

STEPS TO REPRODUCE
1. Pull the code from https://invent.kde.org/graphics/krita/-/merge_requests/1434
2. On this line: https://invent.kde.org/graphics/krita/-/merge_requests/1434/diffs#c802f9b62a00b267298f79be7ad4b5dc821ee2bd_438_480
3. Add a `qDebug() << input->sizeHint().height()`
4. On this line: https://invent.kde.org/graphics/krita/-/merge_requests/1434/diffs#c802f9b62a00b267298f79be7ad4b5dc821ee2bd_56_57
5. Add a `qDebug() << m_input->sizeHint().height` here 
6. Open the Specific Color Selector
7. The first qDebug() outputs 26
8. The second qDebug outputs 25

OBSERVED RESULT

26

EXPECTED RESULT

25

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Arch Linux
Comment 1 littlelightlittlefire 2022-04-28 14:50:21 UTC
The links from the MR doesn't seem to work, here's them again:

The line references are:
1. https://invent.kde.org/graphics/krita/-/blob/c3b812170829a38ab2df92a26ca0974bc9d336a8/libs/widgets/kis_color_input.cpp#L57
2. https://invent.kde.org/graphics/krita/-/blob/c3b812170829a38ab2df92a26ca0974bc9d336a8/libs/widgets/kis_color_input.cpp#L480

Place `qDebug() << m_input->sizeHint().height();` and `qDebug() << input->sizeHint().height();` in those positions respectively.
Comment 2 Deif Lou 2022-04-28 16:26:28 UTC
I remade the slider spin boxes but I didn't touch those color sliders. Do everything points to that weird +1, maybe a leftover of the old widgets. I cannot check right now, but if you can, try removing that and see if it is solved, and tell me.
Comment 3 littlelightlittlefire 2022-04-28 16:48:14 UTC
Gu(In reply to Deif Lou from comment #2)
> I remade the slider spin boxes but I didn't touch those color sliders. Do
> everything points to that weird +1, maybe a leftover of the old widgets. I
> cannot check right now, but if you can, try removing that and see if it is
> solved, and tell me.

I've removed the sliders and it does not help.
I've created an easy reproduction here (patch onto master): https://invent.kde.org/lllf/krita/-/commit/7279a8c797d3dffaf348e4e37006858f5d1ca4a6

Creating the component in the constructor results in 26, creating the component in the update() methods results in 25
Comment 4 Deif Lou 2022-04-29 07:57:22 UTC
The issue is not in Krita's slider spinbox widgets. It can be reproduced using QDoubleSpinBox as well. And I don't think it is an issue with sizeHint. If one uses:
> qDebug() << input->fontMetrics().height();
instead of:
> qDebug() << input->sizeHint().height()
it can be seen that the real problem is in the font size.
I don't know yet how the font size is changing, but it seems that there is not a problem specific to this docker.
Comment 5 Deif Lou 2022-04-29 08:25:25 UTC
The issue is that the font of the dockers is set to one with smaller size with:
> dockWidget->setFont(KisUiFont::dockFont());
and docFont is:
> QFont dockFont()
> {
>     QFont font = normalFont();
>     font.setPointSizeF(font.pointSizeF() * 0.9);
>     return font;
> }
Since the font size is taken into account in the QDoubleSpinBox::sizeHint, this also influences the spinbox size.
It seems to be an intentional thing, so I'm nor sure this is a bug.