This commit is contained in:
恍兮惚兮 2024-06-05 13:19:03 +08:00
parent 790408d1c4
commit c25443a0a5
5 changed files with 38 additions and 34 deletions

View File

@ -376,7 +376,7 @@ class MAINUI:
displayreskwargs.update(iter_context=(iter_res_status, classname)) displayreskwargs.update(iter_context=(iter_res_status, classname))
self.translation_ui.displayres.emit(displayreskwargs) self.translation_ui.displayres.emit(displayreskwargs)
if iter_res_status in (0, 2): # 0为普通1为iter2为iter终止3为起始 if iter_res_status in (0, 2): # 0为普通1为iter2为iter终止
try: try:
self.textsource.sqlqueueput((contentraw, classname, res)) self.textsource.sqlqueueput((contentraw, classname, res))
except: except:

View File

@ -173,8 +173,13 @@ class edittrans(QMainWindow):
color=globalconfig["fanyi"]["realtime_edit"]["color"], color=globalconfig["fanyi"]["realtime_edit"]["color"],
res=text, res=text,
onlytrans=False, onlytrans=False,
iter_context=(1, "realtime_edit_directvis_fakeclass"),
) )
gobject.baseobject.translation_ui.displayres.emit(displayreskwargs) gobject.baseobject.translation_ui.displayres.emit(displayreskwargs)
displayreskwargs.update(
dict(iter_context=(2, "realtime_edit_directvis_fakeclass"))
) # 显示到历史翻译
gobject.baseobject.translation_ui.displayres.emit(displayreskwargs)
self.textOutput.clear() self.textOutput.clear()
except: except:
pass pass

View File

@ -162,6 +162,7 @@ class QUnFrameWindow(resizableframeless):
if clear: if clear:
self.translate_text.clear() self.translate_text.clear()
self.saveiterclasspointer.clear()
if text is None: if text is None:
return return
text = self.cleartext(text) text = self.cleartext(text)
@ -177,28 +178,27 @@ class QUnFrameWindow(resizableframeless):
self.translate_text.setAlignment(Qt.AlignmentFlag.AlignLeft) self.translate_text.setAlignment(Qt.AlignmentFlag.AlignLeft)
if iter_context: if iter_context:
iter_res_status, iter_context_class = iter_context _, iter_context_class = iter_context
if iter_res_status == 3:
if iter_context_class not in self.saveiterclasspointer:
self.translate_text.append(" ", hira, origin) self.translate_text.append(" ", hira, origin)
self.saveiterclasspointer[iter_context_class] = { self.saveiterclasspointer[iter_context_class] = {
"currtext": "", "currtext": "",
"curr": self.translate_text.getcurrpointer(), "curr": self.translate_text.getcurrpointer(),
"start": self.translate_text.getcurrpointer(), "start": self.translate_text.getcurrpointer(),
} }
else:
currbefore = self.saveiterclasspointer[iter_context_class]["curr"] currbefore = self.saveiterclasspointer[iter_context_class]["curr"]
currlen = len(self.saveiterclasspointer[iter_context_class]["currtext"]) currlen = len(self.saveiterclasspointer[iter_context_class]["currtext"])
if len(text) < currlen: if len(text) < currlen:
self.translate_text.deletebetween( self.translate_text.deletebetween(
self.saveiterclasspointer[iter_context_class]["start"] self.saveiterclasspointer[iter_context_class]["start"] + len(text),
+ len(text),
self.saveiterclasspointer[iter_context_class]["curr"], self.saveiterclasspointer[iter_context_class]["curr"],
) )
else: else:
newtext = text[currlen:] newtext = text[currlen:]
self.translate_text.insertatpointer( self.translate_text.insertatpointer(
self.saveiterclasspointer[iter_context_class]["start"] self.saveiterclasspointer[iter_context_class]["start"] + currlen,
+ currlen,
newtext, newtext,
) )
@ -604,7 +604,7 @@ class QUnFrameWindow(resizableframeless):
self.displayraw1.connect(self.showraw) self.displayraw1.connect(self.showraw)
self.refreshtooliconsignal.connect(self.refreshtoolicon) self.refreshtooliconsignal.connect(self.refreshtoolicon)
self.showsavegame_signal.connect( self.showsavegame_signal.connect(
lambda: dialog_savedgame_new(gobject.baseobject.settin_ui) lambda: dialog_savedgame_integrated(gobject.baseobject.settin_ui)
) )
self.clickRange_signal.connect(self.clickRange) self.clickRange_signal.connect(self.clickRange)
self.showhide_signal.connect(self.showhideocrrange) self.showhide_signal.connect(self.showhideocrrange)

View File

@ -274,9 +274,7 @@ class basetrans(commonbase):
def _iterget(self, __callback, rid, __res): def _iterget(self, __callback, rid, __res):
succ = True succ = True
for i, _res in enumerate(__res): for _res in __res:
if i == 0:
__callback("", 3)
if self.requestid != rid: if self.requestid != rid:
succ = False succ = False
break break

View File

@ -10,10 +10,11 @@ class TS(basetrans):
except: except:
return None return None
(ret,) = sql.execute( ret = sql.execute(
"SELECT machineTrans FROM artificialtrans WHERE source = ?", (content,) "SELECT machineTrans FROM artificialtrans WHERE source = ?", (content,)
).fetchone() ).fetchone()
if ret is None: if ret is None:
return None return None
(ret,) = ret
ret = json.loads(ret) ret = json.loads(ret)
return ret.get("realtime_edit", None) return ret.get("realtime_edit", None)