使用 ProgressInfoBar 替代原有方案
This commit is contained in:
@@ -5,9 +5,10 @@ from qfluentwidgets import InfoBar, InfoBarPosition, InfoBarIcon, FluentIconBase
|
||||
|
||||
|
||||
class ProgressInfoBar(InfoBar):
|
||||
def __init__(self, icon: InfoBarIcon | FluentIconBase | QIcon | str, title: str, content: str, orient=Qt.Horizontal,
|
||||
def __init__(self, icon: InfoBarIcon | FluentIconBase | QIcon | str = InfoBarIcon.INFORMATION, title: str = "1",
|
||||
content: str = "", orient=Qt.Horizontal,
|
||||
isClosable=True, duration=1000,
|
||||
position=InfoBarPosition.TOP_RIGHT, parent=None):
|
||||
position=InfoBarPosition.BOTTOM, parent=None):
|
||||
super().__init__(icon, title, content, orient, isClosable, duration, position, parent)
|
||||
|
||||
self.pb = ProgressBar()
|
||||
@@ -30,8 +31,7 @@ class ProgressInfoBar(InfoBar):
|
||||
self.pb.setVisible(False)
|
||||
self.adjustSize()
|
||||
manager.add(self)
|
||||
else:
|
||||
return
|
||||
|
||||
else:
|
||||
if not self.pb.isVisible():
|
||||
manager.remove(self)
|
||||
@@ -72,3 +72,18 @@ class ProgressInfoBar(InfoBar):
|
||||
duration=duration,
|
||||
parent=self.parent()
|
||||
)
|
||||
|
||||
def show_error(self, title: str = '错误!', content: str = "操作失败", isCloseable: bool = True,
|
||||
duration: int = 5000):
|
||||
self.setVisible(False)
|
||||
InfoBarManager.make(self.position).remove(self)
|
||||
|
||||
InfoBar.error(
|
||||
title=title,
|
||||
content=content,
|
||||
orient=Qt.Horizontal,
|
||||
isClosable=isCloseable,
|
||||
position=InfoBarPosition.BOTTOM,
|
||||
duration=duration,
|
||||
parent=self.parent()
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user