mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Replace all remaining use of QMessageBox with calibre's message boxes
This commit is contained in:
parent
312e1951dc
commit
3590afbaea
@ -197,8 +197,7 @@ def error_dialog(parent, title, msg, det_msg='', show=False,
|
||||
return d.exec_()
|
||||
return d
|
||||
|
||||
def question_dialog(parent, title, msg, det_msg='', show_copy_button=False,
|
||||
buttons=None, yes_button=None):
|
||||
def question_dialog(parent, title, msg, det_msg='', show_copy_button=False):
|
||||
from calibre.gui2.dialogs.message_box import MessageBox
|
||||
d = MessageBox(MessageBox.QUESTION, title, msg, det_msg, parent=parent,
|
||||
show_copy_button=show_copy_button)
|
||||
|
@ -7,7 +7,7 @@ import re, os
|
||||
|
||||
from PyQt4.Qt import Qt, QDialog, QGridLayout, QVBoxLayout, QFont, QLabel, \
|
||||
pyqtSignal, QDialogButtonBox, QInputDialog, QLineEdit, \
|
||||
QMessageBox, QDate
|
||||
QDate
|
||||
|
||||
from calibre.gui2.dialogs.metadata_bulk_ui import Ui_MetadataBulkDialog
|
||||
from calibre.gui2.dialogs.tag_editor import TagEditor
|
||||
@ -15,7 +15,8 @@ from calibre.ebooks.metadata import string_to_authors, authors_to_string
|
||||
from calibre.ebooks.metadata.book.base import composite_formatter
|
||||
from calibre.ebooks.metadata.meta import get_metadata
|
||||
from calibre.gui2.custom_column_widgets import populate_metadata_page
|
||||
from calibre.gui2 import error_dialog, ResizableDialog, UNDEFINED_QDATE, gprefs
|
||||
from calibre.gui2 import error_dialog, ResizableDialog, UNDEFINED_QDATE, \
|
||||
gprefs, question_dialog
|
||||
from calibre.gui2.progress_indicator import ProgressIndicator
|
||||
from calibre.utils.config import dynamic, JSONConfig
|
||||
from calibre.utils.titlecase import titlecase
|
||||
@ -888,12 +889,9 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
|
||||
if self.query_field.currentIndex() == 0:
|
||||
return
|
||||
|
||||
ret = QMessageBox.question(self, _("Delete saved search/replace"),
|
||||
if not question_dialog(self, _("Delete saved search/replace"),
|
||||
_("The selected saved search/replace will be deleted. "
|
||||
"Are you sure?"),
|
||||
QMessageBox.Ok, QMessageBox.Cancel)
|
||||
|
||||
if ret == QMessageBox.Cancel:
|
||||
"Are you sure?")):
|
||||
return
|
||||
|
||||
item_id = self.query_field.currentIndex()
|
||||
@ -917,11 +915,9 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
|
||||
new = True
|
||||
name = unicode(name)
|
||||
if name in self.queries.keys():
|
||||
ret = QMessageBox.question(self, _("Save search/replace"),
|
||||
if not question_dialog(self, _("Save search/replace"),
|
||||
_("That saved search/replace already exists and will be overwritten. "
|
||||
"Are you sure?"),
|
||||
QMessageBox.Ok, QMessageBox.Cancel)
|
||||
if ret == QMessageBox.Cancel:
|
||||
"Are you sure?")):
|
||||
return
|
||||
new = False
|
||||
|
||||
|
@ -4,7 +4,7 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
import sys, os, time, socket, traceback
|
||||
from functools import partial
|
||||
|
||||
from PyQt4.Qt import QCoreApplication, QIcon, QMessageBox, QObject, QTimer, \
|
||||
from PyQt4.Qt import QCoreApplication, QIcon, QObject, QTimer, \
|
||||
QThread, pyqtSignal, Qt, QProgressDialog, QString, QPixmap, \
|
||||
QSplashScreen, QApplication
|
||||
|
||||
@ -319,9 +319,6 @@ def run_gui(opts, args, actions, listener, app, gui_debug=None):
|
||||
|
||||
def cant_start(msg=_('If you are sure it is not running')+', ',
|
||||
what=None):
|
||||
d = QMessageBox(QMessageBox.Critical, _('Cannot Start ')+__appname__,
|
||||
'<p>'+(_('%s is already running.')%__appname__)+'</p>',
|
||||
QMessageBox.Ok)
|
||||
base = '<p>%s</p><p>%s %s'
|
||||
where = __appname__ + ' '+_('may be running in the system tray, in the')+' '
|
||||
if isosx:
|
||||
@ -334,8 +331,10 @@ def cant_start(msg=_('If you are sure it is not running')+', ',
|
||||
else:
|
||||
what = _('try deleting the file')+': '+ADDRESS
|
||||
|
||||
d.setInformativeText(base%(where, msg, what))
|
||||
d.exec_()
|
||||
info = base%(where, msg, what)
|
||||
error_dialog(None, _('Cannot Start ')+__appname__,
|
||||
'<p>'+(_('%s is already running.')%__appname__)+'</p>'+info, show=True)
|
||||
|
||||
raise SystemExit(1)
|
||||
|
||||
def communicate(args):
|
||||
|
@ -12,11 +12,9 @@ __docformat__ = 'restructuredtext en'
|
||||
import collections, os, sys, textwrap, time
|
||||
from Queue import Queue, Empty
|
||||
from threading import Thread
|
||||
from PyQt4.Qt import Qt, SIGNAL, QTimer, \
|
||||
QPixmap, QMenu, QIcon, pyqtSignal, \
|
||||
QDialog, \
|
||||
QSystemTrayIcon, QApplication, QKeySequence, \
|
||||
QMessageBox, QHelpEvent, QAction
|
||||
from PyQt4.Qt import Qt, SIGNAL, QTimer, QHelpEvent, QAction, \
|
||||
QMenu, QIcon, pyqtSignal, \
|
||||
QDialog, QSystemTrayIcon, QApplication, QKeySequence
|
||||
|
||||
from calibre import prints
|
||||
from calibre.constants import __appname__, isosx
|
||||
@ -357,11 +355,12 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
||||
def is_minimized_to_tray(self):
|
||||
return getattr(self, '__systray_minimized', False)
|
||||
|
||||
def ask_a_yes_no_question(self, title, msg, **kwargs):
|
||||
awu = kwargs.pop('ans_when_user_unavailable', True)
|
||||
def ask_a_yes_no_question(self, title, msg, det_msg='',
|
||||
show_copy_button=False, ans_when_user_unavailable=True):
|
||||
if self.is_minimized_to_tray:
|
||||
return awu
|
||||
return question_dialog(self, title, msg, **kwargs)
|
||||
return ans_when_user_unavailable
|
||||
return question_dialog(self, title, msg, det_msg=det_msg,
|
||||
show_copy_button=show_copy_button)
|
||||
|
||||
def hide_windows(self):
|
||||
for window in QApplication.topLevelWidgets():
|
||||
@ -601,11 +600,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
||||
Quitting may cause corruption on the device.<br>
|
||||
Are you sure you want to quit?''')+'</p>'
|
||||
|
||||
d = QMessageBox(QMessageBox.Warning, _('WARNING: Active jobs'), msg,
|
||||
QMessageBox.Yes|QMessageBox.No, self)
|
||||
d.setIconPixmap(QPixmap(I('dialog_warning.png')))
|
||||
d.setDefaultButton(QMessageBox.No)
|
||||
if d.exec_() != QMessageBox.Yes:
|
||||
if not question_dialog(self, _('Active jobs'), msg):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user