This commit is contained in:
恍兮惚兮 2024-06-22 04:26:45 +08:00
parent d24d9d3564
commit d556c11829
23 changed files with 73 additions and 60 deletions

View File

@ -14,7 +14,7 @@ from gui.usefulwidget import (
@Singleton
class dialog_selecticon(QDialog):
def __init__(self, parent, dict, key, _nouse_for_click_arg) -> None:
def __init__(self, parent, dict, key) -> None:
super().__init__(parent, Qt.WindowType.WindowCloseButtonHint)
self.dict = dict

View File

@ -188,15 +188,8 @@ def resetgroudswitchcallback(self, group):
goodfontgroupswitch = FocusCombo()
if group == "textbrowser" or group == "QWebEngine":
self.goodfontsettingsformlayout.addRow(
_TR("可选取模式"),
getsimpleswitch(
globalconfig,
"selectable",
callback=lambda x: gobject.baseobject.translation_ui.translate_text.textbrowser.setselectable(),
),
)
# if group == "textbrowser" or group == "QWebEngine":
if group == "webview" or group == "QWebEngine":
_btn = QPushButton(_TR("额外的html"))
self.goodfontsettingsformlayout.addRow(_btn)
@ -432,6 +425,16 @@ def xianshigrid(self):
("收到翻译结果时才刷新", 5),
D_getsimpleswitch(globalconfig, "refresh_on_get_trans"),
],
[
("可选取的", 5),
D_getsimpleswitch(
globalconfig,
"selectable",
callback=lambda x: gobject.baseobject.translation_ui.refreshtoolicon(),
parent=self,
name="selectable_btn",
),
],
),
),
0,

View File

@ -65,6 +65,7 @@ class Textbrowser(QLabel):
self.masklabel_bottom.setMouseTracking(True)
# self.masklabel_bottom.setStyleSheet('background-color:red')
def iter_append(self, iter_context_class, origin, atcenter, text, color):
cleared = self.cleared
self.cleared = False

View File

@ -244,6 +244,7 @@ class QUnFrameWindow(resizableframeless):
"mousetransbutton": self.mousetransparent,
"backtransbutton": self.backtransparent,
"locktoolsbutton": globalconfig["locktools"],
"selectable": globalconfig["selectable"],
"hideocrrange": self.showhidestate,
"bindwindow": self.isbindedwindow,
"keepontop": globalconfig["keepontop"],
@ -400,6 +401,7 @@ class QUnFrameWindow(resizableframeless):
("ocr_once", self.ocr_once_signal.emit),
("minmize", self.hide_),
("quit", self.close),
("selectable", self.setselectable),
)
_type = {"quit": 2}
@ -534,11 +536,7 @@ class QUnFrameWindow(resizableframeless):
self.stylebuttons = {}
def displayglobaltooltip_f(self, string):
QToolTip.showText(
QCursor.pos(),
string,
gobject.baseobject.translation_ui,
)
QToolTip.showText(QCursor.pos(), string, self)
def initsignals(self):
self.hidesignal.connect(self.hide_)
@ -587,12 +585,22 @@ class QUnFrameWindow(resizableframeless):
self.addbuttons()
self.translate_text = Textbrowser(self)
self.translate_text.contentsChanged.connect(self.textAreaChanged)
self.translate_text.textbrowser.setselectable(globalconfig["selectable"])
t = QTimer(self)
t.setInterval(100)
self._isentered = False
t.timeout.connect(self.__betterenterevent)
t.start()
def setselectable(self):
try:
gobject.baseobject.settin_ui.selectable_btn.click()
except:
globalconfig["selectable"] = not globalconfig["selectable"]
self.translate_text.textbrowser.setselectable(globalconfig["selectable"])
self.refreshtoolicon()
def createborderradiusstring(self, r, merge, top=False):
if merge:
if top:
@ -815,7 +823,7 @@ class QUnFrameWindow(resizableframeless):
gobject.baseobject.settin_ui.show_original_switch.click()
except:
globalconfig["isshowrawtext"] = not globalconfig["isshowrawtext"]
gobject.baseobject.translation_ui.refreshtoolicon()
self.refreshtoolicon()
def changeTranslateMode(self):
globalconfig["autorun"] = not globalconfig["autorun"]

