系统诊断增加设备检测
This commit is contained in:
@ -61,7 +61,6 @@ class SystemCenterDialog(QDialog):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self._init_ui()
|
||||
self.init_animations() # 初始化动画
|
||||
|
||||
def _init_ui(self):
|
||||
# 弹窗基础设置
|
||||
@ -103,47 +102,6 @@ class SystemCenterDialog(QDialog):
|
||||
painter.drawPixmap(self.rect(), self.background)
|
||||
super().paintEvent(event)
|
||||
|
||||
def init_animations(self):
|
||||
"""初始化显示动画(可根据喜好选择或组合)"""
|
||||
# 1. 淡入动画(透明度从0→1)
|
||||
self.opacity_anim = QPropertyAnimation(self, b"windowOpacity")
|
||||
self.opacity_anim.setDuration(300) # 动画时长300ms
|
||||
self.opacity_anim.setStartValue(0.0)
|
||||
self.opacity_anim.setEndValue(1.0)
|
||||
self.opacity_anim.setEasingCurve(QEasingCurve.InOutCubic) # 缓动曲线(平滑加速减速)
|
||||
|
||||
# 2. 缩放动画(从80%→100%大小)
|
||||
self.scale_anim = QPropertyAnimation(self, b"geometry")
|
||||
self.scale_anim.setDuration(300)
|
||||
# 起点和终点在显示时动态设置(依赖当前弹窗位置)
|
||||
self.scale_anim.setEasingCurve(QEasingCurve.OutBack) # 带弹性的缓动曲线(弹出感)
|
||||
|
||||
# 3. 组合动画(同时执行淡入+缩放)
|
||||
from PySide6.QtCore import QParallelAnimationGroup
|
||||
self.anim_group = QParallelAnimationGroup(self)
|
||||
self.anim_group.addAnimation(self.opacity_anim)
|
||||
self.anim_group.addAnimation(self.scale_anim)
|
||||
|
||||
def showEvent(self, event):
|
||||
"""重写显示事件,每次显示时启动动画"""
|
||||
# 必须先调用父类showEvent,否则弹窗无法正常显示
|
||||
super().showEvent(event)
|
||||
|
||||
# 动态设置缩放动画的起点(基于当前弹窗位置和大小)
|
||||
current_geometry = self.geometry() # 弹窗当前位置和大小(已通过move设置)
|
||||
# 起点:缩小到80%,并保持中心位置不变
|
||||
start_rect = QRect(
|
||||
current_geometry.center().x() - current_geometry.width() * 0.4,
|
||||
current_geometry.center().y() - current_geometry.height() * 0.4,
|
||||
int(current_geometry.width() * 0.8),
|
||||
int(current_geometry.height() * 0.8)
|
||||
)
|
||||
self.scale_anim.setStartValue(start_rect)
|
||||
self.scale_anim.setEndValue(current_geometry) # 终点:原始大小
|
||||
|
||||
# 启动组合动画
|
||||
self.anim_group.start()
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QApplication(sys.argv)
|
||||
dialog = SystemCenterDialog()
|
||||
|
||||
Reference in New Issue
Block a user