77from app .common .config import get_theme_icon , load_custom_font , check_for_updates , VERSION , themeColor
88from app .common .path_utils import path_manager , open_file
99
10- def show_update_notification (latest_version ):
10+ def show_update_notification (latest_version , auto_close = False ):
1111 """显示更新通知窗口"""
1212 if hasattr (QApplication .instance (), 'update_notification_window' ):
1313 # 如果窗口已存在则激活它
@@ -19,19 +19,21 @@ def show_update_notification(latest_version):
1919 return
2020
2121 # 创建新的通知窗口
22- notification_window = UpdateNotification (latest_version )
22+ notification_window = UpdateNotification (latest_version , auto_close = auto_close )
2323 QApplication .instance ().update_notification_window = notification_window
2424 notification_window .show ()
2525
2626class UpdateNotification (QDialog ):
2727 """自定义更新通知窗口"""
28- def __init__ (self , latest_version ):
28+ def __init__ (self , latest_version , auto_close = False ):
2929 super ().__init__ (parent = None , flags = Qt .FramelessWindowHint | Qt .WindowStaysOnTopHint | Qt .Tool )
3030 self .latest_version = latest_version
31- self .duration = 15000 # 默认显示15秒
31+ self .auto_close = auto_close
32+ self .duration = 30000 # 默认显示30秒(如果启用自动关闭)
3233 self .init_ui ()
3334 self .init_animation ()
34- self .start_auto_close_timer ()
35+ if self .auto_close :
36+ self .start_auto_close_timer ()
3537
3638 def init_ui (self ):
3739 """初始化UI界面"""
@@ -214,8 +216,8 @@ def close_with_animation(self):
214216 self .group_animation .start ()
215217
216218 def mousePressEvent (self , event ):
217- """鼠标按下事件 - 重置自动关闭定时器"""
218- if event .button () == Qt .LeftButton :
219+ """鼠标按下事件 - 重置自动关闭定时器(仅在启用自动关闭时) """
220+ if event .button () == Qt .LeftButton and self . auto_close and hasattr ( self , 'timer' ) :
219221 self .timer .start (self .duration )
220222 super ().mousePressEvent (event )
221223
0 commit comments