issues/564 and other

This commit is contained in:
恍兮惚兮 2024-03-08 13:05:29 +08:00
parent 03c875d13f
commit e23ba55dee
3 changed files with 45 additions and 14 deletions

View File

@ -238,7 +238,28 @@ class postconfigdialog_(QDialog):
self.key=key
self.configdict=configdict
self.closeevent=True
search=QHBoxLayout()
searchcontent=QLineEdit()
search.addWidget(searchcontent)
button4=QPushButton()
button4.setText(_TR('搜索'))
def clicked4():
text=searchcontent.text()
rows=model.rowCount()
cols=model.columnCount()
for row in range(rows):
ishide=True
for c in range(cols):
if text in model.item(row,c).text():
ishide=False
break
table.setRowHidden(row,ishide)
button4.clicked.connect(clicked4)
search.addWidget(button4)
formLayout.addWidget(table)
formLayout.addLayout(search)
formLayout.addWidget(button)
formLayout.addWidget(button2)
self.resize(QSize(600,400))

View File

@ -247,9 +247,13 @@ class Textbrowser( ):
def showyinyingtext2(self,color,iter_context_class,pos,text):
if iter_context_class not in self.iteryinyinglabelsave:
self.iteryinyinglabelsave[iter_context_class]=[]
maxh=0
maxh2=9999999
for label in self.iteryinyinglabelsave[iter_context_class]:
maxh2=min(label.pos().y(),maxh2)
if label.isVisible()==False:continue
label.hide()
maxh=max(label.pos().y(),maxh)
subtext=[]
subpos=[]
@ -265,13 +269,14 @@ class Textbrowser( ):
subtext.append('')
subtext[-1]+=text[i]
maxnewh=0
if (len(subtext))>len(self.iteryinyinglabelsave[iter_context_class]):
_newlabels=[QLabel(self.toplabel2) for i in range(len(subtext)-len(self.iteryinyinglabelsave[iter_context_class]))]
self.iteryinyinglabelsave[iter_context_class]+=_newlabels
for lb in _newlabels:
lb.setTextFormat(Qt.PlainText)
for i in range(len(subtext)):
maxnewh=max(maxnewh,subpos[i].y())
_=self.iteryinyinglabelsave[iter_context_class][i]
_.move(subpos[i])
_.setText(subtext[i])
@ -280,7 +285,13 @@ class Textbrowser( ):
_.setStyleSheet("color:{}; background-color:rgba(0,0,0,0)".format(globalconfig['miaobiancolor']))
_.setGraphicsEffect(self.geteffect(globalconfig['fontsize'],color,globalconfig['shadowforce']))
_.show()
if maxh:
for label in self.yinyinglabels:
if label.isVisible()==False:continue
if label.pos().y()>maxh:
if maxnewh==0:
maxnewh=maxh2
label.move(label.pos().x(),label.pos().y()+maxnewh-maxh)
def showyinyingtext(self,color ):
linei=self.yinyingposline

View File

@ -195,17 +195,17 @@ class QUnFrameWindow(resizableframeless):
iter_res_status,iter_context_class=iter_context
if iter_res_status==3:
self.translate_text.append(' ',hira,origin)
self.saveiterclasspointer[iter_context_class]={'curr':self.translate_text.getcurrpointer(),'start':self.translate_text.getcurrpointer()}
self.saveiterclasspointer[iter_context_class]={'currtext':'','curr':self.translate_text.getcurrpointer(),'start':self.translate_text.getcurrpointer()}
else:
currbefore=self.saveiterclasspointer[iter_context_class]['curr']
if globalconfig['zitiyangshi'] !=3:
#阴影字体blcoksignal会UpdateLayeredWindowIndirect failed for
#其他字体不blocksignal会高度抖动
self.document.blockSignals(True)
self.translate_text.deletebetween(self.saveiterclasspointer[iter_context_class]['start'],self.saveiterclasspointer[iter_context_class]['curr'])
if globalconfig['zitiyangshi'] !=3:
self.document.blockSignals(False)
self.translate_text.insertatpointer(self.saveiterclasspointer[iter_context_class]['start'],text)
currlen=len(self.saveiterclasspointer[iter_context_class]['currtext'])
if len(text)<currlen:
self.translate_text.deletebetween(self.saveiterclasspointer[iter_context_class]['start']+len(text),self.saveiterclasspointer[iter_context_class]['curr'])
else:
newtext=text[currlen:]
self.translate_text.insertatpointer(self.saveiterclasspointer[iter_context_class]['start']+currlen,newtext)
self.saveiterclasspointer[iter_context_class]['currtext']=text
currcurrent=self.translate_text.getcurrpointer()
self.saveiterclasspointer[iter_context_class]['curr']=currcurrent
currchange=currcurrent-currbefore
@ -217,8 +217,7 @@ class QUnFrameWindow(resizableframeless):
if globalconfig['zitiyangshi'] ==3:
self.translate_text.showyinyingtext2(color,iter_context_class,self.saveiterclasspointer[iter_context_class]['start'],text)
return
else:
self.translate_text.append(text,hira,origin)
if globalconfig['zitiyangshi'] ==3: