mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 08:34:13 +08:00
fix
This commit is contained in:
parent
1930b9895d
commit
7a775c2410
@ -199,10 +199,6 @@ class Textbrowser:
|
|||||||
self.textbrowser.resize(int(_1), int(_2))
|
self.textbrowser.resize(int(_1), int(_2))
|
||||||
self.textbrowserback.resize(int(_1), int(_2))
|
self.textbrowserback.resize(int(_1), int(_2))
|
||||||
|
|
||||||
def clear(self):
|
|
||||||
self.clear()
|
|
||||||
self.blockcount = 0
|
|
||||||
|
|
||||||
def setnextfont(self, origin):
|
def setnextfont(self, origin):
|
||||||
self.textbrowser.moveCursor(QTextCursor.End)
|
self.textbrowser.moveCursor(QTextCursor.End)
|
||||||
self.textbrowserback.moveCursor(QTextCursor.End)
|
self.textbrowserback.moveCursor(QTextCursor.End)
|
||||||
@ -230,25 +226,21 @@ class Textbrowser:
|
|||||||
else:
|
else:
|
||||||
self.align = False
|
self.align = False
|
||||||
|
|
||||||
def showhide(self):
|
def append(self, x, tag, color):
|
||||||
self.textbrowserback.setVisible(globalconfig["zitiyangshi"] != 3)
|
|
||||||
self.textbrowser.setVisible(globalconfig["zitiyangshi"] != 3)
|
|
||||||
QApplication.processEvents()
|
|
||||||
|
|
||||||
def append(self, x, tag, origin):
|
|
||||||
if self.cleared:
|
if self.cleared:
|
||||||
_space = ""
|
_space = ""
|
||||||
self.blockcount = 0
|
self.blockcount = 0
|
||||||
self.b1 = 0
|
b1 = 0
|
||||||
else:
|
else:
|
||||||
_space = "\n"
|
_space = "\n"
|
||||||
self.b1 = self.textbrowser.document().blockCount()
|
b1 = self.textbrowser.document().blockCount()
|
||||||
self.cleared = False
|
self.cleared = False
|
||||||
if self.needdouble:
|
if self.needdouble:
|
||||||
self.textbrowserback.insertPlainText(_space + x)
|
self.textbrowserback.insertPlainText(_space + x)
|
||||||
self.textbrowser.insertPlainText(_space + x)
|
self.textbrowser.insertPlainText(_space + x)
|
||||||
|
|
||||||
self.b2 = self.textbrowser.document().blockCount()
|
b2 = self.textbrowser.document().blockCount()
|
||||||
|
|
||||||
if True: # self.addtaged:
|
if True: # self.addtaged:
|
||||||
if self.addtaged:
|
if self.addtaged:
|
||||||
@ -273,6 +265,9 @@ class Textbrowser:
|
|||||||
|
|
||||||
self.movep(0, self.savey)
|
self.movep(0, self.savey)
|
||||||
|
|
||||||
|
if globalconfig["zitiyangshi"] == 3:
|
||||||
|
self.showyinyingtext(color, b1, b2)
|
||||||
|
|
||||||
def getcurrpointer(self):
|
def getcurrpointer(self):
|
||||||
return self.textcursor.position()
|
return self.textcursor.position()
|
||||||
|
|
||||||
@ -366,17 +361,13 @@ class Textbrowser:
|
|||||||
if label.pos().y() > maxh:
|
if label.pos().y() > maxh:
|
||||||
label.move(label.pos().x(), label.pos().y() + maxnewh - maxh)
|
label.move(label.pos().x(), label.pos().y() + maxnewh - maxh)
|
||||||
|
|
||||||
def showyinyingtext(self, color):
|
def showyinyingtext(self, color, b1, b2):
|
||||||
|
|
||||||
linei = self.yinyingposline
|
linei = self.yinyingposline
|
||||||
|
|
||||||
doc = self.textbrowser.document()
|
doc = self.textbrowser.document()
|
||||||
block = doc.findBlockByNumber(0)
|
block = doc.findBlockByNumber(0)
|
||||||
|
|
||||||
start = self.b1
|
for blocki in range(b1, b2):
|
||||||
end = self.b2
|
|
||||||
|
|
||||||
for blocki in range(start, end):
|
|
||||||
block = doc.findBlockByNumber(blocki)
|
block = doc.findBlockByNumber(blocki)
|
||||||
layout = block.layout()
|
layout = block.layout()
|
||||||
blockstart = block.position()
|
blockstart = block.position()
|
||||||
@ -390,7 +381,7 @@ class Textbrowser:
|
|||||||
self.textcursor.setPosition(blockstart + s)
|
self.textcursor.setPosition(blockstart + s)
|
||||||
self.textbrowser.setTextCursor(self.textcursor)
|
self.textbrowser.setTextCursor(self.textcursor)
|
||||||
tl1 = self.textbrowser.cursorRect(self.textcursor).topLeft()
|
tl1 = self.textbrowser.cursorRect(self.textcursor).topLeft()
|
||||||
# print(tl1)
|
print(tl1)
|
||||||
if (lc + linei) > len(self.yinyinglabels):
|
if (lc + linei) > len(self.yinyinglabels):
|
||||||
_newlabels = [
|
_newlabels = [
|
||||||
QLabel(self.toplabel2)
|
QLabel(self.toplabel2)
|
||||||
|
@ -258,7 +258,6 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
self.saveiterclasspointer[klass]["curr"] += currchange
|
self.saveiterclasspointer[klass]["curr"] += currchange
|
||||||
self.saveiterclasspointer[klass]["start"] += currchange
|
self.saveiterclasspointer[klass]["start"] += currchange
|
||||||
|
|
||||||
self.translate_text.showhide()
|
|
||||||
if globalconfig["zitiyangshi"] == 3:
|
if globalconfig["zitiyangshi"] == 3:
|
||||||
self.translate_text.showyinyingtext2(
|
self.translate_text.showyinyingtext2(
|
||||||
color,
|
color,
|
||||||
@ -269,11 +268,8 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
self.translate_text.append(
|
self.translate_text.append(
|
||||||
text, hira if globalconfig["isshowhira"] else [], origin
|
text, hira if globalconfig["isshowhira"] else [], color
|
||||||
)
|
)
|
||||||
self.translate_text.showhide()
|
|
||||||
if globalconfig["zitiyangshi"] == 3:
|
|
||||||
self.translate_text.showyinyingtext(color)
|
|
||||||
|
|
||||||
if hira:
|
if hira:
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ class TS(basetrans):
|
|||||||
def __init__(self, typename):
|
def __init__(self, typename):
|
||||||
super().__init__(typename)
|
super().__init__(typename)
|
||||||
self.timeout = 30
|
self.timeout = 30
|
||||||
self.api_url = ""
|
|
||||||
self.history = {"ja": [], "zh": []}
|
self.history = {"ja": [], "zh": []}
|
||||||
self.session = requests.Session()
|
self.session = requests.Session()
|
||||||
|
|
||||||
@ -161,8 +160,7 @@ class TS(basetrans):
|
|||||||
def translate(self, query):
|
def translate(self, query):
|
||||||
self.checkempty(["API接口地址"])
|
self.checkempty(["API接口地址"])
|
||||||
self.timeout = self.config["API超时(秒)"]
|
self.timeout = self.config["API超时(秒)"]
|
||||||
if self.api_url == "":
|
self.get_client(self.config["API接口地址"])
|
||||||
self.get_client(self.config["API接口地址"])
|
|
||||||
frequency_penalty = float(self.config["frequency_penalty"])
|
frequency_penalty = float(self.config["frequency_penalty"])
|
||||||
if not bool(
|
if not bool(
|
||||||
self.config["利用上文信息翻译(通常会有一定的效果提升,但会导致变慢)"]
|
self.config["利用上文信息翻译(通常会有一定的效果提升,但会导致变慢)"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user