from PyQt6.QtWidgets import ( QWidget, QVBoxLayout, QLabel, QPlainTextEdit, ) from PyQt6.QtCore import pyqtSignal from src.gui.theme import Theme from src.gui.components.editor import LyricEditor class ScratchpadWidget(QWidget): content_changed = pyqtSignal(str) def __init__(self, parent=None): super().__init__(parent) self.setMinimumWidth(200) self.setStyleSheet(f"background-color: {Theme.BACKGROUND_SECONDARY}; border-left: 1px solid {Theme.CURRENT_LINE};") layout = QVBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) # Header header = QLabel("Scratchpad") header.setStyleSheet( f"color: {Theme.FOREGROUND}; background-color: {Theme.BACKGROUND_SECONDARY}; padding: 10px; font-weight: bold; border-bottom: 1px solid {Theme.CURRENT_LINE};" ) layout.addWidget(header) # Editor self.editor = LyricEditor() # Or just QPlainTextEdit if we don't need highlighting self.editor.setStyleSheet( f"QPlainTextEdit {{ background-color: {Theme.BACKGROUND_SECONDARY}; color: {Theme.FOREGROUND}; padding: 10px; border: none; }}" ) layout.addWidget(self.editor) self.editor.textChanged.connect(self._on_text_changed) def _on_text_changed(self): self.content_changed.emit(self.editor.toPlainText()) def set_content(self, text: str): self.editor.blockSignals(True) self.editor.setPlainText(text) self.editor.blockSignals(False) def get_content(self) -> str: return self.editor.toPlainText()