diff --git a/resources/template-functions.json b/resources/template-functions.json index cf858c7691..7656db4021 100644 --- a/resources/template-functions.json +++ b/resources/template-functions.json @@ -3,10 +3,12 @@ "divide": "def evaluate(self, formatter, kwargs, mi, locals, x, y):\n x = float(x if x else 0)\n y = float(y if y else 0)\n return unicode(x / y)\n", "uppercase": "def evaluate(self, formatter, kwargs, mi, locals, val):\n return val.upper()\n", "strcat": "def evaluate(self, formatter, kwargs, mi, locals, *args):\n i = 0\n res = ''\n for i in range(0, len(args)):\n res += args[i]\n return res\n", + "in_list": "def evaluate(self, formatter, kwargs, mi, locals, val, sep, pat, fv, nfv):\n l = [v.strip() for v in val.split(sep) if v.strip()]\n for v in l:\n if re.search(pat, v):\n return fv\n return nfv\n", "substr": "def evaluate(self, formatter, kwargs, mi, locals, str_, start_, end_):\n return str_[int(start_): len(str_) if int(end_) == 0 else int(end_)]\n", "ifempty": "def evaluate(self, formatter, kwargs, mi, locals, val, value_if_empty):\n if val:\n return val\n else:\n return value_if_empty\n", "booksize": "def evaluate(self, formatter, kwargs, mi, locals):\n if mi.book_size is not None:\n try:\n return str(mi.book_size)\n except:\n pass\n return ''\n", "select": "def evaluate(self, formatter, kwargs, mi, locals, val, key):\n if not val:\n return ''\n vals = [v.strip() for v in val.split(',')]\n for v in vals:\n if v.startswith(key+':'):\n return v[len(key)+1:]\n return ''\n", + "first_non_empty": "def evaluate(self, formatter, kwargs, mi, locals, *args):\n i = 0\n while i < len(args):\n if args[i]:\n return args[i]\n i += 1\n return ''\n", "field": "def evaluate(self, formatter, kwargs, mi, locals, name):\n return formatter.get_value(name, [], kwargs)\n", "subtract": "def evaluate(self, formatter, kwargs, mi, locals, x, y):\n x = float(x if x else 0)\n y = float(y if y else 0)\n return unicode(x - y)\n", "list_item": "def evaluate(self, formatter, kwargs, mi, locals, val, index, sep):\n if not val:\n return ''\n index = int(index)\n val = val.split(sep)\n try:\n return val[index]\n except:\n return ''\n", diff --git a/src/calibre/gui2/dialogs/template_line_editor.py b/src/calibre/gui2/dialogs/template_line_editor.py index 95727e442b..26f4dd0753 100644 --- a/src/calibre/gui2/dialogs/template_line_editor.py +++ b/src/calibre/gui2/dialogs/template_line_editor.py @@ -63,6 +63,7 @@ class TagWizard(QDialog): self.tags = tags l = QGridLayout() self.setLayout(l) + l.setColumnStretch(0, 1) l.addWidget(QLabel(_('Tag Value')), 0, 0, 1, 1) l.addWidget(QLabel(_('Color')), 0, 1, 1, 1) self.tagboxes = [] diff --git a/src/calibre/gui2/preferences/look_feel.py b/src/calibre/gui2/preferences/look_feel.py index 483934825d..49bfb1df1a 100644 --- a/src/calibre/gui2/preferences/look_feel.py +++ b/src/calibre/gui2/preferences/look_feel.py @@ -167,8 +167,8 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): '' 'tutorial on using templates.') + '

' + - _('If you want to color a field based on tags, then right-click ' - 'in an empty template line and choose tags wizard. ' + _('If you want to color a field based on tags, then click the ' + 'button next to an empty line to open the tags wizard. ' 'It will build a template for you. You can later edit that ' 'template with the same wizard. If you edit it by hand, the ' 'wizard might not work or might restore old values.') + diff --git a/src/calibre/gui2/preferences/look_feel.ui b/src/calibre/gui2/preferences/look_feel.ui index a67a3585cb..fe6134f235 100644 --- a/src/calibre/gui2/preferences/look_feel.ui +++ b/src/calibre/gui2/preferences/look_feel.ui @@ -442,6 +442,9 @@ then the tags will be displayed each on their own line. :/images/wizard.png:/images/wizard.png + + Open the tags wizard. + @@ -456,6 +459,9 @@ then the tags will be displayed each on their own line. :/images/wizard.png:/images/wizard.png + + Open the tags wizard. + @@ -470,6 +476,9 @@ then the tags will be displayed each on their own line. :/images/wizard.png:/images/wizard.png + + Open the tags wizard. + @@ -484,6 +493,9 @@ then the tags will be displayed each on their own line. :/images/wizard.png:/images/wizard.png + + Open the tags wizard. + @@ -498,6 +510,9 @@ then the tags will be displayed each on their own line. :/images/wizard.png:/images/wizard.png + + Open the tags wizard. +