gui: Reject dialogs if key escape is pressed #13791

pull promag wants to merge 3 commits into bitcoin:master from promag:2018-07-editaddressdialog changing 4 files +32 −0
  1. promag commented at 11:01 PM on July 28, 2018: member

    Currently EditAddressDialog and OptionsDialog don't close when the escape key is pressed. The QDataWidgetMapper instances prevents closing the dialogs because the escape key is used to reset the widgets values. More details and workarounds in https://stackoverflow.com/a/51487847 and http://qtramblings.blogspot.com/2010/10/qdatawidgetmapper-annoyances.html.

    The adopted solution is different from the above references. It turns out that QDataWidgetMapper::setItemDelegate sets the event filter for all mapped widgets. So in this PR the mapper's delegate are changed to a custom GUIUtil::ItemDelegate that offers the signal keyEscapePressed, which is connected to the QDialog::reject slot.

    Note that the installed event filter lets all events pass, so the current behaviour isn't changed, meaning that widgets values are reset in addition to closing the dialog.

  2. promag force-pushed on Jul 28, 2018
  3. MarcoFalke added the label GUI on Jul 28, 2018
  4. MarcoFalke renamed this:
    ui: Reject EditAddressDialog on ESC key
    gui: Reject EditAddressDialog on ESC key
    on Jul 28, 2018
  5. jonasschnelli commented at 7:21 AM on July 30, 2018: contributor

    Trivial utACK ffa9fa4bce06cc680cf5a7833bcb255454439c80

  6. laanwj commented at 12:02 PM on July 30, 2018: member

    I'm disappointed at Qt that verbose code like this is needed to make simple ESC functionality work. Is this the only place where this is needed?

    utACK ffa9fa4bce06cc680cf5a7833bcb255454439c80.

  7. promag commented at 12:11 PM on July 30, 2018: member

    I could add some comments here for future reference.

    Is this the only place where this is needed? @laanwj I'll check.

  8. laanwj commented at 12:15 PM on July 30, 2018: member

    I could add some comments here for future reference.

    THank you, good idea.

  9. promag commented at 2:37 PM on July 30, 2018: member

    @laanwj looks like the options dialog has the same problem. At least on macOS pressing ESC doesn't close it. I'll see what can be done to fix both cases.

  10. promag force-pushed on Jul 30, 2018
  11. promag renamed this:
    gui: Reject EditAddressDialog on ESC key
    gui: Reject dialogs if key escape is pressed
    on Jul 30, 2018
  12. promag commented at 10:02 PM on July 30, 2018: member

    @jonasschnelli @laanwj udpated OP and pushed an alternative implementation that also fixes options dialog.

    Edit: not sure about the GUIUtil::ItemDelegate class name 🙄

  13. promag force-pushed on Jul 30, 2018
  14. gui: Add GUIUtil::ItemDelegate with keyEscapePressed signal f7a553177d
  15. gui: Reject edit address dialog when key escape is pressed 4a43306a4f
  16. gui: Reject options dialog when key escape is pressed 7bf22bf0c2
  17. promag force-pushed on Jul 30, 2018
  18. ken2812221 commented at 11:17 PM on July 30, 2018: contributor

    f49253fda works on Windows. ACK 7bf22bf0c21d13557ec46a67413819ebcabc3df0

  19. laanwj commented at 10:06 AM on July 31, 2018: member

    Your code looks much better this way, by organizing it into the delegate class utACK 7bf22bf0c21d13557ec46a67413819ebcabc3df0

  20. laanwj merged this on Aug 2, 2018
  21. laanwj closed this on Aug 2, 2018

  22. laanwj referenced this in commit 2c14c1fa2f on Aug 2, 2018
  23. jasonbcox referenced this in commit ba2504cc30 on Jan 3, 2020
  24. jonspock referenced this in commit 07786bc953 on Jan 10, 2020
  25. proteanx referenced this in commit eec3fc81f1 on Jan 10, 2020
  26. PastaPastaPasta referenced this in commit 5cad181033 on Jul 29, 2020
  27. PastaPastaPasta referenced this in commit dc914a32bc on Jul 29, 2020
  28. MarcoFalke 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-04-21 18:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me