tmacOS: duplicate Qt "Preferences" menu item - electrum - Electrum Bitcoin wallet (HTM) git clone https://git.parazyd.org/electrum (DIR) Log (DIR) Files (DIR) Refs (DIR) Submodules --- (DIR) commit 40dc54e8b8f5d02f490524cd5d821460b5dc5a2c (DIR) parent 54e1520ee4cce041d46a011cdef3ba9d2d4ec043 (HTM) Author: SomberNight <somber.night@protonmail.com> Date: Mon, 13 Apr 2020 19:53:52 +0200 macOS: duplicate Qt "Preferences" menu item There is a standardised location along with reserved hotkey for "Preferences" in applications on macOS. Let's put *another* preferences menu item there. The duplicate items ensure that - an electrum user coming from a different OS, - a macOS user used to the standardised preferences location, will both find "Preferences" easily. Diffstat: M electrum/gui/qt/main_window.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) --- (DIR) diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py t@@ -45,7 +45,8 @@ from PyQt5.QtWidgets import (QMessageBox, QComboBox, QSystemTrayIcon, QTabWidget QVBoxLayout, QGridLayout, QLineEdit, QHBoxLayout, QPushButton, QScrollArea, QTextEdit, QShortcut, QMainWindow, QCompleter, QInputDialog, - QWidget, QSizePolicy, QStatusBar, QToolTip, QDialog) + QWidget, QSizePolicy, QStatusBar, QToolTip, QDialog, + QMenu, QAction) import electrum from electrum import (keystore, ecc, constants, util, bitcoin, commands, t@@ -692,10 +693,17 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): add_toggle_action(view_menu, self.contacts_tab) add_toggle_action(view_menu, self.console_tab) - tools_menu = menubar.addMenu(_("&Tools")) + tools_menu = menubar.addMenu(_("&Tools")) # type: QMenu + preferences_action = tools_menu.addAction(_("Preferences"), self.settings_dialog) # type: QAction + if sys.platform == 'darwin': + # "Settings"/"Preferences" are all reserved keywords in macOS. + # preferences_action will get picked up based on name (and put into a standardized location, + # and given a standard reserved hotkey) + # Hence, this menu item will be at a "uniform location re macOS processes" + preferences_action.setMenuRole(QAction.PreferencesRole) # make sure OS recognizes it as preferences + # Add another preferences item, to also have a "uniform location for Electrum between different OSes" + tools_menu.addAction(_("Electrum preferences"), self.settings_dialog) - # Settings / Preferences are all reserved keywords in macOS using this as work around - tools_menu.addAction(_("Electrum preferences") if sys.platform == 'darwin' else _("Preferences"), self.settings_dialog) tools_menu.addAction(_("&Network"), self.gui_object.show_network_dialog).setEnabled(bool(self.network)) tools_menu.addAction(_("&Lightning Network"), self.gui_object.show_lightning_dialog).setEnabled(bool(self.wallet.has_lightning() and self.network)) tools_menu.addAction(_("Local &Watchtower"), self.gui_object.show_watchtower_dialog).setEnabled(bool(self.network and self.network.local_watchtower))