Remove dynamic classes in trezor compatible plugins.
This is unecessarily complex, and can be achieved by inheritance.
This commit is contained in:
parent
b07d3466c0
commit
e542b24bc6
|
@ -1,8 +1,8 @@
|
||||||
from ..trezor.qt_generic import qt_plugin_class
|
from ..trezor.qt_generic import QtPlugin
|
||||||
from keepkey import KeepKeyPlugin
|
from keepkey import KeepKeyPlugin
|
||||||
|
|
||||||
|
|
||||||
class Plugin(qt_plugin_class(KeepKeyPlugin)):
|
class Plugin(KeepKeyPlugin, QtPlugin):
|
||||||
icon_paired = ":icons/keepkey.png"
|
icon_paired = ":icons/keepkey.png"
|
||||||
icon_unpaired = ":icons/keepkey_unpaired.png"
|
icon_unpaired = ":icons/keepkey_unpaired.png"
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
from ..trezor.qt_generic import qt_plugin_class
|
from ..trezor.qt_generic import QtPlugin
|
||||||
from trezor import TrezorPlugin
|
from trezor import TrezorPlugin
|
||||||
|
|
||||||
|
|
||||||
class Plugin(qt_plugin_class(TrezorPlugin)):
|
class Plugin(TrezorPlugin, QtPlugin):
|
||||||
icon_unpaired = ":icons/trezor_unpaired.png"
|
icon_unpaired = ":icons/trezor_unpaired.png"
|
||||||
icon_paired = ":icons/trezor.png"
|
icon_paired = ":icons/trezor.png"
|
||||||
|
|
||||||
|
|
|
@ -178,9 +178,7 @@ class QtHandler(QtHandlerBase):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def qt_plugin_class(base_plugin_class):
|
class QtPlugin(object):
|
||||||
|
|
||||||
class QtPlugin(base_plugin_class):
|
|
||||||
# Derived classes must provide the following class-static variables:
|
# Derived classes must provide the following class-static variables:
|
||||||
# icon_file
|
# icon_file
|
||||||
# pin_matrix_widget_class
|
# pin_matrix_widget_class
|
||||||
|
@ -194,8 +192,8 @@ def qt_plugin_class(base_plugin_class):
|
||||||
if type(keystore) != self.keystore_class:
|
if type(keystore) != self.keystore_class:
|
||||||
continue
|
continue
|
||||||
tooltip = self.device + ' ' + (keystore.label or '')
|
tooltip = self.device + ' ' + (keystore.label or '')
|
||||||
button = StatusBarButton(QIcon(self.icon_unpaired), tooltip,
|
cb = lambda: self.show_settings_dialog(window, keystore)
|
||||||
partial(self.settings_dialog, window, keystore))
|
button = StatusBarButton(QIcon(self.icon_unpaired), tooltip, cb)
|
||||||
window.statusBar().addPermanentWidget(button)
|
window.statusBar().addPermanentWidget(button)
|
||||||
handler = self.create_handler(window)
|
handler = self.create_handler(window)
|
||||||
handler.button = button
|
handler.button = button
|
||||||
|
@ -223,7 +221,7 @@ def qt_plugin_class(base_plugin_class):
|
||||||
keystore.thread.add(partial(self.show_address, wallet, addrs[0]))
|
keystore.thread.add(partial(self.show_address, wallet, addrs[0]))
|
||||||
menu.addAction(_("Show on %s") % self.device, show_address)
|
menu.addAction(_("Show on %s") % self.device, show_address)
|
||||||
|
|
||||||
def settings_dialog(self, window, keystore):
|
def show_settings_dialog(self, window, keystore):
|
||||||
device_id = self.choose_device(window, keystore)
|
device_id = self.choose_device(window, keystore)
|
||||||
if device_id:
|
if device_id:
|
||||||
SettingsDialog(window, self, device_id).exec_()
|
SettingsDialog(window, self, device_id).exec_()
|
||||||
|
@ -321,7 +319,7 @@ def qt_plugin_class(base_plugin_class):
|
||||||
|
|
||||||
return (item, unicode(name.text()), pin, cb_phrase.isChecked())
|
return (item, unicode(name.text()), pin, cb_phrase.isChecked())
|
||||||
|
|
||||||
return QtPlugin
|
|
||||||
|
|
||||||
|
|
||||||
class SettingsDialog(WindowModalDialog):
|
class SettingsDialog(WindowModalDialog):
|
||||||
|
|
Loading…
Reference in New Issue