Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
HIllya51 committed Jan 21, 2025
1 parent 0196b3e commit 72e5d90
Show file tree
Hide file tree
Showing 14 changed files with 283 additions and 158 deletions.
4 changes: 2 additions & 2 deletions cpp/version.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

set(VERSION_MAJOR 7)
set(VERSION_MINOR 1)
set(VERSION_PATCH 8)
set(VERSION_MINOR 2)
set(VERSION_PATCH 0)
set(VERSION_REVISION 0)
set(LUNA_VERSION "{${VERSION_MAJOR},${VERSION_MINOR},${VERSION_PATCH},${VERSION_REVISION}}")
add_library(VERSION_DEF ${CMAKE_CURRENT_LIST_DIR}/version_def.cpp)
Expand Down
4 changes: 2 additions & 2 deletions py/LunaTranslator/LunaTranslator.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,9 @@ def maybeneedtranslateshowhidetranslate(self):
if globalconfig["showfanyi"]:
if not self.thishastranslated:
self.textgetmethod(self.currenttext, is_auto_run=False)
self.translation_ui.translate_text.textbrowser.showhidetranslate(True)
self.translation_ui.translate_text.showhidetranslate(True)
else:
self.translation_ui.translate_text.textbrowser.showhidetranslate(False)
self.translation_ui.translate_text.showhidetranslate(False)

def textgetmethod(
self,
Expand Down
27 changes: 19 additions & 8 deletions py/LunaTranslator/gui/inputdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,10 +768,13 @@ def __init__(self, parent) -> None:
_hori = QHBoxLayout()
l = LLabel("不透明度")
_hori.addWidget(l)
_s = FocusSpin()
_s.setValue(globalconfig["showcixing_touming"])
_s.setMinimum(1)
_s.setMaximum(100)
_s = getspinbox(
1,
100,
d=globalconfig,
key="showcixing_touming",
callback=gobject.baseobject.translation_ui.translate_text.setcolorstyle,
)
_hori.addWidget(_s)
formLayout.addRow(_hori)
_s.valueChanged.connect(
Expand All @@ -788,9 +791,10 @@ def __init__(self, parent) -> None:

hori.addWidget(l)

b = MySwitch(sign=globalconfig["cixingcolorshow"][k])
b.clicked.connect(
functools.partial(globalconfig["cixingcolorshow"].__setitem__, k)
b = getsimpleswitch(
d=globalconfig["cixingcolorshow"],
key=k,
callback=gobject.baseobject.translation_ui.translate_text.setcolorstyle,
)

p = getcolorbutton(
Expand All @@ -801,7 +805,14 @@ def __init__(self, parent) -> None:
)

p.clicked.connect(
functools.partial(selectcolor, self, globalconfig["cixingcolor"], k, p)
functools.partial(
selectcolor,
self,
globalconfig["cixingcolor"],
k,
p,
callback=gobject.baseobject.translation_ui.translate_text.setcolorstyle,
)
)
hori.addWidget(b)
hori.addWidget(p)
Expand Down
33 changes: 23 additions & 10 deletions py/LunaTranslator/gui/setting_cishu.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,6 @@ def initinternal(self, names):
return cishugrid


def mayberealtimesetfont(_=None):
gobject.baseobject.translation_ui.translate_text.textbrowser.setfontstyle()


def setTabcishu_l(self):

grids_1 = [
Expand Down Expand Up @@ -233,7 +229,11 @@ def setTabcishu_l(self):
grid=(
[
"显示注音",
D_getsimpleswitch(globalconfig, "isshowhira"),
D_getsimpleswitch(
globalconfig,
"isshowhira",
callback=gobject.baseobject.translation_ui.translate_text.showhidert,
),
"",
"颜色",
D_getcolorbutton(
Expand All @@ -244,7 +244,7 @@ def setTabcishu_l(self):
globalconfig,
"jiamingcolor",
self.jiamingcolor_b,
callback=gobject.baseobject.translation_ui.translate_text.textbrowser.setcolorstyle,
callback=gobject.baseobject.translation_ui.translate_text.setcolorstyle,
),
name="jiamingcolor_b",
parent=self,
Expand All @@ -258,7 +258,7 @@ def setTabcishu_l(self):
"kanarate",
double=True,
step=0.05,
callback=mayberealtimesetfont,
callback=gobject.baseobject.translation_ui.translate_text.setfontstyle,
),
],
[
Expand All @@ -271,10 +271,15 @@ def setTabcishu_l(self):
],
globalconfig,
"hira_vis_type",
callback=lambda _: gobject.baseobject.translation_ui.translate_text.refreshcontent(),
),
"",
"语法加亮",
D_getsimpleswitch(globalconfig, "show_fenci"),
D_getsimpleswitch(
globalconfig,
"show_fenci",
callback=gobject.baseobject.translation_ui.translate_text.setcolorstyle,
),
"",
"词性颜色",
D_getIconButton(
Expand Down Expand Up @@ -312,14 +317,22 @@ def setTabcishu_l(self):
[
"点击单词查词",
(
D_getsimpleswitch(globalconfig, "usesearchword"),
D_getsimpleswitch(
globalconfig,
"usesearchword",
callback=gobject.baseobject.translation_ui.translate_text.showhideclick,
),
1,
),
"",
"",
"点击单词复制",
(
D_getsimpleswitch(globalconfig, "usecopyword"),
D_getsimpleswitch(
globalconfig,
"usecopyword",
callback=gobject.baseobject.translation_ui.translate_text.showhideclick,
),
1,
),
"",
Expand Down
37 changes: 15 additions & 22 deletions py/LunaTranslator/gui/setting_display_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@

def __changeuibuttonstate(self, x):
gobject.baseobject.translation_ui.refreshtoolicon()
gobject.baseobject.translation_ui.translate_text.textbrowser.showhideorigin(x)
gobject.baseobject.translation_ui.translate_text.showhideorigin(x)
try:
self.fenyinsettings.setEnabled(x)
except:
pass


def changeshowerrorstate(self, x):
gobject.baseobject.translation_ui.translate_text.textbrowser.showhideerror(x)
gobject.baseobject.translation_ui.translate_text.showhideerror(x)


def mayberealtimesetfont(_=None):
gobject.baseobject.translation_ui.translate_text.textbrowser.setfontstyle()
gobject.baseobject.translation_ui.translate_text.setfontstyle()


def createtextfontcom(key):
Expand Down Expand Up @@ -99,15 +99,11 @@ def __init__(self, parent) -> None:
self.show()


def mayberefreshe():
gobject.baseobject.translation_ui.translate_text.textbrowser.setcolorstyle()


def createinternalfontsettings(self, forml: LFormLayout, group, _type):
need = globalconfig["rendertext_using_internal"][group] != _type
globalconfig["rendertext_using_internal"][group] = _type
if need:
gobject.baseobject.translation_ui.translate_text.textbrowser.resetstyle()
gobject.baseobject.translation_ui.translate_text.resetstyle()
__internal = globalconfig["rendertext"][group][_type]
dd = __internal.get("args", {})

Expand Down Expand Up @@ -136,7 +132,7 @@ def createinternalfontsettings(self, forml: LFormLayout, group, _type):
keyx,
True,
widthline.get("step", 0.1),
callback=lambda _: mayberefreshe(),
callback=gobject.baseobject.translation_ui.translate_text.setcolorstyle,
),
__,
getspinbox(
Expand All @@ -146,7 +142,7 @@ def createinternalfontsettings(self, forml: LFormLayout, group, _type):
key,
True,
line.get("step", 0.1),
callback=lambda _: mayberefreshe(),
callback=gobject.baseobject.translation_ui.translate_text.setcolorstyle,
),
]
),
Expand All @@ -164,7 +160,7 @@ def createinternalfontsettings(self, forml: LFormLayout, group, _type):
dd,
key,
self.miaobian_color_button,
callback=mayberefreshe,
callback=gobject.baseobject.translation_ui.translate_text.setcolorstyle,
),
dd,
key,
Expand All @@ -180,16 +176,15 @@ def createinternalfontsettings(self, forml: LFormLayout, group, _type):
key,
_type == "spin",
line.get("step", 0.1),
callback=lambda _: mayberefreshe(),
callback=gobject.baseobject.translation_ui.translate_text.setcolorstyle,
)
elif _type == "switch":
lineW = MySwitch(sign=dd[key])

