mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 16:44:13 +08:00
idx
This commit is contained in:
parent
62112fb75d
commit
0b89b27210
@ -808,7 +808,6 @@ class dialog_setting_game_internal(QWidget):
|
|||||||
)
|
)
|
||||||
return _w
|
return _w
|
||||||
|
|
||||||
|
|
||||||
def doaddtab(self, wfunct, exe, layout):
|
def doaddtab(self, wfunct, exe, layout):
|
||||||
w = wfunct(exe)
|
w = wfunct(exe)
|
||||||
layout.addWidget(w)
|
layout.addWidget(w)
|
||||||
@ -1053,8 +1052,7 @@ class dialog_setting_game_internal(QWidget):
|
|||||||
"",
|
"",
|
||||||
callback=lambda x: noundictconfigdialog1(
|
callback=lambda x: noundictconfigdialog1(
|
||||||
self,
|
self,
|
||||||
savehook_new_data[exepath],
|
savehook_new_data[exepath]["tts_repair_regex"],
|
||||||
"tts_repair_regex",
|
|
||||||
"语音修正",
|
"语音修正",
|
||||||
["正则", "原文", "替换"],
|
["正则", "原文", "替换"],
|
||||||
),
|
),
|
||||||
|
@ -13,7 +13,7 @@ from gui.usefulwidget import (
|
|||||||
getsimplepatheditor,
|
getsimplepatheditor,
|
||||||
FocusSpin,
|
FocusSpin,
|
||||||
FocusDoubleSpin,
|
FocusDoubleSpin,
|
||||||
FocusCombo
|
FocusCombo,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -28,12 +28,12 @@ class noundictconfigdialog1(QDialog):
|
|||||||
self.model.index(row, 0), getsimpleswitch(item, "regex")
|
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)
|
super().__init__(parent, Qt.WindowType.WindowCloseButtonHint)
|
||||||
|
|
||||||
self.setWindowTitle(_TR(title))
|
self.setWindowTitle(_TR(title))
|
||||||
# self.setWindowModality(Qt.ApplicationModal)
|
# self.setWindowModality(Qt.ApplicationModal)
|
||||||
|
self.reflist = reflist
|
||||||
formLayout = QVBoxLayout(self) # 配置layout
|
formLayout = QVBoxLayout(self) # 配置layout
|
||||||
|
|
||||||
self.model = QStandardItemModel()
|
self.model = QStandardItemModel()
|
||||||
@ -48,7 +48,7 @@ class noundictconfigdialog1(QDialog):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.table = table
|
self.table = table
|
||||||
for row, item in enumerate(configdict[configkey]):
|
for row, item in enumerate(reflist):
|
||||||
self.newline(row, item)
|
self.newline(row, item)
|
||||||
|
|
||||||
search = QHBoxLayout()
|
search = QHBoxLayout()
|
||||||
@ -76,22 +76,18 @@ class noundictconfigdialog1(QDialog):
|
|||||||
button = threebuttons()
|
button = threebuttons()
|
||||||
|
|
||||||
def clicked1():
|
def clicked1():
|
||||||
self.configdict[configkey].insert(
|
self.reflist.insert(0, {"key": "", "value": "", "regex": False})
|
||||||
0, {"key": "", "value": "", "regex": False}
|
self.newline(0, self.reflist[0])
|
||||||
)
|
|
||||||
self.newline(0, self.configdict[configkey][0])
|
|
||||||
|
|
||||||
button.btn1clicked.connect(clicked1)
|
button.btn1clicked.connect(clicked1)
|
||||||
|
|
||||||
def clicked2():
|
def clicked2():
|
||||||
self.model.removeRow(table.currentIndex().row())
|
self.model.removeRow(table.currentIndex().row())
|
||||||
self.configdict[configkey].pop(table.currentIndex().row())
|
self.reflist.pop(table.currentIndex().row())
|
||||||
|
|
||||||
button.btn2clicked.connect(clicked2)
|
button.btn2clicked.connect(clicked2)
|
||||||
button.btn3clicked.connect(self.apply)
|
button.btn3clicked.connect(self.apply)
|
||||||
self.button = button
|
self.button = button
|
||||||
self.configdict = configdict
|
|
||||||
self.configkey = configkey
|
|
||||||
formLayout.addWidget(table)
|
formLayout.addWidget(table)
|
||||||
formLayout.addLayout(search)
|
formLayout.addLayout(search)
|
||||||
formLayout.addWidget(button)
|
formLayout.addWidget(button)
|
||||||
@ -100,18 +96,18 @@ class noundictconfigdialog1(QDialog):
|
|||||||
|
|
||||||
def apply(self):
|
def apply(self):
|
||||||
rows = self.model.rowCount()
|
rows = self.model.rowCount()
|
||||||
rowoffset = 0
|
|
||||||
dedump = set()
|
dedump = set()
|
||||||
|
needremoves = []
|
||||||
for row in range(rows):
|
for row in range(rows):
|
||||||
k, v = self.model.item(row, 1).text(), self.model.item(row, 2).text()
|
k, v = self.model.item(row, 1).text(), self.model.item(row, 2).text()
|
||||||
if k == "" or k in dedump:
|
if k == "" or k in dedump:
|
||||||
self.configdict[self.configkey].pop(row - rowoffset)
|
needremoves.append(row)
|
||||||
rowoffset += 1
|
|
||||||
continue
|
continue
|
||||||
self.configdict[self.configkey][row - rowoffset].update(
|
self.reflist[row].update({"key": k, "value": v})
|
||||||
{"key": k, "value": v}
|
|
||||||
)
|
|
||||||
dedump.add(k)
|
dedump.add(k)
|
||||||
|
for row in reversed(needremoves):
|
||||||
|
self.model.removeRow(row)
|
||||||
|
self.reflist.pop(row)
|
||||||
|
|
||||||
def closeEvent(self, a0: QCloseEvent) -> None:
|
def closeEvent(self, a0: QCloseEvent) -> None:
|
||||||
self.button.setFocus()
|
self.button.setFocus()
|
||||||
|
@ -164,8 +164,7 @@ def setTab5lz(self):
|
|||||||
"",
|
"",
|
||||||
callback=lambda x: noundictconfigdialog1(
|
callback=lambda x: noundictconfigdialog1(
|
||||||
self,
|
self,
|
||||||
globalconfig["ttscommon"],
|
globalconfig["ttscommon"]["tts_repair_regex"],
|
||||||
"tts_repair_regex",
|
|
||||||
"语音修正",
|
"语音修正",
|
||||||
["正则", "原文", "替换"],
|
["正则", "原文", "替换"],
|
||||||
),
|
),
|
||||||
|
@ -8,8 +8,7 @@ class Process:
|
|||||||
def get_setting_window(parent_window):
|
def get_setting_window(parent_window):
|
||||||
return noundictconfigdialog1(
|
return noundictconfigdialog1(
|
||||||
parent_window,
|
parent_window,
|
||||||
transerrorfixdictconfig,
|
transerrorfixdictconfig["dict_v2"],
|
||||||
"dict_v2",
|
|
||||||
"翻译结果替换设置",
|
"翻译结果替换设置",
|
||||||
["正则", "翻译", "替换"],
|
["正则", "翻译", "替换"],
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user