mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Allow device driver to pass an error message to GUI when they dont support backloading
This commit is contained in:
parent
08c0321b5c
commit
6d8acbb5c9
@ -39,9 +39,9 @@ class DevicePlugin(Plugin):
|
|||||||
#: Whether the metadata on books can be set via the GUI.
|
#: Whether the metadata on books can be set via the GUI.
|
||||||
CAN_SET_METADATA = ['title', 'authors', 'collections']
|
CAN_SET_METADATA = ['title', 'authors', 'collections']
|
||||||
|
|
||||||
# Set this to True if the books on the device are files that the GUI can
|
# Set this to None if the books on the device are files that the GUI can
|
||||||
# access in order to add the books from the device to the library
|
# access in order to add the books from the device to the library
|
||||||
SUPPORTS_BACKLOADING = False
|
BACKLOADING_ERROR_MESSAGE = _('Cannot get files from this device')
|
||||||
|
|
||||||
#: Path separator for paths to books on device
|
#: Path separator for paths to books on device
|
||||||
path_sep = os.sep
|
path_sep = os.sep
|
||||||
|
@ -96,7 +96,7 @@ class Device(DeviceConfig, DevicePlugin):
|
|||||||
|
|
||||||
# USB disk-based devices can see the book files on the device, so can
|
# USB disk-based devices can see the book files on the device, so can
|
||||||
# copy these back to the library
|
# copy these back to the library
|
||||||
SUPPORTS_BACKLOADING = True
|
BACKLOADING_ERROR_MESSAGE = None
|
||||||
|
|
||||||
def reset(self, key='-1', log_packets=False, report_progress=None,
|
def reset(self, key='-1', log_packets=False, report_progress=None,
|
||||||
detected_device=None):
|
detected_device=None):
|
||||||
|
@ -235,6 +235,10 @@ class AddAction(InterfaceAction):
|
|||||||
self.gui.refresh_ondevice()
|
self.gui.refresh_ondevice()
|
||||||
|
|
||||||
def add_books_from_device(self, view, paths=None):
|
def add_books_from_device(self, view, paths=None):
|
||||||
|
backloading_err = self.gui.device_manager.device.BACKLOADING_ERROR_MESSAGE
|
||||||
|
if backloading_err is not None:
|
||||||
|
return error_dialog(self.gui, _('Add to library'), backloading_err,
|
||||||
|
show=True)
|
||||||
if paths is None:
|
if paths is None:
|
||||||
rows = view.selectionModel().selectedRows()
|
rows = view.selectionModel().selectedRows()
|
||||||
if not rows or len(rows) == 0:
|
if not rows or len(rows) == 0:
|
||||||
|
@ -19,12 +19,7 @@ class AddToLibraryAction(InterfaceAction):
|
|||||||
self.qaction.triggered.connect(self.add_books_to_library)
|
self.qaction.triggered.connect(self.add_books_to_library)
|
||||||
|
|
||||||
def location_selected(self, loc):
|
def location_selected(self, loc):
|
||||||
enabled = False
|
enabled = loc != 'library'
|
||||||
if loc != 'library':
|
|
||||||
if self.gui.device_manager.is_device_connected:
|
|
||||||
device = self.gui.device_manager.connected_device
|
|
||||||
if device is not None:
|
|
||||||
enabled = getattr(device, 'SUPPORTS_BACKLOADING', False)
|
|
||||||
self.qaction.setEnabled(enabled)
|
self.qaction.setEnabled(enabled)
|
||||||
|
|
||||||
def add_books_to_library(self, *args):
|
def add_books_to_library(self, *args):
|
||||||
|
@ -794,13 +794,16 @@ class DeviceMixin(object): # {{{
|
|||||||
mainlist, cardalist, cardblist = job.result
|
mainlist, cardalist, cardblist = job.result
|
||||||
self.memory_view.set_database(mainlist)
|
self.memory_view.set_database(mainlist)
|
||||||
self.memory_view.set_editable(self.device_manager.device.CAN_SET_METADATA,
|
self.memory_view.set_editable(self.device_manager.device.CAN_SET_METADATA,
|
||||||
self.device_manager.device.SUPPORTS_BACKLOADING)
|
self.device_manager.device.BACKLOADING_ERROR_MESSAGE
|
||||||
|
is None)
|
||||||
self.card_a_view.set_database(cardalist)
|
self.card_a_view.set_database(cardalist)
|
||||||
self.card_a_view.set_editable(self.device_manager.device.CAN_SET_METADATA,
|
self.card_a_view.set_editable(self.device_manager.device.CAN_SET_METADATA,
|
||||||
self.device_manager.device.SUPPORTS_BACKLOADING)
|
self.device_manager.device.BACKLOADING_ERROR_MESSAGE
|
||||||
|
is None)
|
||||||
self.card_b_view.set_database(cardblist)
|
self.card_b_view.set_database(cardblist)
|
||||||
self.card_b_view.set_editable(self.device_manager.device.CAN_SET_METADATA,
|
self.card_b_view.set_editable(self.device_manager.device.CAN_SET_METADATA,
|
||||||
self.device_manager.device.SUPPORTS_BACKLOADING)
|
self.device_manager.device.BACKLOADING_ERROR_MESSAGE
|
||||||
|
is None)
|
||||||
self.sync_news()
|
self.sync_news()
|
||||||
self.sync_catalogs()
|
self.sync_catalogs()
|
||||||
self.refresh_ondevice()
|
self.refresh_ondevice()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user