2929from PyQt6 .QtCore import Qt , pyqtSignal , pyqtSlot
3030from PyQt6 .QtGui import QAction , QCloseEvent , QKeyEvent , QKeySequence
3131from PyQt6 .QtWidgets import (
32- QCompleter , QDialogButtonBox , QFileDialog , QHBoxLayout , QLineEdit ,
32+ QCompleter , QDialogButtonBox , QFileDialog , QHBoxLayout , QLineEdit , QMenu ,
3333 QPushButton , QVBoxLayout , QWidget
3434)
3535
@@ -600,6 +600,7 @@ def buildForm(self) -> None:
600600 self .sidebar .addButton (title , section )
601601 self .mainForm .addGroupLabel (title , section )
602602
603+ # Dialogue Quotes
603604 self .dialogStyle = NComboBox (self )
604605 self .dialogStyle .addItem (self .tr ("None" ), 0 )
605606 self .dialogStyle .addItem (self .tr ("Single Quotes" ), 1 )
@@ -611,6 +612,15 @@ def buildForm(self) -> None:
611612 self .tr ("Applies to the selected quote styles." )
612613 )
613614
615+ # Open-Ended Dialogue
616+ self .allowOpenDial = NSwitch (self )
617+ self .allowOpenDial .setChecked (CONFIG .allowOpenDial )
618+ self .mainForm .addRow (
619+ self .tr ("Allow open-ended dialogue" ), self .allowOpenDial ,
620+ self .tr ("Highlight dialogue line with no closing quote." )
621+ )
622+
623+ # Alternative Dialogue
614624 self .altDialogOpen = QLineEdit (self )
615625 self .altDialogOpen .setMaxLength (4 )
616626 self .altDialogOpen .setFixedWidth (boxFixed )
@@ -628,23 +638,30 @@ def buildForm(self) -> None:
628638 self .tr ("Custom highlighting of dialogue text." )
629639 )
630640
631- self .allowOpenDial = NSwitch (self )
632- self .allowOpenDial .setChecked (CONFIG .allowOpenDial )
633- self .mainForm .addRow (
634- self .tr ("Allow open-ended dialogue" ), self .allowOpenDial ,
635- self .tr ("Highlight dialogue line with no closing quote." )
636- )
641+ # Dialogue Line
642+ self .mnLineSymbols = QMenu (self )
643+ for symbol in nwQuotes .ALLOWED :
644+ label = trConst (nwQuotes .SYMBOLS .get (symbol , nwQuotes .DASHES .get (symbol , "None" )))
645+ self .mnLineSymbols .addAction (
646+ f"[ { symbol } ] { label } " ,
647+ lambda symbol = symbol : self ._insertDialogLineSymbol (symbol )
648+ )
637649
638650 self .dialogLine = QLineEdit (self )
639- self .dialogLine .setMaxLength (4 )
640- self .dialogLine .setFixedWidth (boxFixed )
651+ self .dialogLine .setMinimumWidth (100 )
641652 self .dialogLine .setAlignment (QtAlignCenter )
642- self .dialogLine .setText (CONFIG .dialogLine )
653+ self .dialogLine .setText (" " .join (CONFIG .dialogLine ))
654+
655+ self .dialogLineButton = NIconToolButton (self , iSz , "add" , "green" )
656+ self .dialogLineButton .setMenu (self .mnLineSymbols )
657+
643658 self .mainForm .addRow (
644659 self .tr ("Dialogue line symbols" ), self .dialogLine ,
645- self .tr ("Lines starting with any of these symbols are dialogue." )
660+ self .tr ("Lines starting with any of these symbols are dialogue." ),
661+ button = self .dialogLineButton
646662 )
647663
664+ # Narrator Break
648665 self .narratorBreak = NComboBox (self )
649666 self .narratorDialog = NComboBox (self )
650667 for key , value in nwQuotes .DASHES .items ():
@@ -664,13 +681,15 @@ def buildForm(self) -> None:
664681 self .tr ("Alternates dialogue highlighting within any paragraph." )
665682 )
666683
684+ # Emphasis
667685 self .highlightEmph = NSwitch (self )
668686 self .highlightEmph .setChecked (CONFIG .highlightEmph )
669687 self .mainForm .addRow (
670688 self .tr ("Add highlight colour to emphasised text" ), self .highlightEmph ,
671689 self .tr ("Applies to the document editor only." )
672690 )
673691
692+ # Additional Spaces
674693 self .showMultiSpaces = NSwitch (self )
675694 self .showMultiSpaces .setChecked (CONFIG .showMultiSpaces )
676695 self .mainForm .addRow (
@@ -906,6 +925,14 @@ def _toggledBackupOnClose(self, state: bool) -> None:
906925 self .askBeforeBackup .setEnabled (state )
907926 return
908927
928+ @pyqtSlot (str )
929+ def _insertDialogLineSymbol (self , symbol : str ) -> None :
930+ """Insert a symbol in the dialogue line box."""
931+ current = self .dialogLine .text ()
932+ values = processDialogSymbols (f"{ current } { symbol } " )
933+ self .dialogLine .setText (" " .join (values ))
934+ return
935+
909936 @pyqtSlot (bool )
910937 def _toggleAutoReplaceMain (self , state : bool ) -> None :
911938 """Toggle switches controlled by the auto replace switch."""
0 commit comments