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