Add a tweak that permits setting a style sheet for the selected cell.

This commit is contained in:
Charles Haley 2013-05-11 12:53:10 +02:00
parent 3f98133107
commit 2f45ed19c3
2 changed files with 22 additions and 0 deletions

View File

@ -544,3 +544,22 @@ highlight_virtual_library_book_count = True
# for a list of valid color names # for a list of valid color names
column_header_highlight_color = 'lightgrey' 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 = ''

View File

@ -169,6 +169,9 @@ class BooksView(QTableView): # {{{
self._model.sorting_done.connect(self.sorting_done, self._model.sorting_done.connect(self.sorting_done,
type=Qt.QueuedConnection) type=Qt.QueuedConnection)
if tweaks['selected_cell_highlight_css']:
self.setStyleSheet(tweaks['selected_cell_highlight_css'])
def currentChanged(self, current, previous): def currentChanged(self, current, previous):
self.model().set_current_cell(current) self.model().set_current_cell(current)
QTableView.currentChanged(self, current, previous) QTableView.currentChanged(self, current, previous)