61 lines
2.0 KiB
Python
61 lines
2.0 KiB
Python
# Copyright (c) 2025 Jeffrey Hsu - JITToolBox
|
|
# #
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
# #
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
# #
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
from PySide6.QtCore import Qt
|
|
from PySide6.QtWidgets import QVBoxLayout
|
|
from qfluentwidgets import PushButton, InfoBarIcon, InfoBarPosition
|
|
|
|
from ui.components.infobar import ProgressInfoBar
|
|
from ui.components.widget import Widget
|
|
|
|
|
|
class TestWidget(Widget):
|
|
def __init__(self, key: str, parents=None):
|
|
super().__init__(key, parents)
|
|
|
|
self.button = PushButton('测试按钮')
|
|
self.vbox = QVBoxLayout(self)
|
|
|
|
self.vbox.addWidget(self.button)
|
|
self.vbox.addStretch(1)
|
|
|
|
self.pib = ProgressInfoBar(
|
|
icon=InfoBarIcon.INFORMATION,
|
|
title='请稍后',
|
|
content="",
|
|
orient=Qt.Horizontal,
|
|
isClosable=False,
|
|
position=InfoBarPosition.BOTTOM,
|
|
duration=-1,
|
|
parent=self
|
|
)
|
|
|
|
self.p = -20
|
|
|
|
self.button.clicked.connect(self.add_progress)
|
|
|
|
def add_progress(self):
|
|
self.p += 10
|
|
self.pib.setVisible(True)
|
|
self.pib.set_progress(self.p)
|
|
if 0 <= self.p <= 100:
|
|
self.pib.set_title('正在制作')
|
|
elif 100 <= self.p <= 110:
|
|
self.pib.set_title('请稍后')
|
|
elif self.p > 110:
|
|
self.pib.show_success()
|
|
self.p = -20
|
|
self.pib.set_title('正在等待')
|