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.key=key
self.configdict=configdict self.configdict=configdict
self.closeevent=True 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.addWidget(table)
formLayout.addLayout(search)
formLayout.addWidget(button) formLayout.addWidget(button)
formLayout.addWidget(button2) formLayout.addWidget(button2)
self.resize(QSize(600,400)) self.resize(QSize(600,400))

View File

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

View File

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