Browse Source

improved buttons

283
ThomasV 10 years ago
parent
commit
fa446eac2e
  1. 19
      gui/qt/main_window.py
  2. 8
      gui/qt/util.py

19
gui/qt/main_window.py

@ -579,7 +579,7 @@ class ElectrumWindow(QMainWindow):
grid.setColumnMinimumWidth(3, 300)
self.receive_address_e = ButtonsLineEdit()
self.receive_address_e.addButton(":icons/copy.png", lambda: self.app.clipboard().setText(str(self.receive_address_e.text())), _("Copy Address to Clibboard"))
self.receive_address_e.addCopyButton(self.app)
self.receive_address_e.setReadOnly(True)
self.receive_address_label = QLabel(_('Receiving address'))
self.receive_address_e.textChanged.connect(self.update_receive_qr)
@ -1749,7 +1749,8 @@ class ElectrumWindow(QMainWindow):
mpk_text.setMaximumHeight(170)
vbox.addWidget(mpk_text)
vbox.addLayout(Buttons(CopyButton(mpk_text, self.app), CloseButton(dialog)))
mpk_text.addCopyButton(self.app)
vbox.addLayout(Buttons(CloseButton(dialog)))
dialog.setLayout(vbox)
dialog.exec_()
@ -1815,9 +1816,10 @@ class ElectrumWindow(QMainWindow):
vbox = QVBoxLayout()
vbox.addWidget( QLabel(_("Address") + ': ' + address))
vbox.addWidget( QLabel(_("Public key") + ':'))
keys = ShowQRTextEdit(text='\n'.join(pubkey_list))
vbox.addWidget(keys)
vbox.addLayout(Buttons(CopyButton(keys, self.app), CloseButton(d)))
keys_e = ShowQRTextEdit(text='\n'.join(pubkey_list))
keys_e.addCopyButton(self.app)
vbox.addWidget(keys_e)
vbox.addLayout(Buttons(CloseButton(d)))
d.setLayout(vbox)
d.exec_()
@ -1838,9 +1840,10 @@ class ElectrumWindow(QMainWindow):
vbox = QVBoxLayout()
vbox.addWidget( QLabel(_("Address") + ': ' + address))
vbox.addWidget( QLabel(_("Private key") + ':'))
keys = ShowQRTextEdit(text='\n'.join(pk_list))
vbox.addWidget(keys)
vbox.addLayout(Buttons(CopyButton(keys, self.app), CloseButton(d)))
keys_e = ShowQRTextEdit(text='\n'.join(pk_list))
keys_e.addCopyButton(self.app)
vbox.addWidget(keys_e)
vbox.addLayout(Buttons(CloseButton(d)))
d.setLayout(vbox)
d.exec_()

8
gui/qt/util.py

@ -342,13 +342,18 @@ class ButtonsWidget(QWidget):
def addButton(self, icon_name, on_click, tooltip):
button = QToolButton(self)
button.setIcon(QIcon(icon_name))
button.setStyleSheet("QToolButton { border: none; padding: 0px; }")
button.setStyleSheet("QToolButton { border: none; hover {border: 1px} pressed {border: 1px} padding: 0px; }")
button.setVisible(True)
button.setToolTip(tooltip)
button.clicked.connect(on_click)
self.buttons.append(button)
return button
def addCopyButton(self, app):
self.app = app
f = lambda: self.app.clipboard().setText(str(self.text()))
self.addButton(":icons/copy.png", f, _("Copy to Clibboard"))
class ButtonsLineEdit(QLineEdit, ButtonsWidget):
def __init__(self, text=None):
QLineEdit.__init__(self, text)
@ -363,6 +368,7 @@ class ButtonsTextEdit(QPlainTextEdit, ButtonsWidget):
def __init__(self, text=None):
QPlainTextEdit.__init__(self, text)
self.setText = self.setPlainText
self.text = self.toPlainText
self.buttons = []
def resizeEvent(self, e):

Loading…
Cancel
Save