恍兮惚兮 2024-08-26 21:55:46 +08:00
parent 9be5ac3606
commit 36b901412c
25 changed files with 89 additions and 38 deletions

View File

@ -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(),

View File

@ -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,

View File

@ -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:

View File

@ -947,6 +947,11 @@
"name": "朗读",
"keystring": ""
},
"_7_1": {
"use": false,
"name": "朗读_中断",
"keystring": ""
},
"_8": {
"use": false,
"name": "鼠标穿透窗口",

View File

@ -842,5 +842,6 @@
"按键": "مفتاح",
"事件": "الأحداث",
"按下": "ضغط",
"松开": "خففت"
"松开": "خففت",
"中断": "توقف"
}

View File

@ -842,5 +842,6 @@
"按键": "按鍵",
"事件": "事件",
"按下": "按下",
"松开": "鬆開"
"松开": "鬆開",
"中断": "中斷"
}

View File

@ -842,5 +842,6 @@
"按键": "Klíč",
"事件": "událost",
"按下": "Stiskněte dolů",
"松开": "uvolnění"
"松开": "uvolnění",
"中断": "přerušit"
}

View File

@ -842,5 +842,6 @@
"按键": "Schlüssel",
"事件": "Ereignis",
"按下": "Drücken Sie nach unten",
"松开": "Freigabe"
"松开": "Freigabe",
"中断": "Unterbrechung"
}

View File

@ -842,5 +842,6 @@
"按键": "Key",
"事件": "event",
"按下": "Press down",
"松开": "release"
"松开": "release",
"中断": "interrupt"
}

View File

@ -842,5 +842,6 @@
"按键": "Teclas",
"事件": "Incidencias",
"按下": "Presionar",
"松开": "Soltar"
"松开": "Soltar",
"中断": "Interrupción"
}

View File

@ -842,5 +842,6 @@
"按键": "Appuyez sur la clé",
"事件": "Événements",
"按下": "Appuyez sur",
"松开": "Desserrer"
"松开": "Desserrer",
"中断": "Interruption"
}

View File

@ -842,5 +842,6 @@
"按键": "Chiave",
"事件": "evento",
"按下": "Premere verso il basso",
"松开": "rilascio"
"松开": "rilascio",
"中断": "interrupt"
}

View File

@ -842,5 +842,6 @@
"按键": "キーを押す",
"事件": "イベント#イベント#",
"按下": "押す",
"松开": "ゆるめる"
"松开": "ゆるめる",
"中断": "わりこみ"
}

View File

@ -842,5 +842,6 @@
"按键": "키",
"事件": "이벤트",
"按下": "누르기",
"松开": "풀어"
"松开": "풀어",
"中断": "중단"
}

View File

@ -842,5 +842,6 @@
"按键": "Sleutel",
"事件": "gebeurtenis",
"按下": "Druk omlaag",
"松开": "release"
"松开": "release",
"中断": "onderbreken"
}

View File

@ -842,5 +842,6 @@
"按键": "Klucz",
"事件": "zdarzenie",
"按下": "Naciśnij w dół",
"松开": "uwolnienie"
"松开": "uwolnienie",
"中断": "przerwać"
}

View File

@ -842,5 +842,6 @@
"按键": "Chave",
"事件": "evento",
"按下": "Pressione para baixo",
"松开": "libertação"
"松开": "libertação",
"中断": "interromper"
}

View File

@ -842,5 +842,6 @@
"按键": "Клавиши",
"事件": "События",
"按下": "Нажмите",
"松开": "Отпусти."
"松开": "Отпусти.",
"中断": "Прерывание"
}

View File

@ -842,5 +842,6 @@
"按键": "Nyckel",
"事件": "händelse",
"按下": "Tryck ner",
"松开": "frigörande"
"松开": "frigörande",
"中断": "avbryt"
}

View File

@ -842,5 +842,6 @@
"按键": "ปุ่มกด",
"事件": "กิจกรรม",
"按下": "กด",
"松开": "ปล่อย"
"松开": "ปล่อย",
"中断": "หยุดชะงัก"
}

View File

@ -842,5 +842,6 @@
"按键": "Anahtar",
"事件": "Olay",
"按下": "Aşağı basın",
"松开": "serbest"
"松开": "serbest",
"中断": "bölme"
}

View File

@ -842,5 +842,6 @@
"按键": "Ключ",
"事件": "подія",
"按下": "Натисніть вниз",
"松开": "випускати"
"松开": "випускати",
"中断": "перервати"
}

View File

@ -842,5 +842,6 @@
"按键": "Phím",
"事件": "Sự kiện",
"按下": "Nhấn",
"松开": "Thả lỏng"
"松开": "Thả lỏng",
"中断": "Ngắt"
}

View File

@ -843,7 +843,5 @@
"事件": "",
"按下": "",
"松开": "",
"v0.10pre1支持gpt词典": "",
"prompt格式需要根据模型版本决定": "",
"英文": ""
"中断": ""
}

View File

@ -97,8 +97,7 @@
1. #### <i class="fa fa-eye"></i> <i class="btnstatus2 fa fa-eye-slash"></i> 显示/隐藏翻译
切换是否显示翻译的状态,当下一次读取文本时,才真正生效。
1. #### <i class="fa fa-music"></i> <i class="fa fa-icon fa-rotate-right"></i> 朗读
对当前文本进行语音合成。<br>
该朗读会无视`跳过`(如果在`语音指定`中,匹配当前文本目标为`跳过`,则使用按钮进行朗读时,会无视跳过,强制进行朗读)
左击按钮会对当前文本进行语音合成。<br>右击该按钮会中断朗读。<br> 该朗读会无视`跳过`(如果在`语音指定`中,匹配当前文本目标为`跳过`,则使用按钮进行朗读时,会无视跳过,强制进行朗读)
1. #### <i class="fa fa-copy"></i> <i class="fa fa-icon fa-rotate-right"></i> 复制到剪贴板
复制当前提取到的文本到剪贴板一次。如果想要自动提取到剪贴板,应当激活`文本输入`->`文本输出`->`剪贴板`->`自动输出`。
1. #### <i class="fa fa-rotate-left"></i> <i class="fa fa-icon fa-rotate-right"></i> 显示/隐藏历史翻译