move update_status in handler
This commit is contained in:
parent
257c0915b5
commit
47f1a7b632
|
@ -384,7 +384,7 @@ class DeviceMgr(ThreadJob, PrintError):
|
||||||
|
|
||||||
def client_for_keystore(self, plugin, handler, keystore, force_pair):
|
def client_for_keystore(self, plugin, handler, keystore, force_pair):
|
||||||
self.print_error("getting client for keystore")
|
self.print_error("getting client for keystore")
|
||||||
plugin.update_status(handler, False)
|
handler.update_status(False)
|
||||||
devices = self.scan_devices()
|
devices = self.scan_devices()
|
||||||
xpub = keystore.xpub
|
xpub = keystore.xpub
|
||||||
derivation = keystore.get_derivation()
|
derivation = keystore.get_derivation()
|
||||||
|
@ -393,7 +393,7 @@ class DeviceMgr(ThreadJob, PrintError):
|
||||||
info = self.select_device(plugin, handler, keystore, devices)
|
info = self.select_device(plugin, handler, keystore, devices)
|
||||||
client = self.force_pair_xpub(plugin, handler, info, xpub, derivation, devices)
|
client = self.force_pair_xpub(plugin, handler, info, xpub, derivation, devices)
|
||||||
if client:
|
if client:
|
||||||
plugin.update_status(handler, True)
|
handler.update_status(True)
|
||||||
self.print_error("end client for keystore")
|
self.print_error("end client for keystore")
|
||||||
return client
|
return client
|
||||||
|
|
||||||
|
@ -489,12 +489,11 @@ class DeviceMgr(ThreadJob, PrintError):
|
||||||
# Note this import must be local so those without hardware
|
# Note this import must be local so those without hardware
|
||||||
# wallet libraries are not affected.
|
# wallet libraries are not affected.
|
||||||
import hid
|
import hid
|
||||||
|
|
||||||
self.print_error("scanning devices...")
|
self.print_error("scanning devices...")
|
||||||
|
hid_list = hid.enumerate(0, 0)
|
||||||
# First see what's connected that we know about
|
# First see what's connected that we know about
|
||||||
devices = []
|
devices = []
|
||||||
for d in hid.enumerate(0, 0):
|
for d in hid_list:
|
||||||
product_key = (d['vendor_id'], d['product_id'])
|
product_key = (d['vendor_id'], d['product_id'])
|
||||||
if product_key in self.recognised_hardware:
|
if product_key in self.recognised_hardware:
|
||||||
# Older versions of hid don't provide interface_number
|
# Older versions of hid don't provide interface_number
|
||||||
|
|
|
@ -46,6 +46,7 @@ class QtHandlerBase(QObject, PrintError):
|
||||||
clear_signal = pyqtSignal()
|
clear_signal = pyqtSignal()
|
||||||
query_signal = pyqtSignal(object, object)
|
query_signal = pyqtSignal(object, object)
|
||||||
yes_no_signal = pyqtSignal(object)
|
yes_no_signal = pyqtSignal(object)
|
||||||
|
status_signal = pyqtSignal(object)
|
||||||
|
|
||||||
def __init__(self, win, device):
|
def __init__(self, win, device):
|
||||||
super(QtHandlerBase, self).__init__()
|
super(QtHandlerBase, self).__init__()
|
||||||
|
@ -56,6 +57,7 @@ class QtHandlerBase(QObject, PrintError):
|
||||||
self.word_signal.connect(self.word_dialog)
|
self.word_signal.connect(self.word_dialog)
|
||||||
self.query_signal.connect(self.win_query_choice)
|
self.query_signal.connect(self.win_query_choice)
|
||||||
self.yes_no_signal.connect(self.win_yes_no_question)
|
self.yes_no_signal.connect(self.win_yes_no_question)
|
||||||
|
self.status_signal.connect(self._update_status)
|
||||||
self.win = win
|
self.win = win
|
||||||
self.device = device
|
self.device = device
|
||||||
self.dialog = None
|
self.dialog = None
|
||||||
|
@ -64,6 +66,14 @@ class QtHandlerBase(QObject, PrintError):
|
||||||
def top_level_window(self):
|
def top_level_window(self):
|
||||||
return self.win.top_level_window()
|
return self.win.top_level_window()
|
||||||
|
|
||||||
|
def update_status(self, paired):
|
||||||
|
self.status_signal.emit(paired)
|
||||||
|
|
||||||
|
def _update_status(self, paired):
|
||||||
|
button = self.button
|
||||||
|
icon = button.icon_paired if paired else button.icon_unpaired
|
||||||
|
button.setIcon(QIcon(icon))
|
||||||
|
|
||||||
def query_choice(self, msg, labels):
|
def query_choice(self, msg, labels):
|
||||||
self.done.clear()
|
self.done.clear()
|
||||||
self.query_signal.emit(msg, labels)
|
self.query_signal.emit(msg, labels)
|
||||||
|
|
|
@ -97,7 +97,6 @@ class TrezorCompatiblePlugin(HW_PluginBase):
|
||||||
|
|
||||||
def _try_bridge(self, device):
|
def _try_bridge(self, device):
|
||||||
self.print_error("Trying to connect over Trezor Bridge...")
|
self.print_error("Trying to connect over Trezor Bridge...")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return self.bridge_transport({'path': hexlify(device.path)})
|
return self.bridge_transport({'path': hexlify(device.path)})
|
||||||
except BaseException as e:
|
except BaseException as e:
|
||||||
|
|
|
@ -194,6 +194,8 @@ class QtPlugin(object):
|
||||||
tooltip = self.device + ' ' + (keystore.label or '')
|
tooltip = self.device + ' ' + (keystore.label or '')
|
||||||
cb = lambda: self.show_settings_dialog(window, keystore)
|
cb = lambda: self.show_settings_dialog(window, keystore)
|
||||||
button = StatusBarButton(QIcon(self.icon_unpaired), tooltip, cb)
|
button = StatusBarButton(QIcon(self.icon_unpaired), tooltip, cb)
|
||||||
|
button.icon_paired = self.icon_paired
|
||||||
|
button.icon_unpaired = self.icon_unpaired
|
||||||
window.statusBar().addPermanentWidget(button)
|
window.statusBar().addPermanentWidget(button)
|
||||||
handler = self.create_handler(window)
|
handler = self.create_handler(window)
|
||||||
handler.button = button
|
handler.button = button
|
||||||
|
@ -202,15 +204,6 @@ class QtPlugin(object):
|
||||||
# Trigger a pairing
|
# Trigger a pairing
|
||||||
keystore.thread.add(partial(self.get_client, keystore))
|
keystore.thread.add(partial(self.get_client, keystore))
|
||||||
|
|
||||||
window.connect(window, SIGNAL('keystore_status'), self._update_status)
|
|
||||||
|
|
||||||
def update_status(self, handler, paired):
|
|
||||||
handler.win.emit(SIGNAL('keystore_status'), handler, paired)
|
|
||||||
|
|
||||||
def _update_status(self, handler, paired):
|
|
||||||
icon = self.icon_paired if paired else self.icon_unpaired
|
|
||||||
handler.button.setIcon(QIcon(icon))
|
|
||||||
|
|
||||||
@hook
|
@hook
|
||||||
def receive_menu(self, menu, addrs, wallet):
|
def receive_menu(self, menu, addrs, wallet):
|
||||||
if type(wallet) is not Standard_Wallet:
|
if type(wallet) is not Standard_Wallet:
|
||||||
|
|
Loading…
Reference in New Issue