[Qt] Use flexible font size for QRCode image address #12173

pull jonasschnelli wants to merge 1 commits into bitcoin:master from jonasschnelli:2018/01/fix_qr_font changing 3 files +20 −2
  1. jonasschnelli commented at 9:36 PM on January 12, 2018: contributor

    Bech32 addresses are currently cut off in the QRCode image in the GUI receive tab. This adds a simple font size calculation logic that "must" (down to 4pt) fix into the given image width.

    Examples OSX HiDPI: <img width="332" alt="bildschirmfoto 2018-01-12 um 11 25 40" src="https://user-images.githubusercontent.com/178464/34896144-c0c65d76-f78c-11e7-93e1-94dc8e203269.png"> <img width="322" alt="bildschirmfoto 2018-01-12 um 11 25 46" src="https://user-images.githubusercontent.com/178464/34896145-c0edfe1c-f78c-11e7-8c09-c15155e2160e.png">

    Examples Ubuntu non HIDPI: <img width="314" alt="bildschirmfoto 2018-01-12 um 11 27 51" src="https://user-images.githubusercontent.com/178464/34896151-c88347f4-f78c-11e7-8a03-df8049dcfed6.png"> <img width="322" alt="bildschirmfoto 2018-01-12 um 11 27 42" src="https://user-images.githubusercontent.com/178464/34896152-c8bb881c-f78c-11e7-89d2-6f04ec608a19.png">

  2. jonasschnelli added the label GUI on Jan 12, 2018
  3. jonasschnelli added this to the milestone 0.16.0 on Jan 12, 2018
  4. jonasschnelli cross-referenced this on Jan 12, 2018 from issue [qt] Receive: checkbox for bech32 address by Sjors
  5. Sjors commented at 1:56 PM on January 13, 2018: member

    Concept ACK

  6. in src/qt/receiverequestdialog.cpp:189 in 07c4e9ea8d outdated
     182 | @@ -183,9 +183,19 @@ void ReceiveRequestDialog::update()
     183 |              QPainter painter(&qrAddrImage);
     184 |              painter.drawImage(0, 0, qrImage.scaled(QR_IMAGE_SIZE, QR_IMAGE_SIZE));
     185 |              QFont font = GUIUtil::fixedPitchFont();
     186 | -            font.setPixelSize(12);
     187 | -            painter.setFont(font);
     188 |              QRect paddedRect = qrAddrImage.rect();
     189 | +
     190 | +            // calculate ideal font size
     191 | +            qreal fontSize = 14; // don't go larger then 14 points
    


    laanwj commented at 8:35 AM on January 15, 2018:

    Please factor this out into a function: this makes it easier to read and I think this might come in useful in other places as well.

  7. in src/qt/receiverequestdialog.cpp:190 in 07c4e9ea8d outdated
     187 | -            painter.setFont(font);
     188 |              QRect paddedRect = qrAddrImage.rect();
     189 | +
     190 | +            // calculate ideal font size
     191 | +            qreal fontSize = 14; // don't go larger then 14 points
     192 | +            while(fontSize > 4) {
    


    promag commented at 9:53 AM on January 15, 2018:

    Nit, space after while.


    MarcoFalke commented at 3:12 PM on January 15, 2018:

    Since we are nitting: Also, font_size (camel case).

  8. promag commented at 10:10 AM on January 15, 2018: member

    Concept ACK.

    Agree with @laanwj.

  9. jonasschnelli force-pushed on Jan 15, 2018
  10. Use flexible font size for QRCode image address 59f9e2aaf3
  11. jonasschnelli force-pushed on Jan 15, 2018
  12. jonasschnelli commented at 7:34 PM on January 15, 2018: contributor

    Factored out the font size calculation, fixed @MarcoFalke's nit.

  13. MarcoFalke commented at 9:17 PM on January 15, 2018: member

    Appears to work: Before: before After: after

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA512
    
    utACK 59f9e2aaf3fe73961cc02042f929b430fee59f9c
    -----BEGIN PGP SIGNATURE-----
    
    iQIcBAEBCgAGBQJaXRoLAAoJENLqSFDnUoslZLkP/16J05ldrI9MrfutOdhgcDwT
    2+rM4V/8FgiAQ7tSzJGp5BLQ2InvZLCYR+34F7xXmOjJiKkfSjC0AuJA5CmugVed
    zi67g1v6Z9A21VQd/K0PKL4t1fKfyaL21sGgkQHG6xNayKedthI8ACAyr65GsALr
    D1YxrcF0NgrbR+djLP6WF6yGJiB3kscVasNENcHDtPAwWf/CddKaSSMfqRTyeZ6I
    GQ57JgGdArndWTrnpSFIVNqT/2ljeVrlQuzQjzL1GKdEgcBcd3NcewLFANBV8ajp
    Wj9Z3F7afO7RG5ySYDzS4o1Kri/cEiarDxkApLzLViiYGo0UMHv1jGL42/h06zzp
    VQTbQHyWy9g+Qr2UoRy89SNWNqZGseV76yLpaAaZzzAEawU3GJ107oZw7f2U5CSL
    KG0Jfn9lI2iJUw2+jRPr4+6kek5+dloBwdU/4w54VKi4c0sHu9oMKVWBo8DU2PhZ
    PM1LZpWBXsWmipAvSkDVgzA+c9/RpXnu0U+XxrNfbbH5XtiE1SJTc4woWMlxG0zH
    jnTGMCTTdxClf4QBA/slG6jsgAVahbg5hUMBeO0d2UAMHWXklNtYALT/2QZfZ7gv
    87IO1QWeBFxStMBuyquOV2L/280hLw10i+fUR58rrcUNWMsvYNib+HcJajCvqoia
    y9MLx0zq84yA6mPJh8Od
    =EswI
    -----END PGP SIGNATURE-----
    
  14. laanwj commented at 10:33 PM on January 15, 2018: member

    utACK 59f9e2a

  15. laanwj merged this on Jan 15, 2018
  16. laanwj closed this on Jan 15, 2018

  17. laanwj referenced this in commit bbc91b7699 on Jan 15, 2018
  18. PastaPastaPasta referenced this in commit 3bee32d565 on Apr 4, 2020
  19. PastaPastaPasta referenced this in commit 7fb5b5b3a5 on Apr 5, 2020
  20. jasonbcox referenced this in commit 357a4cd67b on Sep 23, 2020
  21. ckti referenced this in commit 653005eec4 on Mar 28, 2021
  22. bitcoin locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-20 06:55 UTC