def __(dd, key, x):
dd[key] = x
mayberefreshe()
lineW = getsimpleswitch(
d=dd,
key=key,
callback=gobject.baseobject.translation_ui.translate_text.setcolorstyle,
)

lineW.clicked.connect(functools.partial(__, dd, key))
forml.addRow(
name,
lineW,
Expand Down Expand Up @@ -352,7 +347,7 @@ def xianshigrid_style(self):
globalconfig,
"rawtextcolor",
self.original_color_button,
callback=gobject.baseobject.translation_ui.translate_text.textbrowser.setcolorstyle,
callback=gobject.baseobject.translation_ui.translate_text.setcolorstyle,
),
name="original_color_button",
parent=self,
Expand Down Expand Up @@ -433,9 +428,7 @@ def xianshigrid_style(self):
D_getsimpleswitch(
globalconfig,
"showatcenter",
callback=lambda x: gobject.baseobject.translation_ui.translate_text.textbrowser.showatcenter(
x
),
callback=gobject.baseobject.translation_ui.translate_text.showatcenter,
),
"",
"收到翻译时才刷新",
Expand Down
2 changes: 1 addition & 1 deletion py/LunaTranslator/gui/setting_display_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def uisetting(self, l):

def __changeselectablestate(self, x):
gobject.baseobject.translation_ui.refreshtoolicon()
gobject.baseobject.translation_ui.translate_text.textbrowser.setselectable(x)
gobject.baseobject.translation_ui.translate_text.setselectable(x)


def mainuisetting(self):
Expand Down
4 changes: 2 additions & 2 deletions py/LunaTranslator/gui/setting_translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def initsome11(self, l, label=None, btnplus=False):
None,
self,
"fanyicolor_" + fanyi,
callback=gobject.baseobject.translation_ui.translate_text.textbrowser.setcolorstyle,
callback=gobject.baseobject.translation_ui.translate_text.setcolorstyle,
),
),
last,
Expand Down Expand Up @@ -468,7 +468,7 @@ def setTabTwo_lazy(self, basel: QVBoxLayout):
D_getsimpleswitch(
globalconfig,
"showfanyisource",
callback=gobject.baseobject.translation_ui.translate_text.textbrowser.showhidename,
callback=gobject.baseobject.translation_ui.translate_text.showhidename,
),
"",
"使用翻译缓存",
Expand Down
Loading

0 comments on commit 72e5d90

Please sign in to comment.