diff --git a/LunaTranslator/LunaTranslator/gui/usefulwidget.py b/LunaTranslator/LunaTranslator/gui/usefulwidget.py index 4a2f102f..24165a0f 100644 --- a/LunaTranslator/LunaTranslator/gui/usefulwidget.py +++ b/LunaTranslator/LunaTranslator/gui/usefulwidget.py @@ -120,13 +120,26 @@ class saveposwindow(QMainWindow): super().__init__(parent, flags=flags) else: super().__init__(parent) - d = QApplication.primaryScreen() + self.poslist = poslist if self.poslist: - poslist[2] = max(0, min(poslist[2], d.size().width())) - poslist[3] = max(0, min(poslist[3], d.size().height())) - poslist[0] = min(max(poslist[0], 0), d.size().width() - poslist[2]) - poslist[1] = min(max(poslist[1], 0), d.size().height() - poslist[3]) + contains = False + usescreen = QApplication.primaryScreen() + for screen in QApplication.screens(): + if not screen.geometry().contains(QPoint(poslist[0], poslist[1])): + continue + contains = True + usescreen = screen + break + poslist[2] = max(0, min(poslist[2], usescreen.size().width())) + poslist[3] = max(0, min(poslist[3], usescreen.size().height())) + if not contains: + poslist[0] = min( + max(poslist[0], 0), usescreen.size().width() - poslist[2] + ) + poslist[1] = min( + max(poslist[1], 0), usescreen.size().height() - poslist[3] + ) self.setGeometry(*poslist) def __checked_savepos(self): diff --git a/LunaTranslator/LunaTranslator/rendertext/webview.html b/LunaTranslator/LunaTranslator/rendertext/webview.html index bb474d33..947961ef 100644 --- a/LunaTranslator/LunaTranslator/rendertext/webview.html +++ b/LunaTranslator/LunaTranslator/rendertext/webview.html @@ -201,13 +201,13 @@ ele.style.textAlign = "center" let tags = _splittags(tag) tags.forEach(tag => { - let ruby = document.createElement('ruby') + let mayberuby = [] tag.forEach(word => { let eleori = regist_style_imp[style](styleargs, word.orig, { atcenter: true, fontFamily: fmori, fontSize: fsori, bold: boldori, color: color, lineHeight: line_height }) - if (isshow_fenci || isfenciclick) { let div = document.createElement('div') + div.style.display='inline-block' div.id = _simpleuid() let style = document.createElement('style') if (isshow_fenci) @@ -228,9 +228,9 @@ div.appendChild(style) div.appendChild(eleori) - ruby.appendChild(div) + mayberuby.push(div) } else - ruby.appendChild(eleori) + mayberuby.push(div) if (isshowhira) { let rt = document.createElement('rt') @@ -238,10 +238,22 @@ rt.appendChild(regist_style_imp[style](styleargs, word.hira, { atcenter: true, fontFamily: fmkana, fontSize: fskana, bold: boldkana, color: kanacolor, lineHeight: 0 })) } - ruby.appendChild(rt) + mayberuby.push(rt) } }) - ele.appendChild(ruby) + if (isshowhira) { + + let ruby = document.createElement('ruby') + mayberuby.forEach(e => { + ruby.appendChild(e) + }); + ele.appendChild(ruby) + } + else { + mayberuby.forEach(e => { + ele.appendChild(e) + }); + } ele.appendChild(document.createElement('br')) }) safe_calllunaheightchange(document.getElementById(rootdivid).offsetHeight)