mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 16:44:13 +08:00
inspect
This commit is contained in:
parent
16455b4619
commit
9f2bb25b7b
@ -41,7 +41,7 @@ class AttachProcessDialog(saveposwindow):
|
|||||||
super().closeEvent(e)
|
super().closeEvent(e)
|
||||||
|
|
||||||
def __init__(self, parent, callback, hookselectdialog=None):
|
def __init__(self, parent, callback, hookselectdialog=None):
|
||||||
super().__init__(parent, globalconfig, "attachprocessgeo")
|
super().__init__(parent, poslist=globalconfig["attachprocessgeo"])
|
||||||
self.setcurrentpidpnamesignal.connect(self.selectwindowcallback)
|
self.setcurrentpidpnamesignal.connect(self.selectwindowcallback)
|
||||||
|
|
||||||
self.iconcache = {}
|
self.iconcache = {}
|
||||||
|
@ -24,8 +24,7 @@ class dialog_memory(saveposwindow):
|
|||||||
parent,
|
parent,
|
||||||
flags=Qt.WindowType.WindowCloseButtonHint
|
flags=Qt.WindowType.WindowCloseButtonHint
|
||||||
| Qt.WindowType.WindowMinMaxButtonsHint,
|
| Qt.WindowType.WindowMinMaxButtonsHint,
|
||||||
dic=globalconfig,
|
poslist=globalconfig["memorydialoggeo"],
|
||||||
key="memorydialoggeo",
|
|
||||||
)
|
)
|
||||||
self.setWindowTitle(_TR("备忘录"))
|
self.setWindowTitle(_TR("备忘录"))
|
||||||
self.gamemd5 = gamemd5
|
self.gamemd5 = gamemd5
|
||||||
|
@ -479,7 +479,7 @@ class browserdialog(saveposwindow):
|
|||||||
self.startupsettitle(exepath)
|
self.startupsettitle(exepath)
|
||||||
|
|
||||||
def __init__(self, parent, exepath=None) -> None:
|
def __init__(self, parent, exepath=None) -> None:
|
||||||
super().__init__(parent, globalconfig, "browserwidget")
|
super().__init__(parent, poslist=globalconfig["browserwidget"])
|
||||||
if exepath:
|
if exepath:
|
||||||
self.setWindowIcon(getExeIcon(exepath, cache=True))
|
self.setWindowIcon(getExeIcon(exepath, cache=True))
|
||||||
self.browser = auto_select_webview(self)
|
self.browser = auto_select_webview(self)
|
||||||
@ -1703,8 +1703,7 @@ class dialog_savedgame_integrated(saveposwindow):
|
|||||||
parent,
|
parent,
|
||||||
flags=Qt.WindowType.WindowMinMaxButtonsHint
|
flags=Qt.WindowType.WindowMinMaxButtonsHint
|
||||||
| Qt.WindowType.WindowCloseButtonHint,
|
| Qt.WindowType.WindowCloseButtonHint,
|
||||||
dic=globalconfig,
|
poslist=globalconfig["savegamedialoggeo"]
|
||||||
key="savegamedialoggeo",
|
|
||||||
)
|
)
|
||||||
self.setWindowTitle(_TR("游戏管理"))
|
self.setWindowTitle(_TR("游戏管理"))
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ class edittext(saveposwindow):
|
|||||||
super().closeEvent(e)
|
super().closeEvent(e)
|
||||||
|
|
||||||
def __init__(self, parent, cached):
|
def __init__(self, parent, cached):
|
||||||
super().__init__(parent, globalconfig, "edit_geo")
|
super().__init__(parent, poslist=globalconfig["edit_geo"])
|
||||||
self.setupUi()
|
self.setupUi()
|
||||||
|
|
||||||
# self.setWindowFlags(self.windowFlags()&~Qt.WindowMinimizeButtonHint)
|
# self.setWindowFlags(self.windowFlags()&~Qt.WindowMinimizeButtonHint)
|
||||||
|
@ -373,7 +373,7 @@ class hookselect(closeashidewindow):
|
|||||||
update_item_new_line = pyqtSignal(tuple, str)
|
update_item_new_line = pyqtSignal(tuple, str)
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
super(hookselect, self).__init__(parent, globalconfig, "selecthookgeo")
|
super(hookselect, self).__init__(parent, globalconfig["selecthookgeo"])
|
||||||
self.setupUi()
|
self.setupUi()
|
||||||
self.changeprocessclearsignal.connect(self.changeprocessclear)
|
self.changeprocessclearsignal.connect(self.changeprocessclear)
|
||||||
self.removehooksignal.connect(self.removehook)
|
self.removehooksignal.connect(self.removehook)
|
||||||
|
@ -72,7 +72,7 @@ class Setting(closeashidewindow):
|
|||||||
showandsolvesig = pyqtSignal(str)
|
showandsolvesig = pyqtSignal(str)
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
super(Setting, self).__init__(parent, globalconfig, "setting_geo_2")
|
super(Setting, self).__init__(parent, globalconfig["setting_geo_2"])
|
||||||
self.setWindowIcon(qtawesome.icon("fa.gear"))
|
self.setWindowIcon(qtawesome.icon("fa.gear"))
|
||||||
self.mp3player = wavmp3player()
|
self.mp3player = wavmp3player()
|
||||||
self.mp3playsignal.connect(self.mp3player.mp3playfunction)
|
self.mp3playsignal.connect(self.mp3player.mp3playfunction)
|
||||||
|
@ -96,7 +96,7 @@ class extrahtml(saveposwindow):
|
|||||||
ff.write(self.vistext.toPlainText())
|
ff.write(self.vistext.toPlainText())
|
||||||
|
|
||||||
def __init__(self, parent) -> None:
|
def __init__(self, parent) -> None:
|
||||||
super().__init__(parent, globalconfig, "geo_extrahtml")
|
super().__init__(parent, poslist=globalconfig["geo_extrahtml"])
|
||||||
self.setWindowTitle(_TR("额外的html"))
|
self.setWindowTitle(_TR("额外的html"))
|
||||||
|
|
||||||
self.btn_save = QPushButton(_TR("保存"))
|
self.btn_save = QPushButton(_TR("保存"))
|
||||||
|
@ -50,7 +50,7 @@ class showocrimage(saveposwindow):
|
|||||||
def __init__(self, parent, cached):
|
def __init__(self, parent, cached):
|
||||||
self.img1 = None
|
self.img1 = None
|
||||||
self.originimage = None
|
self.originimage = None
|
||||||
super().__init__(parent, globalconfig, "showocrgeo")
|
super().__init__(parent, poslist=globalconfig["showocrgeo"])
|
||||||
self.setWindowIcon(qtawesome.icon("fa.picture-o"))
|
self.setWindowIcon(qtawesome.icon("fa.picture-o"))
|
||||||
self.setWindowTitle(_TR("查看处理效果"))
|
self.setWindowTitle(_TR("查看处理效果"))
|
||||||
self.originlabel = pixlabel()
|
self.originlabel = pixlabel()
|
||||||
|
@ -724,7 +724,7 @@ class searchwordW(closeashidewindow):
|
|||||||
showtabsignal = pyqtSignal(float, str, str)
|
showtabsignal = pyqtSignal(float, str, str)
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
super(searchwordW, self).__init__(parent, globalconfig, "sw_geo")
|
super(searchwordW, self).__init__(parent, globalconfig["sw_geo"])
|
||||||
# self.setWindowFlags(self.windowFlags()&~Qt.WindowMinimizeButtonHint)
|
# self.setWindowFlags(self.windowFlags()&~Qt.WindowMinimizeButtonHint)
|
||||||
self.getnewsentencesignal.connect(self.getnewsentence)
|
self.getnewsentencesignal.connect(self.getnewsentence)
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ class transhist(closeashidewindow):
|
|||||||
getnewtranssignal = pyqtSignal(str, str)
|
getnewtranssignal = pyqtSignal(str, str)
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
super(transhist, self).__init__(parent, globalconfig, "hist_geo")
|
super(transhist, self).__init__(parent, globalconfig["hist_geo"])
|
||||||
self.setupUi()
|
self.setupUi()
|
||||||
# self.setWindowFlags(self.windowFlags()&~Qt.WindowMinimizeButtonHint)
|
# self.setWindowFlags(self.windowFlags()&~Qt.WindowMinimizeButtonHint)
|
||||||
self.getnewsentencesignal.connect(self.getnewsentence)
|
self.getnewsentencesignal.connect(self.getnewsentence)
|
||||||
|
@ -579,8 +579,7 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
None,
|
None,
|
||||||
flags=Qt.WindowType.FramelessWindowHint
|
flags=Qt.WindowType.FramelessWindowHint
|
||||||
| Qt.WindowType.WindowMinimizeButtonHint,
|
| Qt.WindowType.WindowMinimizeButtonHint,
|
||||||
dic=globalconfig,
|
poslist=globalconfig["transuigeo"]
|
||||||
key="transuigeo",
|
|
||||||
) # 设置为顶级窗口,无边框
|
) # 设置为顶级窗口,无边框
|
||||||
icon = getExeIcon(sys.argv[0]) #'./LunaTranslator.exe')# QIcon()
|
icon = getExeIcon(sys.argv[0]) #'./LunaTranslator.exe')# QIcon()
|
||||||
# icon.addPixmap(QPixmap('./files/luna.png'), QIcon.Normal, QIcon.On)
|
# icon.addPixmap(QPixmap('./files/luna.png'), QIcon.Normal, QIcon.On)
|
||||||
|
@ -115,27 +115,28 @@ def makerect(_):
|
|||||||
|
|
||||||
|
|
||||||
class saveposwindow(QMainWindow):
|
class saveposwindow(QMainWindow):
|
||||||
def __init__(self, parent, dic=None, key=None, flags=None) -> None:
|
def __init__(self, parent, poslist=None, flags=None) -> None:
|
||||||
if flags:
|
if flags:
|
||||||
super().__init__(parent, flags=flags)
|
super().__init__(parent, flags=flags)
|
||||||
else:
|
else:
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
d = QApplication.primaryScreen()
|
d = QApplication.primaryScreen()
|
||||||
self.dic, self.key = dic, key
|
self.poslist = poslist
|
||||||
if self.dic:
|
if self.poslist:
|
||||||
dic[key][2] = max(0, min(dic[key][2], d.size().width()))
|
poslist[2] = max(0, min(poslist[2], d.size().width()))
|
||||||
dic[key][3] = max(0, min(dic[key][3], d.size().height()))
|
poslist[3] = max(0, min(poslist[3], d.size().height()))
|
||||||
dic[key][0] = min(max(dic[key][0], 0), d.size().width() - dic[key][2])
|
poslist[0] = min(max(poslist[0], 0), d.size().width() - poslist[2])
|
||||||
dic[key][1] = min(max(dic[key][1], 0), d.size().height() - dic[key][3])
|
poslist[1] = min(max(poslist[1], 0), d.size().height() - poslist[3])
|
||||||
self.setGeometry(*dic[key])
|
self.setGeometry(*poslist)
|
||||||
|
|
||||||
def __checked_savepos(self):
|
def __checked_savepos(self):
|
||||||
if not self.dic:
|
if not self.poslist:
|
||||||
return
|
return
|
||||||
if windows.IsZoomed(int(self.winId())) != 0:
|
if windows.IsZoomed(int(self.winId())) != 0:
|
||||||
return
|
return
|
||||||
# self.isMaximized()会在event结束后才被设置,不符合预期。
|
# self.isMaximized()会在event结束后才被设置,不符合预期。
|
||||||
self.dic[self.key] = list(self.geometry().getRect())
|
for i, _ in enumerate(self.geometry().getRect()):
|
||||||
|
self.poslist[i] = _
|
||||||
|
|
||||||
def resizeEvent(self, a0) -> None:
|
def resizeEvent(self, a0) -> None:
|
||||||
self.__checked_savepos()
|
self.__checked_savepos()
|
||||||
@ -151,8 +152,8 @@ class closeashidewindow(saveposwindow):
|
|||||||
showsignal = pyqtSignal()
|
showsignal = pyqtSignal()
|
||||||
realshowhide = pyqtSignal(bool)
|
realshowhide = pyqtSignal(bool)
|
||||||
|
|
||||||
def __init__(self, parent, dic=None, key=None) -> None:
|
def __init__(self, parent, poslist=None) -> None:
|
||||||
super().__init__(parent, dic, key)
|
super().__init__(parent, poslist)
|
||||||
self.showsignal.connect(self.showfunction)
|
self.showsignal.connect(self.showfunction)
|
||||||
self.realshowhide.connect(self.realshowhidefunction)
|
self.realshowhide.connect(self.realshowhidefunction)
|
||||||
|
|
||||||
@ -400,8 +401,8 @@ class MySwitch2(QPushButton):
|
|||||||
|
|
||||||
|
|
||||||
class resizableframeless(saveposwindow):
|
class resizableframeless(saveposwindow):
|
||||||
def __init__(self, parent, flags, dic, key) -> None:
|
def __init__(self, parent, flags, poslist) -> None:
|
||||||
super().__init__(parent, dic, key, flags)
|
super().__init__(parent, poslist, flags)
|
||||||
self.setMouseTracking(True)
|
self.setMouseTracking(True)
|
||||||
|
|
||||||
self._padding = 5
|
self._padding = 5
|
||||||
@ -1166,7 +1167,7 @@ class CustomKeySequenceEdit(QKeySequenceEdit):
|
|||||||
|
|
||||||
|
|
||||||
def getsimplekeyseq(dic, key, callback=None):
|
def getsimplekeyseq(dic, key, callback=None):
|
||||||
key1 = CustomKeySequenceEdit(QKeySequence(dic[key]))
|
key1 = CustomKeySequenceEdit(QKeySequence(poslist))
|
||||||
|
|
||||||
def __(_d, _k, cb, s):
|
def __(_d, _k, cb, s):
|
||||||
_d[_k] = s
|
_d[_k] = s
|
||||||
|
@ -4,7 +4,7 @@ from rendertext.somefunctions import dataget
|
|||||||
import gobject, uuid, json, os
|
import gobject, uuid, json, os
|
||||||
from urllib.parse import quote
|
from urllib.parse import quote
|
||||||
from myutils.config import globalconfig
|
from myutils.config import globalconfig
|
||||||
from gui.usefulwidget import WebivewWidget, QWebWrap
|
from gui.usefulwidget import WebivewWidget, QWebWrap, saveposwindow
|
||||||
from myutils.utils import checkportavailable
|
from myutils.utils import checkportavailable
|
||||||
|
|
||||||
testsavejs = False
|
testsavejs = False
|
||||||
@ -33,6 +33,7 @@ class TextBrowser(QWidget, dataget):
|
|||||||
Qt.ContextMenuPolicy.CustomContextMenu
|
Qt.ContextMenuPolicy.CustomContextMenu
|
||||||
)
|
)
|
||||||
self.webivewwidget.internal.customContextMenuRequested.connect(self._qwmenu)
|
self.webivewwidget.internal.customContextMenuRequested.connect(self._qwmenu)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# webview2当会执行alert之类的弹窗js时,若qt窗口不可视,会卡住
|
# webview2当会执行alert之类的弹窗js时,若qt窗口不可视,会卡住
|
||||||
self.webivewwidget = WebivewWidget(self)
|
self.webivewwidget = WebivewWidget(self)
|
||||||
@ -47,27 +48,45 @@ class TextBrowser(QWidget, dataget):
|
|||||||
self.isfirst = True
|
self.isfirst = True
|
||||||
|
|
||||||
def _qwmenu(self, pos):
|
def _qwmenu(self, pos):
|
||||||
web_menu = QMenu()
|
from PyQt5.QtWebEngineWidgets import QWebEnginePage, QWebEngineView
|
||||||
inspect = QAction("inspect")
|
|
||||||
web_menu.addAction(inspect)
|
|
||||||
action = web_menu.exec_(self.webivewwidget.mapToGlobal(pos))
|
|
||||||
if action == inspect:
|
|
||||||
from PyQt5.QtWebEngineWidgets import QWebEngineView
|
|
||||||
|
|
||||||
self.inspector = QWebEngineView()
|
loadinspector = QAction("Inspect")
|
||||||
|
web_menu = self.webivewwidget.internal.page().createStandardContextMenu()
|
||||||
def __(_):
|
if (
|
||||||
self.webivewwidget.internal.setContextMenuPolicy(
|
self.webivewwidget.internal.page().action(
|
||||||
Qt.ContextMenuPolicy.CustomContextMenu
|
QWebEnginePage.WebAction.InspectElement
|
||||||
)
|
|
||||||
|
|
||||||
self.inspector.closeEvent = __
|
|
||||||
self.inspector.load(QUrl(self.DEBUG_URL))
|
|
||||||
self.webivewwidget.internal.page().setDevToolsPage(self.inspector.page())
|
|
||||||
self.inspector.show()
|
|
||||||
self.webivewwidget.internal.setContextMenuPolicy(
|
|
||||||
Qt.ContextMenuPolicy.DefaultContextMenu
|
|
||||||
)
|
)
|
||||||
|
not in web_menu.actions()
|
||||||
|
):
|
||||||
|
web_menu.addAction(loadinspector)
|
||||||
|
action = web_menu.exec_(self.webivewwidget.mapToGlobal(pos))
|
||||||
|
|
||||||
|
if action == loadinspector:
|
||||||
|
|
||||||
|
class QMW(saveposwindow):
|
||||||
|
def closeEvent(_self, e):
|
||||||
|
self.webivewwidget.internal.page().setDevToolsPage(None)
|
||||||
|
super(QMW, _self).closeEvent(e)
|
||||||
|
|
||||||
|
def __init__(_self) -> None:
|
||||||
|
super().__init__(
|
||||||
|
gobject.baseobject.settin_ui,
|
||||||
|
poslist=globalconfig["qwebinspectgeo"]
|
||||||
|
)
|
||||||
|
_self.setWindowTitle("Inspect")
|
||||||
|
_self.internal = QWebEngineView(_self)
|
||||||
|
_self.setCentralWidget(_self.internal)
|
||||||
|
_self.internal.load(QUrl(self.DEBUG_URL))
|
||||||
|
self.webivewwidget.internal.page().setDevToolsPage(
|
||||||
|
_self.internal.page()
|
||||||
|
)
|
||||||
|
self.webivewwidget.internal.page().triggerAction(
|
||||||
|
QWebEnginePage.WebAction.InspectElement
|
||||||
|
)
|
||||||
|
|
||||||
|
_self.show()
|
||||||
|
|
||||||
|
QMW()
|
||||||
|
|
||||||
def showEvent(self, e):
|
def showEvent(self, e):
|
||||||
if not self.isfirst:
|
if not self.isfirst:
|
||||||
|
@ -310,6 +310,12 @@
|
|||||||
"maxHistorySize": 1000000,
|
"maxHistorySize": 1000000,
|
||||||
"yuanjiao_r": 0,
|
"yuanjiao_r": 0,
|
||||||
"yuanjiao_merge": true,
|
"yuanjiao_merge": true,
|
||||||
|
"qwebinspectgeo": [
|
||||||
|
100,
|
||||||
|
100,
|
||||||
|
800,
|
||||||
|
400
|
||||||
|
],
|
||||||
"transuigeo": [
|
"transuigeo": [
|
||||||
500,
|
500,
|
||||||
500,
|
500,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user