diff --git a/LunaTranslator/LunaTranslator/gui/rangeselect.py b/LunaTranslator/LunaTranslator/gui/rangeselect.py index 8bc238b2..cb49bdce 100644 --- a/LunaTranslator/LunaTranslator/gui/rangeselect.py +++ b/LunaTranslator/LunaTranslator/gui/rangeselect.py @@ -14,6 +14,7 @@ class rangeadjust(Mainw): def traceoffset(self, curr): if self._isTracking: + self.tracepos = QPoint() return _geo = self.geometry() if self.tracepos.isNull(): @@ -64,7 +65,6 @@ class rangeadjust(Mainw): ) def mouseMoveEvent(self, e): - self.tracepos = QPoint() if self._isTracking: self._endPos = e.pos() - self._startPos _geo = self.geometry() diff --git a/LunaTranslator/LunaTranslator/gui/translatorUI.py b/LunaTranslator/LunaTranslator/gui/translatorUI.py index f21b46f1..96eda6cb 100644 --- a/LunaTranslator/LunaTranslator/gui/translatorUI.py +++ b/LunaTranslator/LunaTranslator/gui/translatorUI.py @@ -264,6 +264,9 @@ class QUnFrameWindow(resizableframeless): if not globalconfig["movefollow"]: lastpos = None continue + if self.isdoingsomething(): + lastpos = None + continue try: hwnd = gobject.baseobject.textsource.hwnd if hwnd != tracehwnd: @@ -291,7 +294,7 @@ class QUnFrameWindow(resizableframeless): try: gobject.baseobject.textsource.traceoffset(rect) except: - print_exc() + pass self.move_signal.emit(tracepos - lastpos + rect) def showres(self, kwargs): # name,color,res,onlytrans,iter_context): @@ -782,7 +785,6 @@ class QUnFrameWindow(resizableframeless): self.isletgamefullscreened = False self.fullscreenmanager = None self.fullscreenmethod = None - self._isTracking = False self.showhidestate = False self.autohidestart = False self.processismuteed = False diff --git a/LunaTranslator/LunaTranslator/gui/usefulwidget.py b/LunaTranslator/LunaTranslator/gui/usefulwidget.py index 38c9d124..26419eb6 100644 --- a/LunaTranslator/LunaTranslator/gui/usefulwidget.py +++ b/LunaTranslator/LunaTranslator/gui/usefulwidget.py @@ -626,6 +626,19 @@ class resizableframeless(saveposwindow): self._padding = 5 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): self._move_drag = False self._corner_drag_youxia = False diff --git a/LunaTranslator/LunaTranslator/rendertext/webview.py b/LunaTranslator/LunaTranslator/rendertext/webview.py index 508dd02c..b14ec606 100644 --- a/LunaTranslator/LunaTranslator/rendertext/webview.py +++ b/LunaTranslator/LunaTranslator/rendertext/webview.py @@ -84,6 +84,7 @@ class TextBrowser(QWidget, dataget): @threader def trackingthread(self): pos = gobject.baseobject.translation_ui.pos() + gobject.baseobject.translation_ui._move_drag = True cus = QCursor.pos() while True: keystate = windows.GetKeyState(windows.VK_LBUTTON) @@ -93,6 +94,7 @@ class TextBrowser(QWidget, dataget): pos + QCursor.pos() - cus ) time.sleep(0.01) + gobject.baseobject.translation_ui._move_drag = False def extrahandle(self, orig, hwnd, msg, wp, lp): if wp == windows.WM_LBUTTONDOWN: diff --git a/LunaTranslator/LunaTranslator/transoptimi/vndbnamemap.py b/LunaTranslator/LunaTranslator/transoptimi/vndbnamemap.py index 85c4401c..0ec3d63e 100644 --- a/LunaTranslator/LunaTranslator/transoptimi/vndbnamemap.py +++ b/LunaTranslator/LunaTranslator/transoptimi/vndbnamemap.py @@ -14,7 +14,7 @@ class Process: parent_window, globalconfig["global_namemap2"], "专有名词翻译_直接替换_设置", - ["正则",'转义', "原文", "翻译"], + ["正则", "转义", "原文", "翻译"], ), ) @@ -25,7 +25,7 @@ class Process: parent_window, savehook_new_data[gameuid]["namemap2"], "专有名词翻译_直接替换_-_" + savehook_new_data[gameuid]["title"], - ["正则",'转义', "原文", "翻译"], + ["正则", "转义", "原文", "翻译"], ).setWindowIcon(getExeIcon(uid2gamepath[gameuid], cache=True)) @property @@ -40,24 +40,12 @@ class Process: gameuid = gobject.baseobject.textsource.gameuid return savehook_new_data[gameuid]["namemap2"] 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): namemap = self.usewhich() - 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) + s = parsemayberegexreplace(namemap, s) return s, {}