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):
_dia = Prompt_dialog(
gobject.baseobject.settin_ui,
self,
_TR("收藏"),
"",
[
@ -487,17 +487,17 @@ class _browserdialog(saveposwindow):
],
)
_dia.exec()
if _dia.exec():
text = []
for _t in _dia.text:
text.append(_t.text())
if self.exepath:
savehook_new_data[self.exepath]["relationlinks"].append(text)
self.tagswidget.addTag(text[0], tagitem.TYPE_GAME_LIKE, text[1])
else:
globalconfig["relationlinks"].append(text)
self.tagswidget.addTag(text[0], tagitem.TYPE_GLOABL_LIKE, text[1])
text = []
for _t in _dia.text:
text.append(_t.text())
if self.exepath:
savehook_new_data[self.exepath]["relationlinks"].append(text)
self.tagswidget.addTag(text[0], tagitem.TYPE_GAME_LIKE, text[1])
else:
globalconfig["relationlinks"].append(text)
self.tagswidget.addTag(text[0], tagitem.TYPE_GLOABL_LIKE, text[1])
def tagschanged(self, tags):
__ = []

View File

@ -11,7 +11,12 @@ from PyQt5.QtWidgets import (
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.QtCore import Qt, pyqtSignal, QSize
from myutils.config import _TR, globalconfig
@ -366,19 +371,12 @@ class Prompt_dialog(QDialog):
hl.addWidget(QLabel(_[0]))
hl.addWidget(le)
_layout.addLayout(hl)
button = QDialogButtonBox(QDialogButtonBox.Ok)
button = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
button.accepted.connect(self.accept)
button.rejected.connect(self.reject)
_layout.addWidget(button)
self.setLayout(_layout)
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, _):
@ -545,14 +543,16 @@ class WebivewWidget(QWidget):
)
)
)
class _Webview(Webview):
def navigate(_, url: str) -> webview_error_t:
self.on_load.emit(url)
return super().navigate(url)
self.webview = _Webview(debug=debug, window=int(self.winId()))
#self.webview.bind("__on_load", self._on_load)
#self.webview.init("""window.__on_load(window.location.href)""")
# self.webview.bind("__on_load", self._on_load)
# self.webview.init("""window.__on_load(window.location.href)""")
def _on_load(self, _, href):
self.on_load.emit(json.loads(href)[0])