diff --git a/src/calibre/gui2/dialogs/template_line_editor.py b/src/calibre/gui2/dialogs/template_line_editor.py index 69999f59a0..c3598a8abb 100644 --- a/src/calibre/gui2/dialogs/template_line_editor.py +++ b/src/calibre/gui2/dialogs/template_line_editor.py @@ -5,7 +5,7 @@ __license__ = 'GPL v3' __copyright__ = '2010, Kovid Goyal ' __docformat__ = 'restructuredtext en' -from PyQt4.Qt import (SIGNAL, QLineEdit) +from PyQt4.Qt import QLineEdit from calibre.gui2.dialogs.template_dialog import TemplateDialog class TemplateLineEditor(QLineEdit): @@ -18,13 +18,14 @@ class TemplateLineEditor(QLineEdit): menu = self.createStandardContextMenu() menu.addSeparator() - action_open_editor = menu.addAction(_('Open Editor')) + action_open_editor = menu.addAction(_('Open Template Editor')) - self.connect(action_open_editor, SIGNAL('triggered()'), self.open_editor) + action_open_editor.triggered.connect(self.open_editor) menu.exec_(event.globalPos()) def open_editor(self): t = TemplateDialog(self, self.text()) + t.setWindowTitle(_('Edit template')) if t.exec_(): self.setText(t.textbox.toPlainText()) diff --git a/src/calibre/gui2/library/delegates.py b/src/calibre/gui2/library/delegates.py index d66959a87c..50c411aaa4 100644 --- a/src/calibre/gui2/library/delegates.py +++ b/src/calibre/gui2/library/delegates.py @@ -323,16 +323,18 @@ class CcCommentsDelegate(QStyledItemDelegate): # {{{ style = QApplication.style() if option.widget is None \ else option.widget.style() self.document.setHtml(option.text) - option.text = "" - style.drawControl(QStyle.CE_ItemViewItem, option, painter); + option.text = u'' + if hasattr(QStyle, 'CE_ItemViewItem'): + style.drawControl(QStyle.CE_ItemViewItem, option, painter) ctx = QAbstractTextDocumentLayout.PaintContext() ctx.palette = option.palette #.setColor(QPalette.Text, QColor("red")); - textRect = style.subElementRect(QStyle.SE_ItemViewItemText, option) - painter.save() - painter.translate(textRect.topLeft()) - painter.setClipRect(textRect.translated(-textRect.topLeft())) - self.document.documentLayout().draw(painter, ctx) - painter.restore() + if hasattr(QStyle, 'SE_ItemViewItemText'): + textRect = style.subElementRect(QStyle.SE_ItemViewItemText, option) + painter.save() + painter.translate(textRect.topLeft()) + painter.setClipRect(textRect.translated(-textRect.topLeft())) + self.document.documentLayout().draw(painter, ctx) + painter.restore() def createEditor(self, parent, option, index): m = index.model() diff --git a/src/calibre/gui2/library/models.py b/src/calibre/gui2/library/models.py index ae3a53b376..d698655746 100644 --- a/src/calibre/gui2/library/models.py +++ b/src/calibre/gui2/library/models.py @@ -707,7 +707,7 @@ class BooksModel(QAbstractTableModel): # {{{ return self.column_to_dc_map[col](index.row()) elif role == Qt.BackgroundRole: if self.id(index) in self.ids_to_highlight_set: - return QColor('lightgreen') + return QVariant(QColor('lightgreen')) elif role == Qt.ForegroundRole: key = self.column_map[col] if key in self.column_color_map: @@ -716,9 +716,9 @@ class BooksModel(QAbstractTableModel): # {{{ try: color = QColor(composite_formatter.safe_format(fmt, mi, '', mi)) if color.isValid(): - return color + return QVariant(color) except: - return None + return NONE elif self.is_custom_column(key) and \ self.custom_columns[key]['datatype'] == 'enumeration': cc = self.custom_columns[self.column_map[col]]['display'] @@ -729,10 +729,10 @@ class BooksModel(QAbstractTableModel): # {{{ try: color = QColor(colors[values.index(txt)]) if color.isValid(): - return color + return QVariant(color) except: pass - return None + return NONE elif role == Qt.DecorationRole: if self.column_to_dc_decorator_map[col] is not None: return self.column_to_dc_decorator_map[index.column()](index.row()) diff --git a/src/calibre/gui2/preferences/look_feel.py b/src/calibre/gui2/preferences/look_feel.py index ffbc82eefd..1c9d4abfce 100644 --- a/src/calibre/gui2/preferences/look_feel.py +++ b/src/calibre/gui2/preferences/look_feel.py @@ -160,9 +160,12 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): self.df_down_button.clicked.connect(self.move_df_down) self.color_help_text.setText('

' + - _('Here you can specify coloring rules for fields shown in the ' - 'library view. Choose the field you wish to color, then ' - 'supply a template that specifies the color to use.') + + _('Here you can specify coloring rules for columns shown in the ' + 'library view. Choose the column you wish to color, then ' + 'supply a template that specifies the color to use based on ' + 'the values in the column. There is a ' + '' + 'tutorial on using templates.') + '

' + _('The template must evaluate to one of the color names shown ' 'below. You can use any legal template expression. ' @@ -187,8 +190,8 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): '

' + _('You can access a multi-line template editor from the ' 'context menu (right-click).') + '

' + - _('Note: if you want to color a "custom column with a fixed set ' - 'of values", it is possible and often easier to specify the ' + _('Note: if you want to color a "custom column with a fixed set ' + 'of values", it is often easier to specify the ' 'colors in the column definition dialog. There you can ' 'provide a color for each value without using a template.')+ '

') choices = db.field_metadata.displayable_field_keys() diff --git a/src/calibre/gui2/preferences/look_feel.ui b/src/calibre/gui2/preferences/look_feel.ui index 9dedcf4f8c..ad990a1586 100644 --- a/src/calibre/gui2/preferences/look_feel.ui +++ b/src/calibre/gui2/preferences/look_feel.ui @@ -7,7 +7,7 @@ 0 0 717 - 390 + 519 @@ -417,86 +417,124 @@ then the tags will be displayed each on their own line. - + Column name - - - - true - - - - - - + Selection template - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - + Color names - - - + + + + + 0 + 200 + + + true - - - 0 - 1 - + + Qt::AlignCenter + + + + 0 + 0 + 687 + 194 + + + + + + + true + + + true + + + + + + + + + + + + 16777215 + 120 + + + + true + + + + + 0 + 0 + 687 + 61 + + + + + + + true + + + + +