mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2025-01-14 08:23:55 +08:00
xp
This commit is contained in:
parent
d42ab9cf77
commit
dbeaefbee3
@ -11,6 +11,7 @@ from myutils.config import (
|
||||
getlanguse,
|
||||
set_font_default,
|
||||
_TR,
|
||||
isascii,
|
||||
)
|
||||
from myutils.utils import (
|
||||
minmaxmoveobservefunc,
|
||||
@ -606,8 +607,8 @@ class MAINUI:
|
||||
else:
|
||||
if item["condition"] == 1:
|
||||
if (
|
||||
res.isascii()
|
||||
and item["key"].isascii()
|
||||
isascii(res)
|
||||
and isascii(item["key"])
|
||||
and (" " not in item["key"])
|
||||
): # 目标可能有空格
|
||||
resx = res.split(" ")
|
||||
|
@ -1,6 +1,6 @@
|
||||
import math, base64, uuid, gobject
|
||||
from cishu.cishubase import DictTree
|
||||
|
||||
from myutils.config import isascii
|
||||
|
||||
class FlexBuffer:
|
||||
|
||||
@ -2039,9 +2039,9 @@ class mdict(cishubase):
|
||||
t: str = os.path.basename(f)[:-4]
|
||||
if index._title.strip() != "":
|
||||
t1 = index._title.strip()
|
||||
if (t1.isascii()) and (t.isascii()):
|
||||
if (isascii(t1)) and (isascii(t)):
|
||||
t = t1
|
||||
elif not t1.isascii():
|
||||
elif not isascii(t1):
|
||||
t = t1
|
||||
title = t
|
||||
return title
|
||||
|
@ -1,10 +1,9 @@
|
||||
from myutils.utils import getlangsrc
|
||||
import requests
|
||||
from urllib.parse import quote
|
||||
import re, os
|
||||
from cishu.cishubase import cishubase
|
||||
from myutils.utils import simplehtmlparser
|
||||
from myutils.utils import get_element_by
|
||||
from myutils.utils import get_element_by, simplehtmlparser, getlangsrc
|
||||
from myutils.config import isascii
|
||||
|
||||
|
||||
class youdao(cishubase):
|
||||
@ -12,7 +11,7 @@ class youdao(cishubase):
|
||||
def search(self, word: str):
|
||||
lang = getlangsrc()
|
||||
if lang == "auto":
|
||||
if word.isascii():
|
||||
if isascii(word):
|
||||
lang = "en"
|
||||
else:
|
||||
lang = "ja"
|
||||
|
@ -185,7 +185,7 @@ class ImageDelegate(QStyledItemDelegate):
|
||||
def initStyleOption(self, opt: QStyleOptionViewItem, index: QModelIndex):
|
||||
super().initStyleOption(opt, index)
|
||||
if not index.data(ImageRequestedRole):
|
||||
opt.features |= opt.ViewItemFeature.HasDecoration
|
||||
opt.features |= QStyleOptionViewItem.ViewItemFeature.HasDecoration
|
||||
opt.decorationSize = QSize(100, 100)
|
||||
|
||||
|
||||
|
@ -3,7 +3,7 @@ import functools, binascii
|
||||
from collections import OrderedDict
|
||||
from traceback import print_exc
|
||||
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.wrapper import Singleton_close
|
||||
from gui.dialog_savedgame import dialog_setting_game
|
||||
@ -706,7 +706,7 @@ class hookselect(closeashidewindow):
|
||||
|
||||
def gethide(self, res: str):
|
||||
if self.checkfilt_notascii.isChecked():
|
||||
if res.isascii():
|
||||
if isascii(res):
|
||||
return True
|
||||
if self.checkfilt_notshiftjis.isChecked():
|
||||
if checkchaos(res):
|
||||
|
@ -921,19 +921,20 @@ class TranslatorWindow(resizableframeless):
|
||||
self.changeshowhidetranssig.connect(self.changeshowhidetrans)
|
||||
|
||||
def __init__(self):
|
||||
|
||||
flags = (
|
||||
Qt.WindowType.FramelessWindowHint | Qt.WindowType.WindowMinimizeButtonHint
|
||||
)
|
||||
if globalconfig["keepontop"]:
|
||||
flags |= Qt.WindowType.WindowStaysOnTopHint
|
||||
super(TranslatorWindow, self).__init__(
|
||||
None,
|
||||
flags=Qt.WindowType.FramelessWindowHint
|
||||
| Qt.WindowType.WindowMinimizeButtonHint,
|
||||
flags=flags,
|
||||
poslist=globalconfig["transuigeo"],
|
||||
) # 设置为顶级窗口,无边框
|
||||
icon = getExeIcon(getcurrexe()) #'./LunaTranslator.exe')# QIcon()
|
||||
# icon.addPixmap(QPixmap('./files/luna.png'), QIcon.Normal, QIcon.On)
|
||||
self.setWindowIcon(icon)
|
||||
self.firstshow = True
|
||||
if globalconfig["keepontop"]:
|
||||
self.setWindowFlag(Qt.WindowType.WindowStaysOnTopHint)
|
||||
self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||
self.setAttribute(Qt.WidgetAttribute.WA_ShowWithoutActivating, True)
|
||||
self.setWindowTitle("LunaTranslator")
|
||||
@ -1193,7 +1194,9 @@ class TranslatorWindow(resizableframeless):
|
||||
globalconfig["isshowrawtext"]
|
||||
)
|
||||
try:
|
||||
gobject.baseobject.settin_ui.fenyinsettings.setEnabled(globalconfig["isshowrawtext"])
|
||||
gobject.baseobject.settin_ui.fenyinsettings.setEnabled(
|
||||
globalconfig["isshowrawtext"]
|
||||
)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
import winsharedutils
|
||||
import os, csv, gobject
|
||||
from hiraparse.basehira import basehira
|
||||
from myutils.config import isascii
|
||||
|
||||
# # 2.1.2 src schema
|
||||
# UnidicFeatures17 = namedtuple('UnidicFeatures17',
|
||||
@ -109,7 +110,7 @@ class mecab(basehira):
|
||||
if "-" in origorig:
|
||||
try:
|
||||
hira_ = origorig.split("-")[1]
|
||||
if hira_.isascii(): # 腰を引いて-->引く-他動詞
|
||||
if isascii(hira): # 腰を引いて-->引く-他動詞
|
||||
hira = hira_
|
||||
origorig = origorig.split("-")[0]
|
||||
except:
|
||||
|
@ -4,6 +4,17 @@ from traceback import print_exc
|
||||
from qtsymbols import *
|
||||
|
||||
|
||||
def isascii(s: str):
|
||||
try:
|
||||
return s.isascii()
|
||||
except:
|
||||
try:
|
||||
s.encode("ascii")
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
||||
|
||||
def namemapcast(namemap):
|
||||
bettermap = namemap.copy()
|
||||
for k, v in namemap.items():
|
||||
@ -576,7 +587,7 @@ def loadlanguage():
|
||||
def _TR(k: str):
|
||||
if not k:
|
||||
return ""
|
||||
if k.isascii():
|
||||
if isascii(k):
|
||||
return k
|
||||
loadlanguage()
|
||||
if "_" in k:
|
||||
|
@ -1,12 +1,12 @@
|
||||
from collections import defaultdict
|
||||
import re
|
||||
from myutils.utils import cinranges
|
||||
|
||||
from myutils.config import isascii
|
||||
|
||||
def guess(string: str):
|
||||
if not string:
|
||||
return "en"
|
||||
if string.isascii():
|
||||
if isascii(string):
|
||||
return "en"
|
||||
checkers = {
|
||||
"ru": lambda c: cinranges(
|
||||
|
@ -275,9 +275,9 @@ _SendMessage = _user32.SendMessageW
|
||||
_SendMessage.argtypes = c_int, c_uint, c_void_p, c_void_p
|
||||
_keybd_event = _user32.keybd_event
|
||||
_keybd_event.argtypes = c_byte, c_byte, c_uint, c_void_p
|
||||
RegisterWindowMessageW = _user32.RegisterWindowMessageW
|
||||
RegisterWindowMessageW.argtypes = (LPCWSTR,)
|
||||
RegisterWindowMessageW.restype = UINT
|
||||
RegisterWindowMessage = _user32.RegisterWindowMessageW
|
||||
RegisterWindowMessage.argtypes = (LPCWSTR,)
|
||||
RegisterWindowMessage.restype = UINT
|
||||
_GetWindowThreadProcessId = _user32.GetWindowThreadProcessId
|
||||
_GetWindowThreadProcessId.argtypes = HWND, c_void_p
|
||||
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