mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge from trunk
This commit is contained in:
commit
2ec97d2b89
@ -10,7 +10,7 @@ import os
|
||||
from PyQt4.Qt import QDialog
|
||||
|
||||
from calibre.gui2.dialogs.choose_library_ui import Ui_Dialog
|
||||
from calibre.gui2 import error_dialog, choose_dir, warning_dialog
|
||||
from calibre.gui2 import error_dialog, choose_dir
|
||||
from calibre.constants import filesystem_encoding
|
||||
from calibre import isbytestring, patheq
|
||||
from calibre.utils.config import prefs
|
||||
@ -62,12 +62,6 @@ class ChooseLibrary(QDialog, Ui_Dialog):
|
||||
return True
|
||||
|
||||
def perform_action(self, ac, loc):
|
||||
if ac in ('new', 'existing'):
|
||||
warning_dialog(self.parent(), _('Custom columns'),
|
||||
_('If you use custom columns and they differ between '
|
||||
'libraries, you will have various problems. Best '
|
||||
'to ensure you have the same custom columns in each '
|
||||
'library.'), show=True)
|
||||
if ac in ('new', 'existing'):
|
||||
prefs['library_path'] = loc
|
||||
self.callback(loc)
|
||||
|
@ -62,6 +62,7 @@ class SchedulerDialog(QDialog, Ui_Dialog):
|
||||
self.search_done)
|
||||
self.disconnect(self.recipe_model, SIGNAL('searched(PyQt_PyObject)'),
|
||||
self.search.search_done)
|
||||
self.search.search.disconnect()
|
||||
self.recipe_model = None
|
||||
|
||||
def search_done(self, *args):
|
||||
|
@ -62,7 +62,7 @@ class TagCategories(QDialog, Ui_TagCategories):
|
||||
self.all_items.append(t)
|
||||
self.all_items_dict[label+':'+n] = t
|
||||
|
||||
self.categories = dict.copy(db.prefs['user_categories'])
|
||||
self.categories = dict.copy(db.prefs.get('user_categories', {}))
|
||||
if self.categories is None:
|
||||
self.categories = {}
|
||||
for cat in self.categories:
|
||||
|
@ -16,7 +16,6 @@ from calibre.gui2 import config
|
||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||
from calibre.gui2.dialogs.saved_search_editor import SavedSearchEditor
|
||||
from calibre.gui2.dialogs.search import SearchDialog
|
||||
from calibre.utils.config import prefs
|
||||
from calibre.utils.search_query_parser import saved_searches
|
||||
|
||||
class SearchLineEdit(QLineEdit):
|
||||
|
@ -17,7 +17,6 @@ from PyQt4.Qt import Qt, QTreeView, QApplication, pyqtSignal, \
|
||||
|
||||
from calibre.ebooks.metadata import title_sort
|
||||
from calibre.gui2 import config, NONE
|
||||
from calibre.utils.config import prefs
|
||||
from calibre.library.field_metadata import TagsIcons
|
||||
from calibre.utils.search_query_parser import saved_searches
|
||||
from calibre.gui2 import error_dialog
|
||||
@ -224,7 +223,7 @@ class TagsView(QTreeView): # {{{
|
||||
|
||||
# Always show the user categories editor
|
||||
self.context_menu.addSeparator()
|
||||
if category in self.db.prefs['user_categories'].keys():
|
||||
if category in self.db.prefs.get('user_categories', {}).keys():
|
||||
self.context_menu.addAction(_('Manage User Categories'),
|
||||
partial(self.context_menu_handler, action='manage_categories',
|
||||
category=category))
|
||||
@ -426,7 +425,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
for k in tb_cats.keys():
|
||||
if tb_cats[k]['kind'] in ['user', 'search']:
|
||||
del tb_cats[k]
|
||||
for user_cat in sorted(self.db.prefs['user_categories'].keys()):
|
||||
for user_cat in sorted(self.db.prefs.get('user_categories', {}).keys()):
|
||||
cat_name = user_cat+':' # add the ':' to avoid name collision
|
||||
tb_cats.add_user_category(label=cat_name, name=user_cat)
|
||||
if len(saved_searches().names()):
|
||||
|
@ -144,17 +144,18 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
self.prefs = DBPrefs(self)
|
||||
|
||||
# Migrate saved search and user categories to db preference scheme
|
||||
def migrate_preference(name):
|
||||
def migrate_preference(name, default):
|
||||
obsolete = '###OBSOLETE--DON\'T USE ME###'
|
||||
ans = self.prefs.get(name, None)
|
||||
if ans is None:
|
||||
ans = prefs[name]
|
||||
if ans is None:
|
||||
raise ValueError('Preference %s is None!'%name)
|
||||
prefs[name] = '###OBSOLETE--DON\'T USE ME###'
|
||||
if ans in (None, obsolete):
|
||||
ans = default
|
||||
prefs[name] = obsolete
|
||||
self.prefs[name] = ans
|
||||
|
||||
migrate_preference('user_categories')
|
||||
migrate_preference('saved_searches')
|
||||
migrate_preference('user_categories', {})
|
||||
migrate_preference('saved_searches', {})
|
||||
set_saved_searches(self, 'saved_searches')
|
||||
|
||||
self.conn.executescript('''
|
||||
@ -285,7 +286,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
for k in tb_cats.keys():
|
||||
if tb_cats[k]['kind'] in ['user', 'search']:
|
||||
del tb_cats[k]
|
||||
for user_cat in sorted(self.prefs['user_categories'].keys()):
|
||||
for user_cat in sorted(self.prefs.get('user_categories', {}).keys()):
|
||||
cat_name = user_cat+':' # add the ':' to avoid name collision
|
||||
tb_cats.add_user_category(label=cat_name, name=user_cat)
|
||||
if len(saved_searches().names()):
|
||||
|
@ -42,6 +42,8 @@ def get_lang():
|
||||
lang = match.group()
|
||||
if lang == 'zh':
|
||||
lang = 'zh_CN'
|
||||
if lang is None:
|
||||
lang = 'en'
|
||||
return lang
|
||||
|
||||
def messages_path(lang):
|
||||
|
@ -35,7 +35,7 @@ class SavedSearchQueries(object):
|
||||
self.opt_name = _opt_name;
|
||||
self.db = db
|
||||
if db is not None:
|
||||
self.queries = db.prefs[self.opt_name]
|
||||
self.queries = db.prefs.get(self.opt_name, {})
|
||||
else:
|
||||
self.queries = {}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user