1
0

add watchtower_window

This commit is contained in:
ThomasV
2019-01-30 17:24:43 +01:00
parent 7bb4ea150f
commit 19e60f00bb
5 changed files with 121 additions and 8 deletions

View File

@@ -111,6 +111,7 @@ class ElectrumGui(Logger):
self.timer.setInterval(500) # msec
self.nd = None
self.watchtower_window = None
self.network_updated_signal_obj = QNetworkUpdatedSignalObject()
self._num_wizards_in_progress = 0
self._num_wizards_lock = threading.Lock()
@@ -149,8 +150,12 @@ class ElectrumGui(Logger):
else:
m = self.tray.contextMenu()
m.clear()
if self.watchtower_window:
submenu = m.addMenu(_("watchtower"))
submenu.addAction(_("Show/Hide"), self.watchtower_window.show_or_hide)
for window in self.windows:
submenu = m.addMenu(window.wallet.basename())
name = window.wallet.basename()
submenu = m.addMenu(name)
submenu.addAction(_("Show/Hide"), window.show_or_hide)
submenu.addAction(_("Close"), window.close)
m.addAction(_("Dark/Light"), self.toggle_tray_icon)
@@ -180,11 +185,20 @@ class ElectrumGui(Logger):
def close(self):
for window in self.windows:
window.close()
if self.watchtower_window:
self.watchtower_window.close()
def new_window(self, path, uri=None):
# Use a signal as can be called from daemon thread
self.app.new_window_signal.emit(path, uri)
def create_watchtower_window(self):
from .watchtower_window import WatchTowerWindow
self.watchtower_window = WatchTowerWindow(self)
def show_watchtower_dialog(self, parent):
self.watchtower_window.bring_to_top()
def show_network_dialog(self, parent):
if not self.daemon.network:
parent.show_warning(_('You are using Electrum in offline mode; restart Electrum if you want to get connected'), title=_('Offline'))
@@ -326,6 +340,9 @@ class ElectrumGui(Logger):
self.logger.exception('')
return
self.timer.start()
# todo: create this only if channels need it
self.create_watchtower_window()
self.config.open_last_wallet()
path = self.config.get_wallet_path()
if not self.start_new_window(path, self.config.get('url'), app_is_starting=True):
@@ -338,7 +355,7 @@ class ElectrumGui(Logger):
return
# check if a wizard is in progress
with self._num_wizards_lock:
if self._num_wizards_in_progress > 0 or len(self.windows) > 0:
if self._num_wizards_in_progress > 0 or len(self.windows) > 0 or self.watchtower_window:
return
self.app.quit()
self.app.setQuitOnLastWindowClosed(False) # so _we_ can decide whether to quit