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