@@ -82,9 +82,9 @@ def __init__(self,
8282class AsyncTaskManager (QObject ):
8383 """异步任务管理器 - 流程化耗时操作处理"""
8484
85- def __init__ (self , parent_widget = None ):
85+ def __init__ (self , gui = None ):
8686 super ().__init__ ()
87- self .parent_widget = parent_widget
87+ self .gui = gui
8888 self .current_tasks : Dict [str , AsyncTaskThread ] = {}
8989 self .current_tooltips : Dict [str , StateToolTip ] = {}
9090 self ._tooltip_offset_counter = 0 # 用于计算tooltip位置偏移
@@ -250,7 +250,7 @@ def _show_tooltip(self, task_id: str, title: str, content: str,
250250 position : Optional [tuple ] = None , parent : Optional [QObject ] = None ):
251251 """显示状态提示"""
252252 # 确定父组件
253- tooltip_parent = parent or self .parent_widget
253+ tooltip_parent = parent or self .gui
254254 if not tooltip_parent :
255255 return
256256 tooltip = StateToolTip (title , content , tooltip_parent )
@@ -291,13 +291,13 @@ def _cleanup_tooltip(self, task_id: str):
291291
292292 def _rearrange_tooltips (self ):
293293 """重新排列剩余tooltip的位置,避免空隙"""
294- if not self .current_tooltips or not self .parent_widget :
294+ if not self .current_tooltips or not self .gui :
295295 self ._tooltip_offset_counter = 0
296296 return
297297
298298 # 按创建顺序重新排列tooltip位置
299299 for i , tooltip in enumerate (self .current_tooltips .values ()):
300- x = self .parent_widget .width () - tooltip .width () - 30
300+ x = self .gui .width () - tooltip .width () - 30
301301 y = 20 + (i * 80 ) # 每个tooltip垂直间隔80像素
302302 tooltip .move (x , y )
303303
@@ -314,30 +314,31 @@ def _show_success(self, message: str):
314314 ...
315315
316316 def _show_error (self , message : str ):
317- if self .parent_widget :
317+ if self .gui :
318318 InfoBar .error (
319319 title = '错误' , content = message ,
320320 orient = Qt .Horizontal , isClosable = True ,
321321 position = InfoBarPosition .TOP ,
322- duration = - 1 , parent = self .parent_widget
322+ duration = - 1 , parent = self .gui
323323 )
324+ self .gui .log .error (message )
324325
325326 def _show_warning (self , message : str ):
326- if self .parent_widget :
327+ if self .gui :
327328 InfoBar .warning (
328329 title = '警告' , content = message ,
329330 orient = Qt .Horizontal , isClosable = True ,
330331 position = InfoBarPosition .TOP ,
331- duration = 6000 , parent = self .parent_widget
332+ duration = 6000 , parent = self .gui
332333 )
333334
334335 def _show_info (self , message : str ):
335- if self .parent_widget :
336+ if self .gui :
336337 InfoBar .info (
337338 title = '' , content = message ,
338339 orient = Qt .Horizontal , isClosable = True ,
339340 position = InfoBarPosition .TOP ,
340- duration = 2000 , parent = self .parent_widget
341+ duration = 2000 , parent = self .gui
341342 )
342343
343344 def cleanup (self ):
0 commit comments