mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-28 08:04:13 +08:00
ui
This commit is contained in:
parent
07a480c7b8
commit
714c31846e
@ -1,5 +1,6 @@
|
||||
import functools, os
|
||||
import gobject
|
||||
from myutils.utils import splitocrtypes
|
||||
from myutils.config import globalconfig
|
||||
from gui.inputdialog import autoinitdialog, autoinitdialog_items
|
||||
from gui.usefulwidget import (
|
||||
@ -108,21 +109,11 @@ def vistranslate_rank(self):
|
||||
)
|
||||
|
||||
|
||||
def setTabcishu_l(self):
|
||||
|
||||
grids = [
|
||||
[
|
||||
(
|
||||
dict(title="分词器", type="grid", grid=gethiragrid(self)),
|
||||
0,
|
||||
"group",
|
||||
)
|
||||
],
|
||||
]
|
||||
def initinternal(self, names):
|
||||
cishugrid = []
|
||||
line = []
|
||||
i = 0
|
||||
for cishu in globalconfig["cishu"]:
|
||||
for cishu in names:
|
||||
_f = "./LunaTranslator/cishu/{}.py".format(cishu)
|
||||
if os.path.exists(_f) == False:
|
||||
continue
|
||||
@ -163,10 +154,52 @@ def setTabcishu_l(self):
|
||||
i += 1
|
||||
if len(line):
|
||||
cishugrid.append(line)
|
||||
return cishugrid
|
||||
|
||||
|
||||
def setTabcishu_l(self):
|
||||
|
||||
grids = [
|
||||
[
|
||||
(
|
||||
dict(title="分词器", type="grid", grid=gethiragrid(self)),
|
||||
0,
|
||||
"group",
|
||||
)
|
||||
],
|
||||
]
|
||||
offline, online = splitocrtypes(globalconfig["cishu"])
|
||||
grids += [
|
||||
[
|
||||
(
|
||||
dict(title="辞书", type="grid", grid=cishugrid),
|
||||
dict(
|
||||
title="辞书",
|
||||
type="grid",
|
||||
grid=[
|
||||
[
|
||||
(
|
||||
dict(
|
||||
title="离线",
|
||||
type="grid",
|
||||
grid=initinternal(self, offline),
|
||||
),
|
||||
0,
|
||||
"group",
|
||||
)
|
||||
],
|
||||
[
|
||||
(
|
||||
dict(
|
||||
title="在线",
|
||||
type="grid",
|
||||
grid=initinternal(self, online),
|
||||
),
|
||||
0,
|
||||
"group",
|
||||
)
|
||||
],
|
||||
],
|
||||
),
|
||||
0,
|
||||
"group",
|
||||
)
|
||||
|
@ -339,11 +339,6 @@ def _createseletengeinecombo(self):
|
||||
return self.seletengeinecombo
|
||||
|
||||
|
||||
def __changeselectablestate(self, x):
|
||||
gobject.baseobject.translation_ui.refreshtoolicon()
|
||||
gobject.baseobject.translation_ui.translate_text.textbrowser.setselectable(x)
|
||||
|
||||
|
||||
def vistranslate_rank(self):
|
||||
_not = []
|
||||
for i, k in enumerate(globalconfig["fix_translate_rank_rank"]):
|
||||
@ -370,63 +365,94 @@ def xianshigrid_text(self):
|
||||
type="grid",
|
||||
grid=(
|
||||
[
|
||||
"可选取的",
|
||||
D_getsimpleswitch(
|
||||
globalconfig,
|
||||
"selectable",
|
||||
callback=functools.partial(
|
||||
__changeselectablestate, self
|
||||
(
|
||||
dict(
|
||||
title="原文",
|
||||
type="grid",
|
||||
grid=(
|
||||
[
|
||||
"显示原文",
|
||||
D_getsimpleswitch(
|
||||
globalconfig,
|
||||
"isshowrawtext",
|
||||
callback=lambda x: __changeuibuttonstate(
|
||||
self, x
|
||||
),
|
||||
name="show_original_switch",
|
||||
parent=self,
|
||||
),
|
||||
"",
|
||||
"居中显示",
|
||||
D_getsimpleswitch(
|
||||
globalconfig, "showatcenter"
|
||||
),
|
||||
"",
|
||||
"最长显示字数",
|
||||
D_getspinbox(
|
||||
0,
|
||||
1000000,
|
||||
globalconfig,
|
||||
"maxoriginlength",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
parent=self,
|
||||
name="selectable_btn",
|
||||
),
|
||||
0,
|
||||
"group",
|
||||
)
|
||||
],
|
||||
[
|
||||
"显示原文",
|
||||
D_getsimpleswitch(
|
||||
globalconfig,
|
||||
"isshowrawtext",
|
||||
callback=lambda x: __changeuibuttonstate(self, x),
|
||||
name="show_original_switch",
|
||||
parent=self,
|
||||
),
|
||||
"",
|
||||
"最长显示字数",
|
||||
D_getspinbox(0, 1000000, globalconfig, "maxoriginlength"),
|
||||
"",
|
||||
],
|
||||
[
|
||||
"显示翻译",
|
||||
D_getsimpleswitch(
|
||||
globalconfig,
|
||||
"showfanyi",
|
||||
callback=lambda x: __changeuibuttonstate2(self, x),
|
||||
name="show_fany_switch",
|
||||
parent=self,
|
||||
),
|
||||
"",
|
||||
("显示翻译器名称"),
|
||||
D_getsimpleswitch(globalconfig, "showfanyisource"),
|
||||
"",
|
||||
],
|
||||
[
|
||||
"收到翻译时才刷新",
|
||||
D_getsimpleswitch(globalconfig, "refresh_on_get_trans"),
|
||||
"",
|
||||
"显示错误信息",
|
||||
D_getsimpleswitch(globalconfig, "showtranexception"),
|
||||
"",
|
||||
],
|
||||
[
|
||||
"固定翻译显示顺序",
|
||||
D_getsimpleswitch(globalconfig, "fix_translate_rank"),
|
||||
D_getIconButton(
|
||||
functools.partial(vistranslate_rank, self), "fa.gear"
|
||||
),
|
||||
],
|
||||
[
|
||||
"居中显示",
|
||||
D_getsimpleswitch(globalconfig, "showatcenter"),
|
||||
(
|
||||
dict(
|
||||
title="翻译",
|
||||
type="grid",
|
||||
grid=(
|
||||
[
|
||||
"显示翻译",
|
||||
D_getsimpleswitch(
|
||||
globalconfig,
|
||||
"showfanyi",
|
||||
callback=lambda x: __changeuibuttonstate2(
|
||||
self, x
|
||||
),
|
||||
name="show_fany_switch",
|
||||
parent=self,
|
||||
),
|
||||
"",
|
||||
"固定翻译显示顺序",
|
||||
D_getsimpleswitch(
|
||||
globalconfig, "fix_translate_rank"
|
||||
),
|
||||
D_getIconButton(
|
||||
functools.partial(
|
||||
vistranslate_rank, self
|
||||
),
|
||||
"fa.gear",
|
||||
),
|
||||
],
|
||||
[
|
||||
"显示翻译器名称",
|
||||
D_getsimpleswitch(
|
||||
globalconfig, "showfanyisource"
|
||||
),
|
||||
"",
|
||||
"显示错误信息",
|
||||
D_getsimpleswitch(
|
||||
globalconfig, "showtranexception"
|
||||
),
|
||||
"",
|
||||
"",
|
||||
"收到翻译时才刷新",
|
||||
D_getsimpleswitch(
|
||||
globalconfig, "refresh_on_get_trans"
|
||||
),
|
||||
"",
|
||||
],
|
||||
),
|
||||
),
|
||||
0,
|
||||
"group",
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -251,6 +251,11 @@ def uisetting(self, l):
|
||||
do()
|
||||
|
||||
|
||||
def __changeselectablestate(self, x):
|
||||
gobject.baseobject.translation_ui.refreshtoolicon()
|
||||
gobject.baseobject.translation_ui.translate_text.textbrowser.setselectable(x)
|
||||
|
||||
|
||||
def mainuisetting(self):
|
||||
|
||||
return (
|
||||
@ -293,8 +298,16 @@ def mainuisetting(self):
|
||||
callback=lambda _: gobject.baseobject.translation_ui.set_color_transparency(),
|
||||
),
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"可选取的",
|
||||
D_getsimpleswitch(
|
||||
globalconfig,
|
||||
"selectable",
|
||||
callback=functools.partial(
|
||||
__changeselectablestate, self
|
||||
),
|
||||
parent=self,
|
||||
name="selectable_btn",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -132,7 +132,7 @@ def getocrgrid(self):
|
||||
|
||||
grids = []
|
||||
|
||||
offline, online = splitocrtypes()
|
||||
offline, online = splitocrtypes(globalconfig["ocr"])
|
||||
self.ocrswitchs = {}
|
||||
|
||||
def vissolvebtn():
|
||||
|
@ -1,6 +1,7 @@
|
||||
from qtsymbols import *
|
||||
import os, functools
|
||||
import gobject
|
||||
from myutils.utils import splitocrtypes, translate_exits
|
||||
from myutils.config import globalconfig, static_data
|
||||
from gui.inputdialog import (
|
||||
autoinitdialog_items,
|
||||
@ -64,13 +65,13 @@ def setTab5(self, l):
|
||||
makescrollgrid(setTab5lz(self), l)
|
||||
|
||||
|
||||
def getttsgrid(self):
|
||||
def getttsgrid(self, names):
|
||||
|
||||
grids = []
|
||||
i = 0
|
||||
self.ttswitchs = {}
|
||||
line = []
|
||||
for name in globalconfig["reader"]:
|
||||
for name in names:
|
||||
|
||||
_f = "./LunaTranslator/tts/{}.py".format(name)
|
||||
if os.path.exists(_f) == False:
|
||||
@ -126,10 +127,45 @@ def getttsgrid(self):
|
||||
|
||||
def setTab5lz(self):
|
||||
grids = []
|
||||
offline, online = splitocrtypes(globalconfig["reader"])
|
||||
alltransvis = []
|
||||
alltrans = []
|
||||
for x in globalconfig["fanyi"]:
|
||||
if not translate_exits(x):
|
||||
continue
|
||||
alltransvis.append(globalconfig["fanyi"][x]["name"])
|
||||
alltrans.append(x)
|
||||
grids += [
|
||||
[
|
||||
(
|
||||
dict(title="引擎", type="grid", grid=getttsgrid(self)),
|
||||
dict(
|
||||
title="引擎",
|
||||
type="grid",
|
||||
grid=[
|
||||
[
|
||||
(
|
||||
dict(
|
||||
title="离线",
|
||||
type="grid",
|
||||
grid=getttsgrid(self, offline),
|
||||
),
|
||||
0,
|
||||
"group",
|
||||
)
|
||||
],
|
||||
[
|
||||
(
|
||||
dict(
|
||||
title="在线",
|
||||
type="grid",
|
||||
grid=getttsgrid(self, online),
|
||||
),
|
||||
0,
|
||||
"group",
|
||||
)
|
||||
],
|
||||
],
|
||||
),
|
||||
0,
|
||||
"group",
|
||||
)
|
||||
@ -164,64 +200,96 @@ def setTab5lz(self):
|
||||
type="grid",
|
||||
grid=[
|
||||
[
|
||||
"自动朗读",
|
||||
D_getsimpleswitch(
|
||||
globalconfig, "autoread", name="autoread", parent=self
|
||||
),
|
||||
],
|
||||
[
|
||||
"不被打断",
|
||||
D_getsimpleswitch(globalconfig, "ttsnointerrupt"),
|
||||
],
|
||||
[
|
||||
"朗读原文",
|
||||
D_getsimpleswitch(globalconfig, "read_raw"),
|
||||
],
|
||||
[
|
||||
"朗读翻译",
|
||||
D_getsimpleswitch(globalconfig, "read_trans"),
|
||||
],
|
||||
[
|
||||
"朗读的翻译",
|
||||
(
|
||||
D_getsimplecombobox(
|
||||
[
|
||||
globalconfig["fanyi"][x]["name"]
|
||||
for x in globalconfig["fanyi"]
|
||||
dict(
|
||||
type="grid",
|
||||
grid=[
|
||||
[
|
||||
"自动朗读",
|
||||
D_getsimpleswitch(
|
||||
globalconfig,
|
||||
"autoread",
|
||||
name="autoread",
|
||||
parent=self,
|
||||
),
|
||||
"",
|
||||
"不被打断",
|
||||
D_getsimpleswitch(
|
||||
globalconfig, "ttsnointerrupt"
|
||||
),
|
||||
],
|
||||
[
|
||||
"朗读原文",
|
||||
D_getsimpleswitch(globalconfig, "read_raw"),
|
||||
"",
|
||||
"朗读翻译",
|
||||
D_getsimpleswitch(
|
||||
globalconfig, "read_trans"
|
||||
),
|
||||
D_getsimplecombobox(
|
||||
alltransvis,
|
||||
globalconfig,
|
||||
"read_translator",
|
||||
internal=alltrans,
|
||||
),
|
||||
"",
|
||||
],
|
||||
],
|
||||
globalconfig,
|
||||
"read_translator",
|
||||
),
|
||||
0,
|
||||
),
|
||||
"group",
|
||||
)
|
||||
],
|
||||
[
|
||||
"语音指定",
|
||||
D_getsimpleswitch(globalconfig["ttscommon"], "tts_skip"),
|
||||
D_getIconButton(
|
||||
callback=lambda: yuyinzhidingsetting(
|
||||
self, globalconfig["ttscommon"]["tts_skip_regex"]
|
||||
(
|
||||
dict(
|
||||
type="grid",
|
||||
grid=[
|
||||
[
|
||||
"语音指定",
|
||||
D_getsimpleswitch(
|
||||
globalconfig["ttscommon"], "tts_skip"
|
||||
),
|
||||
D_getIconButton(
|
||||
callback=lambda: yuyinzhidingsetting(
|
||||
self,
|
||||
globalconfig["ttscommon"][
|
||||
"tts_skip_regex"
|
||||
],
|
||||
),
|
||||
icon="fa.gear",
|
||||
),
|
||||
],
|
||||
[
|
||||
"语音修正",
|
||||
D_getsimpleswitch(
|
||||
globalconfig["ttscommon"], "tts_repair"
|
||||
),
|
||||
D_getIconButton(
|
||||
callback=lambda: noundictconfigdialog1(
|
||||
self,
|
||||
globalconfig["ttscommon"][
|
||||
"tts_repair_regex"
|
||||
],
|
||||
"语音修正",
|
||||
["正则", "转义", "原文", "替换"],
|
||||
),
|
||||
icon="fa.gear",
|
||||
),
|
||||
"",
|
||||
D_getsimpleswitch(
|
||||
globalconfig["ttscommon"],
|
||||
"tts_repair_use_at_translate",
|
||||
),
|
||||
"作用于翻译",
|
||||
"",
|
||||
"",
|
||||
],
|
||||
],
|
||||
),
|
||||
icon="fa.gear",
|
||||
),
|
||||
],
|
||||
[
|
||||
"语音修正",
|
||||
D_getsimpleswitch(globalconfig["ttscommon"], "tts_repair"),
|
||||
D_getIconButton(
|
||||
callback=lambda: noundictconfigdialog1(
|
||||
self,
|
||||
globalconfig["ttscommon"]["tts_repair_regex"],
|
||||
"语音修正",
|
||||
["正则", "转义", "原文", "替换"],
|
||||
),
|
||||
icon="fa.gear",
|
||||
),
|
||||
"",
|
||||
D_getsimpleswitch(
|
||||
globalconfig["ttscommon"], "tts_repair_use_at_translate"
|
||||
),
|
||||
"作用于翻译",
|
||||
0,
|
||||
"group",
|
||||
)
|
||||
],
|
||||
],
|
||||
),
|
||||
|
@ -317,13 +317,13 @@ def splittranslatortypes():
|
||||
return offline, pre, free, dev, api
|
||||
|
||||
|
||||
def splitocrtypes():
|
||||
def splitocrtypes(dic):
|
||||
offline, online = [], []
|
||||
for k in globalconfig["ocr"]:
|
||||
for k in dic:
|
||||
try:
|
||||
{"online": online, "offline": offline}[
|
||||
globalconfig["ocr"][k].get("type", "online")
|
||||
].append(k)
|
||||
{"online": online, "offline": offline}[dic[k].get("type", "online")].append(
|
||||
k
|
||||
)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
@ -1055,7 +1055,7 @@
|
||||
},
|
||||
"reader": {
|
||||
"windowstts": {
|
||||
"use": false,
|
||||
"use": true,
|
||||
"voice": "",
|
||||
"name": "WindowsTTS",
|
||||
"type": "offline"
|
||||
|
@ -29,7 +29,7 @@ include(generate_product_version)
|
||||
|
||||
set(VERSION_MAJOR 5)
|
||||
set(VERSION_MINOR 26)
|
||||
set(VERSION_PATCH 2)
|
||||
set(VERSION_PATCH 3)
|
||||
|
||||
add_library(pch pch.cpp)
|
||||
target_precompile_headers(pch PUBLIC pch.h)
|
||||
|
Loading…
x
Reference in New Issue
Block a user