|
@ -1,6 +1,7 @@ |
|
|
from functools import partial |
|
|
from functools import partial |
|
|
import traceback |
|
|
import traceback |
|
|
import sys |
|
|
import sys |
|
|
|
|
|
from typing import TYPE_CHECKING |
|
|
|
|
|
|
|
|
from PyQt5.QtCore import QObject, pyqtSignal |
|
|
from PyQt5.QtCore import QObject, pyqtSignal |
|
|
from PyQt5.QtWidgets import (QHBoxLayout, QLabel, QVBoxLayout) |
|
|
from PyQt5.QtWidgets import (QHBoxLayout, QLabel, QVBoxLayout) |
|
@ -11,6 +12,10 @@ from electrum.gui.qt.util import ThreadedButton, Buttons, EnterButton, WindowMod |
|
|
|
|
|
|
|
|
from .labels import LabelsPlugin |
|
|
from .labels import LabelsPlugin |
|
|
|
|
|
|
|
|
|
|
|
if TYPE_CHECKING: |
|
|
|
|
|
from electrum.gui.qt import ElectrumGui |
|
|
|
|
|
from electrum.gui.qt.main_window import ElectrumWindow |
|
|
|
|
|
from electrum.wallet import Abstract_Wallet |
|
|
|
|
|
|
|
|
class QLabelsSignalObject(QObject): |
|
|
class QLabelsSignalObject(QObject): |
|
|
labels_changed_signal = pyqtSignal(object) |
|
|
labels_changed_signal = pyqtSignal(object) |
|
@ -21,6 +26,7 @@ class Plugin(LabelsPlugin): |
|
|
def __init__(self, *args): |
|
|
def __init__(self, *args): |
|
|
LabelsPlugin.__init__(self, *args) |
|
|
LabelsPlugin.__init__(self, *args) |
|
|
self.obj = QLabelsSignalObject() |
|
|
self.obj = QLabelsSignalObject() |
|
|
|
|
|
self._init_qt_received = False |
|
|
|
|
|
|
|
|
def requires_settings(self): |
|
|
def requires_settings(self): |
|
|
return True |
|
|
return True |
|
@ -63,10 +69,17 @@ class Plugin(LabelsPlugin): |
|
|
dialog.show_error(_("Error synchronising labels") + f':\n{repr(exc_info[1])}') |
|
|
dialog.show_error(_("Error synchronising labels") + f':\n{repr(exc_info[1])}') |
|
|
|
|
|
|
|
|
@hook |
|
|
@hook |
|
|
def load_wallet(self, wallet, window): |
|
|
def init_qt(self, gui: 'ElectrumGui'): |
|
|
# FIXME if the user just enabled the plugin, this hook won't be called |
|
|
if self._init_qt_received: # only need/want the first signal |
|
|
# as the wallet is already loaded, and hence the plugin will be in |
|
|
return |
|
|
# a non-functional state for that window |
|
|
self._init_qt_received = True |
|
|
|
|
|
# If the user just enabled the plugin, the 'load_wallet' hook would not |
|
|
|
|
|
# get called for already loaded wallets, hence we call it manually for those: |
|
|
|
|
|
for window in gui.windows: |
|
|
|
|
|
self.load_wallet(window.wallet, window) |
|
|
|
|
|
|
|
|
|
|
|
@hook |
|
|
|
|
|
def load_wallet(self, wallet: 'Abstract_Wallet', window: 'ElectrumWindow'): |
|
|
self.obj.labels_changed_signal.connect(window.update_tabs) |
|
|
self.obj.labels_changed_signal.connect(window.update_tabs) |
|
|
self.start_wallet(wallet) |
|
|
self.start_wallet(wallet) |
|
|
|
|
|
|
|
|