mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-27 15:44:12 +08:00
...
This commit is contained in:
parent
f2773e23df
commit
49f04da800
@ -599,6 +599,8 @@ class mshtmlWidget(QWidget):
|
||||
|
||||
def __init__(self, parent=None) -> None:
|
||||
super().__init__(parent)
|
||||
if HTMLBrowser.version() < 10001: # ie10之前,sethtml会乱码
|
||||
self.html_limit = 0
|
||||
self.browser = HTMLBrowser(int(self.winId()))
|
||||
threading.Thread(target=self.__getcurrenturl).start()
|
||||
|
||||
@ -625,7 +627,7 @@ class mshtmlWidget(QWidget):
|
||||
self.browser.set_html(html)
|
||||
|
||||
def parsehtml(self, html):
|
||||
html = """<html><head><meta http-equiv='x-ua-compatible' content='IE=edge' charset="utf-8"></head><body style=" font-family:'{}'">{}</body></html>""".format(
|
||||
html = """<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /></head><body style=" font-family:'{}'">{}</body></html>""".format(
|
||||
QFontDatabase.systemFont(QFontDatabase.GeneralFont).family(), html
|
||||
)
|
||||
return html
|
||||
|
@ -247,7 +247,10 @@ thisapppath = os.path.normpath(os.getcwd())
|
||||
|
||||
if lastapppath is None:
|
||||
lastapppath = thisapppath
|
||||
lastapppath = os.path.normpath(lastapppath)
|
||||
else:
|
||||
lastapppath = os.path.normpath(lastapppath)
|
||||
|
||||
globalconfig["lastapppath"] = thisapppath
|
||||
|
||||
|
||||
def dynamicrelativepath(abspath):
|
||||
@ -316,8 +319,6 @@ def _TRL(kk):
|
||||
|
||||
|
||||
def saveallconfig():
|
||||
globalconfig["lastapppath"] = thisapppath
|
||||
|
||||
def safesave(fname, js):
|
||||
# 有时保存时意外退出,会导致config文件被清空
|
||||
with open(fname + ".tmp", "w", encoding="utf-8") as ff:
|
||||
|
@ -149,13 +149,15 @@ class mecabwrap:
|
||||
surface = POINTER(c_char_p)()
|
||||
feature = POINTER(c_char_p)()
|
||||
num = c_uint()
|
||||
_mecab_parse(
|
||||
succ = _mecab_parse(
|
||||
self.kks,
|
||||
text.encode(codec),
|
||||
pointer(surface),
|
||||
pointer(feature),
|
||||
pointer(num),
|
||||
)
|
||||
if not succ:
|
||||
raise Exception # failed
|
||||
res = []
|
||||
for i in range(num.value):
|
||||
f = feature[i]
|
||||
@ -185,6 +187,8 @@ def clipboard_get():
|
||||
return ""
|
||||
|
||||
|
||||
html_version = utilsdll.html_version
|
||||
html_version.restype = DWORD
|
||||
html_new = utilsdll.html_new
|
||||
html_new.argtypes = (c_void_p,)
|
||||
html_new.restype = c_void_p
|
||||
@ -204,6 +208,10 @@ html_set_html.argtypes = (
|
||||
|
||||
|
||||
class HTMLBrowser:
|
||||
@staticmethod
|
||||
def version():
|
||||
return html_version()
|
||||
|
||||
def __init__(self, parent) -> None:
|
||||
self.html = html_new(parent)
|
||||
|
||||
|
@ -106,6 +106,10 @@ BOOL DoSetBrowserEmulation(DWORD dwValue)
|
||||
|
||||
return bOK;
|
||||
}
|
||||
extern "C" __declspec(dllexport) DWORD html_version()
|
||||
{
|
||||
return getemulation();
|
||||
}
|
||||
extern "C" __declspec(dllexport) void *html_new(HWND parent)
|
||||
{
|
||||
DoSetBrowserEmulation(getemulation());
|
||||
|
Loading…
x
Reference in New Issue
Block a user