diff --git a/LunaTranslator/LunaTranslator/gui/setting_hotkey.py b/LunaTranslator/LunaTranslator/gui/setting_hotkey.py index ed7171ed..a701aa46 100644 --- a/LunaTranslator/LunaTranslator/gui/setting_hotkey.py +++ b/LunaTranslator/LunaTranslator/gui/setting_hotkey.py @@ -47,6 +47,7 @@ def registrhotkeys(self): "_51": gobject.baseobject.translation_ui.changeshowhidetrans, "_6": lambda: gobject.baseobject.transhis.showsignal.emit(), "_7": lambda: gobject.baseobject.readcurrent(force=True), + "_7_1": lambda: gobject.baseobject.audioplayer.stop(), "_8": lambda: gobject.baseobject.translation_ui.changemousetransparentstate(0), "_9": gobject.baseobject.translation_ui.changetoolslockstate, "_10": lambda: gobject.baseobject.translation_ui.showsavegame_signal.emit(), diff --git a/LunaTranslator/LunaTranslator/gui/translatorUI.py b/LunaTranslator/LunaTranslator/gui/translatorUI.py index ba387256..5cd6fc58 100644 --- a/LunaTranslator/LunaTranslator/gui/translatorUI.py +++ b/LunaTranslator/LunaTranslator/gui/translatorUI.py @@ -71,6 +71,7 @@ class ButtonX(QWidget): class IconLabelX(LIconLabel, ButtonX): clicked = pyqtSignal() + rightclick = pyqtSignal() def mousePressEvent(self, ev: QMouseEvent) -> None: if QObject.receivers(self, self.clicked) == 0: @@ -78,7 +79,10 @@ class IconLabelX(LIconLabel, ButtonX): def mouseReleaseEvent(self, ev: QMouseEvent) -> None: if self.rect().contains(ev.pos()): - self.clicked.emit() + if ev.button() == Qt.MouseButton.RightButton: + self.rightclick.emit() + elif ev.button() == Qt.MouseButton.LeftButton: + self.clicked.emit() return super().mouseReleaseEvent(ev) @@ -165,19 +169,28 @@ class ButtonBar(QFrame): btn.setStyleSheet(style) def takusanbuttons( - self, _type, clickfunc, tips, name, belong=None, iconstate=None, colorstate=None + self, + _type, + clickfunc, + rightclick, + tips, + name, + belong=None, + iconstate=None, + colorstate=None, ): button = IconLabelX() + + def callwrap(call): + try: + call() + except: + print_exc() + if clickfunc: - - def callwrap(call): - try: - call() - except: - print_exc() - button.clicked.connect(functools.partial(callwrap, clickfunc)) - + if rightclick: + button.rightclick.connect(functools.partial(callwrap, rightclick)) if tips: button.setToolTip(tips) if _type not in self.stylebuttons: @@ -567,7 +580,13 @@ class TranslatorWindow(resizableframeless): "transerrorfix", gobject.baseobject.commonstylebase ), ), - ("langdu", lambda: gobject.baseobject.readcurrent(force=True)), + ( + "langdu", + lambda: gobject.baseobject.readcurrent(force=True), + None, + None, + lambda: gobject.baseobject.audioplayer.stop(), + ), ( "mousetransbutton", lambda: self.changemousetransparentstate(0), @@ -670,13 +689,13 @@ class TranslatorWindow(resizableframeless): _type = {"quit": 2} for __ in functions: + btn = func = iconstate = colorstate = rightclick = None if len(__) == 2: btn, func = __ - iconstate = colorstate = None elif len(__) == 4: btn, func, iconstate, colorstate = __ - else: - raise + elif len(__) == 5: + btn, func, iconstate, colorstate, rightclick = __ belong = ( globalconfig["toolbutton"]["buttons"][btn]["belong"] if "belong" in globalconfig["toolbutton"]["buttons"][btn] @@ -686,6 +705,7 @@ class TranslatorWindow(resizableframeless): self.titlebar.takusanbuttons( tp, func, + rightclick, globalconfig["toolbutton"]["buttons"][btn]["tip"], btn, belong, diff --git a/LunaTranslator/LunaTranslator/myutils/audioplayer.py b/LunaTranslator/LunaTranslator/myutils/audioplayer.py index 86d2b56e..e5d6fb72 100644 --- a/LunaTranslator/LunaTranslator/myutils/audioplayer.py +++ b/LunaTranslator/LunaTranslator/myutils/audioplayer.py @@ -103,6 +103,13 @@ class series_audioplayer: self.lastcontext = None threading.Thread(target=self.__dotasks).start() + def stop(self): + try: + self.tasks = (None, 0, True) + self.lock.release() + except: + pass + def play(self, binary, volume, force): try: self.tasks = (binary, volume, force) @@ -120,6 +127,8 @@ class series_audioplayer: continue binary, volume, force = task _playonce = None + if not binary: + continue _playonce = playonce(binary, volume) if globalconfig["ttsnointerrupt"]: while _playonce.isplaying: diff --git a/LunaTranslator/files/defaultconfig/config.json b/LunaTranslator/files/defaultconfig/config.json index 9a13fed8..7747dc6d 100644 --- a/LunaTranslator/files/defaultconfig/config.json +++ b/LunaTranslator/files/defaultconfig/config.json @@ -947,6 +947,11 @@ "name": "朗读", "keystring": "" }, + "_7_1": { + "use": false, + "name": "朗读_中断", + "keystring": "" + }, "_8": { "use": false, "name": "鼠标穿透窗口", diff --git a/LunaTranslator/files/lang/ar.json b/LunaTranslator/files/lang/ar.json index 4ada48b3..0945ca22 100644 --- a/LunaTranslator/files/lang/ar.json +++ b/LunaTranslator/files/lang/ar.json @@ -842,5 +842,6 @@ "按键": "مفتاح", "事件": "الأحداث", "按下": "ضغط", - "松开": "خففت" + "松开": "خففت", + "中断": "توقف" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/cht.json b/LunaTranslator/files/lang/cht.json index 20a020d7..e3cd2e65 100644 --- a/LunaTranslator/files/lang/cht.json +++ b/LunaTranslator/files/lang/cht.json @@ -842,5 +842,6 @@ "按键": "按鍵", "事件": "事件", "按下": "按下", - "松开": "鬆開" + "松开": "鬆開", + "中断": "中斷" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/cs.json b/LunaTranslator/files/lang/cs.json index 72a74eb5..ab9a0cf1 100644 --- a/LunaTranslator/files/lang/cs.json +++ b/LunaTranslator/files/lang/cs.json @@ -842,5 +842,6 @@ "按键": "Klíč", "事件": "událost", "按下": "Stiskněte dolů", - "松开": "uvolnění" + "松开": "uvolnění", + "中断": "přerušit" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/de.json b/LunaTranslator/files/lang/de.json index 7579166c..277a6e02 100644 --- a/LunaTranslator/files/lang/de.json +++ b/LunaTranslator/files/lang/de.json @@ -842,5 +842,6 @@ "按键": "Schlüssel", "事件": "Ereignis", "按下": "Drücken Sie nach unten", - "松开": "Freigabe" + "松开": "Freigabe", + "中断": "Unterbrechung" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/en.json b/LunaTranslator/files/lang/en.json index 04bf5408..09b328f8 100644 --- a/LunaTranslator/files/lang/en.json +++ b/LunaTranslator/files/lang/en.json @@ -842,5 +842,6 @@ "按键": "Key", "事件": "event", "按下": "Press down", - "松开": "release" + "松开": "release", + "中断": "interrupt" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/es.json b/LunaTranslator/files/lang/es.json index 5da832f4..d74d6ede 100644 --- a/LunaTranslator/files/lang/es.json +++ b/LunaTranslator/files/lang/es.json @@ -842,5 +842,6 @@ "按键": "Teclas", "事件": "Incidencias", "按下": "Presionar", - "松开": "Soltar" + "松开": "Soltar", + "中断": "Interrupción" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/fr.json b/LunaTranslator/files/lang/fr.json index e4b25bd1..f222ff52 100644 --- a/LunaTranslator/files/lang/fr.json +++ b/LunaTranslator/files/lang/fr.json @@ -842,5 +842,6 @@ "按键": "Appuyez sur la clé", "事件": "Événements", "按下": "Appuyez sur", - "松开": "Desserrer" + "松开": "Desserrer", + "中断": "Interruption" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/it.json b/LunaTranslator/files/lang/it.json index 11d3f0ec..f618967f 100644 --- a/LunaTranslator/files/lang/it.json +++ b/LunaTranslator/files/lang/it.json @@ -842,5 +842,6 @@ "按键": "Chiave", "事件": "evento", "按下": "Premere verso il basso", - "松开": "rilascio" + "松开": "rilascio", + "中断": "interrupt" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/ja.json b/LunaTranslator/files/lang/ja.json index 8c183c05..692fa7f9 100644 --- a/LunaTranslator/files/lang/ja.json +++ b/LunaTranslator/files/lang/ja.json @@ -842,5 +842,6 @@ "按键": "キーを押す", "事件": "イベント#イベント#", "按下": "押す", - "松开": "ゆるめる" + "松开": "ゆるめる", + "中断": "わりこみ" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/ko.json b/LunaTranslator/files/lang/ko.json index 7d856edc..20225420 100644 --- a/LunaTranslator/files/lang/ko.json +++ b/LunaTranslator/files/lang/ko.json @@ -842,5 +842,6 @@ "按键": "키", "事件": "이벤트", "按下": "누르기", - "松开": "풀어" + "松开": "풀어", + "中断": "중단" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/nl.json b/LunaTranslator/files/lang/nl.json index 7852511f..67d02e84 100644 --- a/LunaTranslator/files/lang/nl.json +++ b/LunaTranslator/files/lang/nl.json @@ -842,5 +842,6 @@ "按键": "Sleutel", "事件": "gebeurtenis", "按下": "Druk omlaag", - "松开": "release" + "松开": "release", + "中断": "onderbreken" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/pl.json b/LunaTranslator/files/lang/pl.json index fe6c55bc..11e71d6d 100644 --- a/LunaTranslator/files/lang/pl.json +++ b/LunaTranslator/files/lang/pl.json @@ -842,5 +842,6 @@ "按键": "Klucz", "事件": "zdarzenie", "按下": "Naciśnij w dół", - "松开": "uwolnienie" + "松开": "uwolnienie", + "中断": "przerwać" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/pt.json b/LunaTranslator/files/lang/pt.json index 9180d9e1..fa41b95b 100644 --- a/LunaTranslator/files/lang/pt.json +++ b/LunaTranslator/files/lang/pt.json @@ -842,5 +842,6 @@ "按键": "Chave", "事件": "evento", "按下": "Pressione para baixo", - "松开": "libertação" + "松开": "libertação", + "中断": "interromper" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/ru.json b/LunaTranslator/files/lang/ru.json index 3ae0ac72..eb8ecbea 100644 --- a/LunaTranslator/files/lang/ru.json +++ b/LunaTranslator/files/lang/ru.json @@ -842,5 +842,6 @@ "按键": "Клавиши", "事件": "События", "按下": "Нажмите", - "松开": "Отпусти." + "松开": "Отпусти.", + "中断": "Прерывание" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/sv.json b/LunaTranslator/files/lang/sv.json index e09fb2c4..7187dfd8 100644 --- a/LunaTranslator/files/lang/sv.json +++ b/LunaTranslator/files/lang/sv.json @@ -842,5 +842,6 @@ "按键": "Nyckel", "事件": "händelse", "按下": "Tryck ner", - "松开": "frigörande" + "松开": "frigörande", + "中断": "avbryt" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/th.json b/LunaTranslator/files/lang/th.json index c85fc84e..c63737d2 100644 --- a/LunaTranslator/files/lang/th.json +++ b/LunaTranslator/files/lang/th.json @@ -842,5 +842,6 @@ "按键": "ปุ่มกด", "事件": "กิจกรรม", "按下": "กด", - "松开": "ปล่อย" + "松开": "ปล่อย", + "中断": "หยุดชะงัก" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/tr.json b/LunaTranslator/files/lang/tr.json index 6ebb32df..56390a0a 100644 --- a/LunaTranslator/files/lang/tr.json +++ b/LunaTranslator/files/lang/tr.json @@ -842,5 +842,6 @@ "按键": "Anahtar", "事件": "Olay", "按下": "Aşağı basın", - "松开": "serbest" + "松开": "serbest", + "中断": "bölme" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/uk.json b/LunaTranslator/files/lang/uk.json index c54119ed..077dbafd 100644 --- a/LunaTranslator/files/lang/uk.json +++ b/LunaTranslator/files/lang/uk.json @@ -842,5 +842,6 @@ "按键": "Ключ", "事件": "подія", "按下": "Натисніть вниз", - "松开": "випускати" + "松开": "випускати", + "中断": "перервати" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/vi.json b/LunaTranslator/files/lang/vi.json index a632892c..adba5564 100644 --- a/LunaTranslator/files/lang/vi.json +++ b/LunaTranslator/files/lang/vi.json @@ -842,5 +842,6 @@ "按键": "Phím", "事件": "Sự kiện", "按下": "Nhấn", - "松开": "Thả lỏng" + "松开": "Thả lỏng", + "中断": "Ngắt" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/zh.json b/LunaTranslator/files/lang/zh.json index b4f3344c..1a660580 100644 --- a/LunaTranslator/files/lang/zh.json +++ b/LunaTranslator/files/lang/zh.json @@ -843,7 +843,5 @@ "事件": "", "按下": "", "松开": "", - "v0.10pre1(支持gpt词典)": "", - "prompt格式(需要根据模型版本决定)": "", - "英文": "" + "中断": "" } \ No newline at end of file diff --git a/docs/zh/alltoolbuttons.md b/docs/zh/alltoolbuttons.md index ff975e9d..72a2f61a 100644 --- a/docs/zh/alltoolbuttons.md +++ b/docs/zh/alltoolbuttons.md @@ -97,8 +97,7 @@ 1. #### 显示/隐藏翻译 切换是否显示翻译的状态,当下一次读取文本时,才真正生效。 1. #### 朗读 - 对当前文本进行语音合成。
- 该朗读会无视`跳过`(如果在`语音指定`中,匹配当前文本目标为`跳过`,则使用按钮进行朗读时,会无视跳过,强制进行朗读) + 左击按钮会对当前文本进行语音合成。
右击该按钮会中断朗读。
该朗读会无视`跳过`(如果在`语音指定`中,匹配当前文本目标为`跳过`,则使用按钮进行朗读时,会无视跳过,强制进行朗读) 1. #### 复制到剪贴板 复制当前提取到的文本到剪贴板一次。如果想要自动提取到剪贴板,应当激活`文本输入`->`文本输出`->`剪贴板`->`自动输出`。 1. #### 显示/隐藏历史翻译