mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 00:24:13 +08:00
bug fix
This commit is contained in:
parent
ba5abb5c04
commit
21aa04382e
@ -599,7 +599,7 @@ class hookselect(closeashidewindow):
|
|||||||
"embedablehook"
|
"embedablehook"
|
||||||
]:
|
]:
|
||||||
hc, ad, c1, c2 = _
|
hc, ad, c1, c2 = _
|
||||||
if (hc, ad, c1, c2) == (hc, tp.addr, tp.ctx, tp.ctx2):
|
if (hc, 0, c1, c2) == (hc, 0, tp.ctx, tp.ctx2):
|
||||||
save.append(_)
|
save.append(_)
|
||||||
for _ in save:
|
for _ in save:
|
||||||
savehook_new_data[gobject.baseobject.textsource.pname][
|
savehook_new_data[gobject.baseobject.textsource.pname][
|
||||||
|
@ -268,6 +268,38 @@ class basetrans(commonbase):
|
|||||||
return False
|
return False
|
||||||
return globalconfig["fanyi"][self.typename]["manual"]
|
return globalconfig["fanyi"][self.typename]["manual"]
|
||||||
|
|
||||||
|
def _iterget(self, __callback, rid, __res):
|
||||||
|
succ = True
|
||||||
|
for i, _res in enumerate(__res):
|
||||||
|
if i == 0:
|
||||||
|
__callback("", 3)
|
||||||
|
if self.requestid != rid:
|
||||||
|
succ = False
|
||||||
|
break
|
||||||
|
__callback(_res, 1)
|
||||||
|
if succ:
|
||||||
|
__callback("", 2)
|
||||||
|
|
||||||
|
def __callback(self, collectiterres, callback, embedcallback, _, is_iter_res):
|
||||||
|
if self.needzhconv:
|
||||||
|
_ = zhconv.convert(_, "zh-tw")
|
||||||
|
if _ == "\0": # 清除前面的输出
|
||||||
|
collectiterres.clear()
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
collectiterres.append(_)
|
||||||
|
callback("".join(collectiterres), embedcallback, is_iter_res)
|
||||||
|
|
||||||
|
def reinitandtrans(self, contentraw, contentsolved, is_auto_run):
|
||||||
|
if self.needreinit or self.initok == False:
|
||||||
|
self.needreinit = False
|
||||||
|
self.renewsesion()
|
||||||
|
try:
|
||||||
|
self._private_init()
|
||||||
|
except Exception as e:
|
||||||
|
raise Exception("inittranslator failed : " + str(stringfyerror(e)))
|
||||||
|
return self.maybecachetranslate(contentraw, contentsolved, is_auto_run)
|
||||||
|
|
||||||
def _fythread(self):
|
def _fythread(self):
|
||||||
self.needreinit = False
|
self.needreinit = False
|
||||||
while self.using:
|
while self.using:
|
||||||
@ -289,48 +321,23 @@ class basetrans(commonbase):
|
|||||||
)
|
)
|
||||||
if checktutukufunction():
|
if checktutukufunction():
|
||||||
|
|
||||||
def reinitandtrans():
|
|
||||||
if self.needreinit or self.initok == False:
|
|
||||||
self.needreinit = False
|
|
||||||
self.renewsesion()
|
|
||||||
try:
|
|
||||||
self._private_init()
|
|
||||||
except Exception as e:
|
|
||||||
raise Exception(
|
|
||||||
"inittranslator failed : " + str(stringfyerror(e))
|
|
||||||
)
|
|
||||||
return self.maybecachetranslate(
|
|
||||||
contentraw, contentsolved, is_auto_run
|
|
||||||
)
|
|
||||||
|
|
||||||
res = timeoutfunction(
|
res = timeoutfunction(
|
||||||
reinitandtrans, checktutukufunction=checktutukufunction
|
functools.partial(
|
||||||
|
self.reinitandtrans, contentraw, contentsolved, is_auto_run
|
||||||
|
),
|
||||||
|
checktutukufunction=checktutukufunction,
|
||||||
)
|
)
|
||||||
collectiterres = []
|
collectiterres = []
|
||||||
|
|
||||||
def __callback(_, is_iter_res):
|
__callback = functools.partial(
|
||||||
if self.needzhconv:
|
self.__callback, collectiterres, callback, embedcallback
|
||||||
_ = zhconv.convert(_, "zh-tw")
|
)
|
||||||
if _ == "\0": # 清除前面的输出
|
|
||||||
collectiterres.clear()
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
collectiterres.append(_)
|
|
||||||
callback("".join(collectiterres), embedcallback, is_iter_res)
|
|
||||||
|
|
||||||
if isinstance(res, types.GeneratorType):
|
if isinstance(res, types.GeneratorType):
|
||||||
|
|
||||||
def _iterget(rid, __res):
|
|
||||||
for i, _res in enumerate(__res):
|
|
||||||
if i == 0:
|
|
||||||
__callback("", 3)
|
|
||||||
if self.requestid != rid:
|
|
||||||
break
|
|
||||||
__callback(_res, 1)
|
|
||||||
__callback("", 2)
|
|
||||||
|
|
||||||
timeoutfunction(
|
timeoutfunction(
|
||||||
functools.partial(_iterget, self.requestid, res),
|
functools.partial(
|
||||||
|
self._iterget, __callback, self.requestid, res
|
||||||
|
),
|
||||||
checktutukufunction=checktutukufunction,
|
checktutukufunction=checktutukufunction,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version":"v2.45.6",
|
"version":"v2.45.7",
|
||||||
"themes":{
|
"themes":{
|
||||||
"dark":[
|
"dark":[
|
||||||
{"file":"dark1.qss","name":"PyQtDarkTheme"},
|
{"file":"dark1.qss","name":"PyQtDarkTheme"},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user