mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #7549 (Crash after prompt to convert news before uploading to Android phone)
This commit is contained in:
parent
005d39ca45
commit
c4e64445c1
@ -20,8 +20,7 @@ from calibre.gui2.dialogs.choose_format import ChooseFormatDialog
|
|||||||
from calibre.utils.ipc.job import BaseJob
|
from calibre.utils.ipc.job import BaseJob
|
||||||
from calibre.devices.scanner import DeviceScanner
|
from calibre.devices.scanner import DeviceScanner
|
||||||
from calibre.gui2 import config, error_dialog, Dispatcher, dynamic, \
|
from calibre.gui2 import config, error_dialog, Dispatcher, dynamic, \
|
||||||
warning_dialog, \
|
warning_dialog, info_dialog, choose_dir
|
||||||
question_dialog, info_dialog, choose_dir
|
|
||||||
from calibre.ebooks.metadata import authors_to_string
|
from calibre.ebooks.metadata import authors_to_string
|
||||||
from calibre import preferred_encoding, prints, force_unicode
|
from calibre import preferred_encoding, prints, force_unicode
|
||||||
from calibre.utils.filenames import ascii_filename
|
from calibre.utils.filenames import ascii_filename
|
||||||
@ -665,6 +664,16 @@ class DeviceMixin(object): # {{{
|
|||||||
if tweaks['auto_connect_to_folder']:
|
if tweaks['auto_connect_to_folder']:
|
||||||
self.connect_to_folder_named(tweaks['auto_connect_to_folder'])
|
self.connect_to_folder_named(tweaks['auto_connect_to_folder'])
|
||||||
|
|
||||||
|
def auto_convert_question(self, msg, autos):
|
||||||
|
autos = u'\n'.join(map(unicode, map(force_unicode, autos)))
|
||||||
|
return self.ask_a_yes_no_question(
|
||||||
|
_('No suitable formats'), msg,
|
||||||
|
buttons=QMessageBox.Yes|QMessageBox.Cancel,
|
||||||
|
ans_when_user_unavailable=True,
|
||||||
|
det_msg=autos,
|
||||||
|
show_copy_button=False
|
||||||
|
)
|
||||||
|
|
||||||
def set_default_thumbnail(self, height):
|
def set_default_thumbnail(self, height):
|
||||||
img = I('book.png', data=True)
|
img = I('book.png', data=True)
|
||||||
self.default_thumbnail = thumbnail(img, height, height)
|
self.default_thumbnail = thumbnail(img, height, height)
|
||||||
@ -978,11 +987,9 @@ class DeviceMixin(object): # {{{
|
|||||||
bad += auto
|
bad += auto
|
||||||
else:
|
else:
|
||||||
autos = [self.library_view.model().db.title(id, index_is_id=True) for id in auto]
|
autos = [self.library_view.model().db.title(id, index_is_id=True) for id in auto]
|
||||||
autos = '\n'.join('%s'%i for i in autos)
|
if self.auto_convert_question(
|
||||||
if question_dialog(self, _('No suitable formats'),
|
|
||||||
_('Auto convert the following books before sending via '
|
_('Auto convert the following books before sending via '
|
||||||
'email?'), det_msg=autos,
|
'email?'), autos):
|
||||||
buttons=QMessageBox.Yes|QMessageBox.Cancel):
|
|
||||||
self.iactions['Convert Books'].auto_convert_mail(to, fmts, delete_from_library, auto, format)
|
self.iactions['Convert Books'].auto_convert_mail(to, fmts, delete_from_library, auto, format)
|
||||||
|
|
||||||
if bad:
|
if bad:
|
||||||
@ -1085,11 +1092,9 @@ class DeviceMixin(object): # {{{
|
|||||||
break
|
break
|
||||||
if format is not None:
|
if format is not None:
|
||||||
autos = [self.library_view.model().db.title(id, index_is_id=True) for id in auto]
|
autos = [self.library_view.model().db.title(id, index_is_id=True) for id in auto]
|
||||||
autos = '\n'.join('%s'%i for i in autos)
|
if self.auto_convert_question(
|
||||||
if question_dialog(self, _('No suitable formats'),
|
|
||||||
_('Auto convert the following books before uploading to '
|
_('Auto convert the following books before uploading to '
|
||||||
'the device?'), det_msg=autos,
|
'the device?'), autos):
|
||||||
buttons=QMessageBox.Yes|QMessageBox.Cancel):
|
|
||||||
self.iactions['Convert Books'].auto_convert_catalogs(auto, format)
|
self.iactions['Convert Books'].auto_convert_catalogs(auto, format)
|
||||||
files = [f for f in files if f is not None]
|
files = [f for f in files if f is not None]
|
||||||
if not files:
|
if not files:
|
||||||
@ -1170,11 +1175,9 @@ class DeviceMixin(object): # {{{
|
|||||||
break
|
break
|
||||||
if format is not None:
|
if format is not None:
|
||||||
autos = [self.library_view.model().db.title(id, index_is_id=True) for id in auto]
|
autos = [self.library_view.model().db.title(id, index_is_id=True) for id in auto]
|
||||||
autos = '\n'.join('%s'%i for i in autos)
|
if self.auto_convert_question(
|
||||||
if question_dialog(self, _('No suitable formats'),
|
|
||||||
_('Auto convert the following books before uploading to '
|
_('Auto convert the following books before uploading to '
|
||||||
'the device?'), det_msg=autos,
|
'the device?'), autos):
|
||||||
buttons=QMessageBox.Yes|QMessageBox.Cancel):
|
|
||||||
self.iactions['Convert Books'].auto_convert_news(auto, format)
|
self.iactions['Convert Books'].auto_convert_news(auto, format)
|
||||||
files = [f for f in files if f is not None]
|
files = [f for f in files if f is not None]
|
||||||
for f in files:
|
for f in files:
|
||||||
@ -1289,11 +1292,9 @@ class DeviceMixin(object): # {{{
|
|||||||
bad += auto
|
bad += auto
|
||||||
else:
|
else:
|
||||||
autos = [self.library_view.model().db.title(id, index_is_id=True) for id in auto]
|
autos = [self.library_view.model().db.title(id, index_is_id=True) for id in auto]
|
||||||
autos = '\n'.join('%s'%i for i in autos)
|
if self.auto_convert_question(
|
||||||
if question_dialog(self, _('No suitable formats'),
|
|
||||||
_('Auto convert the following books before uploading to '
|
_('Auto convert the following books before uploading to '
|
||||||
'the device?'), det_msg=autos,
|
'the device?'), autos):
|
||||||
buttons=QMessageBox.Yes|QMessageBox.Cancel):
|
|
||||||
self.iactions['Convert Books'].auto_convert(auto, on_card, format)
|
self.iactions['Convert Books'].auto_convert(auto, on_card, format)
|
||||||
|
|
||||||
if bad:
|
if bad:
|
||||||
|
@ -26,7 +26,8 @@ from calibre.utils.ipc.server import Server
|
|||||||
from calibre.library.database2 import LibraryDatabase2
|
from calibre.library.database2 import LibraryDatabase2
|
||||||
from calibre.customize.ui import interface_actions
|
from calibre.customize.ui import interface_actions
|
||||||
from calibre.gui2 import error_dialog, GetMetadata, open_local_file, \
|
from calibre.gui2 import error_dialog, GetMetadata, open_local_file, \
|
||||||
gprefs, max_available_height, config, info_dialog, Dispatcher
|
gprefs, max_available_height, config, info_dialog, Dispatcher, \
|
||||||
|
question_dialog
|
||||||
from calibre.gui2.cover_flow import CoverFlowMixin
|
from calibre.gui2.cover_flow import CoverFlowMixin
|
||||||
from calibre.gui2.widgets import ProgressIndicator
|
from calibre.gui2.widgets import ProgressIndicator
|
||||||
from calibre.gui2.update import UpdateMixin
|
from calibre.gui2.update import UpdateMixin
|
||||||
@ -181,9 +182,8 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, # {{{
|
|||||||
self.connect(self.donate_action, SIGNAL('triggered(bool)'), self.donate)
|
self.connect(self.donate_action, SIGNAL('triggered(bool)'), self.donate)
|
||||||
self.connect(self.restore_action, SIGNAL('triggered()'),
|
self.connect(self.restore_action, SIGNAL('triggered()'),
|
||||||
self.show_windows)
|
self.show_windows)
|
||||||
self.connect(self.system_tray_icon,
|
self.system_tray_icon.activated.connect(
|
||||||
SIGNAL('activated(QSystemTrayIcon::ActivationReason)'),
|
self.system_tray_icon_activated)
|
||||||
self.system_tray_icon_activated)
|
|
||||||
|
|
||||||
|
|
||||||
####################### Start spare job server ########################
|
####################### Start spare job server ########################
|
||||||
@ -250,7 +250,6 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, # {{{
|
|||||||
|
|
||||||
self.keyboard_interrupt.connect(self.quit, type=Qt.QueuedConnection)
|
self.keyboard_interrupt.connect(self.quit, type=Qt.QueuedConnection)
|
||||||
|
|
||||||
|
|
||||||
self.read_settings()
|
self.read_settings()
|
||||||
self.finalize_layout()
|
self.finalize_layout()
|
||||||
if self.tool_bar.showing_donate:
|
if self.tool_bar.showing_donate:
|
||||||
@ -301,6 +300,16 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, # {{{
|
|||||||
else:
|
else:
|
||||||
self.show_windows()
|
self.show_windows()
|
||||||
|
|
||||||
|
@property
|
||||||
|
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)
|
||||||
|
if self.is_minimized_to_tray:
|
||||||
|
return awu
|
||||||
|
return question_dialog(self, title, msg, **kwargs)
|
||||||
|
|
||||||
def hide_windows(self):
|
def hide_windows(self):
|
||||||
for window in QApplication.topLevelWidgets():
|
for window in QApplication.topLevelWidgets():
|
||||||
if isinstance(window, (MainWindow, QDialog)) and \
|
if isinstance(window, (MainWindow, QDialog)) and \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user