mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
1) clean up refreshing ondevice when devices are plugged in and out.
2) close xml_file in sony BookList.init
This commit is contained in:
parent
0ce1a052b2
commit
8b197ebd66
@ -41,7 +41,7 @@ class BookList(_BookList):
|
|||||||
opts = settings()
|
opts = settings()
|
||||||
self.collections = opts.extra_customization.split(',') if opts.extra_customization else []
|
self.collections = opts.extra_customization.split(',') if opts.extra_customization else []
|
||||||
db = CACHE_XML if oncard else MEDIA_XML
|
db = CACHE_XML if oncard else MEDIA_XML
|
||||||
xml_file = open(prefix + db, 'rb')
|
with open(prefix + db, 'rb') as xml_file:
|
||||||
xml_file.seek(0)
|
xml_file.seek(0)
|
||||||
self.document = dom.parse(xml_file)
|
self.document = dom.parse(xml_file)
|
||||||
self.root_element = self.document.documentElement
|
self.root_element = self.document.documentElement
|
||||||
|
@ -949,7 +949,6 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
|||||||
'''
|
'''
|
||||||
if connected:
|
if connected:
|
||||||
self._sync_menu.connect_to_folder_action.setEnabled(False)
|
self._sync_menu.connect_to_folder_action.setEnabled(False)
|
||||||
self._sync_menu.disconnect_from_folder_action.setEnabled(False)
|
|
||||||
self.device_manager.get_device_information(\
|
self.device_manager.get_device_information(\
|
||||||
Dispatcher(self.info_read))
|
Dispatcher(self.info_read))
|
||||||
self.set_default_thumbnail(\
|
self.set_default_thumbnail(\
|
||||||
@ -963,10 +962,9 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
|||||||
self.device_manager.device)
|
self.device_manager.device)
|
||||||
self.location_view.model().device_connected(self.device_manager.device)
|
self.location_view.model().device_connected(self.device_manager.device)
|
||||||
self.eject_action.setEnabled(True)
|
self.eject_action.setEnabled(True)
|
||||||
# don't refresh_ondevice here. It will happen in metadata_downloaded
|
self.refresh_ondevice_info (device_connected = True, reset_only = True)
|
||||||
else:
|
else:
|
||||||
self._sync_menu.connect_to_folder_action.setEnabled(True)
|
self._sync_menu.connect_to_folder_action.setEnabled(True)
|
||||||
self._sync_menu.disconnect_from_folder_action.setEnabled(False)
|
|
||||||
self.save_device_view_settings()
|
self.save_device_view_settings()
|
||||||
self.device_connected = False
|
self.device_connected = False
|
||||||
self._sync_menu.enable_device_actions(False)
|
self._sync_menu.enable_device_actions(False)
|
||||||
@ -1035,10 +1033,11 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
|||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
### Force the library view to refresh, taking into consideration books information
|
### Force the library view to refresh, taking into consideration books information
|
||||||
def refresh_ondevice_info(self, device_connected):
|
def refresh_ondevice_info(self, device_connected, reset_only = False):
|
||||||
# Save current column widths because we might be turning on OnDevice
|
|
||||||
self.library_view.write_settings()
|
|
||||||
self.book_on_device(None, reset=True)
|
self.book_on_device(None, reset=True)
|
||||||
|
if reset_only:
|
||||||
|
return
|
||||||
|
self.library_view.write_settings()
|
||||||
self.library_view.model().set_device_connected(device_connected)
|
self.library_view.model().set_device_connected(device_connected)
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user