mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2025-01-01 10:04:12 +08:00
ed
This commit is contained in:
parent
790408d1c4
commit
c25443a0a5
@ -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为iter,2为iter终止,3为起始
|
if iter_res_status in (0, 2): # 0为普通,1为iter,2为iter终止
|
||||||
try:
|
try:
|
||||||
self.textsource.sqlqueueput((contentraw, classname, res))
|
self.textsource.sqlqueueput((contentraw, classname, res))
|
||||||
except:
|
except:
|
||||||
|
@ -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
|
||||||
|
@ -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,41 +178,40 @@ 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"]
|
|
||||||
currlen = len(self.saveiterclasspointer[iter_context_class]["currtext"])
|
|
||||||
if len(text) < currlen:
|
|
||||||
self.translate_text.deletebetween(
|
|
||||||
self.saveiterclasspointer[iter_context_class]["start"]
|
|
||||||
+ len(text),
|
|
||||||
self.saveiterclasspointer[iter_context_class]["curr"],
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
newtext = text[currlen:]
|
|
||||||
self.translate_text.insertatpointer(
|
|
||||||
self.saveiterclasspointer[iter_context_class]["start"]
|
|
||||||
+ currlen,
|
|
||||||
newtext,
|
|
||||||
)
|
|
||||||
|
|
||||||
self.saveiterclasspointer[iter_context_class]["currtext"] = text
|
currbefore = self.saveiterclasspointer[iter_context_class]["curr"]
|
||||||
currcurrent = self.translate_text.getcurrpointer()
|
currlen = len(self.saveiterclasspointer[iter_context_class]["currtext"])
|
||||||
self.saveiterclasspointer[iter_context_class]["curr"] = currcurrent
|
if len(text) < currlen:
|
||||||
currchange = currcurrent - currbefore
|
self.translate_text.deletebetween(
|
||||||
for klass in self.saveiterclasspointer:
|
self.saveiterclasspointer[iter_context_class]["start"] + len(text),
|
||||||
if klass == iter_context_class:
|
self.saveiterclasspointer[iter_context_class]["curr"],
|
||||||
continue
|
)
|
||||||
if self.saveiterclasspointer[klass]["curr"] > currbefore:
|
else:
|
||||||
self.saveiterclasspointer[klass]["curr"] += currchange
|
newtext = text[currlen:]
|
||||||
self.saveiterclasspointer[klass]["start"] += currchange
|
self.translate_text.insertatpointer(
|
||||||
|
self.saveiterclasspointer[iter_context_class]["start"] + currlen,
|
||||||
|
newtext,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.saveiterclasspointer[iter_context_class]["currtext"] = text
|
||||||
|
currcurrent = self.translate_text.getcurrpointer()
|
||||||
|
self.saveiterclasspointer[iter_context_class]["curr"] = currcurrent
|
||||||
|
currchange = currcurrent - currbefore
|
||||||
|
for klass in self.saveiterclasspointer:
|
||||||
|
if klass == iter_context_class:
|
||||||
|
continue
|
||||||
|
if self.saveiterclasspointer[klass]["curr"] > currbefore:
|
||||||
|
self.saveiterclasspointer[klass]["curr"] += currchange
|
||||||
|
self.saveiterclasspointer[klass]["start"] += currchange
|
||||||
|
|
||||||
self.translate_text.showyinyingtext2(
|
self.translate_text.showyinyingtext2(
|
||||||
color,
|
color,
|
||||||
@ -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)
|
||||||
|
@ -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
|
||||||
|
@ -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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user