make it possible to disable highlighters

This commit is contained in:
2023-01-26 19:31:33 +01:00
parent 8eee09680e
commit 07a6ec69fa
4 changed files with 47 additions and 10 deletions

View File

@@ -133,35 +133,57 @@ class HighlightListItemWidget(QWidget):
super(HighlightListItemWidget, self).__init__()
self.highlight_regex = highlight_regex
self.layout = QGridLayout(self)
self.layout.setColumnStretch(4, 1)
row = 0
self.active = QCheckBox("")
self.active.setChecked(highlight_regex.is_active())
self.active.stateChanged.connect(self._change_active_state)
self.layout.addWidget(self.active, row, 0, 3, 1, alignment=QtCore.Qt.AlignmentFlag.AlignVCenter)
query = QLineEdit(self)
query.setText(highlight_regex.query)
query.textChanged[str].connect(lambda: highlight_regex.set_query(query.text()))
self.layout.addWidget(query, row, 0, 1, 3)
query.setEnabled(highlight_regex.is_active())
self.layout.addWidget(query, row, 1, 1, 4)
row = row + 1
self.layout.addWidget(QLabel(_("Hit Background:")), row, 0)
hit_background_label = QLabel(_("Hit Background:"))
hit_background_label.setEnabled(highlight_regex.is_active())
self.layout.addWidget(hit_background_label, row, 1)
hit_background_color = ColorButton(highlight_regex.hit_background_color)
hit_background_color.setToolTip(_("Hit Background"))
hit_background_color.setEnabled(highlight_regex.is_active())
hit_background_color.color_drop_down.currentIndexChanged.connect(
lambda: highlight_regex.set_hit_background_color(hit_background_color.color))
self.layout.addWidget(hit_background_color, row, 1)
self.layout.addWidget(hit_background_color, row, 2)
ignore_case = QCheckBox(_("Ignore Case"))
ignore_case.setChecked(highlight_regex.ignore_case)
ignore_case.stateChanged.connect(lambda: highlight_regex.set_is_ignore_case(ignore_case.isChecked()))
self.layout.addWidget(ignore_case, row, 2)
ignore_case.setEnabled(highlight_regex.is_active())
self.layout.addWidget(ignore_case, row, 3)
row = row + 1
self.layout.addWidget(QLabel(_("Line Background:")), row, 0)
line_background_label = QLabel(_("Line Background:"))
line_background_label.setEnabled(highlight_regex.is_active())
self.layout.addWidget(line_background_label, row, 1)
line_background_color = ColorButton(highlight_regex.line_background_color)
line_background_color.setToolTip(_("Line Background"))
line_background_color.color_drop_down.currentIndexChanged.connect(
lambda: highlight_regex.set_line_background_color(line_background_color.color))
self.layout.addWidget(line_background_color, row, 1)
line_background_color.setEnabled(highlight_regex.is_active())
self.layout.addWidget(line_background_color, row, 2)
is_regex = QCheckBox(_("Regular Expression"))
is_regex.setChecked(highlight_regex.is_regex)
is_regex.stateChanged.connect(lambda: highlight_regex.set_is_regex(is_regex.isChecked()))
self.layout.addWidget(is_regex, row, 2)
is_regex.setEnabled(highlight_regex.is_active())
self.layout.addWidget(is_regex, row, 3)
def _change_active_state(self):
active = self.active.isChecked()
self.highlight_regex.set_active(active)
for child in self.children():
if child is not self.active:
child.setEnabled(active)