MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / createTrayIconMenu

Method createTrayIconMenu

src/qt/bitcoingui.cpp:884–965  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

882}
883
884void BitcoinGUI::createTrayIconMenu()
885{
886#ifndef Q_OS_MACOS
887 if (!trayIcon) return;
888#endif // Q_OS_MACOS
889
890 // Configuration of the tray icon (or Dock icon) menu.
891 QAction* show_hide_action{nullptr};
892#ifndef Q_OS_MACOS
893 // Note: On macOS, the Dock icon's menu already has Show / Hide action.
894 show_hide_action = trayIconMenu->addAction(QString(), this, &BitcoinGUI::toggleHidden);
895 trayIconMenu->addSeparator();
896#endif // Q_OS_MACOS
897
898 QAction* send_action{nullptr};
899 QAction* receive_action{nullptr};
900 QAction* sign_action{nullptr};
901 QAction* verify_action{nullptr};
902 if (enableWallet) {
903 send_action = trayIconMenu->addAction(sendCoinsAction->text(), sendCoinsAction, &QAction::trigger);
904 receive_action = trayIconMenu->addAction(receiveCoinsAction->text(), receiveCoinsAction, &QAction::trigger);
905 trayIconMenu->addSeparator();
906 sign_action = trayIconMenu->addAction(signMessageAction->text(), signMessageAction, &QAction::trigger);
907 verify_action = trayIconMenu->addAction(verifyMessageAction->text(), verifyMessageAction, &QAction::trigger);
908 trayIconMenu->addSeparator();
909 }
910 QAction* options_action = trayIconMenu->addAction(optionsAction->text(), optionsAction, &QAction::trigger);
911 options_action->setMenuRole(QAction::PreferencesRole);
912 QAction* node_window_action = trayIconMenu->addAction(openRPCConsoleAction->text(), openRPCConsoleAction, &QAction::trigger);
913 QAction* quit_action{nullptr};
914#ifndef Q_OS_MACOS
915 // Note: On macOS, the Dock icon's menu already has Quit action.
916 trayIconMenu->addSeparator();
917 quit_action = trayIconMenu->addAction(quitAction->text(), quitAction, &QAction::trigger);
918
919 trayIcon->setContextMenu(trayIconMenu.get());
920 connect(trayIcon, &QSystemTrayIcon::activated, [this](QSystemTrayIcon::ActivationReason reason) {
921 if (reason == QSystemTrayIcon::Trigger) {
922 // Click on system tray icon triggers show/hide of the main window
923 toggleHidden();
924 }
925 });
926#else
927 // Note: On macOS, the Dock icon is used to provide the tray's functionality.
928 MacDockIconHandler* dockIconHandler = MacDockIconHandler::instance();
929 connect(dockIconHandler, &MacDockIconHandler::dockIconClicked, [this] {
930 if (m_node.shutdownRequested()) return; // nothing to show, node is shutting down.
931 show();
932 activateWindow();
933 });
934 trayIconMenu->setAsDockMenu();
935#endif // Q_OS_MACOS
936
937 connect(
938 // Using QSystemTrayIcon::Context is not reliable.
939 // See https://bugreports.qt.io/browse/QTBUG-91697
940 trayIconMenu.get(), &QMenu::aboutToShow,
941 [this, show_hide_action, send_action, receive_action, sign_action, verify_action, options_action, node_window_action, quit_action] {

Callers

nothing calls this directly

Calls 5

isObscuredFunction · 0.85
setTextMethod · 0.80
getMethod · 0.45
shutdownRequestedMethod · 0.45
setEnabledMethod · 0.45

Tested by

no test coverage detected