issues/504

This commit is contained in:
恍兮惚兮 2024-01-28 00:56:46 +08:00
parent a5c83efd7c
commit 1fde4aca87
3 changed files with 93 additions and 87 deletions

View File

@ -1,7 +1,7 @@
import functools
from PyQt5.QtWidgets import QDialogButtonBox,QDialog,QHeaderView,QComboBox,QFormLayout,QDoubleSpinBox,QSpinBox,QHBoxLayout,QLineEdit,QFileDialog,QPushButton,QLabel,QTableView,QVBoxLayout
from PyQt5.QtCore import Qt,QSize
from PyQt5.QtGui import QStandardItem, QStandardItemModel
from PyQt5.QtGui import QCloseEvent, QStandardItem, QStandardItemModel
from PyQt5.QtGui import QColor
import qtawesome,importlib
@ -11,18 +11,18 @@ from myutils.utils import makehtml
from myutils.wrapper import Singleton
@Singleton
class autoinitdialog(QDialog):
def __init__(dialog, parent,title,width,lines,_=None ) -> None:
def __init__(self, parent,title,width,lines,_=None ) -> None:
super().__init__(parent, Qt.WindowCloseButtonHint)
dialog.setWindowTitle(_TR(title))
dialog.resize(QSize(width,10))
self.setWindowTitle(_TR(title))
self.resize(QSize(width,10))
formLayout = QFormLayout()
dialog.setLayout(formLayout)
self.setLayout(formLayout)
regist=[]
def save(callback=None):
for l in regist:
l[0][l[1]]=l[2]()
dialog.close()
self.close()
if callback:
callback()
def openfiledirectory(multi,edit,isdir,filter1='*.*'):
@ -68,7 +68,7 @@ class autoinitdialog(QDialog):
lineW.currentIndexChanged.connect(functools.partial(dd.__setitem__,key))
elif line['t']=='okcancel':
lineW = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel)
lineW.rejected.connect(dialog.close)
lineW.rejected.connect(self.close)
lineW.accepted.connect(functools.partial(save,None if 'callback' not in line else line['callback']))
lineW.button(QDialogButtonBox.Ok).setText(_TR('确定'))
@ -106,7 +106,7 @@ class autoinitdialog(QDialog):
formLayout.addRow(_TR(line['l']),lineW)
else:
formLayout.addRow( lineW)
dialog.show()
self.show()
def getsomepath1(parent,title,d,k,label,callback=None,isdir=False,filter1="*.db"):
autoinitdialog(parent,title,800,[
@ -161,34 +161,44 @@ class multicolorset(QDialog):
self.show()
@Singleton
class postconfigdialog(QDialog):
def __init__(dialog, parent,configdict,title,_=None) -> None:
class postconfigdialog_(QDialog):
def closeEvent(self, a0: QCloseEvent) -> None:
if self.closeevent:
self.button.setFocus()
rows=self.model.rowCount()
newdict={}
for row in range(rows):
if self.model.item(row,0).text()=="":
continue
newdict[(self.model.item(row,0).text())]=(self.model.item(row,1).text())
self.configdict[self.key]=newdict
def __init__(self, parent,configdict,title) -> None:
super().__init__(parent,Qt.WindowCloseButtonHint)
dialog.setWindowTitle(_TR(title))
#dialog.setWindowModality(Qt.ApplicationModal)
formLayout = QVBoxLayout(dialog) # 配置layout
print(title)
self.setWindowTitle(_TR(title))
#self.setWindowModality(Qt.ApplicationModal)
self.closeevent=False
formLayout = QVBoxLayout(self) # 配置layout
key=list(configdict.keys())[0]
lb=QLabel(dialog)
lb=QLabel(self)
lb.setText(_TR(key) )
formLayout.addWidget(lb)
if type(configdict[key]) in (float,int):
spin=QSpinBox(dialog)
spin=QSpinBox(self)
spin.setMinimum(1)
spin.setMaximum(100)
spin.setValue(configdict[key])
spin.valueChanged.connect(lambda x:configdict.__setitem__(key,x))
formLayout.addWidget(spin)
dialog.resize(QSize(600,1))
self.resize(QSize(600,1))
elif type(configdict[key])==type({}):
# lines=QTextEdit(dialog)
# lines=QTextEdit(self)
# lines.setPlainText('\n'.join(configdict[key]))
# lines.textChanged.connect(lambda :configdict.__setitem__(key,lines.toPlainText().split('\n')))
# formLayout.addWidget(lines)
model=QStandardItemModel(len(configdict[key]),1 , dialog)
model=QStandardItemModel(len(configdict[key]),1 , self)
row=0
for key1 in ( (configdict[key])): # 2
@ -200,37 +210,33 @@ class postconfigdialog(QDialog):
model.setItem(row, 1, item)
row+=1
model.setHorizontalHeaderLabels(_TRL([ '原文内容','替换为']))
table = QTableView(dialog)
table = QTableView(self)
table.setModel(model)
table.setWordWrap(False)
table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
#table.setEditTriggers(QAbstractItemView.NoEditTriggers)
#table.clicked.connect(self.show_info)
button=QPushButton(dialog)
button=QPushButton(self)
button.setText(_TR('添加行'))
def clicked1():
model.insertRow(0,[QStandardItem(''),QStandardItem('')])
button.clicked.connect(clicked1)
button2=QPushButton(dialog)
button2=QPushButton(self)
button2.setText(_TR('删除选中行'))
def clicked2():
model.removeRow(table.currentIndex().row())
button2.clicked.connect(clicked2)
def clicked3(_):
button.setFocus()
rows=model.rowCount()
newdict={}
for row in range(rows):
if model.item(row,0).text()=="":
continue
newdict[(model.item(row,0).text())]=(model.item(row,1).text())
configdict[key]=newdict
dialog.closeEvent=(clicked3)
self.button=button
self.model=model
self.key=key
self.configdict=configdict
self.closeevent=True
formLayout.addWidget(table)
formLayout.addWidget(button)
formLayout.addWidget(button2)
dialog.resize(QSize(600,400))
dialog.show()
self.resize(QSize(600,400))
self.show()
def postconfigdialog(parent,configdict,title):
postconfigdialog_(parent,configdict,title)

View File

@ -3,7 +3,7 @@ import functools
from PyQt5.QtWidgets import QDialog,QLabel ,QLineEdit,QSpinBox,QPushButton ,QTableView, QVBoxLayout,QHBoxLayout,QHeaderView ,QTextEdit,QHBoxLayout,QWidget,QMenu,QAction
from PyQt5.QtCore import QSize,Qt,pyqtSignal,QPoint
from PyQt5.QtGui import QStandardItem, QStandardItemModel
from PyQt5.QtGui import QCloseEvent, QStandardItem, QStandardItemModel
from traceback import print_exc
from myutils.config import globalconfig ,postprocessconfig,noundictconfig,transerrorfixdictconfig,_TR,_TRL,defaultglobalconfig
import functools ,gobject
@ -162,15 +162,15 @@ def setTab7_lazy(self) :
@Singleton
class noundictconfigdialog1(QDialog):
def __init__(dialog,parent,configdict,title,label=[ '原文','翻译'] ,_=None) -> None:
def __init__(self,parent,configdict,title,label=[ '原文','翻译'] ,_=None) -> None:
super().__init__(parent,Qt.WindowCloseButtonHint)
dialog.setWindowTitle(_TR(title))
#dialog.setWindowModality(Qt.ApplicationModal)
self.setWindowTitle(_TR(title))
#self.setWindowModality(Qt.ApplicationModal)
formLayout = QVBoxLayout(dialog) # 配置layout
formLayout = QVBoxLayout(self) # 配置layout
model=QStandardItemModel(len(list(configdict['dict'].keys())),1 , dialog)
model=QStandardItemModel(len(list(configdict['dict'].keys())),1 , self)
row=0
for key in (configdict['dict']): # 2
@ -180,7 +180,7 @@ class noundictconfigdialog1(QDialog):
model.setItem(row, 1, item)
row+=1
model.setHorizontalHeaderLabels(_TRL(label))
table = QTableView(dialog)
table = QTableView(self)
table.setModel(model)
table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
#table.setEditTriggers(QAbstractItemView.NoEditTriggers)
@ -209,46 +209,58 @@ class noundictconfigdialog1(QDialog):
search.addWidget(button4)
button=QPushButton(dialog)
button=QPushButton(self)
button.setText(_TR('添加行'))
def clicked1():
model.insertRow(0,[ QStandardItem(''),QStandardItem('')])
button.clicked.connect(clicked1)
button2=QPushButton(dialog)
button2=QPushButton(self)
button2.setText(_TR('删除选中行'))
def clicked2():
model.removeRow(table.currentIndex().row())
button2.clicked.connect(clicked2)
def clicked3(_):
button.setFocus()
rows=model.rowCount()
newdict={}
for row in range(rows):
if model.item(row,0).text()=="":
continue
newdict[model.item(row,0).text()]=model.item(row,1).text()
configdict['dict']=newdict
dialog.closeEvent=clicked3
self.button=button
self.model=model
self.configdict=configdict
formLayout.addWidget(table)
formLayout.addLayout(search)
formLayout.addWidget(button)
formLayout.addWidget(button2)
dialog.resize(QSize(600,400))
dialog.show()
self.resize(QSize(600,400))
self.show()
def closeEvent(self, a0: QCloseEvent) -> None:
self.button.setFocus()
rows=self.model.rowCount()
newdict={}
for row in range(rows):
if self.model.item(row,0).text()=="":
continue
newdict[self.model.item(row,0).text()]=self.model.item(row,1).text()
self.configdict['dict']=newdict
@Singleton
class noundictconfigdialog(QDialog):
def __init__(dialog,parent,configdict,title,label=['游戏ID MD5' ,'原文','翻译'] ,_=None) -> None:
def closeEvent(self, a0: QCloseEvent) -> None:
self.button.setFocus()
rows=self.model.rowCount()
newdict={}
for row in range(rows):
if self.model.item(row,1).text()=="":
continue
if self.model.item(row,1).text() not in newdict:
newdict[self.model.item(row,1).text()]=[self.model.item(row,0).text(),self.model.item(row,2).text()]
else:
newdict[self.model.item(row,1).text()]+=[self.model.item(row,0).text(),self.model.item(row,2).text()]
self.configdict['dict']=newdict
def __init__(self,parent,configdict,title,label=['游戏ID MD5' ,'原文','翻译'] ,_=None) -> None:
super().__init__(parent,Qt.WindowCloseButtonHint)
dialog.setWindowTitle(_TR(title))
#dialog.setWindowModality(Qt.ApplicationModal)
self.setWindowTitle(_TR(title))
#self.setWindowModality(Qt.ApplicationModal)
formLayout = QVBoxLayout(dialog) # 配置layout
formLayout = QVBoxLayout(self) # 配置layout
model=QStandardItemModel(len(list(configdict['dict'].keys())),1 , dialog)
model=QStandardItemModel(len(list(configdict['dict'].keys())),1 , self)
row=0
for key in (configdict['dict']): # 2
if type(configdict['dict'][key])==str:
@ -263,12 +275,12 @@ class noundictconfigdialog(QDialog):
model.setItem(row, 2, item)
row+=1
model.setHorizontalHeaderLabels(_TRL(label))
table = QTableView(dialog)
table = QTableView(self)
table.setModel(model)
table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
#table.setEditTriggers(QAbstractItemView.NoEditTriggers)
#table.clicked.connect(self.show_info)
button=QPushButton(dialog)
button=QPushButton(self)
button.setText(_TR('添加行'))
def clicked1():
try:
@ -278,13 +290,13 @@ class noundictconfigdialog(QDialog):
print_exc()
model.insertRow(0,[QStandardItem('0'),QStandardItem(''),QStandardItem('')])
button.clicked.connect(clicked1)
button2=QPushButton(dialog)
button2=QPushButton(self)
button2.setText(_TR('删除选中行'))
def clicked2():
model.removeRow(table.currentIndex().row())
button2.clicked.connect(clicked2)
button5=QPushButton(dialog)
button5=QPushButton(self)
button5.setText(_TR('设置所有词条为全局词条'))
def clicked5():
rows=model.rowCount()
@ -292,20 +304,6 @@ class noundictconfigdialog(QDialog):
model.item(row,0).setText('0')
button5.clicked.connect(clicked5)
def clicked3(_):
button.setFocus()
rows=model.rowCount()
newdict={}
for row in range(rows):
if model.item(row,1).text()=="":
continue
if model.item(row,1).text() not in newdict:
newdict[model.item(row,1).text()]=[model.item(row,0).text(),model.item(row,2).text()]
else:
newdict[model.item(row,1).text()]+=[model.item(row,0).text(),model.item(row,2).text()]
configdict['dict']=newdict
dialog.closeEvent=clicked3
search=QHBoxLayout()
searchcontent=QLineEdit()
search.addWidget(searchcontent)
@ -341,7 +339,9 @@ class noundictconfigdialog(QDialog):
button5.clicked.connect(lambda x:gobject.baseobject.__setattr__('currentmd5',md5content.text()))
button5.setText(_TR('修改'))
setmd5layout.addWidget(button5)
self.button=button
self.model=model
self.configdict=configdict
formLayout.addLayout(setmd5layout)
dialog.resize(QSize(600,400))
dialog.show()
self.resize(QSize(600,400))
self.show()

View File

@ -1,5 +1,5 @@
{
"version":"v2.36.1",
"version":"v2.36.2",
"language_list_show":["简体中文","日本語","English","Русский язык","Español","한국어","Français","繁體中文","Tiếng Việt","Türkçe","Polski","Українська Мова","Italiano","اللغة العربية","ภาษาไทย"] ,
"language_list_translator":["简体中文","日文","英文","俄语","西班牙语","韩语","法语","繁体中文","越南语","土耳其语","波兰语","乌克兰语","意大利语","阿拉伯语","泰语"],
"language_list_translator_inner":["zh", "ja", "en","ru","es","ko","fr","cht","vi","tr","pl","uk","it","ar","th"],