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

View File

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

View File

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

View File

@ -64,10 +64,6 @@ class Textbrowser(QLabel):
self.masklabel_bottom = QLabel(self) self.masklabel_bottom = QLabel(self)
self.masklabel_bottom.setMouseTracking(True) self.masklabel_bottom.setMouseTracking(True)
# self.masklabel_bottom.setStyleSheet('background-color:red') # 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): def iter_append(self, iter_context_class, origin, atcenter, text, color):
cleared = self.cleared cleared = self.cleared

View File

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

View File

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