18 lines
5.3 KiB
JSON
18 lines
5.3 KiB
JSON
{
|
|
"sourceFile": "Project Notes/GUI_LOG_CONSOLE_PLAN.md",
|
|
"activeCommit": 0,
|
|
"commits": [
|
|
{
|
|
"activePatchIndex": 0,
|
|
"patches": [
|
|
{
|
|
"date": 1745236923455,
|
|
"content": "Index: \n===================================================================\n--- \n+++ \n"
|
|
}
|
|
],
|
|
"date": 1745236923455,
|
|
"name": "Commit-0",
|
|
"content": "# GUI Log Console Feature Plan\r\n\r\n**Overall Goal:** Add a log console panel to the GUI's editor panel, controlled by a \"View\" menu action. Move the \"Disable Detailed Preview\" control to the same \"View\" menu.\r\n\r\n**Detailed Plan:**\r\n\r\n1. **Create Custom Log Handler:**\r\n * **New File/Location:** Potentially add this to a new `gui/log_handler.py` or keep it within `gui/main_window.py` if simple enough.\r\n * **Implementation:**\r\n * Define a class `QtLogHandler(logging.Handler, QObject)` that inherits from both `logging.Handler` and `QObject` (for signals).\r\n * Add a Qt signal, e.g., `log_record_received = Signal(str)`.\r\n * Override the `emit(self, record)` method:\r\n * Format the log record using `self.format(record)`.\r\n * Emit the `log_record_received` signal with the formatted string.\r\n\r\n2. **Modify `gui/main_window.py`:**\r\n * **Imports:** Add `QMenuBar`, `QMenu`, `QAction` from `PySide6.QtWidgets`. Import the new `QtLogHandler`.\r\n * **UI Elements (`__init__` / `setup_editor_panel_ui`):**\r\n * **Menu Bar:**\r\n * Create `self.menu_bar = self.menuBar()`.\r\n * Create `view_menu = self.menu_bar.addMenu(\"&View\")`.\r\n * **Log Console:**\r\n * Create `self.log_console_output = QTextEdit()`. Set it to read-only (`self.log_console_output.setReadOnly(True)`).\r\n * Create a container widget, e.g., `self.log_console_widget = QWidget()`. Create a layout for it (e.g., `QVBoxLayout`) and add `self.log_console_output` to this layout.\r\n * In `setup_editor_panel_ui`, insert `self.log_console_widget` into the `editor_layout` *before* adding the `list_layout` (the preset list).\r\n * Initially hide the console: `self.log_console_widget.setVisible(False)`.\r\n * **Menu Actions:**\r\n * Create `self.toggle_log_action = QAction(\"Show Log Console\", self, checkable=True)`. Connect `self.toggle_log_action.toggled.connect(self._toggle_log_console_visibility)`. Add it to `view_menu`.\r\n * Create `self.toggle_preview_action = QAction(\"Disable Detailed Preview\", self, checkable=True)`. Connect `self.toggle_preview_action.toggled.connect(self.update_preview)`. Add it to `view_menu`.\r\n * **Remove Old Checkbox:** Delete the lines creating and adding `self.disable_preview_checkbox`.\r\n * **Logging Setup (`__init__`):**\r\n * Instantiate the custom handler: `self.log_handler = QtLogHandler()`.\r\n * Connect its signal: `self.log_handler.log_record_received.connect(self._append_log_message)`.\r\n * Add the handler to the logger: `log.addHandler(self.log_handler)`. Set an appropriate level if needed (e.g., `self.log_handler.setLevel(logging.INFO)`).\r\n * **New Slots:**\r\n * Implement `_toggle_log_console_visibility(self, checked)`: This slot will simply call `self.log_console_widget.setVisible(checked)`.\r\n * Implement `_append_log_message(self, message)`:\r\n * Append the `message` string to `self.log_console_output`.\r\n * Optional: Add logic to limit the number of lines in the text edit to prevent performance issues.\r\n * Optional: Add basic HTML formatting for colors based on log level.\r\n * **Modify `update_preview`:**\r\n * Replace the check for `self.disable_preview_checkbox.isChecked()` with `self.toggle_preview_action.isChecked()`.\r\n * Update the log messages within this method to reflect checking the action state.\r\n\r\n**Mermaid Diagram:**\r\n\r\n```mermaid\r\ngraph TD\r\n subgraph MainWindow\r\n A[Initialization] --> B(Create Menu Bar);\r\n B --> C(Add View Menu);\r\n C --> D(Add 'Show Log Console' Action);\r\n C --> E(Add 'Disable Detailed Preview' Action);\r\n A --> F(Create Log Console QTextEdit);\r\n F --> G(Place Log Console Widget in Layout [Hidden]);\r\n A --> H(Create & Add QtLogHandler);\r\n H --> I(Connect Log Handler Signal to _append_log_message);\r\n\r\n D -- Toggled --> J[_toggle_log_console_visibility];\r\n J --> K(Show/Hide Log Console Widget);\r\n\r\n E -- Toggled --> L[update_preview];\r\n\r\n M[update_preview] --> N{Is 'Disable Preview' Action Checked?};\r\n N -- Yes --> O[Show Simple List View];\r\n N -- No --> P[Start PredictionHandler];\r\n\r\n Q[Any Log Message] -- Emitted by Logger --> H;\r\n I --> R[_append_log_message];\r\n R --> S(Append Message to Log Console QTextEdit);\r\n end\r\n\r\n subgraph QtLogHandler\r\n style QtLogHandler fill:#lightgreen,stroke:#333,stroke-width:2px\r\n T1[emit(record)] --> T2(Format Record);\r\n T2 --> T3(Emit log_record_received Signal);\r\n T3 --> I;\r\n end"
|
|
}
|
|
]
|
|
} |