mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
1) Add a tweak to turn on/off multi-character first-letter partioning in the tag browser
2) Change preferences.tweaks to add a "tweak number" to the tweak name string. This helps tell people which tweak to look at. To keep these valid, we should always add tweaks to the end.
This commit is contained in:
parent
25712ea2cd
commit
3c664b7591
@ -515,3 +515,13 @@ compile_gpm_templates = True
|
||||
# default_tweak_format = 'remember'
|
||||
default_tweak_format = None
|
||||
|
||||
#: Enable multi-character first-letters in the tag browser
|
||||
# Some languages have letters that can be represented by multiple characters.
|
||||
# For example, Czech has a 'character' "ch" that sorts between "h" and "i".
|
||||
# If this tweak is True, then the tag browser will take these characters into
|
||||
# consideration when partitioning by first letter.
|
||||
# Examples:
|
||||
# enable_multicharacters_in_tag_browser = True
|
||||
# enable_multicharacters_in_tag_browser = True
|
||||
enable_multicharacters_in_tag_browser = True
|
||||
|
||||
|
@ -39,7 +39,7 @@ class Delegate(QStyledItemDelegate): # {{{
|
||||
|
||||
class Tweak(object): # {{{
|
||||
|
||||
def __init__(self, name, doc, var_names, defaults, custom):
|
||||
def __init__(self, name, doc, var_names, defaults, custom, tweak_num):
|
||||
translate = _
|
||||
self.name = translate(name)
|
||||
self.doc = doc.strip()
|
||||
@ -53,6 +53,7 @@ class Tweak(object): # {{{
|
||||
for x in var_names:
|
||||
if x in custom:
|
||||
self.custom_values[x] = custom[x]
|
||||
self.tweak_num = tweak_num
|
||||
|
||||
def __str__(self):
|
||||
ans = ['#: ' + self.name]
|
||||
@ -92,6 +93,10 @@ class Tweak(object): # {{{
|
||||
def update(self, varmap):
|
||||
self.custom_values.update(varmap)
|
||||
|
||||
@property
|
||||
def name_with_position_number(self):
|
||||
return "%d: %s"%(self.tweak_num, self.name)
|
||||
|
||||
# }}}
|
||||
|
||||
class Tweaks(QAbstractListModel, SearchQueryParser): # {{{
|
||||
@ -113,7 +118,7 @@ class Tweaks(QAbstractListModel, SearchQueryParser): # {{{
|
||||
except:
|
||||
return NONE
|
||||
if role == Qt.DisplayRole:
|
||||
return textwrap.fill(tweak.name, 40)
|
||||
return textwrap.fill(tweak.name_with_position_number, 40)
|
||||
if role == Qt.FontRole and tweak.is_customized:
|
||||
ans = QFont()
|
||||
ans.setBold(True)
|
||||
@ -182,7 +187,7 @@ class Tweaks(QAbstractListModel, SearchQueryParser): # {{{
|
||||
pos += 1
|
||||
if not var_names:
|
||||
raise ValueError('Failed to find any variables for %r'%name)
|
||||
self.tweaks.append(Tweak(name, doc, var_names, defaults, custom))
|
||||
self.tweaks.append(Tweak(name, doc, var_names, defaults, custom, len(self.tweaks)+1))
|
||||
#print '\n\n', self.tweaks[-1]
|
||||
return pos
|
||||
|
||||
|
@ -260,7 +260,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
db.prefs.set('tag_browser_hidden_categories', list(self.hidden_categories))
|
||||
|
||||
conts = contractions()
|
||||
if len(conts) == 0:
|
||||
if len(conts) == 0 or not tweaks['enable_multicharacters_in_tag_browser']:
|
||||
self.do_contraction = False
|
||||
else:
|
||||
self.do_contraction = True
|
||||
|
Loading…
x
Reference in New Issue
Block a user