From f9563995a1f792d250add8c2060815ae5924850a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Sat, 18 May 2024 01:35:19 +0800 Subject: [PATCH] onlinelink --- LunaTranslator/LunaTranslator/cishu/goo.py | 7 ++++++- LunaTranslator/LunaTranslator/cishu/weblio.py | 7 ++++++- LunaTranslator/LunaTranslator/cishu/youdao.py | 9 ++++++++- LunaTranslator/LunaTranslator/gui/showword.py | 12 +++++++++++- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/LunaTranslator/LunaTranslator/cishu/goo.py b/LunaTranslator/LunaTranslator/cishu/goo.py index 581cb1bf..7907a3ad 100644 --- a/LunaTranslator/LunaTranslator/cishu/goo.py +++ b/LunaTranslator/LunaTranslator/cishu/goo.py @@ -18,4 +18,9 @@ class goo(cishubase): xx = re.sub("", "", xx) - return xx + return ( + '
link
'.format( + url + ) + + xx + ) diff --git a/LunaTranslator/LunaTranslator/cishu/weblio.py b/LunaTranslator/LunaTranslator/cishu/weblio.py index 262916ca..d49c9a10 100644 --- a/LunaTranslator/LunaTranslator/cishu/weblio.py +++ b/LunaTranslator/LunaTranslator/cishu/weblio.py @@ -26,4 +26,9 @@ class weblio(cishubase): join = "
".join(_all) - return join + return ( + '
link
'.format( + url + ) + + join + ) diff --git a/LunaTranslator/LunaTranslator/cishu/youdao.py b/LunaTranslator/LunaTranslator/cishu/youdao.py index ea1e7c69..39300d49 100644 --- a/LunaTranslator/LunaTranslator/cishu/youdao.py +++ b/LunaTranslator/LunaTranslator/cishu/youdao.py @@ -25,4 +25,11 @@ class youdao(cishubase): proxies=getproxy(), ).text fnd = re.findall('
([\\s\\S]*?)
', text) - return fnd[0][1] + return ( + '
link

'.format( + "https://dict.youdao.com/result?word={}&lang={}".format( + quote(word), self.srclang + ) + ) + + fnd[0][1] + ) diff --git a/LunaTranslator/LunaTranslator/gui/showword.py b/LunaTranslator/LunaTranslator/gui/showword.py index 317772b8..733d7966 100644 --- a/LunaTranslator/LunaTranslator/gui/showword.py +++ b/LunaTranslator/LunaTranslator/gui/showword.py @@ -17,7 +17,7 @@ from PyQt5.QtWidgets import ( from PyQt5.QtGui import QPixmap, QImage from traceback import print_exc import requests, json, subprocess, time -from PyQt5.QtCore import pyqtSignal, Qt +from PyQt5.QtCore import pyqtSignal, Qt, QUrl import qtawesome, functools, os, base64 import gobject, uuid, signal from myutils.config import globalconfig, _TR, static_data @@ -694,6 +694,15 @@ class searchwordW(closeashidewindow): self.setCentralWidget(ww) textOutput = QTextBrowser(self) + + def openlink(url): + try: + if url.url().lower().startswith("http"): + os.startfile(url.url()) + except: + pass + + textOutput.anchorClicked.connect(openlink) textOutput.setUndoRedoEnabled(False) textOutput.setReadOnly(True) textOutput.setOpenLinks(False) @@ -755,6 +764,7 @@ class searchwordW(closeashidewindow): for i in range(self.tab.count()): self.tab.removeTab(0) self.tabks.clear() + self.textOutput.clear() self.cache_results.clear() for k, cishu in gobject.baseobject.cishus.items(): cishu.callback = functools.partial(self.showtabsignal.emit, k)