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: except:
pass pass
if not self.device_error_dialog.isVisible(): 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() self.device_error_dialog.show()
# Device connected {{{ # Device connected {{{

View File

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