Skip to content

Commit

Permalink
properly revert foreground color when toggling coloring
Browse files Browse the repository at this point in the history
  • Loading branch information
rkoschmitzky committed Jan 31, 2022
1 parent 1ad6c9b commit f4f0d21
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def __init__(self, parent=None):
self._filter_regex = re.compile(r"{}".format(self.INITIAL_FILTER_REGEX))

self._threadpool = QtCore.QThreadPool()
self._foreground_brush = None
self._filter_regex_compiled = re.compile(self.INITIAL_FILTER_REGEX)
self._colors = {k: QtGui.QColor(*v) for k, v in self.LEVEL_COLORS.items()}
self._setup_ui()
Expand Down Expand Up @@ -381,7 +382,7 @@ def _set_text_color(self, item):
self._colors[self._get_level_name_from_level_value(item.record.levelno)]
)
else:
item.set_foreground_color(QtGui.QColor(0, 0, 0))
item.setForeground(self._foreground_brush)

def _get_level_name_from_level_value(self, value):
""" a helper to retrieve the level name from the associated value """
Expand Down Expand Up @@ -418,6 +419,9 @@ def _add_item():
formatter = self.handler.formatter

item = LogRecordItem(log_record, formatter)
# there is likely a better way to revert back to the initial brush/color of an item
# but for now lets store it before we apply any color change
self._foreground_brush = self._foreground_brush or item.foreground()
self.records_list.addItem(item)
self._set_tooltip(item)
self._filter(item)
Expand Down

0 comments on commit f4f0d21

Please sign in to comment.