def _config(): c = Config('customize') c.add_opt('plugins', default={}, help=_('Installed plugins')) c.add_opt('filetype_mapping', default={}, help=_('Mapping for filetype plugins')) c.add_opt('plugin_customization', default={}, help=_('Local plugin customization')) c.add_opt('disabled_plugins', default=set([]), help=_('Disabled plugins')) c.add_opt('enabled_plugins', default=set([]), help=_('Enabled plugins')) return ConfigProxy(c)
def genesis(self, gui): self.gui = gui self.proxy = ConfigProxy(config()) r = self.register for x in ('asciiize', 'update_metadata', 'save_cover', 'write_opf', 'replace_whitespace', 'to_lowercase', 'formats', 'timefmt'): r(x, self.proxy) r('show_files_after_save', gprefs) self.save_template.changed_signal.connect(self.changed_signal.emit)
def genesis(self, gui): self.gui = gui self.proxy = ConfigProxy(smtp_prefs()) self.send_email_widget.initialize(self.preferred_to_address) self.send_email_widget.changed_signal.connect(self.changed_signal.emit) opts = self.send_email_widget.smtp_opts self._email_accounts = EmailAccounts(opts.accounts, opts.subjects) self._email_accounts.dataChanged.connect( lambda x, y: self.changed_signal.emit()) self.email_view.setModel(self._email_accounts) self.email_add.clicked.connect(self.add_email_account) self.email_make_default.clicked.connect(self.make_default) self.email_view.resizeColumnsToContents() self.email_remove.clicked.connect(self.remove_email_account)
def genesis(self, gui): self.gui = gui self.proxy = ConfigProxy(smtp_prefs()) r = self.register r('add_comments_to_email', gprefs) self.send_email_widget.initialize(self.preferred_to_address) self.send_email_widget.changed_signal.connect(self.changed_signal.emit) opts = self.send_email_widget.smtp_opts self._email_accounts = EmailAccounts(opts.accounts, opts.subjects, opts.aliases, opts.tags) connect_lambda(self._email_accounts.dataChanged, self, lambda self: self.changed_signal.emit()) self.email_view.setModel(self._email_accounts) self.email_view.sortByColumn(0, Qt.SortOrder.AscendingOrder) self.email_view.setSortingEnabled(True) self.email_add.clicked.connect(self.add_email_account) self.email_make_default.clicked.connect(self.make_default) self.email_view.resizeColumnsToContents() self.email_remove.clicked.connect(self.remove_email_account)
def genesis(self, gui): self.gui = gui self.proxy = ConfigProxy(server_config()) db = self.db = gui.library_view.model().db self.server = self.gui.content_server r = self.register r('port', self.proxy) r('username', self.proxy) r('password', self.proxy) r('max_cover', self.proxy) r('max_opds_items', self.proxy) r('max_opds_ungrouped_items', self.proxy) r('url_prefix', self.proxy) self.show_server_password.stateChanged[int].connect( lambda s: self.opt_password.setEchoMode( self.opt_password.Normal if s == Qt.Checked else self.opt_password.Password)) self.opt_password.setEchoMode(self.opt_password.Password) restrictions = sorted(db.prefs['virtual_libraries'].iterkeys(), key=sort_key) choices = [('', '')] + [(x, x) for x in restrictions] # check that the virtual library still exists vls = db.prefs['cs_virtual_lib_on_startup'] if vls and vls not in restrictions: db.prefs['cs_virtual_lib_on_startup'] = '' r('cs_virtual_lib_on_startup', db.prefs, choices=choices) self.start_button.setEnabled( not getattr(self.server, 'is_running', False)) self.test_button.setEnabled(not self.start_button.isEnabled()) self.stop_button.setDisabled(self.start_button.isEnabled()) self.start_button.clicked.connect(self.start_server) self.stop_button.clicked.connect(self.stop_server) self.test_button.clicked.connect(self.test_server) self.view_logs.clicked.connect(self.view_server_logs) r('autolaunch_server', config)
def genesis(self, gui): self.gui = gui self.proxy = ConfigProxy(server_config()) db = self.db = gui.library_view.model().db self.server = self.gui.content_server r = self.register r('port', self.proxy) r('username', self.proxy) r('password', self.proxy) r('max_cover', self.proxy) r('max_opds_items', self.proxy) r('max_opds_ungrouped_items', self.proxy) r('url_prefix', self.proxy) self.show_server_password.stateChanged[int].connect( lambda s: self.opt_password.setEchoMode( self.opt_password.Normal if s == Qt.Checked else self.opt_password.Password)) self.opt_password.setEchoMode(self.opt_password.Password) restrictions = sorted(saved_searches().names(), key=sort_key) # verify that the current restriction still exists. If not, clear it. csr = db.prefs.get('cs_restriction', None) if csr and csr not in restrictions: db.prefs.set('cs_restriction', '') choices = [('', '')] + [(x, x) for x in restrictions] r('cs_restriction', db.prefs, choices=choices) self.start_button.setEnabled( not getattr(self.server, 'is_running', False)) self.test_button.setEnabled(not self.start_button.isEnabled()) self.stop_button.setDisabled(self.start_button.isEnabled()) self.start_button.clicked.connect(self.start_server) self.stop_button.clicked.connect(self.stop_server) self.test_button.clicked.connect(self.test_server) self.view_logs.clicked.connect(self.view_server_logs) r('autolaunch_server', config)
def genesis(self, gui): self.gui = gui self.proxy = ConfigProxy(config()) r = self.register for x in ('send_timefmt',): r(x, self.proxy) choices = [(_('Manual management'), 'manual'), (_('Only on send'), 'on_send'), (_('Automatic management'), 'on_connect')] r('manage_device_metadata', prefs, choices=choices) if gui.device_manager.is_device_connected: self.opt_manage_device_metadata.setEnabled(False) self.opt_manage_device_metadata.setToolTip( _('Cannot change metadata management while a device is connected')) self.mm_label.setText('Metadata management (disabled while ' 'device connected)') self.send_template.changed_signal.connect(self.changed_signal.emit)
def _config(): # {{{ c = Config('gui', 'preferences for the calibre GUI') c.add_opt('send_to_storage_card_by_default', default=False, help=_('Send file to storage card instead of main memory by default')) c.add_opt('confirm_delete', default=False, help=_('Confirm before deleting')) c.add_opt('main_window_geometry', default=None, help=_('Main window geometry')) c.add_opt('new_version_notification', default=True, help=_('Notify when a new version is available')) c.add_opt('use_roman_numerals_for_series_number', default=True, help=_('Use Roman numerals for series number')) c.add_opt('sort_tags_by', default='name', help=_('Sort tags list by name, popularity, or rating')) c.add_opt('match_tags_type', default='any', help=_('Match tags by any or all.')) c.add_opt('cover_flow_queue_length', default=6, help=_('Number of covers to show in the cover browsing mode')) c.add_opt('LRF_conversion_defaults', default=[], help=_('Defaults for conversion to LRF')) c.add_opt('LRF_ebook_viewer_options', default=None, help=_('Options for the LRF ebook viewer')) c.add_opt('internally_viewed_formats', default=['LRF', 'EPUB', 'LIT', 'MOBI', 'PRC', 'POBI', 'AZW', 'AZW3', 'HTML', 'FB2', 'PDB', 'RB', 'SNB', 'HTMLZ', 'KEPUB'], help=_( 'Formats that are viewed using the internal viewer')) c.add_opt('column_map', default=ALL_COLUMNS, help=_('Columns to be displayed in the book list')) c.add_opt('autolaunch_server', default=False, help=_('Automatically launch content server on application startup')) c.add_opt('oldest_news', default=60, help=_('Oldest news kept in database')) c.add_opt('systray_icon', default=False, help=_('Show system tray icon')) c.add_opt('upload_news_to_device', default=True, help=_('Upload downloaded news to device')) c.add_opt('delete_news_from_library_on_upload', default=False, help=_('Delete news books from library after uploading to device')) c.add_opt('separate_cover_flow', default=False, help=_('Show the cover flow in a separate window instead of in the main calibre window')) c.add_opt('disable_tray_notification', default=False, help=_('Disable notifications from the system tray icon')) c.add_opt('default_send_to_device_action', default=None, help=_('Default action to perform when send to device button is ' 'clicked')) c.add_opt('asked_library_thing_password', default=False, help='Asked library thing password at least once.') c.add_opt('search_as_you_type', default=False, help=_('Start searching as you type. If this is disabled then search will ' 'only take place when the Enter or Return key is pressed.')) c.add_opt('highlight_search_matches', default=False, help=_('When searching, show all books with search results ' 'highlighted instead of showing only the matches. You can use the ' 'N or F3 keys to go to the next match.')) c.add_opt('save_to_disk_template_history', default=[], help='Previously used Save to Disk templates') c.add_opt('send_to_device_template_history', default=[], help='Previously used Send to Device templates') c.add_opt('main_search_history', default=[], help='Search history for the main GUI') c.add_opt('viewer_search_history', default=[], help='Search history for the ebook viewer') c.add_opt('viewer_toc_search_history', default=[], help='Search history for the ToC in the ebook viewer') c.add_opt('lrf_viewer_search_history', default=[], help='Search history for the LRF viewer') c.add_opt('scheduler_search_history', default=[], help='Search history for the recipe scheduler') c.add_opt('plugin_search_history', default=[], help='Search history for the plugin preferences') c.add_opt('shortcuts_search_history', default=[], help='Search history for the keyboard preferences') c.add_opt('jobs_search_history', default=[], help='Search history for the tweaks preferences') c.add_opt('tweaks_search_history', default=[], help='Search history for tweaks') c.add_opt('worker_limit', default=6, help=_( 'Maximum number of simultaneous conversion/news download jobs. ' 'This number is twice the actual value for historical reasons.')) c.add_opt('get_social_metadata', default=True, help=_('Download social metadata (tags/rating/etc.)')) c.add_opt('overwrite_author_title_metadata', default=True, help=_('Overwrite author and title with new metadata')) c.add_opt('auto_download_cover', default=False, help=_('Automatically download the cover, if available')) c.add_opt('enforce_cpu_limit', default=True, help=_('Limit max simultaneous jobs to number of CPUs')) c.add_opt('gui_layout', choices=['wide', 'narrow'], help=_('The layout of the user interface. Wide has the ' 'book details panel on the right and narrow has ' 'it at the bottom.'), default='wide') c.add_opt('show_avg_rating', default=True, help=_('Show the average rating per item indication in the tag browser')) c.add_opt('disable_animations', default=False, help=_('Disable UI animations')) # This option is no longer used. It remains for compatibility with upgrades # so the value can be migrated c.add_opt('tag_browser_hidden_categories', default=set(), help=_('tag browser categories not to display')) c.add_opt return ConfigProxy(c)
def _configProxy(cls): return ConfigProxy(cls._config())
iswindows def console_config(): desc = 'Settings to control the calibre console' c = Config('console', desc) c.add_opt('theme', default='native', help='The color theme') c.add_opt('scrollback', default=10000, help='Max number of lines to keep in the scrollback buffer') return c prefs = ConfigProxy(console_config()) dynamic = JSONConfig('console') def prints(*args, **kwargs): kwargs['file'] = sys.__stdout__ prints_(*args, **kwargs) class Process(Worker): @property def env(self): env = dict(os.environ) env.update(self._env) return env