From 50ad1254a108f7252f4466dec5b2f19f4d5de25c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 4 Sep 2010 16:21:44 -0600 Subject: [PATCH] Preferences widget for sending to device --- src/calibre/customize/builtins.py | 11 ++- src/calibre/gui2/preferences/sending.py | 54 ++++++++++++ src/calibre/gui2/preferences/sending.ui | 108 ++++++++++++++++++++++++ 3 files changed, 172 insertions(+), 1 deletion(-) create mode 100644 src/calibre/gui2/preferences/sending.py create mode 100644 src/calibre/gui2/preferences/sending.ui diff --git a/src/calibre/customize/builtins.py b/src/calibre/customize/builtins.py index 9d7f9480d9..a5007fe618 100644 --- a/src/calibre/customize/builtins.py +++ b/src/calibre/customize/builtins.py @@ -757,8 +757,17 @@ class Saving(PreferencesPlugin): name_order = 2 config_widget = 'calibre.gui2.preferences.saving' +class Sending(PreferencesPlugin): + name = 'Sending' + gui_name = _('Sending books to devices') + category = 'Import/Export' + gui_category = _('Import/Export') + category_order = 3 + name_order = 3 + config_widget = 'calibre.gui2.preferences.sending' + plugins += [LookAndFeel, Behavior, Columns, Toolbar, InputOptions, - CommonOptions, OutputOptions, Adding, Saving] + CommonOptions, OutputOptions, Adding, Saving, Sending] #}}} diff --git a/src/calibre/gui2/preferences/sending.py b/src/calibre/gui2/preferences/sending.py new file mode 100644 index 0000000000..748c6b2a2d --- /dev/null +++ b/src/calibre/gui2/preferences/sending.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python +# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai + +__license__ = 'GPL v3' +__copyright__ = '2010, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + + + +from calibre.gui2.preferences import ConfigWidgetBase, test_widget, \ + AbortCommit +from calibre.gui2.preferences.sending_ui import Ui_Form +from calibre.utils.config import ConfigProxy +from calibre.library.save_to_disk import config +from calibre.utils.config import prefs + +class ConfigWidget(ConfigWidgetBase, Ui_Form): + + def genesis(self, gui): + self.gui = gui + self.proxy = ConfigProxy(config()) + + r = self.register + + choices = [(_('Manual management'), 'manual'), + (_('Only on send'), 'on_send'), + (_('Automatic management'), 'on_connect')] + r('manage_device_metadata', prefs, choices=choices) + + self.send_template.changed_signal.connect(self.changed_signal.emit) + + + def initialize(self): + ConfigWidgetBase.initialize(self) + self.send_template.blockSignals(True) + self.send_template.initialize('send_to_device', self.proxy['send_template'], + self.proxy.help('send_template')) + self.send_template.blockSignals(False) + + def restore_defaults(self): + ConfigWidgetBase.restore_defaults(self) + self.send_template.set_value(self.proxy.defaults['send_template']) + + def commit(self): + if not self.send_template.validate(): + raise AbortCommit('abort') + self.send_template.save_settings(self.proxy, 'send_template') + return ConfigWidgetBase.commit(self) + +if __name__ == '__main__': + from PyQt4.Qt import QApplication + app = QApplication([]) + test_widget('Import/Export', 'Sending') + diff --git a/src/calibre/gui2/preferences/sending.ui b/src/calibre/gui2/preferences/sending.ui new file mode 100644 index 0000000000..e064646afd --- /dev/null +++ b/src/calibre/gui2/preferences/sending.ui @@ -0,0 +1,108 @@ + + + Form + + + + 0 + 0 + 807 + 331 + + + + Form + + + + + + + 0 + 0 + + + + Metadata &management: + + + opt_manage_device_metadata + + + + + + + + 0 + 0 + + + + + Manual management + + + + + Only on send + + + + + Automatic management + + + + + + + + Qt::Horizontal + + + + 457 + 20 + + + + + + + + <li><b>Manual management</b>: Calibre updates the metadata and adds collections only when a book is sent. With this option, calibre will never remove a collection.</li> +<li><b>Only on send</b>: Calibre updates metadata and adds/removes collections for a book only when it is sent to the device. </li> +<li><b>Automatic management</b>: Calibre automatically keeps metadata on the device in sync with the calibre library, on every connect</li></ul> + + + true + + + + + + + Here you can control how calibre will save your books when you click the Send to Device button. This setting can be overriden for individual devices by customizing the device interface plugins in Preferences->Advanced->Plugins + + + true + + + + + + + + + + + SaveTemplate + QWidget +
calibre/gui2/preferences/save_template.h
+ 1 +
+
+ + +