Improve dialogue line symbol setting box (#2453)

This commit is contained in:
Veronica Berglyd Olsen
2025-07-06 18:20:13 +02:00
parent dadc7edbd9
commit ec9e478399
3 changed files with 35 additions and 12 deletions
+25 -5
View File
@@ -29,7 +29,7 @@ import logging
from PyQt6.QtCore import Qt, pyqtSignal, pyqtSlot
from PyQt6.QtGui import QAction, QCloseEvent, QKeyEvent, QKeySequence
from PyQt6.QtWidgets import (
QCompleter, QDialogButtonBox, QFileDialog, QHBoxLayout, QLineEdit,
QCompleter, QDialogButtonBox, QFileDialog, QHBoxLayout, QLineEdit, QMenu,
QPushButton, QVBoxLayout, QWidget
)
@@ -639,14 +639,26 @@ class GuiPreferences(NDialog):
)
# Dialogue Line
self.mnLineSymbols = QMenu(self)
for symbol in nwQuotes.ALLOWED:
label = trConst(nwQuotes.SYMBOLS.get(symbol, nwQuotes.DASHES.get(symbol, "None")))
self.mnLineSymbols.addAction(
f"[ {symbol } ] {label}",
lambda symbol=symbol: self._insertDialogLineSymbol(symbol)
)
self.dialogLine = QLineEdit(self)
self.dialogLine.setMaxLength(4)
self.dialogLine.setFixedWidth(boxFixed)
self.dialogLine.setMinimumWidth(100)
self.dialogLine.setAlignment(QtAlignCenter)
self.dialogLine.setText(CONFIG.dialogLine)
self.dialogLine.setText(" ".join(CONFIG.dialogLine))
self.dialogLineButton = NIconToolButton(self, iSz, "add", "green")
self.dialogLineButton.setMenu(self.mnLineSymbols)
self.mainForm.addRow(
self.tr("Dialogue line symbols"), self.dialogLine,
self.tr("Lines starting with any of these symbols are dialogue.")
self.tr("Lines starting with any of these symbols are dialogue."),
button=self.dialogLineButton
)
# Narrator Break
@@ -913,6 +925,14 @@ class GuiPreferences(NDialog):
self.askBeforeBackup.setEnabled(state)
return
@pyqtSlot(str)
def _insertDialogLineSymbol(self, symbol: str) -> None:
"""Insert a symbol in the dialogue line box."""
current = self.dialogLine.text()
values = processDialogSymbols(f"{current} {symbol}")
self.dialogLine.setText(" ".join(values))
return
@pyqtSlot(bool)
def _toggleAutoReplaceMain(self, state: bool) -> None:
"""Toggle switches controlled by the auto replace switch."""