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