Fix device job error dialog not showing actual error

This commit is contained in:
Kovid Goyal 2011-01-29 09:17:12 -07:00
parent 1cec2afd12
commit af6ce250b3
2 changed files with 21 additions and 10 deletions

View File

@ -687,7 +687,7 @@ class DeviceMixin(object): # {{{
except:
pass
if not self.device_error_dialog.isVisible():
self.device_error_dialog.setDetailedText(job.details)
self.device_error_dialog.set_details(job.details)
self.device_error_dialog.show()
# Device connected {{{

View File

@ -45,7 +45,6 @@ class MessageBox(QDialog, Ui_Dialog):
self.ctc_button.clicked.connect(self.copy_to_clipboard)
if det_msg:
self.show_det_msg = _('Show &details')
self.hide_det_msg = _('Hide &details')
self.det_msg_toggle = self.bb.addButton(self.show_det_msg, self.bb.ActionRole)
@ -53,7 +52,6 @@ class MessageBox(QDialog, Ui_Dialog):
self.det_msg_toggle.setToolTip(
_('Show detailed information about this error'))
self.copy_action = QAction(self)
self.addAction(self.copy_action)
self.copy_action.setShortcuts(QKeySequence.Copy)
@ -66,10 +64,14 @@ class MessageBox(QDialog, Ui_Dialog):
else:
self.bb.button(self.bb.Ok).setDefault(True)
if not det_msg:
self.det_msg_toggle.setVisible(False)
self.do_resize()
def toggle_det_msg(self, *args):
vis = self.det_msg.isVisible()
vis = unicode(self.det_msg_toggle.text()) == self.hide_det_msg
self.det_msg_toggle.setText(self.show_det_msg if vis else
self.hide_det_msg)
self.det_msg.setVisible(not vis)
@ -100,6 +102,15 @@ class MessageBox(QDialog, Ui_Dialog):
self.bb.button(self.bb.Ok).setFocus(Qt.OtherFocusReason)
return ret
def set_details(self, msg):
if not msg:
msg = ''
self.det_msg.setPlainText(msg)
self.det_msg_toggle.setText(self.show_det_msg)
self.det_msg_toggle.setVisible(bool(msg))
self.det_msg.setVisible(False)
self.do_resize()
if __name__ == '__main__':
app = QApplication([])
from calibre.gui2 import question_dialog