This commit is contained in:
恍兮惚兮 2024-11-24 15:32:26 +08:00
parent c0f318aa16
commit 3b6cd76116
4 changed files with 38 additions and 5 deletions

View File

@ -1,7 +1,7 @@
set(VERSION_MAJOR 6)
set(VERSION_MINOR 6)
set(VERSION_PATCH 0)
set(VERSION_PATCH 1)
set(VERSION_REVISION 0)
set(LUNA_VERSION "{${VERSION_MAJOR},${VERSION_MINOR},${VERSION_PATCH},${VERSION_REVISION}}")
add_library(VERSION_DEF INTERFACE)

View File

@ -1,9 +1,10 @@
from qtsymbols import *
from myutils.config import globalconfig, static_data
from rendertext.somefunctions import dataget
import gobject, functools, importlib
import gobject, functools, importlib, winsharedutils
from traceback import print_exc
from rendertext.textbrowser_imp.base import base
from gui.dynalang import LAction
class Qlabel_c(QLabel):
@ -97,6 +98,23 @@ class TextBrowser(QWidget, dataget):
self.__makeborder(event.size())
def showmenu(self, p):
curr = self.textbrowser.textCursor().selectedText()
if not curr:
return
menu = QMenu(self)
search = LAction(("查词"))
copy = LAction(("复制"))
menu.addAction(search)
menu.addAction(copy)
action = menu.exec(self.mapToGlobal(p))
if action == search:
gobject.baseobject.searchwordW.search_word.emit(curr, False)
elif action == copy:
winsharedutils.clipboard_set(curr)
def __init__(self, parent) -> None:
super().__init__(parent)
self.setAcceptDrops(True)
@ -108,6 +126,9 @@ class TextBrowser(QWidget, dataget):
self.toplabel2 = QLabel(self)
self.toplabel2.setMouseTracking(True)
self.textbrowser = QTextBrowser(self)
self.textbrowser.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
self.textbrowser.customContextMenuRequested.connect(self.showmenu)
self.textbrowser.document().contentsChanged.connect(self.contentchangedfunction)
self.tranparentcolor = QColor()
self.tranparentcolor.setAlpha(0)

View File

@ -18,6 +18,10 @@
body::-webkit-scrollbar {
display: none;
}
rt {
user-select: none;
}
</style>
<script>document.addEventListener('DOMContentLoaded', () => {

View File

@ -2,7 +2,8 @@ from qtsymbols import *
from rendertext.somefunctions import dataget
import gobject, uuid, json, os, functools, windows, time
from urllib.parse import quote
from myutils.config import globalconfig, static_data
from myutils.utils import threader
from myutils.config import globalconfig, static_data, _TR
from myutils.wrapper import tryprint, threader
from gui.usefulwidget import WebivewWidget
@ -45,7 +46,6 @@ class TextBrowser(QWidget, dataget):
# webview2当会执行alert之类的弹窗js时若qt窗口不可视会卡住
self.webivewwidget = WebivewWidget(self, usedarklight=False)
# webview2无法接收qt事件。
webviewhwnd = self.webivewwidget.get_hwnd()
self.wndproc = windows.WNDPROCTYPE(
functools.partial(
@ -54,7 +54,15 @@ class TextBrowser(QWidget, dataget):
)
)
windows.SetWindowLongPtr(webviewhwnd, windows.GWLP_WNDPROC, self.wndproc)
self.webivewwidget.add_menu(
0,
_TR("查词"),
threader(
lambda w: gobject.baseobject.searchwordW.search_word.emit(
w.replace("\n", "").strip(), False
)
),
)
self.masklabel_left = QLabel(self)
self.masklabel_left.setMouseTracking(True)
# self.masklabel_left.setStyleSheet('background-color:red')