diff --git a/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py b/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py index a1beebf4..cccd5d3d 100644 --- a/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py +++ b/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py @@ -808,7 +808,6 @@ class dialog_setting_game_internal(QWidget): ) return _w - def doaddtab(self, wfunct, exe, layout): w = wfunct(exe) layout.addWidget(w) @@ -1053,8 +1052,7 @@ class dialog_setting_game_internal(QWidget): "", callback=lambda x: noundictconfigdialog1( self, - savehook_new_data[exepath], - "tts_repair_regex", + savehook_new_data[exepath]["tts_repair_regex"], "语音修正", ["正则", "原文", "替换"], ), diff --git a/LunaTranslator/LunaTranslator/gui/inputdialog.py b/LunaTranslator/LunaTranslator/gui/inputdialog.py index 3b56997b..26005e5c 100644 --- a/LunaTranslator/LunaTranslator/gui/inputdialog.py +++ b/LunaTranslator/LunaTranslator/gui/inputdialog.py @@ -13,7 +13,7 @@ from gui.usefulwidget import ( getsimplepatheditor, FocusSpin, FocusDoubleSpin, - FocusCombo + FocusCombo, ) @@ -28,12 +28,12 @@ class noundictconfigdialog1(QDialog): self.model.index(row, 0), getsimpleswitch(item, "regex") ) - def __init__(self, parent, configdict, configkey, title, label) -> None: + def __init__(self, parent, reflist, title, label) -> None: super().__init__(parent, Qt.WindowType.WindowCloseButtonHint) self.setWindowTitle(_TR(title)) # self.setWindowModality(Qt.ApplicationModal) - + self.reflist = reflist formLayout = QVBoxLayout(self) # 配置layout self.model = QStandardItemModel() @@ -48,7 +48,7 @@ class noundictconfigdialog1(QDialog): ) self.table = table - for row, item in enumerate(configdict[configkey]): + for row, item in enumerate(reflist): self.newline(row, item) search = QHBoxLayout() @@ -76,22 +76,18 @@ class noundictconfigdialog1(QDialog): button = threebuttons() def clicked1(): - self.configdict[configkey].insert( - 0, {"key": "", "value": "", "regex": False} - ) - self.newline(0, self.configdict[configkey][0]) + self.reflist.insert(0, {"key": "", "value": "", "regex": False}) + self.newline(0, self.reflist[0]) button.btn1clicked.connect(clicked1) def clicked2(): self.model.removeRow(table.currentIndex().row()) - self.configdict[configkey].pop(table.currentIndex().row()) + self.reflist.pop(table.currentIndex().row()) button.btn2clicked.connect(clicked2) button.btn3clicked.connect(self.apply) self.button = button - self.configdict = configdict - self.configkey = configkey formLayout.addWidget(table) formLayout.addLayout(search) formLayout.addWidget(button) @@ -100,18 +96,18 @@ class noundictconfigdialog1(QDialog): def apply(self): rows = self.model.rowCount() - rowoffset = 0 dedump = set() + needremoves = [] for row in range(rows): k, v = self.model.item(row, 1).text(), self.model.item(row, 2).text() if k == "" or k in dedump: - self.configdict[self.configkey].pop(row - rowoffset) - rowoffset += 1 + needremoves.append(row) continue - self.configdict[self.configkey][row - rowoffset].update( - {"key": k, "value": v} - ) + self.reflist[row].update({"key": k, "value": v}) dedump.add(k) + for row in reversed(needremoves): + self.model.removeRow(row) + self.reflist.pop(row) def closeEvent(self, a0: QCloseEvent) -> None: self.button.setFocus() diff --git a/LunaTranslator/LunaTranslator/gui/setting_tts.py b/LunaTranslator/LunaTranslator/gui/setting_tts.py index 841d07ba..f9c068e0 100644 --- a/LunaTranslator/LunaTranslator/gui/setting_tts.py +++ b/LunaTranslator/LunaTranslator/gui/setting_tts.py @@ -164,8 +164,7 @@ def setTab5lz(self): "", callback=lambda x: noundictconfigdialog1( self, - globalconfig["ttscommon"], - "tts_repair_regex", + globalconfig["ttscommon"]["tts_repair_regex"], "语音修正", ["正则", "原文", "替换"], ), diff --git a/LunaTranslator/LunaTranslator/transoptimi/transerrorfix.py b/LunaTranslator/LunaTranslator/transoptimi/transerrorfix.py index 12726485..97d41e94 100644 --- a/LunaTranslator/LunaTranslator/transoptimi/transerrorfix.py +++ b/LunaTranslator/LunaTranslator/transoptimi/transerrorfix.py @@ -8,8 +8,7 @@ class Process: def get_setting_window(parent_window): return noundictconfigdialog1( parent_window, - transerrorfixdictconfig, - "dict_v2", + transerrorfixdictconfig["dict_v2"], "翻译结果替换设置", ["正则", "翻译", "替换"], )