This commit is contained in:
恍兮惚兮 2024-08-09 18:09:29 +08:00
parent 846253f861
commit e482d179f7
5 changed files with 26 additions and 21 deletions

View File

@ -14,6 +14,7 @@ class rangeadjust(Mainw):
def traceoffset(self, curr): def traceoffset(self, curr):
if self._isTracking: if self._isTracking:
self.tracepos = QPoint()
return return
_geo = self.geometry() _geo = self.geometry()
if self.tracepos.isNull(): if self.tracepos.isNull():
@ -64,7 +65,6 @@ class rangeadjust(Mainw):
) )
def mouseMoveEvent(self, e): def mouseMoveEvent(self, e):
self.tracepos = QPoint()
if self._isTracking: if self._isTracking:
self._endPos = e.pos() - self._startPos self._endPos = e.pos() - self._startPos
_geo = self.geometry() _geo = self.geometry()

View File

@ -264,6 +264,9 @@ class QUnFrameWindow(resizableframeless):
if not globalconfig["movefollow"]: if not globalconfig["movefollow"]:
lastpos = None lastpos = None
continue continue
if self.isdoingsomething():
lastpos = None
continue
try: try:
hwnd = gobject.baseobject.textsource.hwnd hwnd = gobject.baseobject.textsource.hwnd
if hwnd != tracehwnd: if hwnd != tracehwnd:
@ -291,7 +294,7 @@ class QUnFrameWindow(resizableframeless):
try: try:
gobject.baseobject.textsource.traceoffset(rect) gobject.baseobject.textsource.traceoffset(rect)
except: except:
print_exc() pass
self.move_signal.emit(tracepos - lastpos + rect) self.move_signal.emit(tracepos - lastpos + rect)
def showres(self, kwargs): # name,color,res,onlytrans,iter_context): def showres(self, kwargs): # name,color,res,onlytrans,iter_context):
@ -782,7 +785,6 @@ class QUnFrameWindow(resizableframeless):
self.isletgamefullscreened = False self.isletgamefullscreened = False
self.fullscreenmanager = None self.fullscreenmanager = None
self.fullscreenmethod = None self.fullscreenmethod = None
self._isTracking = False
self.showhidestate = False self.showhidestate = False
self.autohidestart = False self.autohidestart = False
self.processismuteed = False self.processismuteed = False

View File

@ -626,6 +626,19 @@ class resizableframeless(saveposwindow):
self._padding = 5 self._padding = 5
self.resetflags() self.resetflags()
def isdoingsomething(self):
return (
self._move_drag
or self._corner_drag_youxia
or self._bottom_drag
or self._top_drag
or self._corner_drag_zuoxia
or self._right_drag
or self._left_drag
or self._corner_drag_zuoshang
or self._corner_drag_youshang
)
def resetflags(self): def resetflags(self):
self._move_drag = False self._move_drag = False
self._corner_drag_youxia = False self._corner_drag_youxia = False

View File

@ -84,6 +84,7 @@ class TextBrowser(QWidget, dataget):
@threader @threader
def trackingthread(self): def trackingthread(self):
pos = gobject.baseobject.translation_ui.pos() pos = gobject.baseobject.translation_ui.pos()
gobject.baseobject.translation_ui._move_drag = True
cus = QCursor.pos() cus = QCursor.pos()
while True: while True:
keystate = windows.GetKeyState(windows.VK_LBUTTON) keystate = windows.GetKeyState(windows.VK_LBUTTON)
@ -93,6 +94,7 @@ class TextBrowser(QWidget, dataget):
pos + QCursor.pos() - cus pos + QCursor.pos() - cus
) )
time.sleep(0.01) time.sleep(0.01)
gobject.baseobject.translation_ui._move_drag = False
def extrahandle(self, orig, hwnd, msg, wp, lp): def extrahandle(self, orig, hwnd, msg, wp, lp):
if wp == windows.WM_LBUTTONDOWN: if wp == windows.WM_LBUTTONDOWN:

View File

@ -14,7 +14,7 @@ class Process:
parent_window, parent_window,
globalconfig["global_namemap2"], globalconfig["global_namemap2"],
"专有名词翻译_直接替换_设置", "专有名词翻译_直接替换_设置",
["正则",'转义', "原文", "翻译"], ["正则", "转义", "原文", "翻译"],
), ),
) )
@ -25,7 +25,7 @@ class Process:
parent_window, parent_window,
savehook_new_data[gameuid]["namemap2"], savehook_new_data[gameuid]["namemap2"],
"专有名词翻译_直接替换_-_" + savehook_new_data[gameuid]["title"], "专有名词翻译_直接替换_-_" + savehook_new_data[gameuid]["title"],
["正则",'转义', "原文", "翻译"], ["正则", "转义", "原文", "翻译"],
).setWindowIcon(getExeIcon(uid2gamepath[gameuid], cache=True)) ).setWindowIcon(getExeIcon(uid2gamepath[gameuid], cache=True))
@property @property
@ -40,24 +40,12 @@ class Process:
gameuid = gobject.baseobject.textsource.gameuid gameuid = gobject.baseobject.textsource.gameuid
return savehook_new_data[gameuid]["namemap2"] return savehook_new_data[gameuid]["namemap2"]
elif which == 3: elif which == 3:
return savehook_new_data[gameuid]["namemap2"] + globalconfig["global_namemap2"] return (
savehook_new_data[gameuid]["namemap2"] + globalconfig["global_namemap2"]
)
def process_before(self, s): def process_before(self, s):
namemap = self.usewhich() namemap = self.usewhich()
s=parsemayberegexreplace(namemap,s) s = parsemayberegexreplace(namemap, s)
bettermap = {}
for k, v in namemap.items():
for sp in ["", " "]:
spja = k.split(sp)
spen = v.split(" ")
if len(spja) == len(spen) and len(spen) > 1:
for i in range(len(spja)):
if len(spja[i]) >= 2:
bettermap[spja[i]] = spen[i]
for k, v in namemap.items():
s = s.replace(k, v)
for k, v in bettermap.items():
s = s.replace(k, v)
return s, {} return s, {}