Browse Source

Qt: warnings with large text use scrollable MessageBox

master
Adam Gibson 9 years ago
parent
commit
a61b18abc9
No known key found for this signature in database
GPG Key ID: B3AE09F1E9A3197A
  1. 7
      scripts/joinmarket-qt.py
  2. 38
      scripts/qtsupport.py

7
scripts/joinmarket-qt.py

@ -741,7 +741,12 @@ class SpendTab(QWidget):
if self.taker_info_type == "info":
w.statusBar().showMessage(self.taker_infomsg)
elif self.taker_info_type == "warn":
JMQtMessageBox(self, self.taker_infomsg, mbtype=self.taker_info_type)
if len(self.taker_infomsg) > 200:
JMQtMessageBox(self, "Details:", mbtype=self.taker_info_type,
detailed_text=self.taker_infomsg)
else:
JMQtMessageBox(self, self.taker_infomsg,
mbtype=self.taker_info_type)
#Abort signal explicitly means this transaction will not continue.
self.abortTransactions()
self.taker_info_response = True

38
scripts/qtsupport.py

@ -113,7 +113,7 @@ donation_more_message = '\n'.join(
'is no change output that can be linked with your inputs later.'])
"""
def JMQtMessageBox(obj, msg, mbtype='info', title=''):
def JMQtMessageBox(obj, msg, mbtype='info', title='', detailed_text= None):
mbtypes = {'info': QMessageBox.information,
'crit': QMessageBox.critical,
'warn': QMessageBox.warning,
@ -123,8 +123,40 @@ def JMQtMessageBox(obj, msg, mbtype='info', title=''):
return QMessageBox.question(obj, title, msg, QMessageBox.Yes,
QMessageBox.No)
else:
mbtypes[mbtype](obj, title, msg)
if detailed_text:
assert mbtype == 'warn'
class JMQtDMessageBox(QMessageBox):
def __init__(self):
QMessageBox.__init__(self)
self.setSizeGripEnabled(True)
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.layout().setSizeConstraint(QLayout.SetMaximumSize)
def resizeEvent(self, event):
self.setMinimumHeight(0)
self.setMaximumHeight(16777215)
self.setMinimumWidth(0)
self.setMaximumWidth(16777215)
result = super(JMQtDMessageBox, self).resizeEvent(event)
details_box = self.findChild(QTextEdit)
if details_box is not None:
details_box.setMinimumHeight(0)
details_box.setMaximumHeight(16777215)
details_box.setMinimumWidth(0)
details_box.setMaximumWidth(16777215)
details_box.setSizePolicy(QSizePolicy.Expanding,
QSizePolicy.Expanding)
return result
b = JMQtDMessageBox()
b.setIcon(QMessageBox.Warning)
b.setWindowTitle(title)
b.setText(msg)
b.setDetailedText(detailed_text)
b.setStandardButtons(QMessageBox.Ok)
retval = b.exec_()
else:
mbtypes[mbtype](obj, title, msg)
class TaskThread(QtCore.QThread):
'''Thread that runs background tasks. Callbacks are guaranteed

Loading…
Cancel
Save