mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add option to restore alternating row colors to the Tag Browser under Preferences->Look & Feel->Tag Browser
This commit is contained in:
parent
afe5f09583
commit
43edf15118
@ -107,6 +107,7 @@ gprefs.defaults['auto_add_check_for_duplicates'] = False
|
|||||||
gprefs.defaults['blocked_auto_formats'] = []
|
gprefs.defaults['blocked_auto_formats'] = []
|
||||||
gprefs.defaults['auto_add_auto_convert'] = True
|
gprefs.defaults['auto_add_auto_convert'] = True
|
||||||
gprefs.defaults['ui_style'] = 'calibre' if iswindows or isosx else 'system'
|
gprefs.defaults['ui_style'] = 'calibre' if iswindows or isosx else 'system'
|
||||||
|
gprefs.defaults['tag_browser_old_look'] = False
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
NONE = QVariant() #: Null value to return from the data function of item models
|
NONE = QVariant() #: Null value to return from the data function of item models
|
||||||
|
@ -104,6 +104,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
r('ui_style', gprefs, restart_required=True, choices=
|
r('ui_style', gprefs, restart_required=True, choices=
|
||||||
[(_('System default'), 'system'), (_('Calibre style'),
|
[(_('System default'), 'system'), (_('Calibre style'),
|
||||||
'calibre')])
|
'calibre')])
|
||||||
|
r('tag_browser_old_look', gprefs, restart_required=True)
|
||||||
|
|
||||||
r('cover_flow_queue_length', config, restart_required=True)
|
r('cover_flow_queue_length', config, restart_required=True)
|
||||||
|
|
||||||
|
@ -312,6 +312,18 @@ Manage Authors. You can use the values {author} and
|
|||||||
<string>Tag Browser</string>
|
<string>Tag Browser</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" name="gridLayout_10">
|
<layout class="QGridLayout" name="gridLayout_10">
|
||||||
|
<item row="3" column="2" colspan="3">
|
||||||
|
<widget class="MultiCompleteLineEdit" name="opt_categories_using_hierarchy">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>A comma-separated list of categories in which items containing
|
||||||
|
periods are displayed in the tag browser trees. For example, if
|
||||||
|
this box contains 'tags' then tags of the form 'Mystery.English'
|
||||||
|
and 'Mystery.Thriller' will be displayed with English and Thriller
|
||||||
|
both under 'Mystery'. If 'tags' is not in this box,
|
||||||
|
then the tags will be displayed each on their own line.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="0" column="0" colspan="2">
|
<item row="0" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="label_9">
|
<widget class="QLabel" name="label_9">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -354,6 +366,19 @@ up into subcategories. If the partition method is set to disable, this value is
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="5" column="0" colspan="5">
|
||||||
|
<spacer name="verticalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>690</width>
|
||||||
|
<height>252</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
<item row="1" column="2">
|
<item row="1" column="2">
|
||||||
<widget class="QLabel" name="label_8111">
|
<widget class="QLabel" name="label_8111">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -396,27 +421,9 @@ a few top-level elements.</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0" colspan="5">
|
<item row="4" column="0" colspan="5">
|
||||||
<spacer name="verticalSpacer_2">
|
<widget class="QCheckBox" name="opt_tag_browser_old_look">
|
||||||
<property name="orientation">
|
<property name="text">
|
||||||
<enum>Qt::Vertical</enum>
|
<string>Use &alternating row colors in the Tag Browser</string>
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>690</width>
|
|
||||||
<height>252</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="2" colspan="3">
|
|
||||||
<widget class="MultiCompleteLineEdit" name="opt_categories_using_hierarchy">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>A comma-separated list of categories in which items containing
|
|
||||||
periods are displayed in the tag browser trees. For example, if
|
|
||||||
this box contains 'tags' then tags of the form 'Mystery.English'
|
|
||||||
and 'Mystery.Thriller' will be displayed with English and Thriller
|
|
||||||
both under 'Mystery'. If 'tags' is not in this box,
|
|
||||||
then the tags will be displayed each on their own line.</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -22,6 +22,10 @@ from calibre.utils.icu import sort_key
|
|||||||
|
|
||||||
class TagDelegate(QStyledItemDelegate): # {{{
|
class TagDelegate(QStyledItemDelegate): # {{{
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
QStyledItemDelegate.__init__(self, *args, **kwargs)
|
||||||
|
self.old_look = gprefs['tag_browser_old_look']
|
||||||
|
|
||||||
def paint(self, painter, option, index):
|
def paint(self, painter, option, index):
|
||||||
item = index.data(Qt.UserRole).toPyObject()
|
item = index.data(Qt.UserRole).toPyObject()
|
||||||
QStyledItemDelegate.paint(self, painter, option, index)
|
QStyledItemDelegate.paint(self, painter, option, index)
|
||||||
@ -46,7 +50,12 @@ class TagDelegate(QStyledItemDelegate): # {{{
|
|||||||
nr = r.adjusted(0, 0, 0, 0)
|
nr = r.adjusted(0, 0, 0, 0)
|
||||||
nr.setBottom(r.bottom()-int(r.height()*(rating/5.0)))
|
nr.setBottom(r.bottom()-int(r.height()*(rating/5.0)))
|
||||||
painter.setClipRect(nr)
|
painter.setClipRect(nr)
|
||||||
painter.fillRect(r, widget.palette().window())
|
bg = option.palette.window()
|
||||||
|
if self.old_look:
|
||||||
|
bg = (option.palette.alternateBase() if
|
||||||
|
option.features&option.Alternate else
|
||||||
|
option.palette.base())
|
||||||
|
painter.fillRect(r, bg)
|
||||||
style.proxy().drawPrimitive(style.PE_PanelItemViewItem, option,
|
style.proxy().drawPrimitive(style.PE_PanelItemViewItem, option,
|
||||||
painter, widget)
|
painter, widget)
|
||||||
painter.setOpacity(0.3)
|
painter.setOpacity(0.3)
|
||||||
@ -108,13 +117,14 @@ class TagsView(QTreeView): # {{{
|
|||||||
self._model.user_categories_edited.connect(self.user_categories_edited,
|
self._model.user_categories_edited.connect(self.user_categories_edited,
|
||||||
type=Qt.QueuedConnection)
|
type=Qt.QueuedConnection)
|
||||||
self._model.drag_drop_finished.connect(self.drag_drop_finished)
|
self._model.drag_drop_finished.connect(self.drag_drop_finished)
|
||||||
self.setStyleSheet('''
|
stylish_tb = '''
|
||||||
QTreeView {
|
QTreeView {
|
||||||
background-color: palette(window);
|
background-color: palette(window);
|
||||||
color: palette(window-text);
|
color: palette(window-text);
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
|
'''
|
||||||
|
self.setStyleSheet('''
|
||||||
QTreeView::item {
|
QTreeView::item {
|
||||||
border: 1px solid transparent;
|
border: 1px solid transparent;
|
||||||
padding-top:0.9ex;
|
padding-top:0.9ex;
|
||||||
@ -126,7 +136,9 @@ class TagsView(QTreeView): # {{{
|
|||||||
border: 1px solid #bfcde4;
|
border: 1px solid #bfcde4;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
}
|
}
|
||||||
''')
|
''' + ('' if gprefs['tag_browser_old_look'] else stylish_tb))
|
||||||
|
if gprefs['tag_browser_old_look']:
|
||||||
|
self.setAlternatingRowColors(True)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hidden_categories(self):
|
def hidden_categories(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user