mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #1785 (Calibre exits when closing preference window on OS X)
This commit is contained in:
parent
edae7237d9
commit
4ecec00044
@ -115,16 +115,11 @@ class Main(MainWindow, Ui_MainWindow):
|
|||||||
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(bool)'), lambda c : self.show())
|
self.connect(self.restore_action, SIGNAL('triggered(bool)'), lambda c : self.show())
|
||||||
self.connect(self.action_show_book_details, SIGNAL('triggered(bool)'), self.show_book_info)
|
self.connect(self.action_show_book_details, SIGNAL('triggered(bool)'), self.show_book_info)
|
||||||
def restart_app(c):
|
self.connect(self.action_restart, SIGNAL('triggered(bool)'),
|
||||||
self.quit(None, restart=True)
|
lambda c : self.quit(None, restart=True))
|
||||||
self.connect(self.action_restart, SIGNAL('triggered(bool)'), restart_app)
|
self.connect(self.system_tray_icon, SIGNAL('activated(QSystemTrayIcon::ActivationReason)'),
|
||||||
def sta(r):
|
self.system_tray_icon_activated)
|
||||||
if r == QSystemTrayIcon.Trigger:
|
self.tool_bar.contextMenuEvent = self.no_op
|
||||||
self.hide() if self.isVisible() else self.show()
|
|
||||||
self.connect(self.system_tray_icon, SIGNAL('activated(QSystemTrayIcon::ActivationReason)'), sta)
|
|
||||||
def tcme(self, *args):
|
|
||||||
pass
|
|
||||||
self.tool_bar.contextMenuEvent = tcme
|
|
||||||
####################### Location View ########################
|
####################### Location View ########################
|
||||||
QObject.connect(self.location_view, SIGNAL('location_selected(PyQt_PyObject)'),
|
QObject.connect(self.location_view, SIGNAL('location_selected(PyQt_PyObject)'),
|
||||||
self.location_selected)
|
self.location_selected)
|
||||||
@ -165,15 +160,11 @@ class Main(MainWindow, Ui_MainWindow):
|
|||||||
sm.addSeparator()
|
sm.addSeparator()
|
||||||
sm.addAction(_('Send to storage card by default'))
|
sm.addAction(_('Send to storage card by default'))
|
||||||
sm.actions()[-1].setCheckable(True)
|
sm.actions()[-1].setCheckable(True)
|
||||||
def default_sync(checked):
|
QObject.connect(sm.actions()[-1], SIGNAL('toggled(bool)'),
|
||||||
config.set('send_to_storage_card_by_default', bool(checked))
|
self.do_default_sync)
|
||||||
QObject.disconnect(self.action_sync, SIGNAL("triggered(bool)"), self.sync_to_main_memory)
|
|
||||||
QObject.disconnect(self.action_sync, SIGNAL("triggered(bool)"), self.sync_to_card)
|
|
||||||
QObject.connect(self.action_sync, SIGNAL("triggered(bool)"), self.sync_to_card if checked else self.sync_to_main_memory)
|
|
||||||
QObject.connect(sm.actions()[-1], SIGNAL('toggled(bool)'), default_sync)
|
|
||||||
|
|
||||||
sm.actions()[-1].setChecked(config.get('send_to_storage_card_by_default'))
|
sm.actions()[-1].setChecked(config.get('send_to_storage_card_by_default'))
|
||||||
default_sync(sm.actions()[-1].isChecked())
|
self.do_default_sync(sm.actions()[-1].isChecked())
|
||||||
self.sync_menu = sm # Needed
|
self.sync_menu = sm # Needed
|
||||||
md = QMenu()
|
md = QMenu()
|
||||||
md.addAction(_('Edit metadata individually'))
|
md.addAction(_('Edit metadata individually'))
|
||||||
@ -371,6 +362,31 @@ class Main(MainWindow, Ui_MainWindow):
|
|||||||
self.connect(self.action_news, SIGNAL('triggered(bool)'), self.scheduler.show_dialog)
|
self.connect(self.action_news, SIGNAL('triggered(bool)'), self.scheduler.show_dialog)
|
||||||
self.location_view.setCurrentIndex(self.location_view.model().index(0))
|
self.location_view.setCurrentIndex(self.location_view.model().index(0))
|
||||||
|
|
||||||
|
def no_op(self, *args):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def system_tray_icon_activated(self, r):
|
||||||
|
if r == QSystemTrayIcon.Trigger:
|
||||||
|
if self.isVisible():
|
||||||
|
for window in QApplication.topLevelWidgets():
|
||||||
|
if isinstance(window, (MainWindow, QDialog)):
|
||||||
|
window.hide()
|
||||||
|
else:
|
||||||
|
for window in QApplication.topLevelWidgets():
|
||||||
|
if isinstance(window, (MainWindow, QDialog)):
|
||||||
|
if window not in (self.device_error_dialog, self.jobs_dialog):
|
||||||
|
window.show()
|
||||||
|
|
||||||
|
|
||||||
|
def do_default_sync(self, checked):
|
||||||
|
config.set('send_to_storage_card_by_default', bool(checked))
|
||||||
|
QObject.disconnect(self.action_sync, SIGNAL("triggered(bool)"),
|
||||||
|
self.sync_to_main_memory)
|
||||||
|
QObject.disconnect(self.action_sync, SIGNAL("triggered(bool)"),
|
||||||
|
self.sync_to_card)
|
||||||
|
QObject.connect(self.action_sync, SIGNAL("triggered(bool)"),
|
||||||
|
self.sync_to_card if checked else self.sync_to_main_memory)
|
||||||
|
|
||||||
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']:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user