From 2f45ed19c33c6cfcd51498cf5cea630ddd04261d Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Sat, 11 May 2013 12:53:10 +0200 Subject: [PATCH] Add a tweak that permits setting a style sheet for the selected cell. --- resources/default_tweaks.py | 19 +++++++++++++++++++ src/calibre/gui2/library/views.py | 3 +++ 2 files changed, 22 insertions(+) diff --git a/resources/default_tweaks.py b/resources/default_tweaks.py index f1b36d3cf8..90fc1d8e2f 100644 --- a/resources/default_tweaks.py +++ b/resources/default_tweaks.py @@ -544,3 +544,22 @@ highlight_virtual_library_book_count = True # for a list of valid color names column_header_highlight_color = 'lightgrey' +#: Control how the currently selected cell is marked. +# You can control how the currently selected cell is marked using something +# very similar to a CSS style sheet. +# This is a very experimental feature. There may be problems using this on some +# platforms or with some setting values. Some system defaults cannot be +# overridded. See +# http://qt-project.org/doc/qt-4.8/stylesheet-reference.html#list-of-properties +# for a list of the CSS properties that are (in theory) supported. +# Example: on windows 7 the following style sheet results in a cell with the +# default background color, black text, and a black border around the cell. +# selected_cell_highlight_css = ('QTableView::item:focus { ' +# 'background:transparent; ' +# 'color:black; ' +# 'border: 1px; ' +# 'border-style: solid; ' +# 'border-color: black; ' +# '}') +# Default (no style): cell_highlight_css = '' +selected_cell_highlight_css = '' diff --git a/src/calibre/gui2/library/views.py b/src/calibre/gui2/library/views.py index 9dbf4df1bd..6c856a48b9 100644 --- a/src/calibre/gui2/library/views.py +++ b/src/calibre/gui2/library/views.py @@ -169,6 +169,9 @@ class BooksView(QTableView): # {{{ self._model.sorting_done.connect(self.sorting_done, type=Qt.QueuedConnection) + if tweaks['selected_cell_highlight_css']: + self.setStyleSheet(tweaks['selected_cell_highlight_css']) + def currentChanged(self, current, previous): self.model().set_current_cell(current) QTableView.currentChanged(self, current, previous)