From e475a2f22d7d578843fb1dcc37f4259ee1f30a28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Sun, 11 Aug 2024 17:00:15 +0800 Subject: [PATCH] x --- .../LunaTranslator/gui/inputdialog.py | 25 +++++++---------- .../gui/setting_display_text.py | 28 ++++++++----------- 2 files changed, 22 insertions(+), 31 deletions(-) diff --git a/LunaTranslator/LunaTranslator/gui/inputdialog.py b/LunaTranslator/LunaTranslator/gui/inputdialog.py index fa22cc73..59bf3689 100644 --- a/LunaTranslator/LunaTranslator/gui/inputdialog.py +++ b/LunaTranslator/LunaTranslator/gui/inputdialog.py @@ -17,6 +17,7 @@ from gui.usefulwidget import ( FocusDoubleSpin, LFocusCombo, getsimplecombobox, + getspinbox, SplitLine, ) from gui.dynalang import ( @@ -558,21 +559,15 @@ class autoinitdialog(LDialog): _.addWidget(lineW) _.addStretch() lineW = _ - elif line["type"] == "spin": - lineW = FocusDoubleSpin() - lineW.setMinimum(line.get("min", 0)) - lineW.setMaximum(line.get("max", 100)) - lineW.setSingleStep(line.get("step", 0.1)) - lineW.setValue(dd[key]) - lineW.valueChanged.connect(functools.partial(dd.__setitem__, key)) - - elif line["type"] == "intspin": - lineW = FocusSpin() - lineW.setMinimum(line.get("min", 0)) - lineW.setMaximum(line.get("max", 100)) - lineW.setSingleStep(line.get("step", 1)) - lineW.setValue(dd[key]) - lineW.valueChanged.connect(functools.partial(dd.__setitem__, key)) + elif line["type"] in ["spin", "intspin"]: + lineW = getspinbox( + line.get("min", 0), + line.get("max", 100), + dd, + key, + line["type"] == "spin", + line.get("step", 0.1), + ) elif line["type"] == "split": lineW = SplitLine() formLayout.addRow(lineW) diff --git a/LunaTranslator/LunaTranslator/gui/setting_display_text.py b/LunaTranslator/LunaTranslator/gui/setting_display_text.py index 2b0e7334..36e0370f 100644 --- a/LunaTranslator/LunaTranslator/gui/setting_display_text.py +++ b/LunaTranslator/LunaTranslator/gui/setting_display_text.py @@ -115,6 +115,8 @@ def createinternalfontsettings(self, forml: LFormLayout, group, _type): keyx = "shadowR" widthline = __internal["argstype"].get(keyx, None) if widthline is not None: + __ = LLabel("x_字体大小_+") + __.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Preferred) forml.addRow( name, getboxlayout( @@ -127,7 +129,7 @@ def createinternalfontsettings(self, forml: LFormLayout, group, _type): True, widthline.get("step", 0.1), ), - LLabel("x_字体大小_+"), + __, getspinbox( line.get("min", 0), line.get("max", 100), @@ -157,21 +159,15 @@ def createinternalfontsettings(self, forml: LFormLayout, group, _type): name="miaobian_color_button", parent=self, ) - elif _type == "spin": - lineW = FocusDoubleSpin() - lineW.setMinimum(line.get("min", 0)) - lineW.setMaximum(line.get("max", 100)) - lineW.setSingleStep(line.get("step", 0.1)) - lineW.setValue(dd[key]) - lineW.valueChanged.connect(functools.partial(dd.__setitem__, key)) - - elif _type == "intspin": - lineW = FocusSpin() - lineW.setMinimum(line.get("min", 0)) - lineW.setMaximum(line.get("max", 100)) - lineW.setSingleStep(line.get("step", 1)) - lineW.setValue(dd[key]) - lineW.valueChanged.connect(functools.partial(dd.__setitem__, key)) + elif _type in ["spin", "intspin"]: + lineW = getspinbox( + line.get("min", 0), + line.get("max", 100), + dd, + key, + _type == "spin", + line.get("step", 0.1), + ) elif _type == "switch": lineW = MySwitch(sign=dd[key]) lineW.clicked.connect(functools.partial(dd.__setitem__, key))