mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 16:44:13 +08:00
repair
This commit is contained in:
parent
0ab032c15a
commit
9e746507d3
@ -2493,6 +2493,7 @@ class mdict(cishubase):
|
|||||||
|
|
||||||
for url in src_matches + href_matches:
|
for url in src_matches + href_matches:
|
||||||
oked = False
|
oked = False
|
||||||
|
iscss = url.lower().endswith(".css")
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
with open(os.path.join(base, url), "rb") as f:
|
with open(os.path.join(base, url), "rb") as f:
|
||||||
@ -2506,7 +2507,8 @@ class mdict(cishubase):
|
|||||||
file_content = index.mdd_lookup(url1)[0]
|
file_content = index.mdd_lookup(url1)[0]
|
||||||
except:
|
except:
|
||||||
func = url.split(r"://")[0]
|
func = url.split(r"://")[0]
|
||||||
|
if func == "entry":
|
||||||
|
continue
|
||||||
url1 = url.split(r"://")[1]
|
url1 = url.split(r"://")[1]
|
||||||
url1 = url1.replace("/", "\\")
|
url1 = url1.replace("/", "\\")
|
||||||
|
|
||||||
@ -2530,16 +2532,20 @@ class mdict(cishubase):
|
|||||||
)
|
)
|
||||||
file_content = None
|
file_content = None
|
||||||
oked = True
|
oked = True
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print(url)
|
print(url)
|
||||||
except:
|
except:
|
||||||
file_content = None
|
file_content = None
|
||||||
if file_content:
|
if file_content:
|
||||||
base64_content = base64.b64encode(file_content).decode("utf-8")
|
base64_content = base64.b64encode(file_content).decode("utf-8")
|
||||||
html_content = html_content.replace(
|
if iscss:
|
||||||
url, f"data:application/octet-stream;base64,{base64_content}"
|
html_content = html_content.replace(
|
||||||
)
|
url, f"data:text/css;base64,{base64_content}"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
html_content = html_content.replace(
|
||||||
|
url, f"data:application/octet-stream;base64,{base64_content}"
|
||||||
|
)
|
||||||
elif not oked:
|
elif not oked:
|
||||||
print(url)
|
print(url)
|
||||||
return html_content
|
return html_content
|
||||||
|
@ -2,13 +2,12 @@ import functools
|
|||||||
from myutils.config import globalconfig, static_data, _TR
|
from myutils.config import globalconfig, static_data, _TR
|
||||||
from myutils.winsyshotkey import SystemHotkey, registerException
|
from myutils.winsyshotkey import SystemHotkey, registerException
|
||||||
from PyQt5.QtGui import QKeySequence
|
from PyQt5.QtGui import QKeySequence
|
||||||
from PyQt5.QtCore import pyqtSignal
|
|
||||||
from PyQt5.QtWidgets import QKeySequenceEdit, QLabel
|
|
||||||
import winsharedutils
|
import winsharedutils
|
||||||
import gobject, windows
|
import gobject, windows
|
||||||
from gui.usefulwidget import getsimpleswitch
|
from PyQt5.QtWidgets import QLabel
|
||||||
|
from gui.usefulwidget import getsimpleswitch, getsimplekeyseq
|
||||||
from myutils.hwnd import grabwindow
|
from myutils.hwnd import grabwindow
|
||||||
from myutils.utils import getimageformat
|
from myutils.utils import getimageformat, parsekeystringtomodvkcode, unsupportkey
|
||||||
|
|
||||||
|
|
||||||
def setTab_quick_direct(self):
|
def setTab_quick_direct(self):
|
||||||
@ -62,21 +61,6 @@ def setTab_quick(self):
|
|||||||
self.tabadd_lazy(self.tab_widget, ("快捷按键"), lambda: setTab_quick_lazy(self))
|
self.tabadd_lazy(self.tab_widget, ("快捷按键"), lambda: setTab_quick_lazy(self))
|
||||||
|
|
||||||
|
|
||||||
class CustomKeySequenceEdit(QKeySequenceEdit):
|
|
||||||
changeedvent = pyqtSignal(str)
|
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
|
||||||
super(CustomKeySequenceEdit, self).__init__(parent)
|
|
||||||
|
|
||||||
def keyPressEvent(self, QKeyEvent):
|
|
||||||
super(CustomKeySequenceEdit, self).keyPressEvent(QKeyEvent)
|
|
||||||
value = self.keySequence()
|
|
||||||
if len(value.toString()):
|
|
||||||
self.clearFocus()
|
|
||||||
self.changeedvent.emit(value.toString().replace("Meta", "Win"))
|
|
||||||
self.setKeySequence(QKeySequence(value))
|
|
||||||
|
|
||||||
|
|
||||||
def setTab_quick_lazy(self):
|
def setTab_quick_lazy(self):
|
||||||
|
|
||||||
grids = [
|
grids = [
|
||||||
@ -93,10 +77,6 @@ def setTab_quick_lazy(self):
|
|||||||
for name in globalconfig["quick_setting"]["all"]:
|
for name in globalconfig["quick_setting"]["all"]:
|
||||||
if name not in self.bindfunctions:
|
if name not in self.bindfunctions:
|
||||||
continue
|
continue
|
||||||
key1 = CustomKeySequenceEdit(
|
|
||||||
QKeySequence(globalconfig["quick_setting"]["all"][name]["keystring"])
|
|
||||||
)
|
|
||||||
key1.changeedvent.connect(functools.partial(__changekeynew, self, name))
|
|
||||||
|
|
||||||
grids.append(
|
grids.append(
|
||||||
[
|
[
|
||||||
@ -106,7 +86,14 @@ def setTab_quick_lazy(self):
|
|||||||
"use",
|
"use",
|
||||||
callback=functools.partial(fanyiselect, self, name),
|
callback=functools.partial(fanyiselect, self, name),
|
||||||
),
|
),
|
||||||
(key1, 2),
|
(
|
||||||
|
getsimplekeyseq(
|
||||||
|
globalconfig["quick_setting"]["all"][name],
|
||||||
|
"keystring",
|
||||||
|
functools.partial(regist_or_not_key, self, name),
|
||||||
|
),
|
||||||
|
2,
|
||||||
|
),
|
||||||
(self.referlabels[name], 4),
|
(self.referlabels[name], 4),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@ -127,40 +114,6 @@ def fanyiselect(self, who, checked):
|
|||||||
regist_or_not_key(self, who)
|
regist_or_not_key(self, who)
|
||||||
|
|
||||||
|
|
||||||
class unsupportkey(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def parsekeystringtomodvkcode(keystring):
|
|
||||||
keys = []
|
|
||||||
mode = 0
|
|
||||||
if keystring[-1] == "+":
|
|
||||||
keys += ["+"]
|
|
||||||
keystring = keystring[:-2]
|
|
||||||
ksl = keystring.split("+")
|
|
||||||
ksl = ksl + keys
|
|
||||||
unsupports = []
|
|
||||||
if ksl[-1].upper() in static_data["vkcode_map"]:
|
|
||||||
vkcode = static_data["vkcode_map"][ksl[-1].upper()]
|
|
||||||
else:
|
|
||||||
unsupports.append(ksl[-1])
|
|
||||||
|
|
||||||
for k in ksl[:-1]:
|
|
||||||
if k.upper() in static_data["mod_map"]:
|
|
||||||
mode = mode | static_data["mod_map"][k.upper()]
|
|
||||||
else:
|
|
||||||
unsupports.append(k)
|
|
||||||
if len(unsupports):
|
|
||||||
raise unsupportkey(unsupports)
|
|
||||||
return mode, vkcode
|
|
||||||
|
|
||||||
|
|
||||||
def __changekeynew(self, name, keystring):
|
|
||||||
globalconfig["quick_setting"]["all"][name]["keystring"] = keystring
|
|
||||||
|
|
||||||
regist_or_not_key(self, name)
|
|
||||||
|
|
||||||
|
|
||||||
def regist_or_not_key(self, name):
|
def regist_or_not_key(self, name):
|
||||||
self.referlabels[name].setText("")
|
self.referlabels[name].setText("")
|
||||||
|
|
||||||
|
@ -17,13 +17,13 @@ from PyQt5.QtWidgets import (
|
|||||||
from myutils.hwnd import grabwindow
|
from myutils.hwnd import grabwindow
|
||||||
|
|
||||||
from urllib.parse import quote
|
from urllib.parse import quote
|
||||||
from PyQt5.QtGui import QPixmap, QImage, QImageWriter
|
from PyQt5.QtGui import QPixmap, QImage
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
import requests, json, time
|
import requests, json, time
|
||||||
from PyQt5.QtCore import pyqtSignal, Qt
|
from PyQt5.QtCore import pyqtSignal, Qt
|
||||||
import qtawesome, functools, os, base64
|
import qtawesome, functools, os, base64
|
||||||
import gobject, uuid, windows
|
import gobject, uuid, windows
|
||||||
from myutils.utils import getimageformat
|
from myutils.utils import getimageformat, parsekeystringtomodvkcode, unsupportkey
|
||||||
from myutils.config import globalconfig, _TR, static_data
|
from myutils.config import globalconfig, _TR, static_data
|
||||||
import myutils.ankiconnect as anki
|
import myutils.ankiconnect as anki
|
||||||
from gui.usefulwidget import (
|
from gui.usefulwidget import (
|
||||||
@ -34,7 +34,7 @@ from gui.usefulwidget import (
|
|||||||
getspinbox,
|
getspinbox,
|
||||||
getlineedit,
|
getlineedit,
|
||||||
getsimpleswitch,
|
getsimpleswitch,
|
||||||
getsimplecombobox,
|
getsimplekeyseq,
|
||||||
getcolorbutton,
|
getcolorbutton,
|
||||||
tabadd_lazy,
|
tabadd_lazy,
|
||||||
)
|
)
|
||||||
@ -296,7 +296,9 @@ class AnkiWindow(QWidget):
|
|||||||
example = self.example.toPlainText()
|
example = self.example.toPlainText()
|
||||||
if globalconfig["ankiconnect"]["boldword"]:
|
if globalconfig["ankiconnect"]["boldword"]:
|
||||||
if self.example.hiras is None:
|
if self.example.hiras is None:
|
||||||
self.example.hiras = gobject.baseobject.translation_ui.parsehira(example)
|
self.example.hiras = gobject.baseobject.translation_ui.parsehira(
|
||||||
|
example
|
||||||
|
)
|
||||||
collect = []
|
collect = []
|
||||||
for hira in self.example.hiras:
|
for hira in self.example.hiras:
|
||||||
if hira["orig"] == word or hira.get("origorig", None) == word:
|
if hira["orig"] == word or hira.get("origorig", None) == word:
|
||||||
@ -400,11 +402,11 @@ class AnkiWindow(QWidget):
|
|||||||
)
|
)
|
||||||
|
|
||||||
layout.addRow(
|
layout.addRow(
|
||||||
_TR("自动TTS_1"),
|
_TR("自动TTS"),
|
||||||
getsimpleswitch(globalconfig["ankiconnect"], "autoruntts"),
|
getsimpleswitch(globalconfig["ankiconnect"], "autoruntts"),
|
||||||
)
|
)
|
||||||
layout.addRow(
|
layout.addRow(
|
||||||
_TR("自动TTS_2"),
|
_TR("自动TTS_例句"),
|
||||||
getsimpleswitch(globalconfig["ankiconnect"], "autoruntts2"),
|
getsimpleswitch(globalconfig["ankiconnect"], "autoruntts2"),
|
||||||
)
|
)
|
||||||
layout.addRow(
|
layout.addRow(
|
||||||
@ -417,23 +419,33 @@ class AnkiWindow(QWidget):
|
|||||||
)
|
)
|
||||||
|
|
||||||
layout.addRow(
|
layout.addRow(
|
||||||
_TR("录音时模拟按键_1"),
|
_TR("录音时模拟按键"),
|
||||||
getsimpleswitch(globalconfig["ankiconnect"]["simulate_key"]["1"], "use"),
|
getboxlayout(
|
||||||
)
|
[
|
||||||
layout.addRow(
|
getsimpleswitch(
|
||||||
_TR("录音时模拟按键_1_VirtualKeyCode"),
|
globalconfig["ankiconnect"]["simulate_key"]["1"], "use"
|
||||||
getspinbox(
|
),
|
||||||
0, 9999, globalconfig["ankiconnect"]["simulate_key"]["1"], "keycode"
|
getsimplekeyseq(
|
||||||
|
globalconfig["ankiconnect"]["simulate_key"]["1"], "keystring"
|
||||||
|
),
|
||||||
|
],
|
||||||
|
margin0=True,
|
||||||
|
makewidget=True,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
layout.addRow(
|
layout.addRow(
|
||||||
_TR("录音时模拟按键_2"),
|
_TR("录音时模拟按键_例句"),
|
||||||
getsimpleswitch(globalconfig["ankiconnect"]["simulate_key"]["2"], "use"),
|
getboxlayout(
|
||||||
)
|
[
|
||||||
layout.addRow(
|
getsimpleswitch(
|
||||||
_TR("录音时模拟按键_2_VirtualKeyCode"),
|
globalconfig["ankiconnect"]["simulate_key"]["2"], "use"
|
||||||
getspinbox(
|
),
|
||||||
0, 9999, globalconfig["ankiconnect"]["simulate_key"]["2"], "keycode"
|
getsimplekeyseq(
|
||||||
|
globalconfig["ankiconnect"]["simulate_key"]["2"], "keystring"
|
||||||
|
),
|
||||||
|
],
|
||||||
|
margin0=True,
|
||||||
|
makewidget=True,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
return wid
|
return wid
|
||||||
@ -444,9 +456,20 @@ class AnkiWindow(QWidget):
|
|||||||
return
|
return
|
||||||
windows.SetForegroundWindow(gobject.baseobject.textsource.hwnd)
|
windows.SetForegroundWindow(gobject.baseobject.textsource.hwnd)
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
key = globalconfig["ankiconnect"]["simulate_key"][i]["keycode"]
|
try:
|
||||||
windows.keybd_event(key, 0, 0, 0)
|
modes, vkcode = parsekeystringtomodvkcode(
|
||||||
windows.keybd_event(key, 0, windows.KEYEVENTF_KEYUP, 0)
|
globalconfig["ankiconnect"]["simulate_key"][i]["keystring"], modes=True
|
||||||
|
)
|
||||||
|
except unsupportkey as e:
|
||||||
|
print("不支持的键")
|
||||||
|
return
|
||||||
|
for mode in modes:
|
||||||
|
windows.keybd_event(mode, 0, 0, 0)
|
||||||
|
windows.keybd_event(vkcode, 0, 0, 0)
|
||||||
|
time.sleep(0.1)
|
||||||
|
windows.keybd_event(vkcode, 0, windows.KEYEVENTF_KEYUP, 0)
|
||||||
|
for mode in modes:
|
||||||
|
windows.keybd_event(mode, 0, windows.KEYEVENTF_KEYUP, 0)
|
||||||
|
|
||||||
def startorendrecord(self, i, target: QLineEdit, idx):
|
def startorendrecord(self, i, target: QLineEdit, idx):
|
||||||
if idx == 1:
|
if idx == 1:
|
||||||
|
@ -1002,6 +1002,8 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
for button in center:
|
for button in center:
|
||||||
button.move(int(leftstart), 0)
|
button.move(int(leftstart), 0)
|
||||||
leftstart += button.width()
|
leftstart += button.width()
|
||||||
|
for button in self.showbuttons:
|
||||||
|
button.show()
|
||||||
|
|
||||||
def callwrap(self, call, _):
|
def callwrap(self, call, _):
|
||||||
try:
|
try:
|
||||||
|
@ -11,7 +11,10 @@ from PyQt5.QtWidgets import (
|
|||||||
QWidget,
|
QWidget,
|
||||||
QLayout,
|
QLayout,
|
||||||
)
|
)
|
||||||
|
from PyQt5.QtCore import pyqtSignal
|
||||||
|
from PyQt5.QtWidgets import QKeySequenceEdit, QLabel
|
||||||
from PyQt5.QtGui import QFontDatabase
|
from PyQt5.QtGui import QFontDatabase
|
||||||
|
from PyQt5.QtGui import QKeySequence
|
||||||
|
|
||||||
from webviewpy import (
|
from webviewpy import (
|
||||||
webview_native_handle_kind_t,
|
webview_native_handle_kind_t,
|
||||||
@ -625,6 +628,32 @@ class mshtmlWidget(QWidget):
|
|||||||
return html
|
return html
|
||||||
|
|
||||||
|
|
||||||
|
class CustomKeySequenceEdit(QKeySequenceEdit):
|
||||||
|
changeedvent = pyqtSignal(str)
|
||||||
|
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
super(CustomKeySequenceEdit, self).__init__(parent)
|
||||||
|
|
||||||
|
def keyPressEvent(self, QKeyEvent):
|
||||||
|
super(CustomKeySequenceEdit, self).keyPressEvent(QKeyEvent)
|
||||||
|
value = self.keySequence()
|
||||||
|
if len(value.toString()):
|
||||||
|
self.clearFocus()
|
||||||
|
self.changeedvent.emit(value.toString().replace("Meta", "Win"))
|
||||||
|
self.setKeySequence(QKeySequence(value))
|
||||||
|
|
||||||
|
|
||||||
|
def getsimplekeyseq(dic, key, callback=None):
|
||||||
|
key1 = CustomKeySequenceEdit(QKeySequence(dic[key]))
|
||||||
|
|
||||||
|
def __(_d, _k, cb, s):
|
||||||
|
_d[_k] = s
|
||||||
|
if cb:
|
||||||
|
cb()
|
||||||
|
|
||||||
|
key1.changeedvent.connect(functools.partial(__, dic, key, callback))
|
||||||
|
return key1
|
||||||
|
|
||||||
class auto_select_webview(QWidget):
|
class auto_select_webview(QWidget):
|
||||||
on_load = pyqtSignal(str)
|
on_load = pyqtSignal(str)
|
||||||
|
|
||||||
|
@ -594,3 +594,35 @@ def loadpostsettingwindowmethod(name):
|
|||||||
return tryprint(Process.get_setting_window)
|
return tryprint(Process.get_setting_window)
|
||||||
except:
|
except:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
class unsupportkey(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def parsekeystringtomodvkcode(keystring, modes=False):
|
||||||
|
keys = []
|
||||||
|
mode = 0
|
||||||
|
_modes = []
|
||||||
|
if keystring[-1] == "+":
|
||||||
|
keys += ["+"]
|
||||||
|
keystring = keystring[:-2]
|
||||||
|
ksl = keystring.split("+")
|
||||||
|
ksl = ksl + keys
|
||||||
|
unsupports = []
|
||||||
|
if ksl[-1].upper() in static_data["vkcode_map"]:
|
||||||
|
vkcode = static_data["vkcode_map"][ksl[-1].upper()]
|
||||||
|
else:
|
||||||
|
unsupports.append(ksl[-1])
|
||||||
|
|
||||||
|
for k in ksl[:-1]:
|
||||||
|
if k.upper() in static_data["mod_map"]:
|
||||||
|
mode = mode | static_data["mod_map"][k.upper()]
|
||||||
|
_modes.append(static_data["mod_map"][k.upper()])
|
||||||
|
else:
|
||||||
|
unsupports.append(k)
|
||||||
|
if len(unsupports):
|
||||||
|
raise unsupportkey(unsupports)
|
||||||
|
if modes:
|
||||||
|
mode = _modes
|
||||||
|
return mode, vkcode
|
||||||
|
@ -187,11 +187,11 @@
|
|||||||
"simulate_key": {
|
"simulate_key": {
|
||||||
"1": {
|
"1": {
|
||||||
"use": false,
|
"use": false,
|
||||||
"keycode": 120
|
"keystring": ""
|
||||||
},
|
},
|
||||||
"2": {
|
"2": {
|
||||||
"use": false,
|
"use": false,
|
||||||
"keycode": 120
|
"keystring": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autocrop": false,
|
"autocrop": false,
|
||||||
|
@ -29,7 +29,7 @@ include(generate_product_version)
|
|||||||
|
|
||||||
set(VERSION_MAJOR 2)
|
set(VERSION_MAJOR 2)
|
||||||
set(VERSION_MINOR 52)
|
set(VERSION_MINOR 52)
|
||||||
set(VERSION_PATCH 7)
|
set(VERSION_PATCH 8)
|
||||||
|
|
||||||
add_library(pch pch.cpp)
|
add_library(pch pch.cpp)
|
||||||
target_precompile_headers(pch PUBLIC pch.h)
|
target_precompile_headers(pch PUBLIC pch.h)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user