mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2025-01-15 00:43:59 +08:00
xp
This commit is contained in:
parent
d42ab9cf77
commit
dbeaefbee3
@ -11,6 +11,7 @@ from myutils.config import (
|
|||||||
getlanguse,
|
getlanguse,
|
||||||
set_font_default,
|
set_font_default,
|
||||||
_TR,
|
_TR,
|
||||||
|
isascii,
|
||||||
)
|
)
|
||||||
from myutils.utils import (
|
from myutils.utils import (
|
||||||
minmaxmoveobservefunc,
|
minmaxmoveobservefunc,
|
||||||
@ -606,8 +607,8 @@ class MAINUI:
|
|||||||
else:
|
else:
|
||||||
if item["condition"] == 1:
|
if item["condition"] == 1:
|
||||||
if (
|
if (
|
||||||
res.isascii()
|
isascii(res)
|
||||||
and item["key"].isascii()
|
and isascii(item["key"])
|
||||||
and (" " not in item["key"])
|
and (" " not in item["key"])
|
||||||
): # 目标可能有空格
|
): # 目标可能有空格
|
||||||
resx = res.split(" ")
|
resx = res.split(" ")
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import math, base64, uuid, gobject
|
import math, base64, uuid, gobject
|
||||||
from cishu.cishubase import DictTree
|
from cishu.cishubase import DictTree
|
||||||
|
from myutils.config import isascii
|
||||||
|
|
||||||
class FlexBuffer:
|
class FlexBuffer:
|
||||||
|
|
||||||
@ -2039,9 +2039,9 @@ class mdict(cishubase):
|
|||||||
t: str = os.path.basename(f)[:-4]
|
t: str = os.path.basename(f)[:-4]
|
||||||
if index._title.strip() != "":
|
if index._title.strip() != "":
|
||||||
t1 = index._title.strip()
|
t1 = index._title.strip()
|
||||||
if (t1.isascii()) and (t.isascii()):
|
if (isascii(t1)) and (isascii(t)):
|
||||||
t = t1
|
t = t1
|
||||||
elif not t1.isascii():
|
elif not isascii(t1):
|
||||||
t = t1
|
t = t1
|
||||||
title = t
|
title = t
|
||||||
return title
|
return title
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
from myutils.utils import getlangsrc
|
|
||||||
import requests
|
import requests
|
||||||
from urllib.parse import quote
|
from urllib.parse import quote
|
||||||
import re, os
|
import re, os
|
||||||
from cishu.cishubase import cishubase
|
from cishu.cishubase import cishubase
|
||||||
from myutils.utils import simplehtmlparser
|
from myutils.utils import get_element_by, simplehtmlparser, getlangsrc
|
||||||
from myutils.utils import get_element_by
|
from myutils.config import isascii
|
||||||
|
|
||||||
|
|
||||||
class youdao(cishubase):
|
class youdao(cishubase):
|
||||||
@ -12,7 +11,7 @@ class youdao(cishubase):
|
|||||||
def search(self, word: str):
|
def search(self, word: str):
|
||||||
lang = getlangsrc()
|
lang = getlangsrc()
|
||||||
if lang == "auto":
|
if lang == "auto":
|
||||||
if word.isascii():
|
if isascii(word):
|
||||||
lang = "en"
|
lang = "en"
|
||||||
else:
|
else:
|
||||||
lang = "ja"
|
lang = "ja"
|
||||||
|
@ -185,7 +185,7 @@ class ImageDelegate(QStyledItemDelegate):
|
|||||||
def initStyleOption(self, opt: QStyleOptionViewItem, index: QModelIndex):
|
def initStyleOption(self, opt: QStyleOptionViewItem, index: QModelIndex):
|
||||||
super().initStyleOption(opt, index)
|
super().initStyleOption(opt, index)
|
||||||
if not index.data(ImageRequestedRole):
|
if not index.data(ImageRequestedRole):
|
||||||
opt.features |= opt.ViewItemFeature.HasDecoration
|
opt.features |= QStyleOptionViewItem.ViewItemFeature.HasDecoration
|
||||||
opt.decorationSize = QSize(100, 100)
|
opt.decorationSize = QSize(100, 100)
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import functools, binascii
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
import qtawesome, windows, winsharedutils, gobject
|
import qtawesome, windows, winsharedutils, gobject
|
||||||
from myutils.config import savehook_new_data, static_data, globalconfig, _TR
|
from myutils.config import savehook_new_data, static_data, globalconfig, _TR, isascii
|
||||||
from myutils.utils import checkchaos, get_time_stamp, dynamiclink, is_ascii_control
|
from myutils.utils import checkchaos, get_time_stamp, dynamiclink, is_ascii_control
|
||||||
from myutils.wrapper import Singleton_close
|
from myutils.wrapper import Singleton_close
|
||||||
from gui.dialog_savedgame import dialog_setting_game
|
from gui.dialog_savedgame import dialog_setting_game
|
||||||
@ -706,7 +706,7 @@ class hookselect(closeashidewindow):
|
|||||||
|
|
||||||
def gethide(self, res: str):
|
def gethide(self, res: str):
|
||||||
if self.checkfilt_notascii.isChecked():
|
if self.checkfilt_notascii.isChecked():
|
||||||
if res.isascii():
|
if isascii(res):
|
||||||
return True
|
return True
|
||||||
if self.checkfilt_notshiftjis.isChecked():
|
if self.checkfilt_notshiftjis.isChecked():
|
||||||
if checkchaos(res):
|
if checkchaos(res):
|
||||||
|
@ -921,19 +921,20 @@ class TranslatorWindow(resizableframeless):
|
|||||||
self.changeshowhidetranssig.connect(self.changeshowhidetrans)
|
self.changeshowhidetranssig.connect(self.changeshowhidetrans)
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
flags = (
|
||||||
|
Qt.WindowType.FramelessWindowHint | Qt.WindowType.WindowMinimizeButtonHint
|
||||||
|
)
|
||||||
|
if globalconfig["keepontop"]:
|
||||||
|
flags |= Qt.WindowType.WindowStaysOnTopHint
|
||||||
super(TranslatorWindow, self).__init__(
|
super(TranslatorWindow, self).__init__(
|
||||||
None,
|
None,
|
||||||
flags=Qt.WindowType.FramelessWindowHint
|
flags=flags,
|
||||||
| Qt.WindowType.WindowMinimizeButtonHint,
|
|
||||||
poslist=globalconfig["transuigeo"],
|
poslist=globalconfig["transuigeo"],
|
||||||
) # 设置为顶级窗口,无边框
|
) # 设置为顶级窗口,无边框
|
||||||
icon = getExeIcon(getcurrexe()) #'./LunaTranslator.exe')# QIcon()
|
icon = getExeIcon(getcurrexe()) #'./LunaTranslator.exe')# QIcon()
|
||||||
# icon.addPixmap(QPixmap('./files/luna.png'), QIcon.Normal, QIcon.On)
|
# icon.addPixmap(QPixmap('./files/luna.png'), QIcon.Normal, QIcon.On)
|
||||||
self.setWindowIcon(icon)
|
self.setWindowIcon(icon)
|
||||||
self.firstshow = True
|
self.firstshow = True
|
||||||
if globalconfig["keepontop"]:
|
|
||||||
self.setWindowFlag(Qt.WindowType.WindowStaysOnTopHint)
|
|
||||||
self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||||
self.setAttribute(Qt.WidgetAttribute.WA_ShowWithoutActivating, True)
|
self.setAttribute(Qt.WidgetAttribute.WA_ShowWithoutActivating, True)
|
||||||
self.setWindowTitle("LunaTranslator")
|
self.setWindowTitle("LunaTranslator")
|
||||||
@ -1193,7 +1194,9 @@ class TranslatorWindow(resizableframeless):
|
|||||||
globalconfig["isshowrawtext"]
|
globalconfig["isshowrawtext"]
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
gobject.baseobject.settin_ui.fenyinsettings.setEnabled(globalconfig["isshowrawtext"])
|
gobject.baseobject.settin_ui.fenyinsettings.setEnabled(
|
||||||
|
globalconfig["isshowrawtext"]
|
||||||
|
)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import winsharedutils
|
import winsharedutils
|
||||||
import os, csv, gobject
|
import os, csv, gobject
|
||||||
from hiraparse.basehira import basehira
|
from hiraparse.basehira import basehira
|
||||||
|
from myutils.config import isascii
|
||||||
|
|
||||||
# # 2.1.2 src schema
|
# # 2.1.2 src schema
|
||||||
# UnidicFeatures17 = namedtuple('UnidicFeatures17',
|
# UnidicFeatures17 = namedtuple('UnidicFeatures17',
|
||||||
@ -109,7 +110,7 @@ class mecab(basehira):
|
|||||||
if "-" in origorig:
|
if "-" in origorig:
|
||||||
try:
|
try:
|
||||||
hira_ = origorig.split("-")[1]
|
hira_ = origorig.split("-")[1]
|
||||||
if hira_.isascii(): # 腰を引いて-->引く-他動詞
|
if isascii(hira): # 腰を引いて-->引く-他動詞
|
||||||
hira = hira_
|
hira = hira_
|
||||||
origorig = origorig.split("-")[0]
|
origorig = origorig.split("-")[0]
|
||||||
except:
|
except:
|
||||||
|
@ -4,6 +4,17 @@ from traceback import print_exc
|
|||||||
from qtsymbols import *
|
from qtsymbols import *
|
||||||
|
|
||||||
|
|
||||||
|
def isascii(s: str):
|
||||||
|
try:
|
||||||
|
return s.isascii()
|
||||||
|
except:
|
||||||
|
try:
|
||||||
|
s.encode("ascii")
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def namemapcast(namemap):
|
def namemapcast(namemap):
|
||||||
bettermap = namemap.copy()
|
bettermap = namemap.copy()
|
||||||
for k, v in namemap.items():
|
for k, v in namemap.items():
|
||||||
@ -576,7 +587,7 @@ def loadlanguage():
|
|||||||
def _TR(k: str):
|
def _TR(k: str):
|
||||||
if not k:
|
if not k:
|
||||||
return ""
|
return ""
|
||||||
if k.isascii():
|
if isascii(k):
|
||||||
return k
|
return k
|
||||||
loadlanguage()
|
loadlanguage()
|
||||||
if "_" in k:
|
if "_" in k:
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
import re
|
import re
|
||||||
from myutils.utils import cinranges
|
from myutils.utils import cinranges
|
||||||
|
from myutils.config import isascii
|
||||||
|
|
||||||
def guess(string: str):
|
def guess(string: str):
|
||||||
if not string:
|
if not string:
|
||||||
return "en"
|
return "en"
|
||||||
if string.isascii():
|
if isascii(string):
|
||||||
return "en"
|
return "en"
|
||||||
checkers = {
|
checkers = {
|
||||||
"ru": lambda c: cinranges(
|
"ru": lambda c: cinranges(
|
||||||
|
@ -275,9 +275,9 @@ _SendMessage = _user32.SendMessageW
|
|||||||
_SendMessage.argtypes = c_int, c_uint, c_void_p, c_void_p
|
_SendMessage.argtypes = c_int, c_uint, c_void_p, c_void_p
|
||||||
_keybd_event = _user32.keybd_event
|
_keybd_event = _user32.keybd_event
|
||||||
_keybd_event.argtypes = c_byte, c_byte, c_uint, c_void_p
|
_keybd_event.argtypes = c_byte, c_byte, c_uint, c_void_p
|
||||||
RegisterWindowMessageW = _user32.RegisterWindowMessageW
|
RegisterWindowMessage = _user32.RegisterWindowMessageW
|
||||||
RegisterWindowMessageW.argtypes = (LPCWSTR,)
|
RegisterWindowMessage.argtypes = (LPCWSTR,)
|
||||||
RegisterWindowMessageW.restype = UINT
|
RegisterWindowMessage.restype = UINT
|
||||||
_GetWindowThreadProcessId = _user32.GetWindowThreadProcessId
|
_GetWindowThreadProcessId = _user32.GetWindowThreadProcessId
|
||||||
_GetWindowThreadProcessId.argtypes = HWND, c_void_p
|
_GetWindowThreadProcessId.argtypes = HWND, c_void_p
|
||||||
GetClipboardOwner = _user32.GetClipboardOwner
|
GetClipboardOwner = _user32.GetClipboardOwner
|
||||||
|
35
py/generate_xp_code.py
Normal file
35
py/generate_xp_code.py
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import os, re
|
||||||
|
|
||||||
|
|
||||||
|
def parsecode(code: str):
|
||||||
|
# PyQt
|
||||||
|
code = code.replace(
|
||||||
|
"QApplication.setAttribute(Qt.ApplicationAttribute.AA_EnableHighDpiScaling)", ""
|
||||||
|
)
|
||||||
|
code = code.replace("QApplication.setHighDpiScaleFactorRoundingPolicy", "print")
|
||||||
|
code = code.replace("Qt.HighDpiScaleFactorRoundingPolicy.PassThrough", "")
|
||||||
|
code = code.replace("self.screen().geometry().height()", "99999")
|
||||||
|
code = code.replace(
|
||||||
|
'"./files/runtime/PyQt5/Qt5/plugins"',
|
||||||
|
r'"C:\Python34\Lib\site-packages\PyQt5\plugins"',
|
||||||
|
)
|
||||||
|
code = code.replace("self.parent().devicePixelRatioF()", "1")
|
||||||
|
code = code.replace("self.devicePixelRatioF()", "1")
|
||||||
|
code = re.sub(
|
||||||
|
r"(Q[a-zA-Z0-9_]+)\.[a-zA-Z0-9_]+\.([a-zA-Z0-9_]+)([ \)\n,:])", r"\1.\2\3", code
|
||||||
|
)
|
||||||
|
# 移除类型注解
|
||||||
|
code = re.sub(r": [a-zA-Z0-9_]+\)", ")", code)
|
||||||
|
code = re.sub(r": [a-zA-Z0-9_]+ = ", " = ", code)
|
||||||
|
return code
|
||||||
|
|
||||||
|
|
||||||
|
for _dir, _, _fs in os.walk("./LunaTranslator"):
|
||||||
|
for _f in _fs:
|
||||||
|
if not _f.endswith(".py"):
|
||||||
|
continue
|
||||||
|
path = os.path.normpath(os.path.abspath(os.path.join(_dir, _f)))
|
||||||
|
with open(path, "r", encoding="utf8") as ff:
|
||||||
|
code = ff.read()
|
||||||
|
with open(path, "w", encoding="utf8") as ff:
|
||||||
|
ff.write(parsecode(code))
|
Loading…
x
Reference in New Issue
Block a user