mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 16:44:13 +08:00
fix
This commit is contained in:
parent
299b61bd56
commit
b548dbb2f6
@ -30,6 +30,17 @@ class basehira:
|
|||||||
def proxy(self):
|
def proxy(self):
|
||||||
return getproxy(("cishu", self.typename))
|
return getproxy(("cishu", self.typename))
|
||||||
|
|
||||||
|
def splitspace(self, word: str):
|
||||||
|
start = ""
|
||||||
|
end = ""
|
||||||
|
while word.startswith(" "):
|
||||||
|
start += " "
|
||||||
|
word = word[1:]
|
||||||
|
while word.endswith(" "):
|
||||||
|
end += " "
|
||||||
|
word = word[:-1]
|
||||||
|
return start, word, end
|
||||||
|
|
||||||
def parseparse(self, text):
|
def parseparse(self, text):
|
||||||
hira = []
|
hira = []
|
||||||
try:
|
try:
|
||||||
@ -41,6 +52,22 @@ class basehira:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.needinit = True
|
self.needinit = True
|
||||||
raise e
|
raise e
|
||||||
|
__parsekonge = []
|
||||||
|
for word in hira:
|
||||||
|
ori = word["orig"]
|
||||||
|
start, w, end = self.splitspace(ori)
|
||||||
|
if len(start) == 0 and len(end) == 0:
|
||||||
|
__parsekonge.append(word)
|
||||||
|
continue
|
||||||
|
word["orig"] = w
|
||||||
|
word["hira"] = self.splitspace(word["hira"])[1]
|
||||||
|
|
||||||
|
if len(start):
|
||||||
|
__parsekonge.append({"orig": start, "hira": start})
|
||||||
|
__parsekonge.append(word)
|
||||||
|
if len(end):
|
||||||
|
__parsekonge.append({"orig": end, "hira": end})
|
||||||
|
hira = __parsekonge
|
||||||
for _1 in range(len(hira)):
|
for _1 in range(len(hira)):
|
||||||
_ = len(hira) - 1 - _1
|
_ = len(hira) - 1 - _1
|
||||||
if globalconfig["hira_vis_type"] == 0:
|
if globalconfig["hira_vis_type"] == 0:
|
||||||
|
@ -413,7 +413,7 @@ class TextBrowser(QWidget, dataget):
|
|||||||
tl3 = self.textbrowser.cursorRect(self.textcursor).topLeft()
|
tl3 = self.textbrowser.cursorRect(self.textcursor).topLeft()
|
||||||
color = self._randomcolor(word)
|
color = self._randomcolor(word)
|
||||||
if color:
|
if color:
|
||||||
if word["orig"] not in ["\n", " ", ""]:
|
if len(word["orig"].strip()):
|
||||||
if labeli >= len(self.searchmasklabels) - 1:
|
if labeli >= len(self.searchmasklabels) - 1:
|
||||||
ql = QLabel(self.atback2)
|
ql = QLabel(self.atback2)
|
||||||
ql.setMouseTracking(True)
|
ql.setMouseTracking(True)
|
||||||
|
@ -113,13 +113,14 @@
|
|||||||
}
|
}
|
||||||
#${_id} .nostroken {
|
#${_id} .nostroken {
|
||||||
color: ${c2};
|
color: ${c2};
|
||||||
|
z-index: 2;
|
||||||
}`
|
}`
|
||||||
for (let i = 0; i < 1 + styleargs.trace * 10; i++) {
|
for (let i = 0; i < 1 + styleargs.trace * 10; i++) {
|
||||||
style.innerHTML += `#${_id} .stroken${i}{
|
style.innerHTML += `#${_id} .stroken${i}{
|
||||||
color: ${c1};
|
color: ${c1};
|
||||||
-webkit-text-stroke: ${args.fontSize * styleargs.width_rate + styleargs.width}px ${c1};
|
-webkit-text-stroke: ${args.fontSize * styleargs.width_rate + styleargs.width}px ${c1};
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: -1;
|
z-index: 1;
|
||||||
left: ${(i + 1) / 10}px;
|
left: ${(i + 1) / 10}px;
|
||||||
top: ${(i + 1) / 10}px;
|
top: ${(i + 1) / 10}px;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
@ -179,6 +180,7 @@
|
|||||||
commoninit_font_align_height(__1, args)
|
commoninit_font_align_height(__1, args)
|
||||||
wrap.appendChild(__1)
|
wrap.appendChild(__1)
|
||||||
}
|
}
|
||||||
|
|
||||||
return wrap
|
return wrap
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@ -245,7 +247,15 @@
|
|||||||
let mayberuby = []
|
let mayberuby = []
|
||||||
tag.forEach(word => {
|
tag.forEach(word => {
|
||||||
let eleori = dispatch_text_style(style, styleargs, word.orig, { atcenter: true, fontFamily: fmori, fontSize: fsori, bold: boldori, color: color, lineHeight: line_height })
|
let eleori = dispatch_text_style(style, styleargs, word.orig, { atcenter: true, fontFamily: fmori, fontSize: fsori, bold: boldori, color: color, lineHeight: line_height })
|
||||||
|
if (word.orig.trim().length == 0) {
|
||||||
|
if (isshowhira) {
|
||||||
|
let rt = document.createElement('rt')
|
||||||
|
rt.appendChild(eleori)
|
||||||
|
eleori = rt
|
||||||
|
}
|
||||||
|
mayberuby.push(eleori)
|
||||||
|
return
|
||||||
|
}
|
||||||
if (isshow_fenci || isfenciclick) {
|
if (isshow_fenci || isfenciclick) {
|
||||||
let div = document.createElement('div')
|
let div = document.createElement('div')
|
||||||
div.style.display = 'inline-block'
|
div.style.display = 'inline-block'
|
||||||
@ -255,6 +265,7 @@
|
|||||||
style.innerHTML += `#${div.id} {
|
style.innerHTML += `#${div.id} {
|
||||||
background-color: ${word.color};
|
background-color: ${word.color};
|
||||||
}`
|
}`
|
||||||
|
console.log(`${word.color}`)
|
||||||
if (isfenciclick) {
|
if (isfenciclick) {
|
||||||
div.setAttribute('word', JSON.stringify(word))
|
div.setAttribute('word', JSON.stringify(word))
|
||||||
div.addEventListener('click', function (e) {
|
div.addEventListener('click', function (e) {
|
||||||
@ -271,7 +282,7 @@
|
|||||||
|
|
||||||
mayberuby.push(div)
|
mayberuby.push(div)
|
||||||
} else
|
} else
|
||||||
mayberuby.push(div)
|
mayberuby.push(eleori)
|
||||||
if (isshowhira) {
|
if (isshowhira) {
|
||||||
let rt = document.createElement('rt')
|
let rt = document.createElement('rt')
|
||||||
|
|
||||||
@ -289,13 +300,13 @@
|
|||||||
ruby.appendChild(e)
|
ruby.appendChild(e)
|
||||||
});
|
});
|
||||||
ele.appendChild(ruby)
|
ele.appendChild(ruby)
|
||||||
|
ele.appendChild(document.createElement('br'))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mayberuby.forEach(e => {
|
mayberuby.forEach(e => {
|
||||||
ele.appendChild(e)
|
ele.appendChild(e)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
ele.appendChild(document.createElement('br'))
|
|
||||||
})
|
})
|
||||||
safe_calllunaheightchange(document.getElementById(rootdivid).offsetHeight)
|
safe_calllunaheightchange(document.getElementById(rootdivid).offsetHeight)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user