mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-28 08:04:13 +08:00
fix
This commit is contained in:
parent
99d32ad415
commit
b97b97eee0
@ -594,9 +594,8 @@ class MAINUI:
|
|||||||
self.translation_ui.showhidestate = False
|
self.translation_ui.showhidestate = False
|
||||||
self.translation_ui.refreshtooliconsignal.emit()
|
self.translation_ui.refreshtooliconsignal.emit()
|
||||||
|
|
||||||
for button in self.translation_ui.showbuttons:
|
|
||||||
button.show()
|
|
||||||
self.translation_ui.set_color_transparency()
|
self.translation_ui.set_color_transparency()
|
||||||
|
self.translation_ui.adjustbuttons()
|
||||||
try:
|
try:
|
||||||
self.settin_ui.selectbutton.setEnabled(
|
self.settin_ui.selectbutton.setEnabled(
|
||||||
globalconfig["sourcestatus2"]["texthook"]["use"]
|
globalconfig["sourcestatus2"]["texthook"]["use"]
|
||||||
@ -1069,7 +1068,9 @@ class MAINUI:
|
|||||||
except:
|
except:
|
||||||
return
|
return
|
||||||
if widget == self.translation_ui:
|
if widget == self.translation_ui:
|
||||||
winsharedutils.showintab_ex(int(widget.winId()), globalconfig["showintab"])
|
winsharedutils.showintab(
|
||||||
|
int(widget.winId()), globalconfig["showintab"], True
|
||||||
|
)
|
||||||
return
|
return
|
||||||
window_flags = widget.windowFlags()
|
window_flags = widget.windowFlags()
|
||||||
if (
|
if (
|
||||||
@ -1086,7 +1087,9 @@ class MAINUI:
|
|||||||
):
|
):
|
||||||
# combobox的下拉框,然后这个widget会迅速销毁,会导致任务栏闪一下。没别的办法了姑且这样过滤一下
|
# combobox的下拉框,然后这个widget会迅速销毁,会导致任务栏闪一下。没别的办法了姑且这样过滤一下
|
||||||
return
|
return
|
||||||
winsharedutils.showintab(int(widget.winId()), globalconfig["showintab_sub"])
|
winsharedutils.showintab(
|
||||||
|
int(widget.winId()), globalconfig["showintab_sub"], False
|
||||||
|
)
|
||||||
|
|
||||||
def inittray(self):
|
def inittray(self):
|
||||||
|
|
||||||
@ -1190,8 +1193,8 @@ class MAINUI:
|
|||||||
self.parsedefaultfont()
|
self.parsedefaultfont()
|
||||||
self.loadmetadatas()
|
self.loadmetadatas()
|
||||||
self.translation_ui = QUnFrameWindow()
|
self.translation_ui = QUnFrameWindow()
|
||||||
winsharedutils.showintab_ex(
|
winsharedutils.showintab(
|
||||||
int(self.translation_ui.winId()), globalconfig["showintab"]
|
int(self.translation_ui.winId()), globalconfig["showintab"], True
|
||||||
)
|
)
|
||||||
self.translation_ui.show()
|
self.translation_ui.show()
|
||||||
self.translation_ui.aftershowdosomething()
|
self.translation_ui.aftershowdosomething()
|
||||||
|
@ -4,7 +4,7 @@ from qtsymbols import *
|
|||||||
import os, functools, uuid, threading, hashlib, shutil, time
|
import os, functools, uuid, threading, hashlib, shutil, time
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
import windows, gobject, winsharedutils
|
import windows, gobject, winsharedutils, qtawesome
|
||||||
from myutils.config import (
|
from myutils.config import (
|
||||||
savehook_new_list,
|
savehook_new_list,
|
||||||
savehook_new_data,
|
savehook_new_data,
|
||||||
@ -1826,7 +1826,7 @@ class dialog_savedgame_integrated(saveposwindow):
|
|||||||
poslist=globalconfig["savegamedialoggeo"],
|
poslist=globalconfig["savegamedialoggeo"],
|
||||||
)
|
)
|
||||||
self.setWindowTitle("游戏管理")
|
self.setWindowTitle("游戏管理")
|
||||||
|
self.setWindowIcon(qtawesome.icon("fa.gear"))
|
||||||
w, self.internallayout = getboxlayout(
|
w, self.internallayout = getboxlayout(
|
||||||
[], margin0=True, makewidget=True, both=True
|
[], margin0=True, makewidget=True, both=True
|
||||||
)
|
)
|
||||||
|
@ -51,8 +51,6 @@ def doadjust(_):
|
|||||||
gobject.baseobject.translation_ui.adjustbuttons()
|
gobject.baseobject.translation_ui.adjustbuttons()
|
||||||
gobject.baseobject.translation_ui.enterfunction()
|
gobject.baseobject.translation_ui.enterfunction()
|
||||||
|
|
||||||
for button in gobject.baseobject.translation_ui.showbuttons:
|
|
||||||
button.show()
|
|
||||||
|
|
||||||
def changerank(item, up, sortlist, savelist, savelay):
|
def changerank(item, up, sortlist, savelist, savelay):
|
||||||
|
|
||||||
|
@ -26,7 +26,193 @@ from gui.rangeselect import rangeselct_function
|
|||||||
from gui.usefulwidget import resizableframeless, isinrect, getQMessageBox, LIconLabel
|
from gui.usefulwidget import resizableframeless, isinrect, getQMessageBox, LIconLabel
|
||||||
from gui.edittext import edittrans
|
from gui.edittext import edittrans
|
||||||
from gui.dialog_savedgame import browserdialog, dialog_savedgame_integrated
|
from gui.dialog_savedgame import browserdialog, dialog_savedgame_integrated
|
||||||
from gui.dynalang import LPushButton, LDialog
|
from gui.dynalang import LDialog
|
||||||
|
|
||||||
|
|
||||||
|
class ButtonX(QWidget):
|
||||||
|
|
||||||
|
def __init__(self, *argc):
|
||||||
|
super().__init__(*argc)
|
||||||
|
self.reflayout = None
|
||||||
|
self.setMouseTracking(True)
|
||||||
|
self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
|
||||||
|
|
||||||
|
def showinlayout(self, layout):
|
||||||
|
|
||||||
|
layout.addWidget(self)
|
||||||
|
self.show()
|
||||||
|
self.reflayout = layout
|
||||||
|
|
||||||
|
def hideinlayout(self):
|
||||||
|
if self.reflayout is None:
|
||||||
|
return
|
||||||
|
_ = self.reflayout
|
||||||
|
self.reflayout = None
|
||||||
|
_.removeWidget(self)
|
||||||
|
self.hide()
|
||||||
|
|
||||||
|
def resizeEvent(self, e):
|
||||||
|
h = int(e.size().height() / 1.5)
|
||||||
|
self.setFixedWidth(self.height() * 2 / 1.5)
|
||||||
|
self.setIconSize(QSize(h, h))
|
||||||
|
|
||||||
|
|
||||||
|
class IconLabelX(LIconLabel, ButtonX):
|
||||||
|
clicked = pyqtSignal()
|
||||||
|
startpos = QPoint()
|
||||||
|
|
||||||
|
def mousePressEvent(self, ev: QMouseEvent) -> None:
|
||||||
|
if ev.button() == Qt.MouseButton.LeftButton:
|
||||||
|
self.startpos = QCursor.pos()
|
||||||
|
else:
|
||||||
|
self.startpos = QPoint()
|
||||||
|
return super().mousePressEvent(ev)
|
||||||
|
|
||||||
|
def mouseReleaseEvent(self, ev: QMouseEvent) -> None:
|
||||||
|
if ev.button() == Qt.MouseButton.LeftButton:
|
||||||
|
if (QCursor.pos() - self.startpos).manhattanLength() < 16:
|
||||||
|
self.clicked.emit()
|
||||||
|
return super().mouseReleaseEvent(ev)
|
||||||
|
|
||||||
|
|
||||||
|
class ButtonBar(QFrame):
|
||||||
|
def __init__(self, *argc):
|
||||||
|
super().__init__(*argc)
|
||||||
|
|
||||||
|
def __(p=None):
|
||||||
|
_ = QHBoxLayout()
|
||||||
|
_.setContentsMargins(0, 0, 0, 0)
|
||||||
|
_.setSpacing(0)
|
||||||
|
if p is not None:
|
||||||
|
p.addLayout(_)
|
||||||
|
return _
|
||||||
|
|
||||||
|
self.threelayout = __()
|
||||||
|
self._left = __(self.threelayout)
|
||||||
|
self.threelayout.addStretch()
|
||||||
|
self._center = __(self.threelayout)
|
||||||
|
self.threelayout.addStretch()
|
||||||
|
self._right = __(self.threelayout)
|
||||||
|
self.setLayout(self.threelayout)
|
||||||
|
|
||||||
|
self.buttons = {}
|
||||||
|
self.stylebuttons = {}
|
||||||
|
self.iconstate = {}
|
||||||
|
self.colorstate = {}
|
||||||
|
|
||||||
|
def refreshtoolicon(self):
|
||||||
|
for name in self.buttons:
|
||||||
|
if name in self.colorstate:
|
||||||
|
color = (
|
||||||
|
globalconfig["buttoncolor_1"]
|
||||||
|
if self.colorstate[name]()
|
||||||
|
else globalconfig["buttoncolor"]
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
color = globalconfig["buttoncolor"]
|
||||||
|
if name in self.iconstate:
|
||||||
|
icon = (
|
||||||
|
globalconfig["toolbutton"]["buttons"][name]["icon"]
|
||||||
|
if self.iconstate[name]()
|
||||||
|
else globalconfig["toolbutton"]["buttons"][name]["icon2"]
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
icon = globalconfig["toolbutton"]["buttons"][name]["icon"]
|
||||||
|
self.buttons[name].setIcon(qtawesome.icon(icon, color=color))
|
||||||
|
|
||||||
|
def setstyle(self, bottomr, bottomr3):
|
||||||
|
|
||||||
|
self.setStyleSheet(
|
||||||
|
"#titlebar{border-width: 0;%s;background-color: %s}"
|
||||||
|
% (
|
||||||
|
bottomr,
|
||||||
|
str2rgba(
|
||||||
|
globalconfig["backcolor_tool"], globalconfig["transparent_tool"]
|
||||||
|
),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
for _type in self.stylebuttons:
|
||||||
|
style = """
|
||||||
|
IconLabelX{
|
||||||
|
background-color: rgba(255, 255, 255, 0);
|
||||||
|
color: black;%s;
|
||||||
|
border: 0px;
|
||||||
|
font: 100 10pt;
|
||||||
|
}
|
||||||
|
IconLabelX:hover{
|
||||||
|
background-color: %s;
|
||||||
|
border: 0px;%s;
|
||||||
|
font: 100 10pt;
|
||||||
|
}
|
||||||
|
IconLabelX:focus {outline: 0px;}
|
||||||
|
""" % (
|
||||||
|
bottomr3,
|
||||||
|
(
|
||||||
|
globalconfig["button_color_normal"],
|
||||||
|
globalconfig["button_color_close"],
|
||||||
|
)[_type - 1],
|
||||||
|
bottomr3,
|
||||||
|
)
|
||||||
|
|
||||||
|
for btn in self.stylebuttons[_type]:
|
||||||
|
btn.setStyleSheet(style)
|
||||||
|
|
||||||
|
def takusanbuttons(
|
||||||
|
self, _type, clickfunc, tips, name, belong=None, iconstate=None, colorstate=None
|
||||||
|
):
|
||||||
|
button = IconLabelX()
|
||||||
|
if clickfunc:
|
||||||
|
|
||||||
|
def callwrap(call):
|
||||||
|
try:
|
||||||
|
call()
|
||||||
|
except:
|
||||||
|
print_exc()
|
||||||
|
|
||||||
|
button.clicked.connect(functools.partial(callwrap, clickfunc))
|
||||||
|
|
||||||
|
if tips:
|
||||||
|
button.setToolTip(tips)
|
||||||
|
if _type not in self.stylebuttons:
|
||||||
|
self.stylebuttons[_type] = []
|
||||||
|
self.stylebuttons[_type].append(button)
|
||||||
|
button.reflayout = None
|
||||||
|
button.belong = belong
|
||||||
|
self.buttons[name] = button
|
||||||
|
if iconstate:
|
||||||
|
self.iconstate[name] = iconstate
|
||||||
|
if colorstate:
|
||||||
|
self.colorstate[name] = colorstate
|
||||||
|
|
||||||
|
def adjustbuttons(self):
|
||||||
|
__ = [self._left, self._right, self._center]
|
||||||
|
cnt = 0
|
||||||
|
for name in globalconfig["toolbutton"]["rank2"]:
|
||||||
|
button = self.buttons[name]
|
||||||
|
if button.belong:
|
||||||
|
hide = True
|
||||||
|
for k in button.belong:
|
||||||
|
if (
|
||||||
|
k in globalconfig["sourcestatus2"]
|
||||||
|
and globalconfig["sourcestatus2"][k]["use"]
|
||||||
|
):
|
||||||
|
hide = False
|
||||||
|
break
|
||||||
|
if hide:
|
||||||
|
button.hideinlayout()
|
||||||
|
continue
|
||||||
|
if (
|
||||||
|
name in globalconfig["toolbutton"]["buttons"]
|
||||||
|
and globalconfig["toolbutton"]["buttons"][name]["use"] == False
|
||||||
|
):
|
||||||
|
button.hideinlayout()
|
||||||
|
continue
|
||||||
|
layout: QHBoxLayout = __[
|
||||||
|
globalconfig["toolbutton"]["buttons"][name]["align"]
|
||||||
|
]
|
||||||
|
button.showinlayout(layout)
|
||||||
|
cnt += button.width()
|
||||||
|
self.parent().setMinimumWidth(cnt)
|
||||||
|
|
||||||
|
|
||||||
class QUnFrameWindow(resizableframeless):
|
class QUnFrameWindow(resizableframeless):
|
||||||
@ -37,7 +223,6 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
displayraw1 = pyqtSignal(dict)
|
displayraw1 = pyqtSignal(dict)
|
||||||
displaystatus = pyqtSignal(str, str, bool, bool)
|
displaystatus = pyqtSignal(str, str, bool, bool)
|
||||||
showhideuisignal = pyqtSignal()
|
showhideuisignal = pyqtSignal()
|
||||||
hookfollowsignal = pyqtSignal(int, tuple)
|
|
||||||
toolbarhidedelaysignal = pyqtSignal()
|
toolbarhidedelaysignal = pyqtSignal()
|
||||||
showsavegame_signal = pyqtSignal()
|
showsavegame_signal = pyqtSignal()
|
||||||
clickRange_signal = pyqtSignal(bool)
|
clickRange_signal = pyqtSignal(bool)
|
||||||
@ -52,17 +237,43 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
resizesignal = pyqtSignal(QSize)
|
resizesignal = pyqtSignal(QSize)
|
||||||
move_signal = pyqtSignal(QPoint)
|
move_signal = pyqtSignal(QPoint)
|
||||||
|
|
||||||
def hookfollowsignalsolve(self, code, other):
|
@threader
|
||||||
if self._move_drag:
|
def tracewindowposthread(self):
|
||||||
return
|
lastpos = None
|
||||||
if code == 5:
|
while True:
|
||||||
# print(self.pos())
|
time.sleep(0.05)
|
||||||
# self.move(self.pos() + self._endPos)z
|
# 不能太快了,不然有int取整累计误差。其实应该记录起始窗口位置,然后计算与起始的dxdy,而不是与上一次的dxdy,但这太麻烦了
|
||||||
|
if self._move_drag:
|
||||||
|
lastpos = None
|
||||||
|
continue
|
||||||
|
if not globalconfig["movefollow"]:
|
||||||
|
lastpos = None
|
||||||
|
continue
|
||||||
try:
|
try:
|
||||||
gobject.baseobject.textsource.moveui(other[0], other[1])
|
hwnd = gobject.baseobject.textsource.hwnd
|
||||||
|
except:
|
||||||
|
lastpos = None
|
||||||
|
continue
|
||||||
|
rect = windows.GetWindowRect(hwnd)
|
||||||
|
if not rect:
|
||||||
|
lastpos = None
|
||||||
|
continue
|
||||||
|
if not lastpos:
|
||||||
|
lastpos = rect
|
||||||
|
continue
|
||||||
|
rate = self.devicePixelRatioF()
|
||||||
|
|
||||||
|
dx, dy = int((rect[0] - lastpos[0]) / rate), int(
|
||||||
|
(rect[1] - lastpos[1]) / rate
|
||||||
|
)
|
||||||
|
if dx == 0 and dy == 0:
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
gobject.baseobject.textsource.moveui(dx, dy)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
self.move(self.pos().x() + other[0], self.pos().y() + other[1])
|
self.move_signal.emit(QPoint(self.x() + dx, self.y() + dy))
|
||||||
|
lastpos = rect
|
||||||
|
|
||||||
def showres(self, kwargs): # name,color,res,onlytrans,iter_context):
|
def showres(self, kwargs): # name,color,res,onlytrans,iter_context):
|
||||||
try:
|
try:
|
||||||
@ -231,57 +442,11 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
self.showhideui()
|
self.showhideui()
|
||||||
|
|
||||||
def refreshtoolicon(self):
|
def refreshtoolicon(self):
|
||||||
iconstate = {
|
self.titlebar.setFixedHeight(int(globalconfig["buttonsize"] * 1.5))
|
||||||
"fullscreen": self.isletgamefullscreened,
|
self.titlebar.refreshtoolicon()
|
||||||
"muteprocess": self.processismuteed,
|
self.setMinimumHeight(self.titlebar.height() * 2)
|
||||||
"locktoolsbutton": globalconfig["locktools"],
|
|
||||||
"showraw": globalconfig["isshowrawtext"],
|
|
||||||
"automodebutton": globalconfig["autorun"],
|
|
||||||
}
|
|
||||||
colorstate = {
|
|
||||||
"automodebutton": globalconfig["autorun"],
|
|
||||||
"showraw": globalconfig["isshowrawtext"],
|
|
||||||
"mousetransbutton": globalconfig["mousetransparent"],
|
|
||||||
"backtransbutton": globalconfig["backtransparent"],
|
|
||||||
"locktoolsbutton": globalconfig["locktools"],
|
|
||||||
"selectable": globalconfig["selectable"],
|
|
||||||
"hideocrrange": self.showhidestate,
|
|
||||||
"bindwindow": self.isbindedwindow,
|
|
||||||
"keepontop": globalconfig["keepontop"],
|
|
||||||
}
|
|
||||||
|
|
||||||
self._TitleLabel.setFixedHeight(int(globalconfig["buttonsize"] * 1.5))
|
|
||||||
for name in self.buttons:
|
|
||||||
if name in colorstate:
|
|
||||||
color = (
|
|
||||||
globalconfig["buttoncolor_1"]
|
|
||||||
if colorstate[name]
|
|
||||||
else globalconfig["buttoncolor"]
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
color = globalconfig["buttoncolor"]
|
|
||||||
if name in iconstate:
|
|
||||||
icon = (
|
|
||||||
globalconfig["toolbutton"]["buttons"][name]["icon"]
|
|
||||||
if iconstate[name]
|
|
||||||
else globalconfig["toolbutton"]["buttons"][name]["icon2"]
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
icon = globalconfig["toolbutton"]["buttons"][name]["icon"]
|
|
||||||
self.buttons[name].setIcon(qtawesome.icon(icon, color=color)) # (icon[i])
|
|
||||||
self.buttons[name].resize(
|
|
||||||
int(globalconfig["buttonsize"] * 2),
|
|
||||||
int(globalconfig["buttonsize"] * 1.5),
|
|
||||||
)
|
|
||||||
|
|
||||||
self.buttons[name].setIconSize(
|
|
||||||
QSize(globalconfig["buttonsize"], globalconfig["buttonsize"])
|
|
||||||
)
|
|
||||||
self.setMinimumHeight(int(globalconfig["buttonsize"] * 1.5 + 10))
|
|
||||||
self.setMinimumWidth(globalconfig["buttonsize"] * 10)
|
|
||||||
self.set_color_transparency()
|
self.set_color_transparency()
|
||||||
self.seteffect()
|
self.seteffect()
|
||||||
self.adjustbuttons()
|
|
||||||
self.changeextendstated()
|
self.changeextendstated()
|
||||||
|
|
||||||
def ocr_once_function(self):
|
def ocr_once_function(self):
|
||||||
@ -324,7 +489,12 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
functions = (
|
functions = (
|
||||||
("move", None),
|
("move", None),
|
||||||
("retrans", self.startTranslater),
|
("retrans", self.startTranslater),
|
||||||
("automodebutton", self.changeTranslateMode),
|
(
|
||||||
|
"automodebutton",
|
||||||
|
self.changeTranslateMode,
|
||||||
|
lambda: globalconfig["autorun"],
|
||||||
|
lambda: globalconfig["autorun"],
|
||||||
|
),
|
||||||
("setting", lambda: gobject.baseobject.settin_ui.showsignal.emit()),
|
("setting", lambda: gobject.baseobject.settin_ui.showsignal.emit()),
|
||||||
(
|
(
|
||||||
"copy",
|
"copy",
|
||||||
@ -332,7 +502,12 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
),
|
),
|
||||||
("edit", gobject.baseobject.createedittextui),
|
("edit", gobject.baseobject.createedittextui),
|
||||||
("edittrans", lambda: edittrans(gobject.baseobject.commonstylebase)),
|
("edittrans", lambda: edittrans(gobject.baseobject.commonstylebase)),
|
||||||
("showraw", self.changeshowhideraw),
|
(
|
||||||
|
"showraw",
|
||||||
|
self.changeshowhideraw,
|
||||||
|
lambda: globalconfig["isshowrawtext"],
|
||||||
|
lambda: globalconfig["isshowrawtext"],
|
||||||
|
),
|
||||||
("history", lambda: gobject.baseobject.transhis.showsignal.emit()),
|
("history", lambda: gobject.baseobject.transhis.showsignal.emit()),
|
||||||
(
|
(
|
||||||
"noundict",
|
"noundict",
|
||||||
@ -371,9 +546,24 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
("langdu", lambda: gobject.baseobject.readcurrent(force=True)),
|
("langdu", lambda: gobject.baseobject.readcurrent(force=True)),
|
||||||
("mousetransbutton", lambda: self.changemousetransparentstate(0)),
|
(
|
||||||
("backtransbutton", lambda: self.changemousetransparentstate(1)),
|
"mousetransbutton",
|
||||||
("locktoolsbutton", self.changetoolslockstate),
|
lambda: self.changemousetransparentstate(0),
|
||||||
|
None,
|
||||||
|
lambda: globalconfig["mousetransparent"],
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"backtransbutton",
|
||||||
|
lambda: self.changemousetransparentstate(1),
|
||||||
|
None,
|
||||||
|
lambda: globalconfig["backtransparent"],
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"locktoolsbutton",
|
||||||
|
self.changetoolslockstate,
|
||||||
|
lambda: globalconfig["locktools"],
|
||||||
|
lambda: globalconfig["locktools"],
|
||||||
|
),
|
||||||
(
|
(
|
||||||
"gamepad_new",
|
"gamepad_new",
|
||||||
lambda: dialog_savedgame_integrated(gobject.baseobject.commonstylebase),
|
lambda: dialog_savedgame_integrated(gobject.baseobject.commonstylebase),
|
||||||
@ -387,19 +577,34 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
lambda: gobject.baseobject.hookselectdialog.showsignal.emit(),
|
lambda: gobject.baseobject.hookselectdialog.showsignal.emit(),
|
||||||
),
|
),
|
||||||
("selectocrrange", lambda: self.clickRange(False)),
|
("selectocrrange", lambda: self.clickRange(False)),
|
||||||
("hideocrrange", self.showhideocrrange),
|
("hideocrrange", self.showhideocrrange, None, lambda: self.showhidestate),
|
||||||
("bindwindow", self.bindcropwindow_signal.emit),
|
(
|
||||||
|
"bindwindow",
|
||||||
|
self.bindcropwindow_signal.emit,
|
||||||
|
None,
|
||||||
|
lambda: self.isbindedwindow,
|
||||||
|
),
|
||||||
("searchwordW", lambda: gobject.baseobject.searchwordW.showsignal.emit()),
|
("searchwordW", lambda: gobject.baseobject.searchwordW.showsignal.emit()),
|
||||||
("fullscreen", self._fullsgame),
|
("fullscreen", self._fullsgame, lambda: self.isletgamefullscreened, None),
|
||||||
("grabwindow", grabwindow),
|
("grabwindow", grabwindow),
|
||||||
("muteprocess", self.muteprocessfuntion),
|
(
|
||||||
|
"muteprocess",
|
||||||
|
self.muteprocessfuntion,
|
||||||
|
lambda: self.processismuteed,
|
||||||
|
None,
|
||||||
|
),
|
||||||
(
|
(
|
||||||
"memory",
|
"memory",
|
||||||
lambda: dialog_memory(
|
lambda: dialog_memory(
|
||||||
gobject.baseobject.commonstylebase, gobject.baseobject.currentmd5
|
gobject.baseobject.commonstylebase, gobject.baseobject.currentmd5
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
("keepontop", self.btnsetontopfunction),
|
(
|
||||||
|
"keepontop",
|
||||||
|
self.btnsetontopfunction,
|
||||||
|
None,
|
||||||
|
lambda: globalconfig["keepontop"],
|
||||||
|
),
|
||||||
(
|
(
|
||||||
"simulate_key_ctrl",
|
"simulate_key_ctrl",
|
||||||
lambda: threading.Thread(target=simulate_key_ctrl).start(),
|
lambda: threading.Thread(target=simulate_key_ctrl).start(),
|
||||||
@ -428,25 +633,44 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
("ocr_once", self.ocr_once_signal.emit),
|
("ocr_once", self.ocr_once_signal.emit),
|
||||||
("minmize", self.hide_),
|
("minmize", self.hide_),
|
||||||
("quit", self.close),
|
("quit", self.close),
|
||||||
("selectable", self.setselectable),
|
(
|
||||||
|
"selectable",
|
||||||
|
self.setselectable,
|
||||||
|
None,
|
||||||
|
lambda: globalconfig["selectable"],
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
_type = {"quit": 2}
|
_type = {"quit": 2}
|
||||||
|
|
||||||
for btn, func in functions:
|
for __ in functions:
|
||||||
|
if len(__) == 2:
|
||||||
|
btn, func = __
|
||||||
|
iconstate = colorstate = None
|
||||||
|
elif len(__) == 4:
|
||||||
|
btn, func, iconstate, colorstate = __
|
||||||
|
else:
|
||||||
|
raise
|
||||||
belong = (
|
belong = (
|
||||||
globalconfig["toolbutton"]["buttons"][btn]["belong"]
|
globalconfig["toolbutton"]["buttons"][btn]["belong"]
|
||||||
if "belong" in globalconfig["toolbutton"]["buttons"][btn]
|
if "belong" in globalconfig["toolbutton"]["buttons"][btn]
|
||||||
else None
|
else None
|
||||||
)
|
)
|
||||||
tp = _type[btn] if btn in _type else 1
|
tp = _type[btn] if btn in _type else 1
|
||||||
self.takusanbuttons(
|
self.titlebar.takusanbuttons(
|
||||||
tp,
|
tp,
|
||||||
func,
|
func,
|
||||||
globalconfig["toolbutton"]["buttons"][btn]["tip"],
|
globalconfig["toolbutton"]["buttons"][btn]["tip"],
|
||||||
btn,
|
btn,
|
||||||
belong,
|
belong,
|
||||||
|
iconstate,
|
||||||
|
colorstate,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def winid(self):
|
||||||
|
return int(self.winId())
|
||||||
|
|
||||||
def changeextendstated(self):
|
def changeextendstated(self):
|
||||||
|
|
||||||
self.translate_text.move(0, self.dynamicextraheight())
|
self.translate_text.move(0, self.dynamicextraheight())
|
||||||
@ -457,25 +681,25 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
|
|
||||||
def hide_(self):
|
def hide_(self):
|
||||||
if globalconfig["showintab"]:
|
if globalconfig["showintab"]:
|
||||||
windows.ShowWindow(int(self.winId()), windows.SW_SHOWMINIMIZED)
|
windows.ShowWindow(self.winid, windows.SW_SHOWMINIMIZED)
|
||||||
else:
|
else:
|
||||||
self.hide()
|
self.hide()
|
||||||
|
|
||||||
def show_(self):
|
def show_(self):
|
||||||
if globalconfig["showintab"]:
|
if globalconfig["showintab"]:
|
||||||
windows.ShowWindow(int(self.winId()), windows.SW_SHOWNOACTIVATE)
|
windows.ShowWindow(self.winid, windows.SW_SHOWNOACTIVATE)
|
||||||
else:
|
else:
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
def aftershowdosomething(self):
|
def aftershowdosomething(self):
|
||||||
|
|
||||||
windows.SetForegroundWindow(int(self.winId()))
|
windows.SetForegroundWindow(self.winid)
|
||||||
self.refreshtoolicon()
|
self.refreshtoolicon()
|
||||||
self.setontopthread()
|
self.setontopthread()
|
||||||
|
|
||||||
def canceltop(self):
|
def canceltop(self):
|
||||||
windows.SetWindowPos(
|
windows.SetWindowPos(
|
||||||
int(self.winId()),
|
self.winid,
|
||||||
windows.HWND_NOTOPMOST,
|
windows.HWND_NOTOPMOST,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
@ -483,13 +707,13 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
0,
|
0,
|
||||||
windows.SWP_NOACTIVATE | windows.SWP_NOSIZE | windows.SWP_NOMOVE,
|
windows.SWP_NOACTIVATE | windows.SWP_NOSIZE | windows.SWP_NOMOVE,
|
||||||
)
|
)
|
||||||
HWNDStyleEx = windows.GetWindowLong(int(self.winId()), windows.GWL_EXSTYLE)
|
HWNDStyleEx = windows.GetWindowLong(self.winid, windows.GWL_EXSTYLE)
|
||||||
windows.SetWindowLong(
|
windows.SetWindowLong(
|
||||||
int(self.winId()), windows.GWL_EXSTYLE, HWNDStyleEx & ~windows.WS_EX_TOPMOST
|
self.winid, windows.GWL_EXSTYLE, HWNDStyleEx & ~windows.WS_EX_TOPMOST
|
||||||
)
|
)
|
||||||
|
|
||||||
windows.SetWindowPos(
|
windows.SetWindowPos(
|
||||||
int(self.winId()),
|
self.winid,
|
||||||
windows.GetForegroundWindow(),
|
windows.GetForegroundWindow(),
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
@ -500,19 +724,19 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
|
|
||||||
def istopmost(self):
|
def istopmost(self):
|
||||||
return bool(
|
return bool(
|
||||||
windows.GetWindowLong(int(self.winId()), windows.GWL_EXSTYLE)
|
windows.GetWindowLong(self.winid, windows.GWL_EXSTYLE)
|
||||||
& windows.WS_EX_TOPMOST
|
& windows.WS_EX_TOPMOST
|
||||||
)
|
)
|
||||||
|
|
||||||
def settop(self):
|
def settop(self):
|
||||||
if not self.istopmost():
|
if not self.istopmost():
|
||||||
self.canceltop()
|
self.canceltop()
|
||||||
HWNDStyleEx = windows.GetWindowLong(int(self.winId()), windows.GWL_EXSTYLE)
|
HWNDStyleEx = windows.GetWindowLong(self.winid, windows.GWL_EXSTYLE)
|
||||||
windows.SetWindowLong(
|
windows.SetWindowLong(
|
||||||
int(self.winId()), windows.GWL_EXSTYLE, HWNDStyleEx | windows.WS_EX_TOPMOST
|
self.winid, windows.GWL_EXSTYLE, HWNDStyleEx | windows.WS_EX_TOPMOST
|
||||||
)
|
)
|
||||||
windows.SetWindowPos(
|
windows.SetWindowPos(
|
||||||
int(self.winId()),
|
self.winid,
|
||||||
windows.HWND_TOPMOST,
|
windows.HWND_TOPMOST,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
@ -542,14 +766,14 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
|
|
||||||
def seteffect(self):
|
def seteffect(self):
|
||||||
if globalconfig["WindowEffect"] == 0:
|
if globalconfig["WindowEffect"] == 0:
|
||||||
winsharedutils.clearEffect(int(self.winId()))
|
winsharedutils.clearEffect(self.winid)
|
||||||
elif globalconfig["WindowEffect"] == 1:
|
elif globalconfig["WindowEffect"] == 1:
|
||||||
winsharedutils.setAcrylicEffect(
|
winsharedutils.setAcrylicEffect(
|
||||||
int(self.winId()), globalconfig["WindowEffect_shadow"]
|
self.winid, globalconfig["WindowEffect_shadow"]
|
||||||
)
|
)
|
||||||
elif globalconfig["WindowEffect"] == 2:
|
elif globalconfig["WindowEffect"] == 2:
|
||||||
winsharedutils.setAeroEffect(
|
winsharedutils.setAeroEffect(
|
||||||
int(self.winId()), globalconfig["WindowEffect_shadow"]
|
self.winid, globalconfig["WindowEffect_shadow"]
|
||||||
)
|
)
|
||||||
|
|
||||||
def initvalues(self):
|
def initvalues(self):
|
||||||
@ -564,9 +788,6 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
self.processismuteed = False
|
self.processismuteed = False
|
||||||
self.thistimenotsetop = False
|
self.thistimenotsetop = False
|
||||||
self.isbindedwindow = False
|
self.isbindedwindow = False
|
||||||
self.buttons = {}
|
|
||||||
self.showbuttons = []
|
|
||||||
self.stylebuttons = {}
|
|
||||||
|
|
||||||
def displayglobaltooltip_f(self, string):
|
def displayglobaltooltip_f(self, string):
|
||||||
QToolTip.showText(QCursor.pos(), string, self)
|
QToolTip.showText(QCursor.pos(), string, self)
|
||||||
@ -596,7 +817,6 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
self.ocr_once_signal.connect(self.ocr_once_function)
|
self.ocr_once_signal.connect(self.ocr_once_function)
|
||||||
self.displaystatus.connect(self.showstatus)
|
self.displaystatus.connect(self.showstatus)
|
||||||
self.showhideuisignal.connect(self.showhideui)
|
self.showhideuisignal.connect(self.showhideui)
|
||||||
self.hookfollowsignal.connect(self.hookfollowsignalsolve)
|
|
||||||
self.displayres.connect(self.showres)
|
self.displayres.connect(self.showres)
|
||||||
self.displayraw1.connect(self.showraw)
|
self.displayraw1.connect(self.showraw)
|
||||||
self.refreshtooliconsignal.connect(self.refreshtoolicon)
|
self.refreshtooliconsignal.connect(self.refreshtoolicon)
|
||||||
@ -633,19 +853,20 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
self.setWindowTitle("LunaTranslator")
|
self.setWindowTitle("LunaTranslator")
|
||||||
self.initvalues()
|
self.initvalues()
|
||||||
self.initsignals()
|
self.initsignals()
|
||||||
self._TitleLabel = QFrame(self)
|
self.titlebar = ButtonBar(self)
|
||||||
self._TitleLabel.setObjectName("_TitleLabel")
|
self.titlebar.setObjectName("titlebar")
|
||||||
self._TitleLabel.setMouseTracking(True)
|
self.titlebar.setMouseTracking(True)
|
||||||
self.addbuttons()
|
self.addbuttons()
|
||||||
self.translate_text = Textbrowser(self)
|
self.translate_text = Textbrowser(self)
|
||||||
self.translate_text.contentsChanged.connect(self.textAreaChanged)
|
self.translate_text.contentsChanged.connect(self.textAreaChanged)
|
||||||
self.translate_text.textbrowser.setselectable(globalconfig["selectable"])
|
self.translate_text.textbrowser.setselectable(globalconfig["selectable"])
|
||||||
self._TitleLabel.raise_()
|
self.titlebar.raise_()
|
||||||
t = QTimer(self)
|
t = QTimer(self)
|
||||||
t.setInterval(33)
|
t.setInterval(33)
|
||||||
self._isentered = False
|
self._isentered = False
|
||||||
t.timeout.connect(self.__betterenterevent)
|
t.timeout.connect(self.__betterenterevent)
|
||||||
t.start()
|
t.start()
|
||||||
|
self.adjustbuttons = self.titlebar.adjustbuttons
|
||||||
|
|
||||||
def showEvent(self, e):
|
def showEvent(self, e):
|
||||||
if not self.firstshow:
|
if not self.firstshow:
|
||||||
@ -653,10 +874,11 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
return
|
return
|
||||||
self.firstshow = False
|
self.firstshow = False
|
||||||
self.mousetransparent_check()
|
self.mousetransparent_check()
|
||||||
|
self.adjustbuttons()
|
||||||
# 有个莫名其妙的加载时间
|
# 有个莫名其妙的加载时间
|
||||||
self.enterfunction(2 + globalconfig["disappear_delay_tool"])
|
self.enterfunction(2 + globalconfig["disappear_delay_tool"])
|
||||||
self.autohidedelaythread()
|
self.autohidedelaythread()
|
||||||
|
self.tracewindowposthread()
|
||||||
|
|
||||||
def setselectable(self):
|
def setselectable(self):
|
||||||
|
|
||||||
@ -700,13 +922,13 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
globalconfig["yuanjiao_r"],
|
globalconfig["yuanjiao_r"],
|
||||||
)
|
)
|
||||||
use_r2 = min(
|
use_r2 = min(
|
||||||
self._TitleLabel.height() // 2,
|
self.titlebar.height() // 2,
|
||||||
self._TitleLabel.width() // 2,
|
self.titlebar.width() // 2,
|
||||||
globalconfig["yuanjiao_r"],
|
globalconfig["yuanjiao_r"],
|
||||||
)
|
)
|
||||||
topr = self.createborderradiusstring(
|
topr = self.createborderradiusstring(
|
||||||
rate * use_r1,
|
rate * use_r1,
|
||||||
globalconfig["extendtools"] and self._TitleLabel.isVisible(),
|
globalconfig["extendtools"] and self.titlebar.isVisible(),
|
||||||
False,
|
False,
|
||||||
)
|
)
|
||||||
bottomr3 = self.createborderradiusstring(use_r2, False)
|
bottomr3 = self.createborderradiusstring(use_r2, False)
|
||||||
@ -726,40 +948,7 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self._TitleLabel.setStyleSheet(
|
self.titlebar.setstyle(bottomr, bottomr3)
|
||||||
"#_TitleLabel{border-width: 0;%s;background-color: %s}"
|
|
||||||
% (
|
|
||||||
bottomr,
|
|
||||||
str2rgba(
|
|
||||||
globalconfig["backcolor_tool"], globalconfig["transparent_tool"]
|
|
||||||
),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
for _type in self.stylebuttons:
|
|
||||||
style = """
|
|
||||||
QPushButton{
|
|
||||||
background-color: rgba(255, 255, 255, 0);
|
|
||||||
color: black;%s;
|
|
||||||
border: 0px;
|
|
||||||
font: 100 10pt;
|
|
||||||
}
|
|
||||||
QPushButton:hover{
|
|
||||||
background-color: %s;
|
|
||||||
border: 0px;%s;
|
|
||||||
font: 100 10pt;
|
|
||||||
}
|
|
||||||
QPushButton:focus {outline: 0px;}
|
|
||||||
""" % (
|
|
||||||
bottomr3,
|
|
||||||
(
|
|
||||||
globalconfig["button_color_normal"],
|
|
||||||
globalconfig["button_color_close"],
|
|
||||||
)[_type - 1],
|
|
||||||
bottomr3,
|
|
||||||
)
|
|
||||||
|
|
||||||
for btn in self.stylebuttons[_type]:
|
|
||||||
btn.setStyleSheet(style)
|
|
||||||
|
|
||||||
def muteprocessfuntion(self):
|
def muteprocessfuntion(self):
|
||||||
if gobject.baseobject.textsource and gobject.baseobject.textsource.pids:
|
if gobject.baseobject.textsource and gobject.baseobject.textsource.pids:
|
||||||
@ -811,16 +1000,16 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
|
|
||||||
@threader
|
@threader
|
||||||
def mousetransparent_check(self):
|
def mousetransparent_check(self):
|
||||||
hwnd = int(int(self.winId()))
|
hwnd = int(self.winid)
|
||||||
while globalconfig["mousetransparent"]:
|
while globalconfig["mousetransparent"]:
|
||||||
cursor_pos = self.mapFromGlobal(QCursor.pos())
|
cursor_pos = self.mapFromGlobal(QCursor.pos())
|
||||||
if isinrect(
|
if isinrect(
|
||||||
cursor_pos,
|
cursor_pos,
|
||||||
[
|
[
|
||||||
self._TitleLabel.x(),
|
self.titlebar.x(),
|
||||||
self._TitleLabel.x() + self._TitleLabel.width(),
|
self.titlebar.x() + self.titlebar.width(),
|
||||||
self._TitleLabel.y(),
|
self.titlebar.y(),
|
||||||
self._TitleLabel.y() + self._TitleLabel.height(),
|
self.titlebar.y() + self.titlebar.height(),
|
||||||
],
|
],
|
||||||
):
|
):
|
||||||
|
|
||||||
@ -897,7 +1086,7 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
self.refreshtoolicon()
|
self.refreshtoolicon()
|
||||||
|
|
||||||
def dynamicextraheight(self):
|
def dynamicextraheight(self):
|
||||||
return int(globalconfig["extendtools"]) * int(globalconfig["buttonsize"] * 1.5)
|
return int(globalconfig["extendtools"]) * self.titlebar.height()
|
||||||
|
|
||||||
def textAreaChanged(self, size: QSize):
|
def textAreaChanged(self, size: QSize):
|
||||||
|
|
||||||
@ -944,7 +1133,7 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
|
|
||||||
def toolbarhidedelay(self):
|
def toolbarhidedelay(self):
|
||||||
|
|
||||||
self._TitleLabel.hide()
|
self.titlebar.hide()
|
||||||
self.set_color_transparency()
|
self.set_color_transparency()
|
||||||
|
|
||||||
def checkisentered(self):
|
def checkisentered(self):
|
||||||
@ -960,9 +1149,7 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
or ismyprocbutnotmainuiforeground
|
or ismyprocbutnotmainuiforeground
|
||||||
)
|
)
|
||||||
if onlychecktitle:
|
if onlychecktitle:
|
||||||
return self._TitleLabel.geometry().contains(
|
return self.titlebar.geometry().contains(self.mapFromGlobal(QCursor.pos()))
|
||||||
self.mapFromGlobal(QCursor.pos())
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
return self.geometry().contains(QCursor.pos())
|
return self.geometry().contains(QCursor.pos())
|
||||||
|
|
||||||
@ -992,7 +1179,7 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
self.toolbarhidedelaysignal.emit()
|
self.toolbarhidedelaysignal.emit()
|
||||||
|
|
||||||
def enterfunction(self, delay=None):
|
def enterfunction(self, delay=None):
|
||||||
self._TitleLabel.show()
|
self.titlebar.show()
|
||||||
self.set_color_transparency()
|
self.set_color_transparency()
|
||||||
|
|
||||||
self.dodelayhide(delay)
|
self.dodelayhide(delay)
|
||||||
@ -1004,76 +1191,7 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
|
|
||||||
self.translate_text.resize(self.width(), int(height))
|
self.translate_text.resize(self.width(), int(height))
|
||||||
if e.oldSize().width() != e.size().width():
|
if e.oldSize().width() != e.size().width():
|
||||||
self.adjustbuttons()
|
self.titlebar.setFixedWidth(self.width())
|
||||||
self._TitleLabel.setFixedWidth(self.width())
|
|
||||||
|
|
||||||
def adjustbuttons(self):
|
|
||||||
left = []
|
|
||||||
right = []
|
|
||||||
center = []
|
|
||||||
self.showbuttons.clear()
|
|
||||||
__ = [left, right, center]
|
|
||||||
for name in globalconfig["toolbutton"]["rank2"]:
|
|
||||||
button = self.buttons[name]
|
|
||||||
if button.belong:
|
|
||||||
hide = True
|
|
||||||
for k in button.belong:
|
|
||||||
if (
|
|
||||||
k in globalconfig["sourcestatus2"]
|
|
||||||
and globalconfig["sourcestatus2"][k]["use"]
|
|
||||||
):
|
|
||||||
hide = False
|
|
||||||
break
|
|
||||||
if hide:
|
|
||||||
button.hide()
|
|
||||||
continue
|
|
||||||
if (
|
|
||||||
name in globalconfig["toolbutton"]["buttons"]
|
|
||||||
and globalconfig["toolbutton"]["buttons"][name]["use"] == False
|
|
||||||
):
|
|
||||||
button.hide()
|
|
||||||
continue
|
|
||||||
__[globalconfig["toolbutton"]["buttons"][name]["align"]].append(button)
|
|
||||||
self.showbuttons.append(button)
|
|
||||||
|
|
||||||
leftmax = 0
|
|
||||||
rightmax = self.width()
|
|
||||||
for button in left:
|
|
||||||
button.move(leftmax, 0)
|
|
||||||
leftmax += button.width()
|
|
||||||
for button in reversed(right):
|
|
||||||
rightmax -= button.width()
|
|
||||||
button.move(rightmax, 0)
|
|
||||||
sumwidth = 0
|
|
||||||
for button in center:
|
|
||||||
sumwidth += button.width()
|
|
||||||
leftstart = leftmax + (rightmax - leftmax - sumwidth) / 2
|
|
||||||
for button in center:
|
|
||||||
button.move(int(leftstart), 0)
|
|
||||||
leftstart += button.width()
|
|
||||||
|
|
||||||
def callwrap(self, call, _):
|
|
||||||
try:
|
|
||||||
call()
|
|
||||||
except:
|
|
||||||
print_exc()
|
|
||||||
|
|
||||||
def takusanbuttons(self, _type, clickfunc, tips, name, belong=None):
|
|
||||||
if clickfunc:
|
|
||||||
button = LPushButton(self._TitleLabel)
|
|
||||||
button.clicked.connect(functools.partial(self.callwrap, clickfunc))
|
|
||||||
else:
|
|
||||||
|
|
||||||
button = LIconLabel(self._TitleLabel)
|
|
||||||
|
|
||||||
if tips:
|
|
||||||
button.setToolTip(tips)
|
|
||||||
if _type not in self.stylebuttons:
|
|
||||||
self.stylebuttons[_type] = []
|
|
||||||
self.stylebuttons[_type].append(button)
|
|
||||||
|
|
||||||
button.belong = belong
|
|
||||||
self.buttons[name] = button
|
|
||||||
|
|
||||||
def tryremoveuseless(self):
|
def tryremoveuseless(self):
|
||||||
try:
|
try:
|
||||||
|
@ -87,25 +87,19 @@ def grabwindow(app="PNG", callback_origin=None):
|
|||||||
_()
|
_()
|
||||||
|
|
||||||
|
|
||||||
def getprocesslist():
|
|
||||||
|
|
||||||
pids = windows.EnumProcesses()
|
|
||||||
return pids
|
|
||||||
|
|
||||||
|
|
||||||
def getpidexe(pid):
|
def getpidexe(pid):
|
||||||
hwnd1 = windows.AutoHandle(
|
hproc = windows.AutoHandle(
|
||||||
windows.OpenProcess(windows.PROCESS_ALL_ACCESS, False, pid)
|
windows.OpenProcess(windows.PROCESS_ALL_ACCESS, False, pid)
|
||||||
)
|
)
|
||||||
if not hwnd1:
|
if not hproc:
|
||||||
|
|
||||||
hwnd1 = windows.OpenProcess(
|
hproc = windows.OpenProcess(
|
||||||
windows.PROCESS_QUERY_LIMITED_INFORMATION, False, pid
|
windows.PROCESS_QUERY_LIMITED_INFORMATION, False, pid
|
||||||
)
|
)
|
||||||
if not hwnd1:
|
if not hproc:
|
||||||
name_ = None
|
name_ = None
|
||||||
else:
|
else:
|
||||||
name_ = windows.GetProcessFileName(hwnd1)
|
name_ = windows.GetProcessFileName(hproc)
|
||||||
return name_
|
return name_
|
||||||
|
|
||||||
|
|
||||||
@ -126,8 +120,7 @@ def test_injectable(pids):
|
|||||||
|
|
||||||
def ListProcess(filt=True):
|
def ListProcess(filt=True):
|
||||||
ret = []
|
ret = []
|
||||||
pids = getprocesslist()
|
for pid in winsharedutils.Getprcesses():
|
||||||
for pid in pids:
|
|
||||||
if os.getpid() == pid:
|
if os.getpid() == pid:
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
|
@ -458,35 +458,13 @@ def minmaxmoveobservefunc(self):
|
|||||||
gobject.baseobject.translation_ui.thistimenotsetop = True
|
gobject.baseobject.translation_ui.thistimenotsetop = True
|
||||||
if gobject.baseobject.translation_ui.istopmost():
|
if gobject.baseobject.translation_ui.istopmost():
|
||||||
gobject.baseobject.translation_ui.canceltop()
|
gobject.baseobject.translation_ui.canceltop()
|
||||||
if _focusp != windows.GetWindowThreadProcessId(
|
|
||||||
gobject.baseobject.textsource.hwnd
|
|
||||||
):
|
|
||||||
return
|
|
||||||
|
|
||||||
rect = windows.GetWindowRect(hwnd)
|
|
||||||
if event == windows.EVENT_SYSTEM_MOVESIZESTART: #
|
|
||||||
self.lastpos = rect
|
|
||||||
elif event == windows.EVENT_SYSTEM_MOVESIZEEND: #
|
|
||||||
if globalconfig["movefollow"]:
|
|
||||||
if self.lastpos:
|
|
||||||
rate = QApplication.instance().devicePixelRatio()
|
|
||||||
self.hookfollowsignal.emit(
|
|
||||||
5,
|
|
||||||
(
|
|
||||||
int((rect[0] - self.lastpos[0]) / rate),
|
|
||||||
int((rect[1] - self.lastpos[1]) / rate),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
except:
|
except:
|
||||||
print_exc()
|
print_exc()
|
||||||
|
|
||||||
win_event_callback_cfunc = WinEventProcType(win_event_callback)
|
win_event_callback_cfunc = WinEventProcType(win_event_callback)
|
||||||
|
|
||||||
eventpairs = (
|
eventpairs = ((windows.EVENT_SYSTEM_FOREGROUND, windows.EVENT_SYSTEM_FOREGROUND),)
|
||||||
(windows.EVENT_SYSTEM_MOVESIZESTART, windows.EVENT_SYSTEM_MOVESIZEEND),
|
|
||||||
(windows.EVENT_SYSTEM_FOREGROUND, windows.EVENT_SYSTEM_FOREGROUND),
|
|
||||||
)
|
|
||||||
|
|
||||||
def _():
|
def _():
|
||||||
for pair in eventpairs:
|
for pair in eventpairs:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<div id="example_hello">Hello, welcome to use LunaTranslator</div>
|
<div id="example_hello" style="text-align: center;">Hello, welcome to use LunaTranslator</div>
|
||||||
<script>
|
<script>
|
||||||
// alert("welcome")
|
// alert("welcome")
|
||||||
clear_all = function () {
|
clear_all = function () {
|
||||||
|
@ -192,10 +192,6 @@ _kernel32 = windll.Kernel32
|
|||||||
_psapi = windll.Psapi
|
_psapi = windll.Psapi
|
||||||
_Advapi32 = windll.Advapi32
|
_Advapi32 = windll.Advapi32
|
||||||
|
|
||||||
_SetWindowPlacement = _user32.SetWindowPlacement
|
|
||||||
_SetWindowPlacement.argtypes = c_int, POINTER(WINDOWPLACEMENT)
|
|
||||||
_GetWindowPlacement = _user32.GetWindowPlacement
|
|
||||||
_GetWindowPlacement.argtypes = c_int, POINTER(WINDOWPLACEMENT)
|
|
||||||
_GetWindowRect = _user32.GetWindowRect
|
_GetWindowRect = _user32.GetWindowRect
|
||||||
_GetWindowRect.argtypes = c_int, POINTER(RECT)
|
_GetWindowRect.argtypes = c_int, POINTER(RECT)
|
||||||
_GetForegroundWindow = _user32.GetForegroundWindow
|
_GetForegroundWindow = _user32.GetForegroundWindow
|
||||||
@ -427,21 +423,6 @@ def GetClientRect(hwnd):
|
|||||||
return (_rect.left, _rect.top, _rect.right, _rect.bottom)
|
return (_rect.left, _rect.top, _rect.right, _rect.bottom)
|
||||||
|
|
||||||
|
|
||||||
def GetWindowPlacement(hwnd, _simple):
|
|
||||||
_place = WINDOWPLACEMENT()
|
|
||||||
_GetWindowPlacement(hwnd, pointer(_place))
|
|
||||||
if _simple:
|
|
||||||
return (
|
|
||||||
_place.flags,
|
|
||||||
_place.showCmd,
|
|
||||||
) # 只用的着showCmd,所以就先这样了
|
|
||||||
else:
|
|
||||||
return _place
|
|
||||||
|
|
||||||
|
|
||||||
def SetWindowPlacement(hwnd, _place):
|
|
||||||
return _SetWindowPlacement(hwnd, pointer(_place))
|
|
||||||
|
|
||||||
|
|
||||||
def ShowWindow(hwnd, nCmdShow):
|
def ShowWindow(hwnd, nCmdShow):
|
||||||
return _ShowWindow(hwnd, nCmdShow)
|
return _ShowWindow(hwnd, nCmdShow)
|
||||||
@ -542,19 +523,6 @@ def keybd_event(bVk, bScan, dwFlags, _):
|
|||||||
_keybd_event(bVk, bScan, dwFlags, _)
|
_keybd_event(bVk, bScan, dwFlags, _)
|
||||||
|
|
||||||
|
|
||||||
try:
|
|
||||||
_EnumProcesses = _kernel32.EnumProcesses
|
|
||||||
except:
|
|
||||||
_EnumProcesses = _psapi.EnumProcesses
|
|
||||||
|
|
||||||
|
|
||||||
def EnumProcesses():
|
|
||||||
buf = (c_uint * 1024)()
|
|
||||||
dwneed = c_uint()
|
|
||||||
_EnumProcesses(pointer(buf), sizeof(buf), pointer(dwneed))
|
|
||||||
return list(buf)[: dwneed.value // sizeof(c_uint)]
|
|
||||||
|
|
||||||
|
|
||||||
_WaitForSingleObject = _kernel32.WaitForSingleObject
|
_WaitForSingleObject = _kernel32.WaitForSingleObject
|
||||||
_WaitForSingleObject.argtypes = c_void_p, c_uint
|
_WaitForSingleObject.argtypes = c_void_p, c_uint
|
||||||
|
|
||||||
|
@ -250,10 +250,18 @@ def SetTheme(hwnd, dark, backdrop):
|
|||||||
_SetTheme(hwnd, dark, backdrop)
|
_SetTheme(hwnd, dark, backdrop)
|
||||||
|
|
||||||
|
|
||||||
|
getprocesses = utilsdll.getprocesses
|
||||||
|
getprocesses.argtypes = (c_void_p,)
|
||||||
|
|
||||||
|
|
||||||
|
def Getprcesses():
|
||||||
|
ret = []
|
||||||
|
getprocesses(CFUNCTYPE(None, DWORD)(ret.append))
|
||||||
|
return ret
|
||||||
|
|
||||||
|
|
||||||
showintab = utilsdll.showintab
|
showintab = utilsdll.showintab
|
||||||
showintab.argtypes = HWND, c_bool
|
showintab.argtypes = HWND, c_bool, c_bool
|
||||||
showintab_ex = utilsdll.showintab_ex
|
|
||||||
showintab_ex.argtypes = HWND, c_bool
|
|
||||||
|
|
||||||
|
|
||||||
class windowstatus(Structure):
|
class windowstatus(Structure):
|
||||||
|
@ -29,7 +29,7 @@ include(generate_product_version)
|
|||||||
|
|
||||||
set(VERSION_MAJOR 5)
|
set(VERSION_MAJOR 5)
|
||||||
set(VERSION_MINOR 18)
|
set(VERSION_MINOR 18)
|
||||||
set(VERSION_PATCH 4)
|
set(VERSION_PATCH 5)
|
||||||
|
|
||||||
add_library(pch pch.cpp)
|
add_library(pch pch.cpp)
|
||||||
target_precompile_headers(pch PUBLIC pch.h)
|
target_precompile_headers(pch PUBLIC pch.h)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "define.h"
|
#include "define.h"
|
||||||
|
|
||||||
DECLARE void showintab(HWND hwnd, bool show)
|
DECLARE void showintab(HWND hwnd, bool show, bool tool)
|
||||||
{
|
{
|
||||||
// WS_EX_TOOLWINDOW可以立即生效,WS_EX_APPWINDOW必须切换焦点才生效。但是WS_EX_TOOLWINDOW会改变窗口样式,因此只对无边框窗口使用。
|
// WS_EX_TOOLWINDOW可以立即生效,WS_EX_APPWINDOW必须切换焦点才生效。但是WS_EX_TOOLWINDOW会改变窗口样式,因此只对无边框窗口使用。
|
||||||
LONG style = GetWindowLong(hwnd, GWL_STYLE);
|
LONG style = GetWindowLong(hwnd, GWL_STYLE);
|
||||||
@ -9,30 +9,15 @@ DECLARE void showintab(HWND hwnd, bool show)
|
|||||||
{
|
{
|
||||||
style_ex |= WS_EX_APPWINDOW;
|
style_ex |= WS_EX_APPWINDOW;
|
||||||
// if ((style & WS_OVERLAPPEDWINDOW) != WS_OVERLAPPEDWINDOW)
|
// if ((style & WS_OVERLAPPEDWINDOW) != WS_OVERLAPPEDWINDOW)
|
||||||
// style_ex &= ~WS_EX_TOOLWINDOW;
|
if (tool)
|
||||||
|
style_ex &= ~WS_EX_TOOLWINDOW;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
style_ex &= ~WS_EX_APPWINDOW;
|
style_ex &= ~WS_EX_APPWINDOW;
|
||||||
// if ((style & WS_OVERLAPPEDWINDOW) != WS_OVERLAPPEDWINDOW)
|
// if ((style & WS_OVERLAPPEDWINDOW) != WS_OVERLAPPEDWINDOW)
|
||||||
// style_ex |= WS_EX_TOOLWINDOW;
|
if (tool)
|
||||||
}
|
style_ex |= WS_EX_TOOLWINDOW;
|
||||||
SetWindowLong(hwnd, GWL_EXSTYLE, style_ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
DECLARE void showintab_ex(HWND hwnd, bool show)
|
|
||||||
{
|
|
||||||
LONG style = GetWindowLong(hwnd, GWL_STYLE);
|
|
||||||
auto style_ex = GetWindowLong(hwnd, GWL_EXSTYLE);
|
|
||||||
if (show)
|
|
||||||
{
|
|
||||||
style_ex |= WS_EX_APPWINDOW;
|
|
||||||
style_ex &= ~WS_EX_TOOLWINDOW;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
style_ex &= ~WS_EX_APPWINDOW;
|
|
||||||
style_ex |= WS_EX_TOOLWINDOW;
|
|
||||||
}
|
}
|
||||||
SetWindowLong(hwnd, GWL_EXSTYLE, style_ex);
|
SetWindowLong(hwnd, GWL_EXSTYLE, style_ex);
|
||||||
}
|
}
|
||||||
@ -123,4 +108,23 @@ DECLARE bool Is64bit(DWORD pid)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
DECLARE void getprocesses(void (*cb)(DWORD))
|
||||||
|
{
|
||||||
|
std::unordered_map<std::wstring, std::vector<int>> exe_pid;
|
||||||
|
AutoHandle hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||||
|
if (hSnapshot == INVALID_HANDLE_VALUE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
PROCESSENTRY32 pe32;
|
||||||
|
pe32.dwSize = sizeof(PROCESSENTRY32);
|
||||||
|
auto currpid = GetCurrentProcessId();
|
||||||
|
if (Process32First(hSnapshot, &pe32))
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
cb(pe32.th32ProcessID);
|
||||||
|
} while (Process32Next(hSnapshot, &pe32));
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user