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