mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 16:44:13 +08:00
...
This commit is contained in:
parent
c359e86364
commit
64d113ca8e
@ -1,5 +1,5 @@
|
|||||||
from qtsymbols import *
|
from qtsymbols import *
|
||||||
import windows, winsharedutils
|
import windows, winsharedutils, gobject
|
||||||
from myutils.config import globalconfig
|
from myutils.config import globalconfig
|
||||||
from gui.resizeablemainwindow import Mainw
|
from gui.resizeablemainwindow import Mainw
|
||||||
from gui.dynalang import LAction
|
from gui.dynalang import LAction
|
||||||
@ -15,6 +15,15 @@ class rangeadjust(Mainw):
|
|||||||
self.traceposstart = pos
|
self.traceposstart = pos
|
||||||
|
|
||||||
def traceoffset(self, curr):
|
def traceoffset(self, curr):
|
||||||
|
hwnd = gobject.baseobject.hwnd
|
||||||
|
if not hwnd:
|
||||||
|
self.tracepos = QPoint()
|
||||||
|
return
|
||||||
|
if windows.MonitorFromWindow(hwnd) != windows.MonitorFromWindow(
|
||||||
|
int(self.winId())
|
||||||
|
):
|
||||||
|
self.tracepos = QPoint()
|
||||||
|
return
|
||||||
keystate = windows.GetKeyState(windows.VK_LBUTTON)
|
keystate = windows.GetKeyState(windows.VK_LBUTTON)
|
||||||
if keystate < 0 and windows.GetForegroundWindow() == int(self.winId()):
|
if keystate < 0 and windows.GetForegroundWindow() == int(self.winId()):
|
||||||
self.tracepos = QPoint()
|
self.tracepos = QPoint()
|
||||||
|
@ -290,7 +290,7 @@ class TranslatorWindow(resizableframeless):
|
|||||||
if not rect:
|
if not rect:
|
||||||
lastpos = None
|
lastpos = None
|
||||||
continue
|
continue
|
||||||
rate = hwndratex(hwnd)
|
rate = self.devicePixelRatioF()
|
||||||
rect = QRect(
|
rect = QRect(
|
||||||
int(rect[0] / rate),
|
int(rect[0] / rate),
|
||||||
int(rect[1] / rate),
|
int(rect[1] / rate),
|
||||||
@ -305,7 +305,6 @@ class TranslatorWindow(resizableframeless):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if (rect.topLeft() == QPoint(0, 0)) or (rect.size() != lastpos.size()):
|
if (rect.topLeft() == QPoint(0, 0)) or (rect.size() != lastpos.size()):
|
||||||
lastpos = rect
|
lastpos = rect
|
||||||
continue
|
continue
|
||||||
@ -313,6 +312,9 @@ class TranslatorWindow(resizableframeless):
|
|||||||
gobject.baseobject.textsource.traceoffset(rect.topLeft())
|
gobject.baseobject.textsource.traceoffset(rect.topLeft())
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
if windows.MonitorFromWindow(hwnd) != windows.MonitorFromWindow(self.winid):
|
||||||
|
lastpos = None
|
||||||
|
return
|
||||||
self.move_signal.emit(tracepos - lastpos.topLeft() + rect.topLeft())
|
self.move_signal.emit(tracepos - lastpos.topLeft() + rect.topLeft())
|
||||||
|
|
||||||
def showres(self, kwargs):
|
def showres(self, kwargs):
|
||||||
|
@ -457,14 +457,14 @@ class texthook(basetext):
|
|||||||
else None
|
else None
|
||||||
)
|
)
|
||||||
if self.safeembedcheck(text):
|
if self.safeembedcheck(text):
|
||||||
|
trans = self.waitfortranslation(text, engine)
|
||||||
|
else:
|
||||||
collect = []
|
collect = []
|
||||||
for _ in text.split("\n"):
|
for _ in text.split("\n"):
|
||||||
if _ and self.safeembedcheck(_):
|
if _ and self.safeembedcheck(_):
|
||||||
_ = self.waitfortranslation(_, engine)
|
_ = self.waitfortranslation(_, engine)
|
||||||
collect.append(_)
|
collect.append(_)
|
||||||
trans = "\n".join(collect)
|
trans = "\n".join(collect)
|
||||||
else:
|
|
||||||
trans = self.waitfortranslation(text, engine)
|
|
||||||
if not trans:
|
if not trans:
|
||||||
trans = ""
|
trans = ""
|
||||||
if globalconfig["embedded"]["trans_kanji"]:
|
if globalconfig["embedded"]["trans_kanji"]:
|
||||||
@ -525,7 +525,9 @@ class texthook(basetext):
|
|||||||
self.selectinghook = key
|
self.selectinghook = key
|
||||||
select = True
|
select = True
|
||||||
break
|
break
|
||||||
gobject.baseobject.hookselectdialog.addnewhooksignal.emit(key, select, isembedable)
|
gobject.baseobject.hookselectdialog.addnewhooksignal.emit(
|
||||||
|
key, select, isembedable
|
||||||
|
)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def setsettings(self):
|
def setsettings(self):
|
||||||
|
@ -118,7 +118,10 @@ class basetext:
|
|||||||
"SELECT machineTrans FROM artificialtrans WHERE source = ?",
|
"SELECT machineTrans FROM artificialtrans WHERE source = ?",
|
||||||
(src,),
|
(src,),
|
||||||
).fetchone()
|
).fetchone()
|
||||||
|
try:
|
||||||
ret = json.loads((ret[0]))
|
ret = json.loads((ret[0]))
|
||||||
|
except:
|
||||||
|
ret = {}
|
||||||
ret[clsname] = trans
|
ret[clsname] = trans
|
||||||
ret = json.dumps(ret, ensure_ascii=False)
|
ret = json.dumps(ret, ensure_ascii=False)
|
||||||
self.sqlwrite2.execute(
|
self.sqlwrite2.execute(
|
||||||
|
@ -33,6 +33,7 @@ from ctypes.wintypes import (
|
|||||||
HKEY,
|
HKEY,
|
||||||
LPDWORD,
|
LPDWORD,
|
||||||
LPBYTE,
|
LPBYTE,
|
||||||
|
HMONITOR,
|
||||||
LPCVOID,
|
LPCVOID,
|
||||||
LPWSTR,
|
LPWSTR,
|
||||||
WPARAM,
|
WPARAM,
|
||||||
@ -1020,3 +1021,13 @@ def FormatMessage(code, module=None):
|
|||||||
if length:
|
if length:
|
||||||
LocalFree(mess)
|
LocalFree(mess)
|
||||||
return res.strip()
|
return res.strip()
|
||||||
|
|
||||||
|
|
||||||
|
MONITOR_DEFAULTTONEAREST = 0x00000002
|
||||||
|
_MonitorFromWindow = _user32.MonitorFromWindow
|
||||||
|
_MonitorFromWindow.argtypes = HWND, DWORD
|
||||||
|
_MonitorFromWindow.restype = HMONITOR
|
||||||
|
|
||||||
|
|
||||||
|
def MonitorFromWindow(hwnd, dwFlags=MONITOR_DEFAULTTONEAREST):
|
||||||
|
return _MonitorFromWindow(hwnd, dwFlags)
|
||||||
|
@ -29,7 +29,7 @@ include(generate_product_version)
|
|||||||
|
|
||||||
set(VERSION_MAJOR 5)
|
set(VERSION_MAJOR 5)
|
||||||
set(VERSION_MINOR 45)
|
set(VERSION_MINOR 45)
|
||||||
set(VERSION_PATCH 1)
|
set(VERSION_PATCH 2)
|
||||||
|
|
||||||
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