qt ButtonsWidget: Don't pass app instance to addCopyButton
Doesn't make sense to pass the application when we can just use
QApplication.instance() instead.
from 54ccf640c5
This commit is contained in:
@@ -66,7 +66,7 @@ class AddressDialog(WindowModalDialog):
|
||||
|
||||
vbox.addWidget(QLabel(_("Address") + ":"))
|
||||
self.addr_e = ButtonsLineEdit(self.address)
|
||||
self.addr_e.addCopyButton(self.app)
|
||||
self.addr_e.addCopyButton()
|
||||
self.addr_e.add_qr_show_button(config=self.config, title=_("Address"))
|
||||
self.addr_e.setReadOnly(True)
|
||||
vbox.addWidget(self.addr_e)
|
||||
@@ -79,7 +79,7 @@ class AddressDialog(WindowModalDialog):
|
||||
vbox.addWidget(QLabel(_("Public keys") + ':'))
|
||||
for pubkey in pubkeys:
|
||||
pubkey_e = ButtonsLineEdit(pubkey)
|
||||
pubkey_e.addCopyButton(self.app)
|
||||
pubkey_e.addCopyButton()
|
||||
pubkey_e.setReadOnly(True)
|
||||
vbox.addWidget(pubkey_e)
|
||||
|
||||
@@ -87,21 +87,21 @@ class AddressDialog(WindowModalDialog):
|
||||
if redeem_script:
|
||||
vbox.addWidget(QLabel(_("Redeem Script") + ':'))
|
||||
redeem_e = ShowQRTextEdit(text=redeem_script, config=self.config)
|
||||
redeem_e.addCopyButton(self.app)
|
||||
redeem_e.addCopyButton()
|
||||
vbox.addWidget(redeem_e)
|
||||
|
||||
witness_script = self.wallet.get_witness_script(address)
|
||||
if witness_script:
|
||||
vbox.addWidget(QLabel(_("Witness Script") + ':'))
|
||||
witness_e = ShowQRTextEdit(text=witness_script, config=self.config)
|
||||
witness_e.addCopyButton(self.app)
|
||||
witness_e.addCopyButton()
|
||||
vbox.addWidget(witness_e)
|
||||
|
||||
address_path_str = self.wallet.get_address_path_str(address)
|
||||
if address_path_str:
|
||||
vbox.addWidget(QLabel(_("Derivation path") + ':'))
|
||||
der_path_e = ButtonsLineEdit(address_path_str)
|
||||
der_path_e.addCopyButton(self.app)
|
||||
der_path_e.addCopyButton()
|
||||
der_path_e.setReadOnly(True)
|
||||
vbox.addWidget(der_path_e)
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ class ChannelDetailsDialog(QtWidgets.QDialog, MessageBoxMixin):
|
||||
vbox = QtWidgets.QVBoxLayout(self)
|
||||
vbox.addWidget(QLabel(_('Remote Node ID:')))
|
||||
remote_id_e = ButtonsLineEdit(bh2u(chan.node_id))
|
||||
remote_id_e.addCopyButton(self.window.app)
|
||||
remote_id_e.addCopyButton()
|
||||
remote_id_e.setReadOnly(True)
|
||||
vbox.addWidget(remote_id_e)
|
||||
funding_label_text = f'<a href=click_destination>{chan.funding_outpoint.txid}</a>:{chan.funding_outpoint.output_index}'
|
||||
|
||||
@@ -75,7 +75,7 @@ class LightningTxDialog(WindowModalDialog):
|
||||
|
||||
vbox.addWidget(QLabel(_("Payment hash") + ":"))
|
||||
self.hash_e = ButtonsLineEdit(self.payment_hash)
|
||||
self.hash_e.addCopyButton(self.parent.app)
|
||||
self.hash_e.addCopyButton()
|
||||
self.hash_e.add_qr_show_button(config=self.config, title=_("Payment hash"))
|
||||
self.hash_e.setReadOnly(True)
|
||||
self.hash_e.setFont(QFont(MONOSPACE_FONT))
|
||||
@@ -83,7 +83,7 @@ class LightningTxDialog(WindowModalDialog):
|
||||
|
||||
vbox.addWidget(QLabel(_("Preimage") + ":"))
|
||||
self.preimage_e = ButtonsLineEdit(self.preimage)
|
||||
self.preimage_e.addCopyButton(self.parent.app)
|
||||
self.preimage_e.addCopyButton()
|
||||
self.preimage_e.add_qr_show_button(config=self.config, title=_("Preimage"))
|
||||
self.preimage_e.setReadOnly(True)
|
||||
self.preimage_e.setFont(QFont(MONOSPACE_FONT))
|
||||
@@ -92,7 +92,7 @@ class LightningTxDialog(WindowModalDialog):
|
||||
vbox.addWidget(QLabel(_("Lightning Invoice") + ":"))
|
||||
self.invoice_e = ShowQRTextEdit(self.invoice, config=self.config)
|
||||
self.invoice_e.setMaximumHeight(150)
|
||||
self.invoice_e.addCopyButton(self.parent.app)
|
||||
self.invoice_e.addCopyButton()
|
||||
vbox.addWidget(self.invoice_e)
|
||||
|
||||
vbox.addLayout(Buttons(CloseButton(self)))
|
||||
|
||||
@@ -1254,7 +1254,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
||||
|
||||
for e in [self.receive_address_e, self.receive_URI_e, self.receive_lightning_e]:
|
||||
e.setFont(QFont(MONOSPACE_FONT))
|
||||
e.addCopyButton(self.app)
|
||||
e.addCopyButton()
|
||||
e.setReadOnly(True)
|
||||
|
||||
self.receive_lightning_e.textChanged.connect(self.update_receive_widgets)
|
||||
@@ -1534,7 +1534,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
||||
from .paytoedit import PayToEdit
|
||||
self.amount_e = BTCAmountEdit(self.get_decimal_point)
|
||||
self.payto_e = PayToEdit(self)
|
||||
self.payto_e.addPasteButton(self.app)
|
||||
self.payto_e.addPasteButton()
|
||||
msg = (_("Recipient of the funds.") + "\n\n"
|
||||
+ _("You may enter a Bitcoin address, a label from your list of contacts "
|
||||
"(a list of completions will be proposed), "
|
||||
@@ -2459,7 +2459,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
||||
grid.addWidget(QLabel(invoice.message), 2, 1)
|
||||
grid.addWidget(QLabel(_("Hash") + ':'), 3, 0)
|
||||
payhash_e = ButtonsLineEdit(lnaddr.paymenthash.hex())
|
||||
payhash_e.addCopyButton(self.app)
|
||||
payhash_e.addCopyButton()
|
||||
payhash_e.setReadOnly(True)
|
||||
vbox.addWidget(payhash_e)
|
||||
grid.addWidget(payhash_e, 3, 1)
|
||||
@@ -2468,7 +2468,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
||||
grid.addWidget(QLabel(format_time(invoice.time + invoice.exp)), 4, 1)
|
||||
vbox.addLayout(grid)
|
||||
invoice_e = ShowQRTextEdit(config=self.config)
|
||||
invoice_e.addCopyButton(self.app)
|
||||
invoice_e.addCopyButton()
|
||||
invoice_e.setText(invoice.lightning_invoice)
|
||||
vbox.addWidget(invoice_e)
|
||||
vbox.addLayout(Buttons(CloseButton(d),))
|
||||
@@ -2767,7 +2767,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
||||
nodeid_text = self.wallet.lnworker.node_keypair.pubkey.hex()
|
||||
nodeid_e = ButtonsLineEdit(nodeid_text)
|
||||
nodeid_e.add_qr_show_button(config=self.config, title=_("Node ID"))
|
||||
nodeid_e.addCopyButton(self.app)
|
||||
nodeid_e.addCopyButton()
|
||||
nodeid_e.setReadOnly(True)
|
||||
nodeid_e.setFont(QFont(MONOSPACE_FONT))
|
||||
grid.addWidget(nodeid_e, 8, 0, 1, 4)
|
||||
@@ -2814,7 +2814,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
||||
|
||||
mpk_text = ShowQRTextEdit(ks.get_master_public_key(), config=self.config)
|
||||
mpk_text.setMaximumHeight(150)
|
||||
mpk_text.addCopyButton(self.app)
|
||||
mpk_text.addCopyButton()
|
||||
run_hook('show_xpub_button', mpk_text, ks)
|
||||
|
||||
der_path_hbox = QHBoxLayout()
|
||||
@@ -2909,7 +2909,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
||||
vbox.addWidget(QLabel(_("Script type") + ': ' + xtype))
|
||||
vbox.addWidget(QLabel(_("Private key") + ':'))
|
||||
keys_e = ShowQRTextEdit(text=pk, config=self.config)
|
||||
keys_e.addCopyButton(self.app)
|
||||
keys_e.addCopyButton()
|
||||
vbox.addWidget(keys_e)
|
||||
vbox.addLayout(Buttons(CloseButton(d)))
|
||||
d.setLayout(vbox)
|
||||
|
||||
@@ -857,8 +857,9 @@ class ButtonsWidget(QWidget):
|
||||
self.buttons.append(button)
|
||||
return button
|
||||
|
||||
def addCopyButton(self, app: QApplication):
|
||||
def addCopyButton(self):
|
||||
def on_copy():
|
||||
app = QApplication.instance()
|
||||
app.clipboard().setText(self.text())
|
||||
QToolTip.showText(QCursor.pos(), _("Text copied to clipboard"), self)
|
||||
|
||||
@@ -866,13 +867,13 @@ class ButtonsWidget(QWidget):
|
||||
|
||||
def addPasteButton(
|
||||
self,
|
||||
app: QApplication,
|
||||
*,
|
||||
setText: Callable[[str], None] = None,
|
||||
):
|
||||
if setText is None:
|
||||
setText = self.setText
|
||||
def on_paste():
|
||||
app = QApplication.instance()
|
||||
setText(app.clipboard().text())
|
||||
|
||||
self.addButton("copy.png", on_paste, _("Paste from clipboard"))
|
||||
|
||||
Reference in New Issue
Block a user