mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
You can now configure the calibre settings for the currently connected device by right clicking on the device icon in the toolbar, instead of having to go through Preferences->Plugins
This commit is contained in:
parent
7a25cf9b49
commit
c8c3bbb76f
@ -97,3 +97,13 @@ class FOLDER_DEVICE(USBMS):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def settings(self):
|
def settings(self):
|
||||||
return FOLDER_DEVICE_FOR_CONFIG._config().parse()
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,7 +7,8 @@ import os, traceback, Queue, time, cStringIO, re, sys
|
|||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
from PyQt4.Qt import (QMenu, QAction, QActionGroup, QIcon, SIGNAL,
|
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,
|
from calibre.customize.ui import (available_input_formats, available_output_formats,
|
||||||
device_plugins)
|
device_plugins)
|
||||||
@ -718,6 +719,31 @@ class DeviceMixin(object): # {{{
|
|||||||
def disconnect_mounted_device(self):
|
def disconnect_mounted_device(self):
|
||||||
self.device_manager.umount_device()
|
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):
|
def _sync_action_triggered(self, *args):
|
||||||
m = getattr(self, '_sync_menu', None)
|
m = getattr(self, '_sync_menu', None)
|
||||||
if m is not None:
|
if m is not None:
|
||||||
|
@ -25,6 +25,7 @@ class LocationManager(QObject): # {{{
|
|||||||
locations_changed = pyqtSignal()
|
locations_changed = pyqtSignal()
|
||||||
unmount_device = pyqtSignal()
|
unmount_device = pyqtSignal()
|
||||||
location_selected = pyqtSignal(object)
|
location_selected = pyqtSignal(object)
|
||||||
|
configure_device = pyqtSignal()
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
QObject.__init__(self, parent)
|
QObject.__init__(self, parent)
|
||||||
@ -57,6 +58,10 @@ class LocationManager(QObject): # {{{
|
|||||||
a = m.addAction(QIcon(I('eject.png')), _('Eject this device'))
|
a = m.addAction(QIcon(I('eject.png')), _('Eject this device'))
|
||||||
a.triggered.connect(self._eject_requested)
|
a.triggered.connect(self._eject_requested)
|
||||||
self._mem.append(a)
|
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:
|
else:
|
||||||
ac.setToolTip(tooltip)
|
ac.setToolTip(tooltip)
|
||||||
ac.setMenu(m)
|
ac.setMenu(m)
|
||||||
@ -109,6 +114,9 @@ class LocationManager(QObject): # {{{
|
|||||||
def _eject_requested(self, *args):
|
def _eject_requested(self, *args):
|
||||||
self.unmount_device.emit()
|
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):
|
def update_devices(self, cp=(None, None), fs=[-1, -1, -1], icon=None):
|
||||||
if icon is None:
|
if icon is None:
|
||||||
icon = I('reader.png')
|
icon = I('reader.png')
|
||||||
|
@ -265,6 +265,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
|||||||
####################### Location Manager ########################
|
####################### Location Manager ########################
|
||||||
self.location_manager.location_selected.connect(self.location_selected)
|
self.location_manager.location_selected.connect(self.location_selected)
|
||||||
self.location_manager.unmount_device.connect(self.device_manager.umount_device)
|
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)
|
self.eject_action.triggered.connect(self.device_manager.umount_device)
|
||||||
|
|
||||||
#################### Update notification ###################
|
#################### Update notification ###################
|
||||||
|
Loading…
x
Reference in New Issue
Block a user