commit fa446eac2e06ddaa4434787b408ea8fb8fe8baca
parent 2bd9ef1cdb66e605d1e89ded1f92c8ddd486c7f3
Author: ThomasV <thomasv@gitorious>
Date: Mon, 20 Apr 2015 14:15:18 +0200
improved buttons
Diffstat:
2 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/gui/qt/main_window.py b/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_()
diff --git a/gui/qt/util.py b/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):