gui
gui copied to clipboard
QRImageWidget: Sizing and font fixups
- Margin of QRCode should be constant, not change based on complexity of QRCode
- Text region should be sized based on height of actual text, not a constant guess
- Width of image should not be adjusted based on vertical text size/margins
- Adjusted constant QRCode and margin sizes to visually match what we had previously
- If text won't fit, grow up to 25% wider, or split across multiple lines
(Note: Out of scope for this PR, after #497, I think we should allow customising the font used here and default to the embedded monospace for better privacy)
@luke-jr feel free to try the commit 0ac4f7535a90bacb0e5ffe8f110505aa44075ad6 (branch) which avoids manual text wrap by using Qt::TextWrapAnywhere
flag.
Another thing I noticed is that the default minimum font size in calculateIdealFontSize
is too small.
auto rect = fm.boundingRect(max_rect, Qt::AlignCenter, text);
if (rect.width() > max_rect.width() * 5 / 4) {
Isn't this impossible? I find the unnecessary QRect usage hard to follow.
Another thing I noticed is that the default minimum font size in calculateIdealFontSize is too small.
IMO out of scope for this PR
Isn't this impossible?
No because it doesn't wrap.
I find the unnecessary QRect usage hard to follow.
And I think it's unnecessary to calculate lines and manually wrap the text. What is hard to follow?
@luke-jr Screenshots "before" and "after" in the PR description could be useful for further discussion.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Conflicts
No conflicts as of last run.