This commit is contained in:
恍兮惚兮 2024-04-30 02:19:43 +08:00
parent b5a54ea537
commit 4a18ed4d46
2 changed files with 23 additions and 23 deletions

View File

@ -471,7 +471,7 @@ class _browserdialog(saveposwindow):
def likelink(self): def likelink(self):
_dia = Prompt_dialog( _dia = Prompt_dialog(
gobject.baseobject.settin_ui, self,
_TR("收藏"), _TR("收藏"),
"", "",
[ [
@ -487,7 +487,7 @@ class _browserdialog(saveposwindow):
], ],
) )
_dia.exec() if _dia.exec():
text = [] text = []
for _t in _dia.text: for _t in _dia.text:

View File

@ -11,7 +11,12 @@ from PyQt5.QtWidgets import (
QWidget, QWidget,
) )
from webviewpy import webview_error_t, webview_native_handle_kind_t, Webview, declare_library_path from webviewpy import (
webview_error_t,
webview_native_handle_kind_t,
Webview,
declare_library_path,
)
from PyQt5.QtGui import QCursor, QCloseEvent, QColor, QTextCursor, QResizeEvent from PyQt5.QtGui import QCursor, QCloseEvent, QColor, QTextCursor, QResizeEvent
from PyQt5.QtCore import Qt, pyqtSignal, QSize from PyQt5.QtCore import Qt, pyqtSignal, QSize
from myutils.config import _TR, globalconfig from myutils.config import _TR, globalconfig
@ -366,19 +371,12 @@ class Prompt_dialog(QDialog):
hl.addWidget(QLabel(_[0])) hl.addWidget(QLabel(_[0]))
hl.addWidget(le) hl.addWidget(le)
_layout.addLayout(hl) _layout.addLayout(hl)
button = QDialogButtonBox(QDialogButtonBox.Ok) button = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
button.accepted.connect(self.accept) button.accepted.connect(self.accept)
button.rejected.connect(self.reject)
_layout.addWidget(button) _layout.addWidget(button)
self.setLayout(_layout) self.setLayout(_layout)
self.resize(400, 1) self.resize(400, 1)
cursor = QCursor()
pos = cursor.pos()
num_screens = QDesktopWidget().screenCount()
for i in range(num_screens):
_rect = QDesktopWidget().screenGeometry(i)
if isinrect(pos, [_rect.getRect()[_] for _ in [0, 2, 1, 3]]):
self.move(_rect.width() // 2 - self.width() // 2, _rect.height() // 3)
break
def callbackwrap(d, k, call, _): def callbackwrap(d, k, call, _):
@ -545,14 +543,16 @@ class WebivewWidget(QWidget):
) )
) )
) )
class _Webview(Webview): class _Webview(Webview):
def navigate(_, url: str) -> webview_error_t: def navigate(_, url: str) -> webview_error_t:
self.on_load.emit(url) self.on_load.emit(url)
return super().navigate(url) return super().navigate(url)
self.webview = _Webview(debug=debug, window=int(self.winId())) self.webview = _Webview(debug=debug, window=int(self.winId()))
#self.webview.bind("__on_load", self._on_load) # self.webview.bind("__on_load", self._on_load)
#self.webview.init("""window.__on_load(window.location.href)""") # self.webview.init("""window.__on_load(window.location.href)""")
def _on_load(self, _, href): def _on_load(self, _, href):
self.on_load.emit(json.loads(href)[0]) self.on_load.emit(json.loads(href)[0])