Qt: Add option to disable the system tray icon #8006

pull Tyler-Hardin wants to merge 1 commits into bitcoin:master from Tyler-Hardin:disable-tray changing 7 files +65 −2
  1. Tyler-Hardin commented at 12:10 PM on May 5, 2016: contributor

    My changes leave all tray icon and menu creation/initialization logic untouched. It only shows or hides the icon according to the setting.

    A new checkbox was added to the OptionsDialog under the Window tab. A bool option named "disableTray" was added to OptionsModel. This checkbox was mapped like other all options to the OptionsModel.

    A signal was added to the OptionsModel for broadcasting changes the the disableTray option. This signal was connected to a new slot added to BitcoinGUI named updateDisableTray(bool). The slot simply hides or shows the trayIcon in BitcoinGUI according to the parameter recieved.

    The negative wording of "disableTray" instead of a positive wording ("enableTray") because enabled is the default. Perhaps "hideTray" would be better than disable.

    This pull request intends to resolve this issue: #7160

  2. Tyler-Hardin commented at 12:11 PM on May 5, 2016: contributor

    Btw, this is my first pull request. Don't hurt me.

  3. jonasschnelli added the label GUI on May 5, 2016
  4. in src/qt/forms/optionsdialog.ui:None in 8aad6337c5 outdated
      19 | @@ -20,7 +20,7 @@
      20 |     <item>
      21 |      <widget class="QTabWidget" name="tabWidget">
      22 |       <property name="currentIndex">
      23 | -      <number>0</number>
      24 | +      <number>3</number>
    


    jonasschnelli commented at 12:12 PM on May 5, 2016:

    I think this was done by Qt Creator. I guess it should still be 0?

  5. Tyler-Hardin commented at 12:14 PM on May 5, 2016: contributor

    @jonasschnelli, yes, it was. I'll edit it back to zero.

  6. jonasschnelli commented at 12:15 PM on May 5, 2016: contributor

    Nice work! Concept ACK will test in detail soon.

  7. laanwj commented at 12:54 PM on May 5, 2016: member

    Concept ACK.

    Perhaps "hideTray" would be better than disable.

    I'd prefer "setTrayVisible(bool)" - this is closer to Qt's own usage. I agree on the positive versus negative wording in principle, but on the other hand the default could change later, so may as well make it general.

  8. Tyler-Hardin commented at 1:00 PM on May 5, 2016: contributor

    @laanwj, since we're getting verbose anyway, would "setTrayIconVisible(bool)" be even better? Because, technically, I'm setting the visibility on the TrayIcon.

    Btw, thanks for reminding me about the setVisible function. I had used an if(flag) tray->hide(); else tray->show() logic that I can simplify to a single line with setVisible.

  9. laanwj commented at 1:04 PM on May 5, 2016: member

    setTrayIconVisible(bool)

    Sure, even clearer.

  10. Tyler-Hardin commented at 1:57 PM on May 5, 2016: contributor

    @laanwj, fixed.

  11. jonasschnelli commented at 6:28 PM on May 5, 2016: contributor

    This currently results in a startup crash on OSX because trayIcon is NULL on OSX (see void BitcoinGUI::createTrayIcon(const NetworkStyle *networkStyle)).

    IMO this PR should remove the #ifndef Q_OS_MAC for the tray-icon creation (so it also gets created on OSX) and disabled it by default on OSX (over platformstyle class).

  12. laanwj commented at 8:22 PM on May 5, 2016: member

    @jonasschnelli I think the reason it's not created on OSX is because the menu items are added to some other menu (which effectively acts as a tray icon). It was non-trivial to get rid of the #ifdeffing there, at least it seemed back in the day when I implmemented platformstyle.

  13. jonasschnelli commented at 8:35 AM on May 6, 2016: contributor

    utACK (testes a bit but will test more in detail). I can fix the OSX tray-icon support later (if even possible).

  14. jonasschnelli commented at 8:35 AM on May 6, 2016: contributor

    Needs squashing.

  15. Tyler-Hardin force-pushed on May 6, 2016
  16. Tyler-Hardin commented at 9:25 AM on May 6, 2016: contributor

    @jonasschnelli, squashed.

  17. jonasschnelli commented at 7:47 PM on May 11, 2016: contributor

    Tested ACK a8abd45ec7ddb16d09f9abfd90b6eea722c55103

    A little nit: If you have your tray icon disabled, it shortly flickers up during startup of Bitcoin-Qt.

    A simple change can fix this:

    --- a/src/qt/bitcoingui.cpp
    +++ b/src/qt/bitcoingui.cpp
    @@ -545,7 +545,7 @@ void BitcoinGUI::createTrayIcon(const NetworkStyle *networkStyle)
         QString toolTip = tr("%1 client").arg(tr(PACKAGE_NAME)) + " " + networkStyle->getTitleAddText();
         trayIcon->setToolTip(toolTip);
         trayIcon->setIcon(networkStyle->getTrayAndWindowIcon());
    -    trayIcon->show();
    +    trayIcon->hide();
     #endif
    
         notificator = new Notificator(QApplication::applicationName(), trayIcon, this);
    
  18. Qt: Add option to hide the system tray icon
    My changes leave all tray icon and menu creation/initialization logic
    untouched. It only shows or hides the icon according to the setting.
    
    A new checkbox was added to the OptionsDialog under the Window tab. A
    bool option named "hideTrayIcon" was added to OptionsModel. This
    checkbox was mapped like other all options to the OptionsModel.
    
    A signal was added to the OptionsModel for broadcasting changes the the
    hideTrayIcon option. This signal was connected to a new slot added to
    BitcoinGUI named setTrayIconVisible(bool). The slot simply hides or
    shows the trayIcon in BitcoinGUI according to the parameter recieved.
    8b0e497028
  19. Tyler-Hardin force-pushed on May 12, 2016
  20. Tyler-Hardin commented at 2:29 AM on May 12, 2016: contributor

    @jonasschnelli, good catch. I added that edit.

  21. jonasschnelli commented at 9:13 AM on May 12, 2016: contributor

    Tested ACK 8b0e4970281de15472a93a529302f3de15163943

  22. laanwj commented at 9:56 AM on May 12, 2016: member

    Tested ACK 8b0e497

  23. laanwj merged this on May 12, 2016
  24. laanwj closed this on May 12, 2016

  25. laanwj referenced this in commit 7c8558da36 on May 12, 2016
  26. codablock referenced this in commit c8d45d3521 on Sep 7, 2017
  27. UdjinM6 referenced this in commit 9707ca5cea on Sep 9, 2017
  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-13 18:15 UTC

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