gui icon indicating copy to clipboard operation
gui copied to clipboard

QRImageWidget: Sizing and font fixups

Open luke-jr opened this issue 3 years ago • 5 comments

  • 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 avatar Dec 13 '21 06:12 luke-jr

@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.

promag avatar Dec 14 '21 00:12 promag

        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

luke-jr avatar Dec 14 '21 02:12 luke-jr

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?

promag avatar Dec 14 '21 09:12 promag

@luke-jr Screenshots "before" and "after" in the PR description could be useful for further discussion.

hebasto avatar Jun 01 '22 22:06 hebasto

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

No conflicts as of last run.

DrahtBot avatar Jun 12 '22 21:06 DrahtBot