macOS: Post user notifications using QSystemTrayIcon #114

pull hebasto wants to merge 3 commits into bitcoin-core:master from hebasto:201024-qstim changing 8 files +17 −141
  1. hebasto commented at 8:41 pm on October 24, 2020: member

    Pros:

    Cons:

    • this approach does not support launching a just compiled binary from the Terminal (this affects developers rather end users)

    Close #112

    Note: no Growl is required :)

  2. qt: Add QSystemTrayIcon properties into LogQtInfo output 883883e678
  3. qt: Post user notifications using QSystemTrayIcon on macOS 9a8474412c
  4. qt: Remove unused macnotificationhandler module 717f9a25f4
  5. hebasto commented at 10:29 pm on October 24, 2020: member
  6. MarcoFalke added the label macOS on Oct 25, 2020
  7. jonasschnelli commented at 9:10 am on October 25, 2020: contributor
    Will this still use macOS’es Notification Center? How does this interact with non code signed and non “notarized” apps?
  8. hebasto commented at 9:34 am on October 25, 2020: member

    Will this still use macOS’es Notification Center?

    Yes, it will.

    How does this interact with non code signed and non “notarized” apps?

    Tested on non code signed apps: Bitcoin-Core.dmg and gitian bitcoin-717f9a25f414-osx-unsigned.dmg.

  9. jonasschnelli commented at 9:50 am on October 25, 2020: contributor
    Concept ACK
  10. Sjors commented at 11:48 am on October 26, 2020: member

    How do I produce a notification on macOS this way?

    02020-10-26T11:43:32Z [main] System tray properties:
    12020-10-26T11:43:32Z [main]  is available: yes
    22020-10-26T11:43:32Z [main]  supports balloon messages: yes
    

    But sending transactions back and forth doesn’t trigger a notification. I tried making a DMG and installing from that locally.

    I don’t mind making things a bit more annoying for self-compilation on macOS if it allows dropping a whole bunch of deprecated code.

  11. hebasto commented at 2:54 pm on October 26, 2020: member

    @Sjors

    How do I produce a notification on macOS this way?

    But sending transactions back and forth doesn’t trigger a notification. I tried making a DMG and installing from that locally.

    Tested on macOS 10.15:

    • installed Bitcoin-Core.dmg which was cross compiled on Linux Mint 20
    • installed gitian built bitcoin-717f9a25f414-osx-unsigned.dmg

    ~While compiling locally on macOS 10.15 I get an error:~

    0% make deploy
    1...
    2+ Finalizing .dmg disk image +
    3hdiutil: convert failed - Resource temporarily unavailable
    4make: *** [Makefile:1279: Bitcoin-Core.dmg] Error 1
    

    ~Application has actually been installed into Applications folder, but, indeed, has no interactions with the Notification Center.~

    ~Is make deploy broken?~

  12. fanquake commented at 11:03 pm on October 26, 2020: member

    Is make deploy broken?

    No.

    • Finalizing .dmg disk image + hdiutil: convert failed - Resource temporarily unavailable make: *** [Makefile:1279: Bitcoin-Core.dmg] Error 1

    This error happens when you run make deploy, but there is already a Bitcoin-Core.dmg mounted.

    I tested this branch and notifications seem to work fine, although I don’t remember seeing the cloud with the exclamation point before:

    popup

    notif_center

  13. hebasto commented at 7:27 am on October 27, 2020: member

    @Sjors @fanquake

    What are your environments (macOS version, Qt version)?

  14. fanquake commented at 7:43 am on October 27, 2020: member

    What are your environments (macOS version, Qt version)?

    macOS 10.15.7. Qt 5.15.1.

  15. hebasto commented at 9:05 am on October 27, 2020: member

    I’ve re-tested one more time.

    Is make deploy broken?

    No.

    Correct. make deploy works fine. It was wrong usage by me :)

    To make this PR work on macOS one should run Bitcoin Core.app (installation of Bitcoin-Qt.dmg is not required).

    Some screenshots:

    • Catalina 10.15.7 (19H2) Screenshot from 2020-10-27 10-54-15 Screenshot from 2020-10-27 10-54-30

    • Big Sur 11.0 Beta (20A5395g) Screenshot from 2020-10-27 10-53-45 Screenshot from 2020-10-27 10-52-38 Screenshot from 2020-10-27 10-53-11

  16. jonasschnelli commented at 1:07 pm on October 27, 2020: contributor
    Tested ACK 717f9a25f4144fc34cb926a8decf0ac6c9b9dfd8
  17. jonasschnelli added this to the milestone 0.22.0 on Oct 27, 2020
  18. jonasschnelli commented at 1:54 pm on October 27, 2020: contributor
    Is the current notification support on macOS in master broken? If so, this qualifies as a bugfix I’d say.
  19. hebasto commented at 2:06 pm on October 27, 2020: member

    Is the current notification support on macOS in master broken?

    No, it isn’t.

  20. Sjors commented at 2:52 pm on October 30, 2020: member

    macOS 10.15.7 with QT 5.15.1 via homebrew. I tried using Bitcoin-Qt.app rather than the DMG route and it works fine.

    The tray icon is a bit weird, because nothing happens when you click on it:

    That’s because trayIconActivated still has an exception for macOS. It’s a bit annoying that QT requires this tray icon to be visible in order for notifications to work, but anyway.

    The exclamation mark in notifications could be avoided, by tweaking void Notificator::notifySystray:

    0{
    1    QSystemTrayIcon::MessageIcon sicon = QSystemTrayIcon::NoIcon;
    2    switch(cls) // Set icon based on class
    3    {
    4#ifdef Q_OS_MAC
    5    case Information: sicon = QSystemTrayIcon::NoIcon; break;
    6#else
    7    case Information: sicon = QSystemTrayIcon::Information; break;
    8#endif
    
  21. hebasto commented at 8:41 pm on October 30, 2020: member

    @Sjors

    Thank you for reviewing!

    The tray icon is a bit weird, because nothing happens when you click on it:

    I think some behavior could be assigned to the tray icon, but it would be unusual for macOS UX, no?

    The exclamation mark in notifications could be avoided, by tweaking void Notificator::notifySystray:

    Do we need to avoid it?

  22. Sjors commented at 8:27 am on October 31, 2020: member

    Given that we can’t avoid the tray icon (afaik), it would be good if it shows / hides the window. That way at least it doesn’t feel broken.

    Typically on macOS these icons provide a menu with shortcuts to various functions. That might be better, if it’s not too much work:

    As for the explanation mark, I would prefer to avoid it, because it’s very non standard. It could be interpreted as an error. That said, it’s not the end of the world.

  23. hebasto commented at 8:50 am on October 31, 2020: member

    Given that we can’t avoid the tray icon (afaik), it would be good if it shows / hides the window. That way at least it doesn’t feel broken.

    Typically on macOS these icons provide a menu with shortcuts to various functions. That might be better, if it’s not too much work:

    I’d leave adding tray icon functionality for a follow up as it will probably raise another discussion.

    As for the explanation mark, I would prefer to avoid it, because it’s very non standard. It could be interpreted as an error. That said, it’s not the end of the world.

    Ok, Going to patch it.

  24. johnsBeharry commented at 11:25 am on October 31, 2020: none

    Notification Title

    Nitpick for the notification title. Since the logo is already included its not necessary to repeat “Bitcoin Core”.

    Frame 9


    Context Menu

    WRT the menu bar context menu options. Personally I’d like to be able to quickly start/stop syncing cause I’m not always on a consistent connection.

    0Network Activity: Enabled
    1Disable Network Activity
    2---
    3Receive
    4Send
    5---
    6Open Bitcoin Core
    

    @gbks took conceptual look at what the design for a menu bar app could look like. Perhaps he can give some input - it also focused on network activity switch.

    EdiZBWuXsAAAaGbsource

  25. Sjors commented at 5:35 pm on November 2, 2020: member
    @johnsBeharry macOS notifications always have the application name in the title. It’s also good for accessibility, think voice readers.
  26. jonasschnelli commented at 8:42 am on November 4, 2020: contributor
    I missed the new tray icon in my tests and only focused on the actual notification. The visible global menu icon is a NACK element to me. Can we use the system notification without a visible global menu icon? Under the hood, they are two separated frameworks. But maybe Qt combines them as one.
  27. jonasschnelli commented at 8:48 am on November 4, 2020: contributor
  28. hebasto commented at 8:59 am on November 4, 2020: member

    Can we use the system notification without a visible global menu icon?

    No.

    Under the hood, they are two separated frameworks. But maybe Qt combines them as one.

    If a tray icon is hidden, m_statusItem == nil and QCocoaSystemTrayIcon::showMessage is noop.

  29. hebasto commented at 9:30 am on November 12, 2020: member

    This is the mac Qt code for further analysis: https://github.com/qt/qtbase/blob/81e09ae404b632a92e1e4c27f5875bdf027c5401/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm

    It uses the deprecated NSUserNotificationCenter, and in Qt community I’ve found no signs of moving from NSUserNotificationCenter to UNUserNotificationCenter.

  30. luke-jr commented at 6:51 pm on November 13, 2020: member
    While the menu app concept looks nice, I do think users should be able to disable it if they want, and shouldn’t lose notifications by doing so…
  31. DrahtBot commented at 11:46 am on December 1, 2020: contributor

    🐙 This pull request conflicts with the target branch and needs rebase.

    Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a “draft”.

  32. DrahtBot added the label Needs rebase on Dec 1, 2020
  33. hebasto commented at 8:50 pm on December 1, 2020: member

    @luke-jr

    While the menu app concept looks nice, I do think users should be able to disable it if they want, and shouldn’t lose notifications by doing so…

    Only visible icon allows notifications via QSystemTrayIcon. Adding menu to that icon is not a goal of this PR.

    Another approach is to use the new UNUserNotificationCenter, but I have no success to authorize bitcoin-qt for notifications.

    I’ll readily close this PR in favor of any alternative one.

  34. RandyMcMillan commented at 1:57 am on December 7, 2020: contributor

    MacOS 10.14.6 (18G103) Qt Creator 4.13.3 Based on Qt 5.15.2 (Clang 11.0 (Apple), 64 bit) Built on Nov 13 2020 12:39:07 From revision 524cad144a


    I agree with @jonasschnelli on the menu icon. Until more functionality is added to the icon - it should be omitted (imo).

    Screen Shot 2020-12-06 at 8 35 35 PM

    Screen Shot 2020-12-06 at 7 46 16 PM


    build command used…

    rm -f src/bitcoind && rm -rf Bitcoin-Qt.app && rm -rf ~/Library/Saved\ Application\ State/org.bitcoinfoundation.Bitcoin-Qt.savedState && rm -rf ~/Library/Preferences/org.bitcoin.Bitcoin-Qt.plist && make appbundle && wait && ./Bitcoin-Qt.app/Contents/MacOS/Bitcoin-Qt


  35. hebasto commented at 8:20 pm on February 21, 2021: member
    Closing as I cannot see the way to provide notifications in Qt way without the visible global menu icon.
  36. hebasto closed this on Feb 21, 2021

  37. hebasto commented at 8:23 pm on February 21, 2021: member
    @jonasschnelli Could be labeled “Up for grabs” :)
  38. MarcoFalke added the label up for grabs on Feb 22, 2021
  39. hebasto removed the label Needs rebase on Apr 30, 2021
  40. bitcoin-core locked this on Aug 16, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/gui. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-23 07:20 UTC

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