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
72e65402e5
@ -5,7 +5,7 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
from PyQt4.Qt import (SIGNAL, QLineEdit)
|
from PyQt4.Qt import QLineEdit
|
||||||
from calibre.gui2.dialogs.template_dialog import TemplateDialog
|
from calibre.gui2.dialogs.template_dialog import TemplateDialog
|
||||||
|
|
||||||
class TemplateLineEditor(QLineEdit):
|
class TemplateLineEditor(QLineEdit):
|
||||||
@ -18,13 +18,14 @@ class TemplateLineEditor(QLineEdit):
|
|||||||
menu = self.createStandardContextMenu()
|
menu = self.createStandardContextMenu()
|
||||||
menu.addSeparator()
|
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())
|
menu.exec_(event.globalPos())
|
||||||
|
|
||||||
def open_editor(self):
|
def open_editor(self):
|
||||||
t = TemplateDialog(self, self.text())
|
t = TemplateDialog(self, self.text())
|
||||||
|
t.setWindowTitle(_('Edit template'))
|
||||||
if t.exec_():
|
if t.exec_():
|
||||||
self.setText(t.textbox.toPlainText())
|
self.setText(t.textbox.toPlainText())
|
||||||
|
|
||||||
|
@ -323,10 +323,12 @@ class CcCommentsDelegate(QStyledItemDelegate): # {{{
|
|||||||
style = QApplication.style() if option.widget is None \
|
style = QApplication.style() if option.widget is None \
|
||||||
else option.widget.style()
|
else option.widget.style()
|
||||||
self.document.setHtml(option.text)
|
self.document.setHtml(option.text)
|
||||||
option.text = ""
|
option.text = u''
|
||||||
style.drawControl(QStyle.CE_ItemViewItem, option, painter);
|
if hasattr(QStyle, 'CE_ItemViewItem'):
|
||||||
|
style.drawControl(QStyle.CE_ItemViewItem, option, painter)
|
||||||
ctx = QAbstractTextDocumentLayout.PaintContext()
|
ctx = QAbstractTextDocumentLayout.PaintContext()
|
||||||
ctx.palette = option.palette #.setColor(QPalette.Text, QColor("red"));
|
ctx.palette = option.palette #.setColor(QPalette.Text, QColor("red"));
|
||||||
|
if hasattr(QStyle, 'SE_ItemViewItemText'):
|
||||||
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, option)
|
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, option)
|
||||||
painter.save()
|
painter.save()
|
||||||
painter.translate(textRect.topLeft())
|
painter.translate(textRect.topLeft())
|
||||||
|
@ -707,7 +707,7 @@ class BooksModel(QAbstractTableModel): # {{{
|
|||||||
return self.column_to_dc_map[col](index.row())
|
return self.column_to_dc_map[col](index.row())
|
||||||
elif role == Qt.BackgroundRole:
|
elif role == Qt.BackgroundRole:
|
||||||
if self.id(index) in self.ids_to_highlight_set:
|
if self.id(index) in self.ids_to_highlight_set:
|
||||||
return QColor('lightgreen')
|
return QVariant(QColor('lightgreen'))
|
||||||
elif role == Qt.ForegroundRole:
|
elif role == Qt.ForegroundRole:
|
||||||
key = self.column_map[col]
|
key = self.column_map[col]
|
||||||
if key in self.column_color_map:
|
if key in self.column_color_map:
|
||||||
@ -716,9 +716,9 @@ class BooksModel(QAbstractTableModel): # {{{
|
|||||||
try:
|
try:
|
||||||
color = QColor(composite_formatter.safe_format(fmt, mi, '', mi))
|
color = QColor(composite_formatter.safe_format(fmt, mi, '', mi))
|
||||||
if color.isValid():
|
if color.isValid():
|
||||||
return color
|
return QVariant(color)
|
||||||
except:
|
except:
|
||||||
return None
|
return NONE
|
||||||
elif self.is_custom_column(key) and \
|
elif self.is_custom_column(key) and \
|
||||||
self.custom_columns[key]['datatype'] == 'enumeration':
|
self.custom_columns[key]['datatype'] == 'enumeration':
|
||||||
cc = self.custom_columns[self.column_map[col]]['display']
|
cc = self.custom_columns[self.column_map[col]]['display']
|
||||||
@ -729,10 +729,10 @@ class BooksModel(QAbstractTableModel): # {{{
|
|||||||
try:
|
try:
|
||||||
color = QColor(colors[values.index(txt)])
|
color = QColor(colors[values.index(txt)])
|
||||||
if color.isValid():
|
if color.isValid():
|
||||||
return color
|
return QVariant(color)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
return None
|
return NONE
|
||||||
elif role == Qt.DecorationRole:
|
elif role == Qt.DecorationRole:
|
||||||
if self.column_to_dc_decorator_map[col] is not None:
|
if self.column_to_dc_decorator_map[col] is not None:
|
||||||
return self.column_to_dc_decorator_map[index.column()](index.row())
|
return self.column_to_dc_decorator_map[index.column()](index.row())
|
||||||
|
@ -160,9 +160,12 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
self.df_down_button.clicked.connect(self.move_df_down)
|
self.df_down_button.clicked.connect(self.move_df_down)
|
||||||
|
|
||||||
self.color_help_text.setText('<p>' +
|
self.color_help_text.setText('<p>' +
|
||||||
_('Here you can specify coloring rules for fields shown in the '
|
_('Here you can specify coloring rules for columns shown in the '
|
||||||
'library view. Choose the field you wish to color, then '
|
'library view. Choose the column you wish to color, then '
|
||||||
'supply a template that specifies the color to use.') +
|
'supply a template that specifies the color to use based on '
|
||||||
|
'the values in the column. There is a '
|
||||||
|
'<a href="http://calibre-ebook.com/user_manual/template_lang.html">'
|
||||||
|
'tutorial</a> on using templates.') +
|
||||||
'</p><p>' +
|
'</p><p>' +
|
||||||
_('The template must evaluate to one of the color names shown '
|
_('The template must evaluate to one of the color names shown '
|
||||||
'below. You can use any legal template expression. '
|
'below. You can use any legal template expression. '
|
||||||
@ -187,8 +190,8 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
'</p><p>' +
|
'</p><p>' +
|
||||||
_('You can access a multi-line template editor from the '
|
_('You can access a multi-line template editor from the '
|
||||||
'context menu (right-click).') + '</p><p>' +
|
'context menu (right-click).') + '</p><p>' +
|
||||||
_('Note: if you want to color a "custom column with a fixed set '
|
_('<b>Note:</b> if you want to color a "custom column with a fixed set '
|
||||||
'of values", it is possible and often easier to specify the '
|
'of values", it is often easier to specify the '
|
||||||
'colors in the column definition dialog. There you can '
|
'colors in the column definition dialog. There you can '
|
||||||
'provide a color for each value without using a template.')+ '</p>')
|
'provide a color for each value without using a template.')+ '</p>')
|
||||||
choices = db.field_metadata.displayable_field_keys()
|
choices = db.field_metadata.displayable_field_keys()
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>717</width>
|
<width>717</width>
|
||||||
<height>390</height>
|
<height>519</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -417,86 +417,124 @@ then the tags will be displayed each on their own line.</string>
|
|||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" name="column_color_layout">
|
<layout class="QGridLayout" name="column_color_layout">
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Column name</string>
|
<string>Column name</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0" colspan="2">
|
|
||||||
<widget class="QTextEdit" name="color_help_text">
|
|
||||||
<property name="readOnly">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<sizepolicy vsizetype="Minimum" hsizetype="Expanding">
|
|
||||||
</sizepolicy>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QLabel">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Selection template</string>
|
<string>Selection template</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QComboBox" name="opt_column_color_name_1">
|
<widget class="QComboBox" name="opt_column_color_name_1"/>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="TemplateLineEditor" name="opt_column_color_template_1">
|
<widget class="TemplateLineEditor" name="opt_column_color_template_1"/>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QComboBox" name="opt_column_color_name_2">
|
<widget class="QComboBox" name="opt_column_color_name_2"/>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="TemplateLineEditor" name="opt_column_color_template_2">
|
<widget class="TemplateLineEditor" name="opt_column_color_template_2"/>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QComboBox" name="opt_column_color_name_3">
|
<widget class="QComboBox" name="opt_column_color_name_3"/>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="TemplateLineEditor" name="opt_column_color_template_3">
|
<widget class="TemplateLineEditor" name="opt_column_color_template_3"/>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="5" column="0">
|
||||||
<widget class="QComboBox" name="opt_column_color_name_4">
|
<widget class="QComboBox" name="opt_column_color_name_4"/>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="1">
|
<item row="5" column="1">
|
||||||
<widget class="TemplateLineEditor" name="opt_column_color_template_4">
|
<widget class="TemplateLineEditor" name="opt_column_color_template_4"/>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="0">
|
<item row="6" column="0">
|
||||||
<widget class="QComboBox" name="opt_column_color_name_5">
|
<widget class="QComboBox" name="opt_column_color_name_5"/>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="1">
|
<item row="6" column="1">
|
||||||
<widget class="TemplateLineEditor" name="opt_column_color_template_5">
|
<widget class="TemplateLineEditor" name="opt_column_color_template_5"/>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="20" column="0">
|
<item row="20" column="0">
|
||||||
<widget class="QLabel">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Color names</string>
|
<string>Color names</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="21" column="0" colspan="2">
|
<item row="0" column="0" colspan="2">
|
||||||
<widget class="QTextEdit" name="colors_box">
|
<widget class="QScrollArea" name="scrollArea">
|
||||||
<property name="readOnly">
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>200</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="widgetResizable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="alignment">
|
||||||
<sizepolicy vsizetype="Expanding" hsizetype="Expanding">
|
<set>Qt::AlignCenter</set>
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>1</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
</property>
|
||||||
|
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>687</width>
|
||||||
|
<height>194</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="color_help_text">
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="openExternalLinks">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="21" column="0" colspan="2">
|
||||||
|
<widget class="QScrollArea" name="scrollArea_2">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>120</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="widgetResizable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="scrollAreaWidgetContents_2">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>687</width>
|
||||||
|
<height>61</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="colors_box">
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user