X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=gui%2Fqt%2Fpaytoedit.py;h=f3063732d96c7d350337f45bdc4e1e620d06127b;hb=c0fe5962ad32ab43d75b9cee124b860c0acbdf24;hp=05eee9892244ae97c6e64725e2f17f5c79743fb4;hpb=8295ef8c7f1f34bb0cb489b19f4fa727070c8514;p=electrum-nvc.git diff --git a/gui/qt/paytoedit.py b/gui/qt/paytoedit.py index 05eee98..f306373 100644 --- a/gui/qt/paytoedit.py +++ b/gui/qt/paytoedit.py @@ -28,7 +28,7 @@ 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 { }" +normal_style = "QPlainTextEdit { }" class PayToEdit(QRTextEdit): @@ -39,8 +39,6 @@ class PayToEdit(QRTextEdit): self.document().contentsChanged.connect(self.update_size) self.heightMin = 0 self.heightMax = 150 - self.setMinimumHeight(27) - self.setMaximumHeight(27) self.c = None self.textChanged.connect(self.check_text) self.outputs = [] @@ -69,9 +67,14 @@ class PayToEdit(QRTextEdit): self.setStyleSheet("QWidget { background-color:#ffcccc;}") def parse_address_and_amount(self, line): - x, y = line.split(',') - address = self.parse_address(x) - amount = self.parse_amount(y) + m = re.match('^OP_RETURN\s+"(.+)"$', line.strip()) + if m: + address = 'OP_RETURN:' + m.group(1) + amount = 0 + else: + x, y = line.split(',') + address = self.parse_address(x) + amount = self.parse_amount(y) return address, amount @@ -121,7 +124,7 @@ class PayToEdit(QRTextEdit): self.outputs = outputs self.payto_address = None - if total: + if outputs: self.amount_edit.setAmount(total) else: self.amount_edit.setText("") @@ -156,9 +159,11 @@ class PayToEdit(QRTextEdit): def update_size(self): docHeight = self.document().size().height() - if self.heightMin <= docHeight <= self.heightMax: - self.setMinimumHeight(docHeight + 2) - self.setMaximumHeight(docHeight + 2) + h = docHeight*17 + 11 + if self.heightMin <= h <= self.heightMax: + self.setMinimumHeight(h) + self.setMaximumHeight(h) + self.verticalScrollBar().hide() def setCompleter(self, completer): @@ -202,11 +207,7 @@ class PayToEdit(QRTextEdit): e.ignore() return - isShortcut = (e.modifiers() and Qt.ControlModifier) and e.key() == Qt.Key_E - - if not self.c or not isShortcut: - QTextEdit.keyPressEvent(self, e) - + QPlainTextEdit.keyPressEvent(self, e) ctrlOrShift = e.modifiers() and (Qt.ControlModifier or Qt.ShiftModifier) if self.c is None or (ctrlOrShift and e.text().isEmpty()): @@ -216,7 +217,7 @@ class PayToEdit(QRTextEdit): hasModifier = (e.modifiers() != Qt.NoModifier) and not ctrlOrShift; completionPrefix = self.textUnderCursor() - if not isShortcut and (hasModifier or e.text().isEmpty() or completionPrefix.length() < 1 or eow.contains(e.text().right(1)) ): + if hasModifier or e.text().isEmpty() or completionPrefix.length() < 1 or eow.contains(e.text().right(1)): self.c.popup().hide() return @@ -228,4 +229,3 @@ class PayToEdit(QRTextEdit): cr.setWidth(self.c.popup().sizeHintForColumn(0) + self.c.popup().verticalScrollBar().sizeHint().width()) self.c.complete(cr) -