diff --git a/src/calibre/devices/interface.py b/src/calibre/devices/interface.py index aee35649d2..9c10de7d6c 100644 --- a/src/calibre/devices/interface.py +++ b/src/calibre/devices/interface.py @@ -39,6 +39,10 @@ class DevicePlugin(Plugin): #: Whether the metadata on books can be set via the GUI. CAN_SET_METADATA = ['title', 'authors', 'collections'] + # Set this to True 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 + SUPPORTS_BACKLOADING = False + #: Path separator for paths to books on device path_sep = os.sep diff --git a/src/calibre/devices/usbms/device.py b/src/calibre/devices/usbms/device.py index 78d4606e85..cb26f6a50c 100644 --- a/src/calibre/devices/usbms/device.py +++ b/src/calibre/devices/usbms/device.py @@ -94,6 +94,9 @@ class Device(DeviceConfig, DevicePlugin): EBOOK_DIR_CARD_B = '' DELETE_EXTS = [] + # USB disk-based devices can see the book files on the device, so can + # copy these back to the library + SUPPORTS_BACKLOADING = True def reset(self, key='-1', log_packets=False, report_progress=None, detected_device=None): diff --git a/src/calibre/gui2/actions/add_to_library.py b/src/calibre/gui2/actions/add_to_library.py index 05aea8f1dd..efdf645acb 100644 --- a/src/calibre/gui2/actions/add_to_library.py +++ b/src/calibre/gui2/actions/add_to_library.py @@ -19,7 +19,12 @@ class AddToLibraryAction(InterfaceAction): self.qaction.triggered.connect(self.add_books_to_library) def location_selected(self, loc): - enabled = loc != 'library' + enabled = False + 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) def add_books_to_library(self, *args):