use QPlainTextEdit instead of QTextEdit

This commit is contained in:
ThomasV 2014-07-08 17:00:52 +02:00
parent 769b4002cd
commit c0fe5962ad
2 changed files with 10 additions and 10 deletions

View File

@ -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,})\>' RE_ALIAS = '(.*?)\s*\<([1-9A-HJ-NP-Za-km-z]{26,})\>'
frozen_style = "QWidget { background-color:none; border:none;}" frozen_style = "QWidget { background-color:none; border:none;}"
normal_style = "QTextEdit { }" normal_style = "QPlainTextEdit { }"
class PayToEdit(QRTextEdit): class PayToEdit(QRTextEdit):
@ -39,8 +39,6 @@ class PayToEdit(QRTextEdit):
self.document().contentsChanged.connect(self.update_size) self.document().contentsChanged.connect(self.update_size)
self.heightMin = 0 self.heightMin = 0
self.heightMax = 150 self.heightMax = 150
self.setMinimumHeight(27)
self.setMaximumHeight(27)
self.c = None self.c = None
self.textChanged.connect(self.check_text) self.textChanged.connect(self.check_text)
self.outputs = [] self.outputs = []
@ -161,9 +159,11 @@ class PayToEdit(QRTextEdit):
def update_size(self): def update_size(self):
docHeight = self.document().size().height() docHeight = self.document().size().height()
if self.heightMin <= docHeight <= self.heightMax: h = docHeight*17 + 11
self.setMinimumHeight(docHeight + 2) if self.heightMin <= h <= self.heightMax:
self.setMaximumHeight(docHeight + 2) self.setMinimumHeight(h)
self.setMaximumHeight(h)
self.verticalScrollBar().hide()
def setCompleter(self, completer): def setCompleter(self, completer):
@ -207,7 +207,7 @@ class PayToEdit(QRTextEdit):
e.ignore() e.ignore()
return return
QTextEdit.keyPressEvent(self, e) QPlainTextEdit.keyPressEvent(self, e)
ctrlOrShift = e.modifiers() and (Qt.ControlModifier or Qt.ShiftModifier) ctrlOrShift = e.modifiers() and (Qt.ControlModifier or Qt.ShiftModifier)
if self.c is None or (ctrlOrShift and e.text().isEmpty()): if self.c is None or (ctrlOrShift and e.text().isEmpty()):

View File

@ -2,7 +2,7 @@ from electrum.i18n import _
from PyQt4.QtGui import * from PyQt4.QtGui import *
from PyQt4.QtCore import * from PyQt4.QtCore import *
class QRTextEdit(QTextEdit): class QRTextEdit(QPlainTextEdit):
def __init__(self, text=None): def __init__(self, text=None):
QTextEdit.__init__(self, text) QTextEdit.__init__(self, text)
@ -11,11 +11,11 @@ class QRTextEdit(QTextEdit):
self.button.setStyleSheet("QToolButton { border: none; padding: 0px; }") self.button.setStyleSheet("QToolButton { border: none; padding: 0px; }")
self.button.setVisible(True) self.button.setVisible(True)
self.button.clicked.connect(lambda: self.qr_show() if self.isReadOnly() else self.qr_input()) self.button.clicked.connect(lambda: self.qr_show() if self.isReadOnly() else self.qr_input())
self.setText = self.setPlainText
self.scan_f = self.setText self.scan_f = self.setText
def resizeEvent(self, e): def resizeEvent(self, e):
o = QTextEdit.resizeEvent(self, e) o = QPlainTextEdit.resizeEvent(self, e)
sz = self.button.sizeHint() sz = self.button.sizeHint()
frameWidth = self.style().pixelMetric(QStyle.PM_DefaultFrameWidth) frameWidth = self.style().pixelMetric(QStyle.PM_DefaultFrameWidth)
self.button.move(self.rect().right() - frameWidth - sz.width(), self.button.move(self.rect().right() - frameWidth - sz.width(),