This commit is contained in:
恍兮惚兮 2024-06-21 23:12:40 +08:00
parent fc044f41fb
commit 75e84fd22e
6 changed files with 66 additions and 71 deletions

View File

@ -1044,10 +1044,8 @@ class dialog_setting_game_internal(QWidget):
def gettextproc(self, exepath):
_w = QWidget()
_vbox = QVBoxLayout()
formLayout = QFormLayout()
_w.setLayout(_vbox)
_vbox.addLayout(formLayout)
_w.setLayout(formLayout)
__extra = QWidget()
def __function(_):
@ -1065,7 +1063,7 @@ class dialog_setting_game_internal(QWidget):
vbox = QVBoxLayout()
vbox.setContentsMargins(0, 0, 0, 0)
__extra.setLayout(vbox)
_vbox.addWidget(__extra)
formLayout.addRow(__extra)
model = QStandardItemModel()
model.setHorizontalHeaderLabels(_TRL(["使用", "预处理方法", "设置"]))
@ -1207,11 +1205,7 @@ class dialog_setting_game_internal(QWidget):
def getlangtab(self, exepath):
_w = QWidget()
formLayout = QFormLayout()
_vbox = QVBoxLayout()
_vbox.setAlignment(Qt.AlignmentFlag.AlignTop)
_w.setLayout(_vbox)
_vbox.addLayout(formLayout)
_w.setLayout(formLayout)
__extraw = QWidget()
formLayout.addRow(
@ -1230,7 +1224,7 @@ class dialog_setting_game_internal(QWidget):
"private_srclang", globalconfig["srclang3"]
)
_vbox.addWidget(__extraw)
formLayout.addRow(__extraw)
formLayout2 = QFormLayout()
formLayout2.setContentsMargins(0, 0, 0, 0)
__extraw.setLayout(formLayout2)
@ -1255,10 +1249,7 @@ class dialog_setting_game_internal(QWidget):
def gethooktab(self, exepath):
_w = QWidget()
formLayout = QFormLayout()
_vbox = QVBoxLayout()
_vbox.setAlignment(Qt.AlignmentFlag.AlignTop)
_w.setLayout(_vbox)
_vbox.addLayout(formLayout)
_w.setLayout(formLayout)
formLayout.addRow(
_TR("特殊码"),
listediterline(
@ -1306,7 +1297,7 @@ class dialog_setting_game_internal(QWidget):
]:
if k not in savehook_new_data[exepath]["hooksetting_private"]:
savehook_new_data[exepath]["hooksetting_private"][k] = globalconfig[k]
_vbox.addWidget(__extraw)
formLayout.addRow(__extraw)
formLayout2 = QFormLayout()
formLayout2.setContentsMargins(0, 0, 0, 0)
__extraw.setLayout(formLayout2)
@ -1703,7 +1694,7 @@ class dialog_savedgame_integrated(saveposwindow):
parent,
flags=Qt.WindowType.WindowMinMaxButtonsHint
| Qt.WindowType.WindowCloseButtonHint,
poslist=globalconfig["savegamedialoggeo"]
poslist=globalconfig["savegamedialoggeo"],
)
self.setWindowTitle(_TR("游戏管理"))

View File

@ -88,14 +88,6 @@ def _xingw():
callback=lambda _: gobject.baseobject.setshowintab(),
),
],
[
"可选取模式",
D_getsimpleswitch(
globalconfig,
"selectable",
callback=lambda x: gobject.baseobject.translation_ui.translate_text.setselectable(),
),
],
),
),
0,

View File

