commit 10e5ec56a1ab7ffb6eee78b9fe7a0470bc373988
parent 0d02e9fd74031df0c04489462da36b439592a648
Author: ThomasV <thomasv@gitorious>
Date: Thu, 5 Jun 2014 14:49:32 +0200
setFrozen generic method
Diffstat:
3 files changed, 20 insertions(+), 32 deletions(-)
diff --git a/gui/qt/amountedit.py b/gui/qt/amountedit.py
@@ -5,7 +5,13 @@ from PyQt4.QtGui import *
from decimal import Decimal
-class AmountEdit(QLineEdit):
+class MyLineEdit(QLineEdit):
+
+ def setFrozen(self, b):
+ self.setReadOnly(b)
+ self.setFrame(not b)
+
+class AmountEdit(MyLineEdit):
def __init__(self, decimal_point, is_int = False, parent=None):
QLineEdit.__init__(self, parent)
diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py
@@ -44,7 +44,7 @@ from electrum import SimpleConfig, Wallet, WalletStorage
from electrum import bmp, pyqrnative
-from amountedit import AmountEdit
+from amountedit import AmountEdit, MyLineEdit
from network_dialog import NetworkDialog
from qrcodewidget import QRCodeWidget
@@ -656,7 +656,7 @@ class ElectrumWindow(QMainWindow):
self.payto_e.setCompleter(completer)
completer.setModel(self.completions)
- self.message_e = QLineEdit()
+ self.message_e = MyLineEdit()
self.message_help = HelpButton(_('Description of the transaction (not mandatory).') + '\n\n' + _('The description is not sent to the recipient of the funds. It is stored in your wallet file, and displayed in the \'History\' tab.'))
grid.addWidget(QLabel(_('Description')), 2, 0)
grid.addWidget(self.message_e, 2, 1, 1, 3)
@@ -882,11 +882,9 @@ class ElectrumWindow(QMainWindow):
def prepare_for_payment_request(self):
- style = "QWidget { background-color:none;border:none;}"
self.tabs.setCurrentIndex(1)
for e in [self.payto_e, self.amount_e, self.message_e]:
- e.setReadOnly(True)
- e.setStyleSheet(style)
+ e.setFrozen(True)
for h in [self.payto_help, self.amount_help, self.message_help]:
h.hide()
self.payto_e.setText(_("please wait..."))
@@ -924,27 +922,14 @@ class ElectrumWindow(QMainWindow):
self.payto_sig.setVisible(False)
for e in [self.payto_e, self.message_e, self.amount_e, self.fee_e]:
e.setText('')
- self.set_frozen(e,False)
- e.setStyleSheet("")
+ e.setFrozen(False)
+
for h in [self.payto_help, self.amount_help, self.message_help]:
h.show()
self.set_pay_from([])
self.update_status()
- def set_frozen(self,entry,frozen):
- if frozen:
- entry.setReadOnly(True)
- entry.setFrame(False)
- palette = QPalette()
- palette.setColor(entry.backgroundRole(), QColor('lightgray'))
- entry.setPalette(palette)
- else:
- entry.setReadOnly(False)
- entry.setFrame(True)
- palette = QPalette()
- palette.setColor(entry.backgroundRole(), QColor('white'))
- entry.setPalette(palette)
def set_addrs_frozen(self,addrs,freeze):
diff --git a/gui/qt/paytoedit.py b/gui/qt/paytoedit.py
@@ -26,6 +26,9 @@ from electrum import bitcoin
RE_ADDRESS = '[1-9A-HJ-NP-Za-km-z]{26,}'
RE_ALIAS = '(.*?)\s*\<([1-9A-HJ-NP-Za-km-z]{26,})\>'
+frozen_style = "QWidget { background-color:none; border:none;}"
+normal_style = "QTextEdit { }"
+
class PayToEdit(QTextEdit):
def __init__(self, amount_edit):
@@ -36,23 +39,18 @@ class PayToEdit(QTextEdit):
self.heightMax = 150
self.setMinimumHeight(27)
self.setMaximumHeight(27)
- #self.setStyleSheet("QTextEdit { border-style:solid; border-width: 1px;}")
self.c = None
def lock_amount(self):
- e = self.amount_edit
- e.setReadOnly(True)
- e.setFrame(False)
+ self.amount_edit.setFrozen(True)
def unlock_amount(self):
- e = self.amount_edit
- e.setReadOnly(False)
- e.setFrame(True)
-
+ self.amount_edit.setFrozen(False)
- def setFrame(self, b):
- pass
+ def setFrozen(self, b):
+ self.setReadOnly(b)
+ self.setStyleSheet(frozen_style if b else normal_style)
def parse_address_and_amount(self, line):
@@ -88,7 +86,6 @@ class PayToEdit(QTextEdit):
self.payto_address = None
if self.payto_address:
- print "unlock", self.payto_address
self.unlock_amount()
return