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