mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add hooks to GUI plugins for the shutdown process
This commit is contained in:
parent
45d20f7d7c
commit
51c56af079
@ -27,7 +27,8 @@ class InterfaceAction(QObject):
|
|||||||
priority takes precedence.
|
priority takes precedence.
|
||||||
|
|
||||||
Sub-classes should implement the :meth:`genesis`, :meth:`library_moved`,
|
Sub-classes should implement the :meth:`genesis`, :meth:`library_moved`,
|
||||||
:meth:`location_selected` and :meth:`initialization_complete` methods.
|
:meth:`location_selected` :meth:`shutting_down`
|
||||||
|
and :meth:`initialization_complete` methods.
|
||||||
|
|
||||||
Once initialized, this plugin has access to the main calibre GUI via the
|
Once initialized, this plugin has access to the main calibre GUI via the
|
||||||
:attr:`gui` member. You can access other plugins by name, for example::
|
:attr:`gui` member. You can access other plugins by name, for example::
|
||||||
@ -122,3 +123,14 @@ class InterfaceAction(QObject):
|
|||||||
completed.
|
completed.
|
||||||
'''
|
'''
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def shutting_down(self):
|
||||||
|
'''
|
||||||
|
Called once per plugin when the main GUI is in the process of shutting
|
||||||
|
down. Release any used resources, but try not to block the shutdown for
|
||||||
|
long periods of time.
|
||||||
|
|
||||||
|
:return: False to halt the shutdown. You are responsible for telling
|
||||||
|
the user why the shutdown was halted.
|
||||||
|
'''
|
||||||
|
return True
|
||||||
|
@ -352,8 +352,6 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, # {{{
|
|||||||
def booklists(self):
|
def booklists(self):
|
||||||
return self.memory_view.model().db, self.card_a_view.model().db, self.card_b_view.model().db
|
return self.memory_view.model().db, self.card_a_view.model().db, self.card_b_view.model().db
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def library_moved(self, newloc):
|
def library_moved(self, newloc):
|
||||||
if newloc is None: return
|
if newloc is None: return
|
||||||
db = LibraryDatabase2(newloc)
|
db = LibraryDatabase2(newloc)
|
||||||
@ -377,7 +375,6 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, # {{{
|
|||||||
def set_window_title(self):
|
def set_window_title(self):
|
||||||
self.setWindowTitle(__appname__ + u' - ||%s||'%self.iactions['Choose Library'].library_name())
|
self.setWindowTitle(__appname__ + u' - ||%s||'%self.iactions['Choose Library'].library_name())
|
||||||
|
|
||||||
|
|
||||||
def location_selected(self, location):
|
def location_selected(self, location):
|
||||||
'''
|
'''
|
||||||
Called when a location icon is clicked (e.g. Library)
|
Called when a location icon is clicked (e.g. Library)
|
||||||
@ -517,6 +514,9 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, # {{{
|
|||||||
|
|
||||||
|
|
||||||
def shutdown(self, write_settings=True):
|
def shutdown(self, write_settings=True):
|
||||||
|
for action in self.iactions.values():
|
||||||
|
if not action.shutting_down():
|
||||||
|
return
|
||||||
if write_settings:
|
if write_settings:
|
||||||
self.write_settings()
|
self.write_settings()
|
||||||
self.check_messages_timer.stop()
|
self.check_messages_timer.stop()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user