View File

@ -980,12 +980,7 @@ class abstractwebview(QWidget):
class WebivewWidget(abstractwebview):
def __del__(self):
winsharedutils.remove_ZoomFactorChanged(
self.webview.get_native_handle(
webview_native_handle_kind_t.WEBVIEW_NATIVE_HANDLE_KIND_BROWSER_CONTROLLER
),
self.__token,
)
winsharedutils.remove_ZoomFactorChanged(self.get_controller(), self.__token)
def bind(self, fname, func):
self.webview.bind(fname, func)
@ -1070,14 +1065,16 @@ class QWebWrap(abstractwebview):
from PyQt5.QtWebEngineWidgets import QWebEngineView
else:
from PyQt6.QtWebEngineWidgets import QWebEngineView
if 'QTWEBENGINE_REMOTE_DEBUGGING' not in os.environ:
if "QTWEBENGINE_REMOTE_DEBUGGING" not in os.environ:
DEBUG_PORT = 5588
for i in range(100):
if checkportavailable(DEBUG_PORT):
break
DEBUG_PORT += 1
os.environ["QTWEBENGINE_REMOTE_DEBUGGING"] = str(DEBUG_PORT)
self.DEBUG_URL = "http://127.0.0.1:%s" % os.environ["QTWEBENGINE_REMOTE_DEBUGGING"]
self.DEBUG_URL = (
"http://127.0.0.1:%s" % os.environ["QTWEBENGINE_REMOTE_DEBUGGING"]
)
self.internal = QWebEngineView(self)
self.internal.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
self.internal.customContextMenuRequested.connect(self._qwmenu)

View File

@ -103,8 +103,6 @@ class TextBrowser(QWidget, dataget):
self.saveiterclasspointer = {}
self.resets1()
self.setselectable()
def resets1(self):
self.currenttype = globalconfig["rendertext_using_internal"]["textbrowser"]
__ = importlib.import_module(
@ -154,8 +152,8 @@ class TextBrowser(QWidget, dataget):
labels[1] = 0
self.iteryinyinglabelsave.clear()
def setselectable(self):
self.masklabel.setHidden(globalconfig["selectable"])
def setselectable(self, b):
self.masklabel.setHidden(b)
def _createqfont(self, origin):

View File

@ -16,8 +16,8 @@ class TextBrowser(QWidget, dataget):
self.webivewwidget.resize(event.size())
self.masklabel.resize(event.size())
def setselectable(self):
self.masklabel.setHidden(globalconfig["selectable"])
def setselectable(self, b):
self.masklabel.setHidden(b)
def __init__(self, parent) -> None:
super().__init__(parent)
@ -39,7 +39,6 @@ class TextBrowser(QWidget, dataget):
self.saveiterclasspointer = {}
self.isfirst = True
self._qweb_query_word()
self.setselectable()
def showEvent(self, e):
if not self.isfirst:

View File

@ -583,6 +583,7 @@
"open_relative_link",
"open_game_setting",
"ocr_once",
"selectable",
"minmize",
"quit"
],
@ -807,6 +808,12 @@
"tip": "窗口置顶",
"icon": "fa.neuter",
"align": 0
},
"selectable": {
"use": false,
"tip": "可选取模式",
"icon": "fa.i-cursor",
"align": 0
}
}
},

View File

@ -683,7 +683,6 @@
"收藏": "جمع",
"名称": "الإسم",
"网址": "عنوان الموقع",
"可选取模式": "اختيار نمط",
"百度OCR": "بايدو التعرف الضوئي على الحروف",
"飞书OCR": "كتاب الطيران التعرف الضوئي على الحروف",
"讯飞OCR": "التعرف الضوئي على الحروف",
@ -808,5 +807,6 @@
"阴影强度": "كثافة الظل",
"阴影半径": "مكان الظل",
"字体倍率": "معدل الخط",
"固定值": "قيمة ثابتة"
"固定值": "قيمة ثابتة",
"可选取的": "قابل للاختيار"
}

