--- a/eric6/Debugger/VariablesViewer.py Fri May 03 23:01:00 2019 +0200 +++ b/eric6/Debugger/VariablesViewer.py Mon May 13 22:29:15 2019 +0200 @@ -18,7 +18,7 @@ from PyQt5.QtCore import (Qt, QAbstractItemModel, QModelIndex, QRegExp, QCoreApplication, QSortFilterProxyModel, pyqtSignal) -from PyQt5.QtGui import QBrush, QColor, QFontMetrics +from PyQt5.QtGui import QBrush, QFontMetrics from PyQt5.QtWidgets import QTreeView, QAbstractItemView, QToolTip, QMenu from E5Gui.E5Application import e5App @@ -26,6 +26,7 @@ from .Config import ConfigVarTypeDispStrings from DebugClients.Python.DebugConfig import ConfigQtNames, ConfigKnownQtTypes +import Preferences import Utilities SORT_ROLE = Qt.UserRole @@ -652,15 +653,9 @@ elif role == Qt.BackgroundRole: if node in node.parent.changedItems: - color = QColor('#70FF66') - # Set Alpha chanel to get alternating row colors done by Qt - color.setAlpha(40) - return QBrush(color) + return self.__bgColorChanged elif node in node.parent.newItems: - color = QColor('#FFEEAA') - # Set Alpha chanel to get alternating row colors done by Qt - color.setAlpha(40) - return QBrush(color) + return self.__bgColorNew elif role == Qt.ToolTipRole: if column == 0: @@ -831,6 +826,18 @@ pathlist.reverse() return tuple(pathlist) + + def handlePreferencesChanged(self): + """ + Public slot to handle the preferencesChanged signal. + """ + self.__bgColorNew = QBrush(Preferences.getDebugger("BgColorNew")) + self.__bgColorChanged = QBrush( + Preferences.getDebugger("BgColorChanged")) + + idxStart = self.index(0, 0, QModelIndex()) + idxEnd = self.index(0, 2, QModelIndex()) + self.dataChanged.emit(idxStart, idxEnd) class ProxyModel(QSortFilterProxyModel): @@ -889,7 +896,11 @@ This view has two modes for displaying the global and the local variables. + + @signal preferencesChanged() to inform model about new background colours """ + preferencesChanged = pyqtSignal() + def __init__(self, viewer, globalScope, parent=None): """ Constructor @@ -915,6 +926,8 @@ self.proxyModel = ProxyModel() # Variable model implements the underlying data model self.varModel = VariableModel(self, globalScope) + self.preferencesChanged.connect(self.varModel.handlePreferencesChanged) + self.preferencesChanged.emit() # Force initialization of colors self.proxyModel.setSourceModel(self.varModel) self.setModel(self.proxyModel)