diff --git a/src/calibre/devices/folder_device/driver.py b/src/calibre/devices/folder_device/driver.py index 09df8cd6d8..c8ee3a2e77 100644 --- a/src/calibre/devices/folder_device/driver.py +++ b/src/calibre/devices/folder_device/driver.py @@ -97,3 +97,13 @@ class FOLDER_DEVICE(USBMS): @classmethod def settings(self): return FOLDER_DEVICE_FOR_CONFIG._config().parse() + + @classmethod + def config_widget(cls): + return FOLDER_DEVICE_FOR_CONFIG.config_widget() + + @classmethod + def save_settings(cls, config_widget): + return FOLDER_DEVICE_FOR_CONFIG.save_settings(config_widget) + + diff --git a/src/calibre/gui2/device.py b/src/calibre/gui2/device.py index b144a364f2..83c71bb129 100644 --- a/src/calibre/gui2/device.py +++ b/src/calibre/gui2/device.py @@ -7,7 +7,8 @@ import os, traceback, Queue, time, cStringIO, re, sys from threading import Thread from PyQt4.Qt import (QMenu, QAction, QActionGroup, QIcon, SIGNAL, - Qt, pyqtSignal, QDialog, QObject) + Qt, pyqtSignal, QDialog, QObject, QVBoxLayout, + QDialogButtonBox) from calibre.customize.ui import (available_input_formats, available_output_formats, device_plugins) @@ -718,6 +719,31 @@ class DeviceMixin(object): # {{{ def disconnect_mounted_device(self): self.device_manager.umount_device() + def configure_connected_device(self): + if not self.device_manager.is_device_connected: return + if self.job_manager.has_device_jobs(queued_also=True): + return error_dialog(self, _('Running jobs'), + _('Cannot configure the device while there are running' + ' device jobs.'), show=True) + dev = self.device_manager.connected_device + cw = dev.config_widget() + d = QDialog(self) + d.setWindowTitle(_('Configure %s')%dev.get_gui_name()) + d.setWindowIcon(QIcon(I('config.png'))) + l = QVBoxLayout(d) + d.setLayout(l) + bb = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel) + bb.accepted.connect(d.accept) + bb.rejected.connect(d.reject) + l.addWidget(cw) + l.addWidget(bb) + if d.exec_() == d.Accepted: + dev.save_settings(cw) + warning_dialog(self, _('Disconnect device'), + _('Disconnect and re-connect the %s for your changes to' + ' be applied.')%dev.get_gui_name(), show=True, + show_copy_button=False) + def _sync_action_triggered(self, *args): m = getattr(self, '_sync_menu', None) if m is not None: diff --git a/src/calibre/gui2/layout.py b/src/calibre/gui2/layout.py index 423907d8fd..eadf97191a 100644 --- a/src/calibre/gui2/layout.py +++ b/src/calibre/gui2/layout.py @@ -25,6 +25,7 @@ class LocationManager(QObject): # {{{ locations_changed = pyqtSignal() unmount_device = pyqtSignal() location_selected = pyqtSignal(object) + configure_device = pyqtSignal() def __init__(self, parent=None): QObject.__init__(self, parent) @@ -57,6 +58,10 @@ class LocationManager(QObject): # {{{ a = m.addAction(QIcon(I('eject.png')), _('Eject this device')) a.triggered.connect(self._eject_requested) self._mem.append(a) + a = m.addAction(QIcon(I('config.png')), _('Configure this device')) + a.triggered.connect(self._configure_requested) + self._mem.append(a) + else: ac.setToolTip(tooltip) ac.setMenu(m) @@ -109,6 +114,9 @@ class LocationManager(QObject): # {{{ def _eject_requested(self, *args): self.unmount_device.emit() + def _configure_requested(self): + self.configure_device.emit() + def update_devices(self, cp=(None, None), fs=[-1, -1, -1], icon=None): if icon is None: icon = I('reader.png') diff --git a/src/calibre/gui2/ui.py b/src/calibre/gui2/ui.py index 116283a010..98fd7981c9 100644 --- a/src/calibre/gui2/ui.py +++ b/src/calibre/gui2/ui.py @@ -265,6 +265,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{ ####################### Location Manager ######################## self.location_manager.location_selected.connect(self.location_selected) self.location_manager.unmount_device.connect(self.device_manager.umount_device) + self.location_manager.configure_device.connect(self.configure_connected_device) self.eject_action.triggered.connect(self.device_manager.umount_device) #################### Update notification ###################