View File

@ -683,7 +683,6 @@
"收藏": "收藏",
"名称": "名稱",
"网址": "網址",
"可选取模式": "可選取模式",
"百度OCR": "百度OCR",
"飞书OCR": "飛書OCR",
"讯飞OCR": "訊飛OCR",
@ -808,5 +807,6 @@
"阴影强度": "陰影强度",
"阴影半径": "陰影半徑",
"字体倍率": "字體倍率",
"固定值": "固定值"
"固定值": "固定值",
"可选取的": "可選取的"
}

View File

@ -683,7 +683,6 @@
"收藏": "collection",
"名称": "name",
"网址": "Website",
"可选取模式": "Selectable modes",
"百度OCR": "Baidu OCR",
"飞书OCR": "Feishu OCR",
"讯飞OCR": "IFlytek OCR",
@ -808,5 +807,6 @@
"阴影强度": "Shadow intensity",
"阴影半径": "Shadow radius",
"字体倍率": "Font magnification",
"固定值": "Fixed value"
"固定值": "Fixed value",
"可选取的": "Selectable"
}

View File

@ -683,7 +683,6 @@
"收藏": "Colección",
"名称": "Nombre",
"网址": "Sitio web",
"可选取模式": "Modo seleccionable",
"百度OCR": "Baidu OCR",
"飞书OCR": "Flying Book OCR",
"讯飞OCR": "IFLYTEK OCR",
@ -808,5 +807,6 @@
"阴影强度": "Intensidad de la sombra",
"阴影半径": "Radio de sombra",
"字体倍率": "Multiplicación de fuentes",
"固定值": "Valor fijo"
"固定值": "Valor fijo",
"可选取的": "Seleccionable"
}

View File

@ -683,7 +683,6 @@
"收藏": "Collections",
"名称": "Le nom",
"网址": "Adresse Web",
"可选取模式": "Mode sélectionnable",
"百度OCR": "Baidu ocr",
"飞书OCR": "Livre volant ocr",
"讯飞OCR": "OCR volant",
@ -808,5 +807,6 @@
"阴影强度": "Intensité de l'ombre",
"阴影半径": "Rayon d'ombre",
"字体倍率": "Multiplication des polices",
"固定值": "Valeur fixe"
"固定值": "Valeur fixe",
"可选取的": "Sélectionnable"
}

View File

@ -683,7 +683,6 @@
"收藏": "raccolta",
"名称": "nome",
"网址": "Sito web",
"可选取模式": "Modalità selezionabili",
"百度OCR": "OCR Baidu",
"飞书OCR": "OCR Feishu",
"讯飞OCR": "OCR IFlytek",
@ -808,5 +807,6 @@
"阴影强度": "Intensità ombra",
"阴影半径": "Raggio ombra",
"字体倍率": "Ingrandimento dei caratteri",
"固定值": "Valore fisso"
"固定值": "Valore fisso",
"可选取的": "Selezionabile"
}

View File

@ -683,7 +683,6 @@
"收藏": "コレクション",
"名称": "の名前をあげる",
"网址": "Webサイト",
"可选取模式": "選択可能モード",
"百度OCR": "百度OCR",
"飞书OCR": "フライブックOCR",
"讯飞OCR": "アイフライテックOCR",
@ -808,5 +807,6 @@
"阴影强度": "シャドウ強度",
"阴影半径": "シャドウ半径",
"字体倍率": "フォント倍率",
"固定值": "固定値"
"固定值": "固定値",
"可选取的": "選択可能"
}

View File

@ -683,7 +683,6 @@
"收藏": "모음집",
"名称": "이름",
"网址": "웹 주소",
"可选取模式": "선택 가능 모드",
"百度OCR": "바이두 OCR",
"飞书OCR": "페이서 OCR",
"讯飞OCR": "아이플라이테크 OCR",
@ -808,5 +807,6 @@
"阴影强度": "그림자 강도",
"阴影半径": "그림자 반지름",
"字体倍率": "글꼴 배율",
"固定值": "고정값"
"固定值": "고정값",
"可选取的": "선택 가능"
}

