Skip to content

Commit

Permalink
Add a menu to Log View to enable/disable debug options
Browse files Browse the repository at this point in the history
  • Loading branch information
zas committed Apr 7, 2024
1 parent 677f776 commit 4cd52b1
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions picard/ui/logview.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
IntOption,
get_config,
)
from picard.debug_opts import (
debug_opt_set,
debug_opts,
debug_opts_descriptions,
)
from picard.util import (
reconnect,
wildcards_to_regex_pattern,
Expand Down Expand Up @@ -159,6 +164,23 @@ def set_verbosity(self, level):
self.actions[level].setChecked(True)


class DebugOptsMenu(QtWidgets.QMenu):

def __init__(self, parent=None):
super().__init__(parent=parent)

self.actions = {}
for debug_opt, desc in debug_opts_descriptions.items():
action = QtGui.QAction(desc.name, self, checkable=True, checked=debug_opt in debug_opts)
action.setToolTip(_(desc.description))
action.triggered.connect(partial(self.debug_opt_changed, debug_opt))
self.addAction(action)
self.actions[debug_opt] = action

def debug_opt_changed(self, debug_opt, checked):
debug_opt_set(debug_opt, checked)


class LogView(LogViewCommon):

options = [
Expand All @@ -185,6 +207,13 @@ def __init__(self, parent=None):
self.verbosity_menu.verbosity_changed.connect(self._verbosity_changed)
self.verbosity_menu_button.setMenu(self.verbosity_menu)

self.debug_opts_menu_button = QtWidgets.QPushButton(_("Debug Options"))
self.debug_opts_menu_button.setAccessibleName(_("Debug Options"))
self.hbox.addWidget(self.debug_opts_menu_button)

self.debug_opts_menu = DebugOptsMenu()
self.debug_opts_menu_button.setMenu(self.debug_opts_menu)

# highlight input
self.highlight_text = QtWidgets.QLineEdit()
self.highlight_text.setPlaceholderText(_("String to highlight"))
Expand Down

0 comments on commit 4cd52b1

Please sign in to comment.