From 0bb3caac6fe3b0cfd1fdc799892a44665e89ba99 Mon Sep 17 00:00:00 2001 From: Calin Culianu Date: Thu, 14 Mar 2019 23:41:33 +0200 Subject: [PATCH] Fix #91 -- Adjust default position for CashShuffle right-click menu In the "CashShuffle is enabled" case: - We put the "Disable CashShuffle" option at the very END after a separator (subliminally discourage from disabling, heh). - "View Pools", by far the most frequently used option, is now first. In the "CashShuffle is disabled" case: - We put the "Enabled CashShuffle" option at the very beginning, BEFORE anything else (subliminal encouragement to enable). --- gui/qt/main_window.py | 20 +++++++++++++++++--- plugins/shuffle/qt.py | 9 ++++++++- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py index 72df45614265..212076faeb54 100644 --- a/gui/qt/main_window.py +++ b/gui/qt/main_window.py @@ -2175,11 +2175,11 @@ def create_status_bar(self): self.cashshuffle_settings_action.triggered.connect(self.show_cashshuffle_settings) self.cashshuffle_viewpools_action = QAction(_("View pools..."), self.cashshuffle_status_button) self.cashshuffle_viewpools_action.triggered.connect(self.show_cashshuffle_pools) - self.cashshuffle_status_button.addAction(self.cashshuffle_toggle_action) - sep = QAction(self.cashshuffle_status_button); sep.setSeparator(True) - self.cashshuffle_status_button.addAction(sep) self.cashshuffle_status_button.addAction(self.cashshuffle_viewpools_action) self.cashshuffle_status_button.addAction(self.cashshuffle_settings_action) + self.cashshuffle_separator_action = sep = QAction(self.cashshuffle_status_button); sep.setSeparator(True) + self.cashshuffle_status_button.addAction(sep) + self.cashshuffle_status_button.addAction(self.cashshuffle_toggle_action) self.cashshuffle_status_button.setContextMenuPolicy(Qt.ActionsContextMenu) sb.addPermanentWidget(self.cashshuffle_status_button) @@ -2981,6 +2981,20 @@ def update_cashshuffle_icon(self): self.cashshuffle_viewpools_action.setEnabled(False) self.cashshuffle_settings_action.setVisible(en or loaded) self.cashshuffle_viewpools_action.setVisible(en) + if en: + # ensure 'Disable CashShuffle' appears at the end of the context menu + self.cashshuffle_status_button.removeAction(self.cashshuffle_separator_action) + self.cashshuffle_status_button.removeAction(self.cashshuffle_toggle_action) + self.cashshuffle_status_button.addAction(self.cashshuffle_separator_action) + self.cashshuffle_status_button.addAction(self.cashshuffle_toggle_action) + else: + # ensure 'Enable CashShuffle' appears at the beginning of the context menu + self.cashshuffle_status_button.removeAction(self.cashshuffle_separator_action) + self.cashshuffle_status_button.removeAction(self.cashshuffle_toggle_action) + actions = self.cashshuffle_status_button.actions() + self.cashshuffle_status_button.insertAction(actions[0] if actions else None, self.cashshuffle_separator_action) + self.cashshuffle_status_button.insertAction(self.cashshuffle_separator_action, self.cashshuffle_toggle_action) + def show_cashshuffle_settings(self): p = self.cashshuffle_plugin_if_loaded() diff --git a/plugins/shuffle/qt.py b/plugins/shuffle/qt.py index 18a8317c74c5..17981a94e576 100644 --- a/plugins/shuffle/qt.py +++ b/plugins/shuffle/qt.py @@ -528,6 +528,7 @@ def on_new_window(self, window): if not window.is_wallet_cashshuffle_compatible(): # wallet is watching-only, multisig, or hardware so.. mark it permanently for no cashshuffle self.window_set_cashshuffle(window, False) + window.update_status() # this has the side-effect of refreshing the cash shuffle status bar button's context menu (which has actions even for disabled/incompatible windows) return if window.wallet and not self.window_has_cashshuffle(window): if self.window_wants_cashshuffle(window): @@ -617,13 +618,19 @@ def action_callback(): action.setChecked(self._hide_history_txs) def on_close(self): + ''' This is called on plugin unload/disable ''' self.del_network_dialog_tab() PoolsWinMgr.killInstance() for window in self.windows.copy(): self.on_close_window(window) - window.update_status() for window in self.disabled_windows.copy(): self.on_close_window(window) + for window in self.gui.windows: + # lastly, we do this for ALL the extant wallet windows because all + # of their CashShuffle context menus attached to the cashshuffle + # status button need updating when the plugin is exited. Note + # that there may be windows in this set (incompatible windows) + # that aren't in either of the above 2 sets of windows. window.update_status() self.initted = False Plugin.instance = None