qt: Fix start with the `-min` option #14517

pull hebasto wants to merge 1 commits into bitcoin:master from hebasto:20181019-start-minimized-to-tray changing 2 files +11 −7
  1. hebasto commented at 7:52 AM on October 19, 2018: member

    From IRC:

    2018-10-17T12:36:38 <Drakon> The option to minimize to system tray instead of the taskbar ist available, but doesn't have an effect if it is started with the -min option. If I start it via that option, I have to click on the program symbil on the taskbar and then minimize it again in order to get it minimized to system tray. 2018-10-17T12:37:28 <Drakon> That's annoying. 2018-10-17T13:51:19 <wumpus> can you open an issue for that please? https://github.com/bitcoin/bitcoin/issues/new 2018-10-17T13:53:24 <wumpus> (if there isn't one yet-)

    This PR fixes this bug.

  2. fanquake added the label GUI on Oct 19, 2018
  3. promag commented at 2:37 PM on October 19, 2018: member
  4. hebasto commented at 3:09 PM on October 19, 2018: member

    @promag Thank you.

  5. laanwj commented at 2:14 PM on November 12, 2018: member

    I don't think this fixes the mentioned issue; this will prevent -min from doing anything at all in case of minimize to tray but there is no tray icon. But the reported issue seems to be that -min doesn't do the right thing in case minimize-to-tray is enabled.

  6. hebasto commented at 2:09 PM on November 13, 2018: member

    @laanwj Thank you for your review.

    ... this will prevent -min from doing anything at all in case of minimize to tray but there is no tray icon.

    To be exact this will prevent -min from doing anything in case of minimize to tray and there is a tray icon. A user will get a tray icon on the desktop; the main window will be hidden, i.e., it'll be effectively minimized to the tray icon.

  7. in src/qt/bitcoingui.h:88 in 89b7cd525d outdated
      81 | @@ -82,6 +82,11 @@ class BitcoinGUI : public QMainWindow
      82 |  #endif // ENABLE_WALLET
      83 |      bool enableWallet = false;
      84 |  
      85 | +    /** Get the tray icon status.
      86 | +        Some systems have not “system tray” or “notification area” available.
      87 | +    */
      88 | +    bool getTrayIconStatus() { return trayIcon; }
    


    promag commented at 3:58 PM on December 5, 2018:

    hasTrayIcon() or isTrayIconAvailable()?


    hebasto commented at 6:22 PM on December 5, 2018:

    @promag hasTrayIcon(); to not be confused with QSystemTrayIcon::isSystemTrayAvailable().

  8. in src/qt/bitcoin.cpp:492 in 89b7cd525d outdated
     494 | -        }
     495 | -        else
     496 | -        {
     497 | +        // If -min option passed, start window minimized or minimized to tray
     498 | +        if (gArgs.GetBoolArg("-min", false)) {
     499 | +            if (!window->getTrayIconStatus() || !clientModel->getOptionsModel()->getMinimizeToTray()) {
    


    promag commented at 4:07 PM on December 5, 2018:

    What if there is a tray icon and getMinimizeToTray?


    hebasto commented at 6:36 PM on December 5, 2018:

    @promag

    What if there is a tray icon and getMinimizeToTray?

    This is the case described in this PR's description!

    With -min option and there is a tray icon and getMinimizeToTray:

    • current master: client hides the splash screen then shows the normal main window (that is an issue);
    • this PR: client hides the splash screen then does not show the main window as it is minimized to the tray icon (expected behaviour).
  9. hebasto force-pushed on Dec 5, 2018
  10. hebasto commented at 6:42 PM on December 5, 2018: member

    @promag Thank you for your review. Your comment has been addressed.

  11. in src/qt/bitcoin.cpp:491 in 8e399cafdd outdated
     493 | -            window->showMinimized();
     494 | -        }
     495 | -        else
     496 | -        {
     497 | +        // If -min option passed, start window minimized or minimized to tray
     498 | +        if (gArgs.GetBoolArg("-min", false)) {
    


    promag commented at 12:02 AM on December 6, 2018:

    I think it would be more clear doing like:

    if (!gArgs.GetBoolArg("-min", false)) {
        window->show();
    } else if (window->hasTrayIcon() && clientModel->getOptionsModel()->getMinimizeToTray()) {
        // do nothing as the window is managed by the tray icon
    } else {
        // show window minimized as requested
    }
    
  12. hebasto force-pushed on Dec 6, 2018
  13. hebasto commented at 10:18 AM on December 6, 2018: member

    @promag Your suggestion is obviously more clear. Implemented.

  14. in src/qt/bitcoingui.h:88 in 9afd838758 outdated
      81 | @@ -82,6 +82,11 @@ class BitcoinGUI : public QMainWindow
      82 |  #endif // ENABLE_WALLET
      83 |      bool enableWallet = false;
      84 |  
      85 | +    /** Get the tray icon status.
      86 | +        Some systems have not “system tray” or “notification area” available.
      87 | +    */
      88 | +    bool hasTrayIcon() { return trayIcon; }
    


    promag commented at 10:50 AM on December 6, 2018:

    nit. const.

  15. hebasto force-pushed on Dec 6, 2018
  16. hebasto commented at 3:21 PM on December 6, 2018: member

    All comments have been addressed. @promag @laanwj would you mind re-reviewing?

  17. Fix start with the `-min` option
    When GUI starts with the `-min` option, the `Minimize to tray instead of
    the taskbar` option works as expected now.
    93009618b6
  18. in src/qt/bitcoingui.h:86 in 847f67fad7 outdated
      81 | @@ -82,6 +82,11 @@ class BitcoinGUI : public QMainWindow
      82 |  #endif // ENABLE_WALLET
      83 |      bool enableWallet = false;
      84 |  
      85 | +    /** Get the tray icon status.
      86 | +        Some systems have not “system tray” or “notification area” available.
    


    promag commented at 4:02 PM on December 6, 2018:

    nit, could use " instead?


    hebasto commented at 4:24 PM on December 6, 2018:

    @promag sure!

  19. hebasto force-pushed on Dec 6, 2018
  20. luke-jr approved
  21. luke-jr commented at 9:56 PM on December 21, 2018: member

    utACK

  22. luke-jr referenced this in commit b304841e09 on Dec 24, 2018
  23. DrahtBot commented at 5:21 PM on January 5, 2019: member

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #15101 (gui: Add WalletController by promag)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  24. laanwj commented at 6:11 PM on January 9, 2019: member

    utACK 93009618b6d72b6bb253cabc4a5813d7aea18a67

  25. laanwj merged this on Jan 9, 2019
  26. laanwj closed this on Jan 9, 2019

  27. laanwj referenced this in commit 0ed279cb4e on Jan 9, 2019
  28. hebasto deleted the branch on Jan 9, 2019
  29. deadalnix referenced this in commit 5a62487f23 on Oct 9, 2020
  30. PastaPastaPasta referenced this in commit 7ce0fcd564 on Jun 26, 2021
  31. PastaPastaPasta referenced this in commit 0d20f403e0 on Jun 27, 2021
  32. PastaPastaPasta referenced this in commit ed066d8925 on Jun 28, 2021
  33. PastaPastaPasta referenced this in commit 4402463bdc on Jun 28, 2021
  34. PastaPastaPasta referenced this in commit 39d9fdc5ad on Jun 29, 2021
  35. MarcoFalke locked this on Dec 16, 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