diff --git a/src/calibre/gui2/dialogs/config/__init__.py b/src/calibre/gui2/dialogs/config/__init__.py index c5b61f146d..2caaabc2cc 100644 --- a/src/calibre/gui2/dialogs/config/__init__.py +++ b/src/calibre/gui2/dialogs/config/__init__.py @@ -36,6 +36,7 @@ from calibre.gui2.convert.structure_detection import StructureDetectionWidget from calibre.ebooks.conversion.plumber import Plumber from calibre.utils.logging import Log from calibre.gui2.convert.toc import TOCWidget +from calibre.utils.search_query_parser import saved_searches class ConfigTabs(QTabWidget): @@ -447,7 +448,7 @@ class ConfigDialog(ResizableDialog, Ui_Dialog): self.password.setText(opts.password if opts.password else '') self.opt_max_opds_items.setValue(opts.max_opds_items) self.opt_max_opds_ungrouped_items.setValue(opts.max_opds_ungrouped_items) - self.opt_restriction.setText(self.db.prefs.get('cs_restriction', '')) + self.opt_cs_restriction.setText(self.db.prefs.get('cs_restriction', '')) self.auto_launch.setChecked(config['autolaunch_server']) self.systray_icon.setChecked(config['systray_icon']) self.sync_news.setChecked(config['upload_news_to_device']) @@ -494,6 +495,12 @@ class ConfigDialog(ResizableDialog, Ui_Dialog): if x == config['gui_layout']: li = i self.opt_gui_layout.setCurrentIndex(li) + restrictions = sorted(saved_searches().names(), + cmp=lambda x,y: cmp(x.lower(), y.lower())) + restrictions.insert(0, '') + self.opt_gui_restriction.addItems(restrictions) + idx = self.opt_gui_restriction.findText(self.db.prefs.get('gui_restriction', '')) + self.opt_gui_restriction.setCurrentIndex(0 if idx < 0 else idx) self.opt_disable_animations.setChecked(config['disable_animations']) self.opt_show_donate_button.setChecked(config['show_donate_button']) idx = 0 @@ -907,7 +914,7 @@ class ConfigDialog(ResizableDialog, Ui_Dialog): sc.set('max_opds_items', self.opt_max_opds_items.value()) sc.set('max_opds_ungrouped_items', self.opt_max_opds_ungrouped_items.value()) - self.db.prefs.set('cs_restriction', unicode(self.opt_restriction.text())) + self.db.prefs.set('cs_restriction', unicode(self.opt_cs_restriction.text())) config['delete_news_from_library_on_upload'] = self.delete_news.isChecked() config['upload_news_to_device'] = self.sync_news.isChecked() config['search_as_you_type'] = self.search_as_you_type.isChecked() @@ -929,6 +936,7 @@ class ConfigDialog(ResizableDialog, Ui_Dialog): config['internally_viewed_formats'] = fmts val = self.opt_gui_layout.itemData(self.opt_gui_layout.currentIndex()).toString() config['gui_layout'] = unicode(val) + self.db.prefs.set('gui_restriction', unicode(self.opt_gui_restriction.currentText())) if must_restart: warning_dialog(self, _('Must restart'), diff --git a/src/calibre/gui2/dialogs/config/config.ui b/src/calibre/gui2/dialogs/config/config.ui index 62eb7bb620..3c5c109e04 100644 --- a/src/calibre/gui2/dialogs/config/config.ui +++ b/src/calibre/gui2/dialogs/config/config.ui @@ -295,7 +295,7 @@ - + Use &Roman numerals for series number @@ -305,35 +305,35 @@ - + Enable system &tray icon (needs restart) - + Show &notifications in system tray - + Show &splash screen at startup - + Show cover &browser in a separate window (needs restart) - + Show &average ratings in the tags browser @@ -343,7 +343,7 @@ - + Search as you type @@ -353,21 +353,21 @@ - + Automatically send downloaded &news to ebook reader - + &Delete news from library when it is automatically sent to reader - + @@ -384,7 +384,7 @@ - + @@ -570,7 +570,27 @@ + + + + Restriction to apply when the current library is opened (startup or change library): + + + opt_gui_restriction + + + + + + + 250 + 16777215 + + + + + Disable all animations. Useful if you have a slow/old computer. @@ -580,14 +600,14 @@ - + Show &donate button (restart) - + &Toolbar @@ -1041,7 +1061,7 @@ - + Provides a restriction to be used by the content server @@ -1056,7 +1076,7 @@ Restriction (saved search) to apply: - opt_restriction + opt_cs_restriction diff --git a/src/calibre/gui2/search_box.py b/src/calibre/gui2/search_box.py index 95667379a1..7169eb5fd3 100644 --- a/src/calibre/gui2/search_box.py +++ b/src/calibre/gui2/search_box.py @@ -402,8 +402,7 @@ class SavedSearchBoxMixin(object): b.setStatusTip(b.toolTip()) def saved_searches_changed(self): - p = saved_searches().names() - p.sort() + p = sorted(saved_searches().names(), cmp=lambda x,y: cmp(x.lower(), y.lower())) t = unicode(self.search_restriction.currentText()) self.search_restriction.clear() # rebuild the restrictions combobox using current saved searches self.search_restriction.addItem('') diff --git a/src/calibre/gui2/ui.py b/src/calibre/gui2/ui.py index f521bceaf9..41b166b13f 100644 --- a/src/calibre/gui2/ui.py +++ b/src/calibre/gui2/ui.py @@ -230,6 +230,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, # {{{ ######################### Search Restriction ########################## SearchRestrictionMixin.__init__(self) + self.apply_named_search_restriction(db.prefs.get('gui_restriction', '')) ########################### Cover Flow ################################ @@ -373,6 +374,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, # {{{ self.set_window_title() self.apply_named_search_restriction('') # reset restriction to null self.saved_searches_changed() # reload the search restrictions combo box + self.apply_named_search_restriction(db.prefs.get('gui_restriction', '')) def set_window_title(self): self.setWindowTitle(__appname__ + u' - ||%s||'%self.iactions['Choose Library'].library_name())