|
29 | 29 | from PyQt6.QtCore import Qt, pyqtSignal, pyqtSlot |
30 | 30 | from PyQt6.QtGui import QAction, QCloseEvent, QKeyEvent, QKeySequence |
31 | 31 | from PyQt6.QtWidgets import ( |
32 | | - QCompleter, QDialogButtonBox, QFileDialog, QHBoxLayout, QLineEdit, |
| 32 | + QCompleter, QDialogButtonBox, QFileDialog, QHBoxLayout, QLineEdit, QMenu, |
33 | 33 | QPushButton, QVBoxLayout, QWidget |
34 | 34 | ) |
35 | 35 |
|
@@ -639,14 +639,26 @@ def buildForm(self) -> None: |
639 | 639 | ) |
640 | 640 |
|
641 | 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 | + ) |
| 649 | + |
642 | 650 | self.dialogLine = QLineEdit(self) |
643 | | - self.dialogLine.setMaxLength(4) |
644 | | - self.dialogLine.setFixedWidth(boxFixed) |
| 651 | + self.dialogLine.setMinimumWidth(100) |
645 | 652 | self.dialogLine.setAlignment(QtAlignCenter) |
646 | | - 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 | + |
647 | 658 | self.mainForm.addRow( |
648 | 659 | self.tr("Dialogue line symbols"), self.dialogLine, |
649 | | - 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 |
650 | 662 | ) |
651 | 663 |
|
652 | 664 | # Narrator Break |
@@ -913,6 +925,14 @@ def _toggledBackupOnClose(self, state: bool) -> None: |
913 | 925 | self.askBeforeBackup.setEnabled(state) |
914 | 926 | return |
915 | 927 |
|
| 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 | + |
916 | 936 | @pyqtSlot(bool) |
917 | 937 | def _toggleAutoReplaceMain(self, state: bool) -> None: |
918 | 938 | """Toggle switches controlled by the auto replace switch.""" |
|
0 commit comments