Fix bug 2390: Use detailed message pane for message dialogs that have dynamic content.

This commit is contained in:
John Schember 2009-05-06 19:45:34 -04:00
parent 0a67d84598
commit dc81cfe029
4 changed files with 24 additions and 23 deletions

View File

@ -100,27 +100,31 @@ def available_width():
def extension(path): def extension(path):
return os.path.splitext(path)[1][1:].lower() return os.path.splitext(path)[1][1:].lower()
def warning_dialog(parent, title, msg): def warning_dialog(parent, title, msg, det_msg=''):
d = QMessageBox(QMessageBox.Warning, 'WARNING: '+title, msg, QMessageBox.Ok, d = QMessageBox(QMessageBox.Warning, 'WARNING: '+title, msg, QMessageBox.Ok,
parent) parent)
d.setDetailedText(det_msg)
d.setIconPixmap(QPixmap(':/images/dialog_warning.svg')) d.setIconPixmap(QPixmap(':/images/dialog_warning.svg'))
return d return d
def error_dialog(parent, title, msg): def error_dialog(parent, title, msg, det_msg=''):
d = QMessageBox(QMessageBox.Critical, 'ERROR: '+title, msg, QMessageBox.Ok, d = QMessageBox(QMessageBox.Critical, 'ERROR: '+title, msg, QMessageBox.Ok,
parent) parent)
d.setDetailedText(det_msg)
d.setIconPixmap(QPixmap(':/images/dialog_error.svg')) d.setIconPixmap(QPixmap(':/images/dialog_error.svg'))
return d return d
def question_dialog(parent, title, msg): def question_dialog(parent, title, msg, det_msg=''):
d = QMessageBox(QMessageBox.Question, title, msg, QMessageBox.Yes|QMessageBox.No, d = QMessageBox(QMessageBox.Question, title, msg, QMessageBox.Yes|QMessageBox.No,
parent) parent)
d.setDetailedText(det_msg)
d.setIconPixmap(QPixmap(':/images/dialog_information.svg')) d.setIconPixmap(QPixmap(':/images/dialog_information.svg'))
return d return d
def info_dialog(parent, title, msg): def info_dialog(parent, title, msg, det_msg=''):
d = QMessageBox(QMessageBox.Information, title, msg, QMessageBox.NoButton, d = QMessageBox(QMessageBox.Information, title, msg, QMessageBox.NoButton,
parent) parent)
d.setDetailedText(det_msg)
d.setIconPixmap(QPixmap(':/images/dialog_information.svg')) d.setIconPixmap(QPixmap(':/images/dialog_information.svg'))
return d return d

View File

@ -507,10 +507,10 @@ class DeviceGUI(object):
self.status_bar.showMessage(_('Sending email to')+' '+to, 3000) self.status_bar.showMessage(_('Sending email to')+' '+to, 3000)
if bad: if bad:
bad = '\n'.join('<li>%s</li>'%(i,) for i in bad) bad = '\n'.join('%s'%(i,) for i in bad)
d = warning_dialog(self, _('No suitable formats'), d = warning_dialog(self, _('No suitable formats'),
'<p>'+ _('Could not email the following books ' _('Could not email the following books '
'as no suitable formats were found:<br><ul>%s</ul>')%(bad,)) 'as no suitable formats were found:'), bad)
d.exec_() d.exec_()
def emails_sent(self, results, remove=[]): def emails_sent(self, results, remove=[]):
@ -694,12 +694,12 @@ class DeviceGUI(object):
self.auto_convert(_auto_ids, on_card, format) self.auto_convert(_auto_ids, on_card, format)
if bad: if bad:
bad = '\n'.join('<li>%s</li>'%(i,) for i in bad) bad = '\n'.join('%s'%(i,) for i in bad)
d = warning_dialog(self, _('No suitable formats'), d = warning_dialog(self, _('No suitable formats'),
_('Could not upload the following books to the device, ' _('Could not upload the following books to the device, '
'as no suitable formats were found. Try changing the output ' 'as no suitable formats were found. Try changing the output '
'format in the upper right corner next to the red heart and ' 'format in the upper right corner next to the red heart and '
're-converting. <br><ul>%s</ul>')%(bad,)) 're-converting.'), bad)
d.exec_() d.exec_()
def upload_booklists(self): def upload_booklists(self):

View File

@ -445,14 +445,8 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
def change_output_format(self, x): def change_output_format(self, x):
of = unicode(x).strip() of = unicode(x).strip()
if of != prefs['output_format']: if of != prefs['output_format']:
if of not in ('LRF', 'EPUB', 'MOBI'):
warning_dialog(self, 'Warning',
('<p>%s support is still in beta. If you find bugs, '
'please report them by opening a <a href="http://cal'
'ibre.kovidgoyal.net">ticket</a>.')%of).exec_()
prefs.set('output_format', of) prefs.set('output_format', of)
def test_server(self, *args): def test_server(self, *args):
if self.content_server.exception is not None: if self.content_server.exception is not None:
error_dialog(self, _('Failed to start content server'), error_dialog(self, _('Failed to start content server'),
@ -916,14 +910,14 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
callback=callback, callback=callback,
single_format=single_format) single_format=single_format)
if failures and single_format is not None: if failures and single_format is not None:
msg = _('<p>Could not save the following books to disk, ' msg = _('Could not save the following books to disk, '
'because the %s format is not available for them:<ul>')\ 'because the %s format is not available for them')\
%single_format.upper() %single_format.upper()
det_msg = ''
for f in failures: for f in failures:
msg += '<li>%s</li>'%f[1] det_msg += '%s\n'%f[1]
msg += '</ul>'
warning_dialog(self, _('Could not save some ebooks'), warning_dialog(self, _('Could not save some ebooks'),
msg).exec_() msg, det_msg).exec_()
QDesktopServices.openUrl(QUrl('file:'+dir)) QDesktopServices.openUrl(QUrl('file:'+dir))
else: else:
paths = self.current_view().model().paths(rows) paths = self.current_view().model().paths(rows)

View File

@ -12,6 +12,7 @@ import cPickle, os
from PyQt4.Qt import QDialog from PyQt4.Qt import QDialog
from calibre.ptempfile import PersistentTemporaryFile from calibre.ptempfile import PersistentTemporaryFile
from calibre.gui2 import warning_dialog
from calibre.gui2.convert import load_specifics from calibre.gui2.convert import load_specifics
from calibre.gui2.convert.single import NoSupportedInputFormats from calibre.gui2.convert.single import NoSupportedInputFormats
from calibre.gui2.convert.single import Config as SingleConfig from calibre.gui2.convert.single import Config as SingleConfig
@ -60,10 +61,12 @@ def convert_single_ebook(parent, db, book_ids, auto_conversion=False, out_format
res = [] res = []
for id in bad: for id in bad:
title = db.title(id, True) title = db.title(id, True)
res.append('<li>%s</li>'%title) res.append('%s'%title)
msg = _('<p>Could not convert %d of %d books, because no suitable source format was found.<ul>%s</ul>')%(len(res), total, '\n'.join(res)) msg = '%s' % '\n'.join(res)
warning_dialog(parent, _('Could not convert some books'), msg).exec_() warning_dialog(parent, _('Could not convert some books'),
_('Could not convert %d of %d books, because no suitable source format was found.' % (len(res), total)),
msg).exec_()
return jobs, changed, bad return jobs, changed, bad