@ -14,6 +14,7 @@ from gui.usefulwidget import (
D_getIconButton,
D_getcolorbutton,
getcolorbutton,
getboxlayout,
D_getsimpleswitch,
selectcolor,
FocusFontCombo,
@ -87,8 +88,9 @@ class extrahtml(saveposwindow):
@tryprint
def applyhtml(self, _):
gobject.refwebview.set_extra_html(self.vistext.toPlainText())
gobject.baseobject.translation_ui.translate_text.textbrowser.set_extra_html(
self.vistext.toPlainText()
)
def savehtml(self):
os.makedirs("userconfig", exist_ok=True)
@ -117,19 +119,30 @@ class extrahtml(saveposwindow):
self.show()
def createinternalfontsettings(self, group, _type):
def clearlayout(ll: QLayout):
while ll.count():
item = ll.takeAt(0)
if not item:
continue
ll.removeItem(item)
w = item.widget()
if w:
w.deleteLater()
continue
l = item.layout()
if l:
clearlayout(l)
l.deleteLater()
continue
def createinternalfontsettings(self, forml, group, _type):
globalconfig["rendertext_using_internal"][group] = _type
__internal = globalconfig["rendertext"][group][_type]
dd = __internal.get("args", {})
lay: QFormLayout = self.goodfontsettingsWidget.layout()
while lay.count() > 2:
item = lay.takeAt(2)
if not item:
break
w = item.widget()
lay.removeWidget(w)
w.deleteLater()
clearlayout(forml)
for key in dd:
line = __internal["argstype"][key]
@ -165,26 +178,40 @@ def createinternalfontsettings(self, group, _type):
lineW.setSingleStep(line.get("step", 1))
lineW.setValue(dd[key])
lineW.valueChanged.connect(functools.partial(dd.__setitem__, key))
lay.addRow(
forml.addRow(
name,
lineW,
)
if group == "webview":
_btn = QPushButton(_TR("额外的html"))
lay.addWidget(_btn)
_btn.clicked.connect(lambda: extrahtml(self))
def resetgroudswitchcallback(self, group):
clearlayout(self.goodfontsettingsformlayout)
if group == "QWebEngine":
group = "webview"
try:
self.goodfontgroupswitch.currentIndexChanged.disconnect()
except:
pass
self.goodfontgroupswitch.clear()
self.goodfontgroupswitch.addItems(
goodfontgroupswitch = FocusCombo()
if group == "webview":
_btn = QPushButton(_TR("额外的html"))
self.goodfontsettingsformlayout.addRow(_btn)
_btn.clicked.connect(lambda: extrahtml(self))
elif group == "textbrowser":
self.goodfontsettingsformlayout.addRow(
_TR("可选取模式"),
getsimpleswitch(
globalconfig,
"selectable",
callback=lambda x: gobject.baseobject.translation_ui.translate_text.textbrowser.setselectable(),
),
)
__form = QFormLayout()
__form.addRow(_TR("字体样式"), goodfontgroupswitch)
self.goodfontsettingsformlayout.addRow(__form)
forml = QFormLayout()
__form.addRow(forml)
goodfontgroupswitch.addItems(
_TRL(
[
globalconfig["rendertext"][group][x]["name"]
@ -192,32 +219,26 @@ def resetgroudswitchcallback(self, group):
]
)
)
self.goodfontgroupswitch.setCurrentIndex(-1)
self.goodfontgroupswitch.currentIndexChanged.connect(
goodfontgroupswitch.currentIndexChanged.connect(
lambda idx: createinternalfontsettings(
self, group, static_data["textrender"][group][idx]
self, forml, group, static_data["textrender"][group][idx]
)
)
self.goodfontgroupswitch.setCurrentIndex(
goodfontgroupswitch.setCurrentIndex(
static_data["textrender"][group].index(
globalconfig["rendertext_using_internal"][group]
)
)
def firsttime(self):
self.goodfontgroupswitch = FocusCombo()
self.goodfontsettingsformlayout.addRow(_TR("字体样式"), self.goodfontgroupswitch)
resetgroudswitchcallback(self, globalconfig["rendertext_using"])
def creategoodfontwid(self):
self.goodfontsettingsWidget = QGroupBox()
self.goodfontsettingsformlayout = QFormLayout()
self.goodfontsettingsWidget.setLayout(self.goodfontsettingsformlayout)
return self.goodfontsettingsWidget, functools.partial(firsttime, self)
return self.goodfontsettingsWidget, lambda: resetgroudswitchcallback(
self, globalconfig["rendertext_using"]
)
def xianshigrid(self):

View File

@ -64,10 +64,6 @@ class Textbrowser(QLabel):
self.masklabel_bottom = QLabel(self)
self.masklabel_bottom.setMouseTracking(True)
# self.masklabel_bottom.setStyleSheet('background-color:red')
self.setselectable()
def setselectable(self):
self.textbrowser.setselectable(globalconfig["selectable"])
def iter_append(self, iter_context_class, origin, atcenter, text, color):
cleared = self.cleared

View File

@ -58,9 +58,6 @@ class TextBrowser(QWidget, dataget):
self.toplabel2.resize(event.size())
self.masklabel.resize(event.size())
def setselectable(self, b):
self.masklabel.setHidden(b)
def __init__(self, parent) -> None:
super().__init__(parent)
self.atback2 = QLabel(self)
@ -105,6 +102,8 @@ class TextBrowser(QWidget, dataget):
self.iteryinyinglabelsave = {}
self.saveiterclasspointer = {}
self.resets1()
self.setselectable()
def resets1(self):
self.currenttype = globalconfig["rendertext_using_internal"]["textbrowser"]
@ -155,8 +154,8 @@ class TextBrowser(QWidget, dataget):
labels[1] = 0
self.iteryinyinglabelsave.clear()
def setselectable(self, b):
self.masklabel.setHidden(b)
def setselectable(self):
self.masklabel.setHidden(globalconfig["selectable"])
def _createqfont(self, origin):

View File

@ -16,7 +16,6 @@ class TextBrowser(QWidget, dataget):
self.webivewwidget.resize(event.size().width(), event.size().height())
def __init__(self, parent) -> None:
gobject.refwebview = self
super().__init__(parent)
if globalconfig["rendertext_using"] == "QWebEngine":
DEBUG_PORT = 5588
@ -187,9 +186,6 @@ class TextBrowser(QWidget, dataget):
# native api end
def setselectable(self, b):
pass
def iter_append(self, iter_context_class, origin, atcenter, text, color, cleared):
if iter_context_class not in self.saveiterclasspointer: