88from PySide6 .QtCore import Qt
99from PySide6 .QtGui import QAction , QIcon
1010from PySide6 .QtWidgets import (
11+ QFrame ,
1112 QHBoxLayout ,
13+ QLabel ,
1214 QMainWindow ,
1315 QMessageBox ,
1416 QSplitter ,
2224from core .plugin_loader import PluginLoader
2325from gui .plugin_config_dialog import PluginConfigDialog
2426from gui .result_viewer import ResultViewer
25- from gui .styles import apply_styles
2627from gui .tool_pages import ToolPage
2728
2829
@@ -83,9 +84,8 @@ def create_function_tree(self):
8384 tree_layout .setContentsMargins (0 , 0 , 0 , 0 )
8485
8586 # 标题
86- from PySide6 .QtWidgets import QLabel
87- title_label = QLabel ("功能列表" )
88- title_label .setObjectName ("title_label" )
87+ title_label = QLabel ('功能列表' )
88+ title_label .setObjectName ('title_label' )
8989 tree_layout .addWidget (title_label )
9090
9191 # 功能树
@@ -120,7 +120,6 @@ def create_content_area(self):
120120
121121 def show_welcome_message (self ):
122122 """显示欢迎信息"""
123- from PySide6 .QtWidgets import QLabel , QFrame
124123 welcome_widget = QWidget ()
125124 welcome_layout = QVBoxLayout (welcome_widget )
126125 welcome_layout .setAlignment (Qt .AlignCenter )
@@ -138,36 +137,36 @@ def show_welcome_message(self):
138137 icon_layout = QVBoxLayout (icon_frame )
139138 icon_layout .setAlignment (Qt .AlignCenter )
140139
141- icon_label = QLabel ("🚀" )
142- icon_label .setStyleSheet (" font-size: 32px; color: white;" )
140+ icon_label = QLabel ('🚀' )
141+ icon_label .setStyleSheet (' font-size: 32px; color: white;' )
143142 icon_layout .addWidget (icon_label )
144143
145144 welcome_layout .addWidget (icon_frame )
146145
147146 # 欢迎标题
148- welcome_label = QLabel (" 欢迎使用 HapRay GUI" )
149- welcome_label .setStyleSheet (" font-size: 24px; font-weight: bold; color: #667eea; margin: 8px 0px;" )
147+ welcome_label = QLabel (' 欢迎使用 HapRay GUI' )
148+ welcome_label .setStyleSheet (' font-size: 24px; font-weight: bold; color: #667eea; margin: 8px 0px;' )
150149 welcome_layout .addWidget (welcome_label )
151150
152151 # 副标题
153- subtitle_label = QLabel (" HapRay 工具集成平台" )
154- subtitle_label .setStyleSheet (" font-size: 16px; color: #6b7280; margin-bottom: 16px;" )
152+ subtitle_label = QLabel (' HapRay 工具集成平台' )
153+ subtitle_label .setStyleSheet (' font-size: 16px; color: #6b7280; margin-bottom: 16px;' )
155154 welcome_layout .addWidget (subtitle_label )
156155
157156 # 功能介绍
158157 features_layout = QVBoxLayout ()
159158 features_layout .setSpacing (8 )
160159
161160 feature_items = [
162- " 🔧 动态测试 - 性能测试和trace收集" ,
163- " ⚡ 优化检测 - 二进制文件优化级别检测" ,
164- " 🔍 符号恢复 - 二进制符号恢复工具" ,
165- " 📊 静态分析 - HAP包静态分析"
161+ ' 🔧 动态测试 - 性能测试和trace收集' ,
162+ ' ⚡ 优化检测 - 二进制文件优化级别检测' ,
163+ ' 🔍 符号恢复 - 二进制符号恢复工具' ,
164+ ' 📊 静态分析 - HAP包静态分析' ,
166165 ]
167166
168167 for feature in feature_items :
169168 feature_label = QLabel (feature )
170- feature_label .setStyleSheet (" font-size: 14px; color: #4b5563; padding: 4px 0px;" )
169+ feature_label .setStyleSheet (' font-size: 14px; color: #4b5563; padding: 4px 0px;' )
171170 features_layout .addWidget (feature_label )
172171
173172 welcome_layout .addLayout (features_layout )
@@ -183,12 +182,12 @@ def show_welcome_message(self):
183182 """ )
184183 hint_layout = QVBoxLayout (hint_frame )
185184
186- hint_title = QLabel (" 开始使用" )
187- hint_title .setStyleSheet (" font-size: 16px; font-weight: bold; color: #667eea; margin-bottom: 8px;" )
185+ hint_title = QLabel (' 开始使用' )
186+ hint_title .setStyleSheet (' font-size: 16px; font-weight: bold; color: #667eea; margin-bottom: 8px;' )
188187 hint_layout .addWidget (hint_title )
189188
190- hint_label = QLabel (" 请在左侧的功能列表中选择您要使用的工具" )
191- hint_label .setStyleSheet (" font-size: 14px; color: #6b7280; line-height: 1.4;" )
189+ hint_label = QLabel (' 请在左侧的功能列表中选择您要使用的工具' )
190+ hint_label .setStyleSheet (' font-size: 14px; color: #6b7280; line-height: 1.4;' )
192191 hint_layout .addWidget (hint_label )
193192
194193 welcome_layout .addWidget (hint_frame )
@@ -211,61 +210,55 @@ def build_function_tree(self):
211210
212211 # 定义action图标映射
213212 action_icons = {
214- " prepare" : "🔧" , # 用例前置条件配置
215- " perf" : "📊" , # 自动化性能测试
216- " manual" : "🎯" , # 手动性能测试
217- " ui-tech-stack" : "🔍" , # 页面技术栈动态识别
218- " update" : "🔄" , # 更新测试报告
219- " compare" : "⚖️" , # 对比报告
220- " opt" : "⚡" , # SO编译优化
221- " static" : "📱" , # 应用技术栈分析
222- " symbol-recovery" : "🔧" # 符号恢复
213+ ' prepare' : '🔧' , # 用例前置条件配置
214+ ' perf' : '📊' , # 自动化性能测试
215+ ' manual' : '🎯' , # 手动性能测试
216+ ' ui-tech-stack' : '🔍' , # 页面技术栈动态识别
217+ ' update' : '🔄' , # 更新测试报告
218+ ' compare' : '⚖️' , # 对比报告
219+ ' opt' : '⚡' , # SO编译优化
220+ ' static' : '📱' , # 应用技术栈分析
221+ ' symbol-recovery' : '🔧' , # 符号恢复
223222 }
224223
225224 # 定义菜单结构映射:plugin_id -> {action_key -> display_name}
226225 menu_structure = {
227- " 负载测试" : {
228- " plugin_actions" : {
229- " perf_testing" : {
230- " prepare" : " 用例前置条件配置" ,
231- " perf" : " 自动化性能测试" ,
232- " manual" : " 手动性能测试" ,
233- " ui-tech-stack" : " 页面技术栈动态识别" ,
234- " update" : " 更新测试报告" ,
235- " compare" : " 对比报告"
226+ ' 负载测试' : {
227+ ' plugin_actions' : {
228+ ' perf_testing' : {
229+ ' prepare' : ' 用例前置条件配置' ,
230+ ' perf' : ' 自动化性能测试' ,
231+ ' manual' : ' 手动性能测试' ,
232+ ' ui-tech-stack' : ' 页面技术栈动态识别' ,
233+ ' update' : ' 更新测试报告' ,
234+ ' compare' : ' 对比报告' ,
236235 }
237236 }
238237 },
239- "应用分析" : {
240- "plugin_actions" : {
241- "optimization_detector" : {
242- "opt" : "SO编译优化"
243- },
244- "static_analyzer" : {
245- "static" : "应用技术栈分析"
246- },
247- "symbol_recovery" : {
248- "symbol-recovery" : "符号恢复"
249- }
238+ '应用分析' : {
239+ 'plugin_actions' : {
240+ 'optimization_detector' : {'opt' : 'SO编译优化' },
241+ 'static_analyzer' : {'static' : '应用技术栈分析' },
242+ 'symbol_recovery' : {'symbol-recovery' : '符号恢复' },
250243 }
251- }
244+ },
252245 }
253246
254247 # 构建菜单结构
255248 for menu_name , menu_config in menu_structure .items ():
256249 menu_item = QTreeWidgetItem (self .function_tree )
257250
258251 # 为一级菜单添加图标
259- if menu_name == " 负载测试" :
260- menu_item .setText (0 , f" 📊 { menu_name } " )
261- elif menu_name == " 应用分析" :
262- menu_item .setText (0 , f" 🔍 { menu_name } " )
263- elif menu_name == " 符号恢复" :
264- menu_item .setText (0 , f" 🔧 { menu_name } " )
252+ if menu_name == ' 负载测试' :
253+ menu_item .setText (0 , f' 📊 { menu_name } ' )
254+ elif menu_name == ' 应用分析' :
255+ menu_item .setText (0 , f' 🔍 { menu_name } ' )
256+ elif menu_name == ' 符号恢复' :
257+ menu_item .setText (0 , f' 🔧 { menu_name } ' )
265258 else :
266259 menu_item .setText (0 , menu_name )
267260
268- plugin_actions = menu_config .get (" plugin_actions" , {})
261+ plugin_actions = menu_config .get (' plugin_actions' , {})
269262
270263 for plugin_id , action_mapping in plugin_actions .items ():
271264 # 检查插件是否存在且启用
@@ -284,13 +277,11 @@ def build_function_tree(self):
284277 # 创建二级菜单项
285278 action_item = QTreeWidgetItem (menu_item )
286279 # 使用对应的图标,如果没有找到则使用默认图标
287- icon = action_icons .get (action_key , "⚙️" )
288- action_item .setText (0 , f"{ icon } { display_name } " )
289- action_item .setData (0 , Qt .UserRole , {
290- 'type' : 'action' ,
291- 'plugin_id' : plugin_id ,
292- 'action' : action_key
293- })
280+ icon = action_icons .get (action_key , '⚙️' )
281+ action_item .setText (0 , f'{ icon } { display_name } ' )
282+ action_item .setData (
283+ 0 , Qt .UserRole , {'type' : 'action' , 'plugin_id' : plugin_id , 'action' : action_key }
284+ )
294285
295286 # 如果一级菜单下没有子项,隐藏该菜单
296287 if menu_item .childCount () == 0 :
@@ -301,7 +292,7 @@ def build_function_tree(self):
301292
302293 # 添加结果查看器节点
303294 result_item = QTreeWidgetItem (self .function_tree )
304- result_item .setText (0 , " 📋 结果查看" )
295+ result_item .setText (0 , ' 📋 结果查看' )
305296 result_item .setData (0 , Qt .UserRole , {'type' : 'result_viewer' })
306297
307298 def on_function_selected (self , item , column ):
@@ -327,11 +318,9 @@ def show_tool_config(self, plugin_id, action=None):
327318
328319 # 创建工具页面
329320 tool_page = ToolPage (tool )
330- if action :
331- # 如果指定了action,设置当前action
332- if hasattr (tool_page , 'current_action' ) and hasattr (tool_page , 'rebuild_param_form' ):
333- tool_page .current_action = action
334- tool_page .rebuild_param_form ()
321+ if action and hasattr (tool_page , 'current_action' ) and hasattr (tool_page , 'rebuild_param_form' ):
322+ tool_page .current_action = action
323+ tool_page .rebuild_param_form ()
335324
336325 tool_page .execution_finished .connect (self .on_execution_finished )
337326
@@ -423,7 +412,7 @@ def show_about(self):
423412 QMessageBox .about (
424413 self ,
425414 '关于 HapRay GUI' ,
426- 'HapRay GUI v1.3.1 \n \n '
415+ 'HapRay GUI v1.4.0 \n \n '
427416 '工具集成平台\n '
428417 '整合了以下工具:\n '
429418 '- 动态测试 (perf_testing)\n '
@@ -440,7 +429,6 @@ def on_execution_finished(self, tool_name: str, result_path: str):
440429 # 刷新结果查看器
441430 self .result_viewer .refresh_results ()
442431
443-
444432 def closeEvent (self , event ):
445433 """关闭事件"""
446434 # 保存窗口大小
0 commit comments