恍兮惚兮 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, "_51": gobject.baseobject.translation_ui.changeshowhidetrans,
"_6": lambda: gobject.baseobject.transhis.showsignal.emit(), "_6": lambda: gobject.baseobject.transhis.showsignal.emit(),
"_7": lambda: gobject.baseobject.readcurrent(force=True), "_7": lambda: gobject.baseobject.readcurrent(force=True),
"_7_1": lambda: gobject.baseobject.audioplayer.stop(),
"_8": lambda: gobject.baseobject.translation_ui.changemousetransparentstate(0), "_8": lambda: gobject.baseobject.translation_ui.changemousetransparentstate(0),
"_9": gobject.baseobject.translation_ui.changetoolslockstate, "_9": gobject.baseobject.translation_ui.changetoolslockstate,
"_10": lambda: gobject.baseobject.translation_ui.showsavegame_signal.emit(), "_10": lambda: gobject.baseobject.translation_ui.showsavegame_signal.emit(),

View File

@ -71,6 +71,7 @@ class ButtonX(QWidget):
class IconLabelX(LIconLabel, ButtonX): class IconLabelX(LIconLabel, ButtonX):
clicked = pyqtSignal() clicked = pyqtSignal()
rightclick = pyqtSignal()
def mousePressEvent(self, ev: QMouseEvent) -> None: def mousePressEvent(self, ev: QMouseEvent) -> None:
if QObject.receivers(self, self.clicked) == 0: if QObject.receivers(self, self.clicked) == 0:
@ -78,7 +79,10 @@ class IconLabelX(LIconLabel, ButtonX):
def mouseReleaseEvent(self, ev: QMouseEvent) -> None: def mouseReleaseEvent(self, ev: QMouseEvent) -> None:
if self.rect().contains(ev.pos()): 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) return super().mouseReleaseEvent(ev)
@ -165,19 +169,28 @@ class ButtonBar(QFrame):
btn.setStyleSheet(style) btn.setStyleSheet(style)
def takusanbuttons( 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() button = IconLabelX()
def callwrap(call):
try:
call()
except:
print_exc()
if clickfunc: if clickfunc:
def callwrap(call):
try:
call()
except:
print_exc()
button.clicked.connect(functools.partial(callwrap, clickfunc)) button.clicked.connect(functools.partial(callwrap, clickfunc))
if rightclick:
button.rightclick.connect(functools.partial(callwrap, rightclick))
if tips: if tips:
button.setToolTip(tips) button.setToolTip(tips)
if _type not in self.stylebuttons: if _type not in self.stylebuttons:
@ -567,7 +580,13 @@ class TranslatorWindow(resizableframeless):
"transerrorfix", gobject.baseobject.commonstylebase "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", "mousetransbutton",
lambda: self.changemousetransparentstate(0), lambda: self.changemousetransparentstate(0),
@ -670,13 +689,13 @@ class TranslatorWindow(resizableframeless):
_type = {"quit": 2} _type = {"quit": 2}
for __ in functions: for __ in functions:
btn = func = iconstate = colorstate = rightclick = None
if len(__) == 2: if len(__) == 2:
btn, func = __ btn, func = __
iconstate = colorstate = None
elif len(__) == 4: elif len(__) == 4:
btn, func, iconstate, colorstate = __ btn, func, iconstate, colorstate = __
else: elif len(__) == 5:
raise btn, func, iconstate, colorstate, rightclick = __
belong = ( belong = (
globalconfig["toolbutton"]["buttons"][btn]["belong"] globalconfig["toolbutton"]["buttons"][btn]["belong"]
if "belong" in globalconfig["toolbutton"]["buttons"][btn] if "belong" in globalconfig["toolbutton"]["buttons"][btn]
@ -686,6 +705,7 @@ class TranslatorWindow(resizableframeless):
self.titlebar.takusanbuttons( self.titlebar.takusanbuttons(
tp, tp,
func, func,
rightclick,
globalconfig["toolbutton"]["buttons"][btn]["tip"], globalconfig["toolbutton"]["buttons"][btn]["tip"],
btn, btn,
belong, belong,

View File

@ -103,6 +103,13 @@ class series_audioplayer:
self.lastcontext = None self.lastcontext = None
threading.Thread(target=self.__dotasks).start() 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): def play(self, binary, volume, force):
try: try:
self.tasks = (binary, volume, force) self.tasks = (binary, volume, force)
@ -120,6 +127,8 @@ class series_audioplayer:
continue continue
binary, volume, force = task binary, volume, force = task
_playonce = None _playonce = None
if not binary:
continue
_playonce = playonce(binary, volume) _playonce = playonce(binary, volume)
if globalconfig["ttsnointerrupt"]: if globalconfig["ttsnointerrupt"]:
while _playonce.isplaying: while _playonce.isplaying:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -842,5 +842,6 @@
"按键": "Chiave", "按键": "Chiave",
"事件": "evento", "事件": "evento",
"按下": "Premere verso il basso", "按下": "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", "按键": "Sleutel",
"事件": "gebeurtenis", "事件": "gebeurtenis",
"按下": "Druk omlaag", "按下": "Druk omlaag",
"松开": "release" "松开": "release",
"中断": "onderbreken"
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -842,5 +842,6 @@
"按键": "Phím", "按键": "Phím",
"事件": "Sự kiện", "事件": "Sự kiện",
"按下": "Nhấ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-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> 朗读 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-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> 显示/隐藏历史翻译 1. #### <i class="fa fa-rotate-left"></i> <i class="fa fa-icon fa-rotate-right"></i> 显示/隐藏历史翻译