View File

@ -683,7 +683,6 @@
"收藏": "kolekcja",
"名称": "nazwa",
"网址": "Strona internetowa",
"可选取模式": "Tryby wyboru",
"百度OCR": "OCR Baidu",
"飞书OCR": "OCR Feishu",
"讯飞OCR": "OCR IFlytek",
@ -808,5 +807,6 @@
"阴影强度": "Intensywność cienia",
"阴影半径": "Promień cienia",
"字体倍率": "Powiększenie czcionki",
"固定值": "Wartość stała"
"固定值": "Wartość stała",
"可选取的": "Wybór"
}

View File

@ -683,7 +683,6 @@
"收藏": "Коллекция",
"名称": "Имя",
"网址": "Веб - сайт",
"可选取模式": "Выбранный режим",
"百度OCR": "Сотня OCR",
"飞书OCR": "Летающая книга OCR",
"讯飞OCR": "Сигнал OCR",
@ -808,5 +807,6 @@
"阴影强度": "Интенсивность тени",
"阴影半径": "Радиус тени",
"字体倍率": "Увеличить шрифт",
"固定值": "Постоянная величина"
"固定值": "Постоянная величина",
"可选取的": "Выбор"
}

View File

@ -683,7 +683,6 @@
"收藏": "คอลเลกชัน",
"名称": "ชื่อ",
"网址": "ที่อยู่เว็บไซต์",
"可选取模式": "โหมดที่เลือกได้",
"百度OCR": "ไป่ตู้ OCR",
"飞书OCR": "หนังสือบิน OCR",
"讯飞OCR": "โปรแกรม iFlytek OCR",
@ -808,5 +807,6 @@
"阴影强度": "ความเข้มเงา",
"阴影半径": "รัศมีเงา",
"字体倍率": "แบบอักษรคูณ",
"固定值": "ค่าคงที่"
"固定值": "ค่าคงที่",
"可选取的": "เลือกได้"
}

View File

@ -683,7 +683,6 @@
"收藏": "koleksiyon",
"名称": "isim",
"网址": "Web sitesi",
"可选取模式": "Seçilebilir modlar",
"百度OCR": "Baidu OCR",
"飞书OCR": "Feishu OCR",
"讯飞OCR": "IFlytek OCR",
@ -808,5 +807,6 @@
"阴影强度": "Gölge şiddeti",
"阴影半径": "Gölge Yardımcısı",
"字体倍率": "Yazıtipi büyütmesi",
"固定值": "Tam değer"
"固定值": "Tam değer",
"可选取的": "Seçilebilir"
}

View File

@ -683,7 +683,6 @@
"收藏": "збірка",
"名称": "назва",
"网址": "Веб- сайт",
"可选取模式": "Вибрані режими",
"百度OCR": "Baidu OCR",
"飞书OCR": "Feishu OCR",
"讯飞OCR": "IFlytek OCR",
@ -808,5 +807,6 @@
"阴影强度": "Інтензитет тіні",
"阴影半径": "Радіус тіні",
"字体倍率": "Збільшення шрифту",
"固定值": "Визначене значення"
"固定值": "Визначене значення",
"可选取的": "Вибраний"
}

View File

@ -683,7 +683,6 @@
"收藏": "Bộ sưu tập",
"名称": "Tên",
"网址": "Trang chủ",
"可选取模式": "Chế độ chọn",
"百度OCR": "Số lượng OCR",
"飞书OCR": "Sách bay OCR",
"讯飞OCR": "Máy bay OCR",
@ -808,5 +807,6 @@
"阴影强度": "Cường độ bóng",
"阴影半径": "Bán kính bóng",
"字体倍率": "Độ phóng đại phông chữ",
"固定值": "Giá trị cố định"
"固定值": "Giá trị cố định",
"可选取的": "Chọn"
}

View File

@ -688,7 +688,7 @@
"收藏": "",
"名称": "",
"网址": "",
"可选取模式": "",
"可选取": "",
"百度OCR": "",
"飞书OCR": "",
"讯飞OCR": "",