Skip to content

Commit

Permalink
Fix #91 -- Adjust default position for CashShuffle right-click menu
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
cculianu committed Mar 14, 2019
1 parent e1edfa5 commit 0bb3caa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
20 changes: 17 additions & 3 deletions gui/qt/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
9 changes: 8 additions & 1 deletion plugins/shuffle/qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0bb3caa

Please sign in to comment.