2727 "skin_mode" : "Classic" ,
2828 "PC_PATH" : ".\\ " ,
2929 "MCU_PATH" : "" ,
30- "Now_Focus" : "PC"
30+ "Now_Focus" : "PC" ,
31+ "MCU_folders" : []
3132}
3233
3334supported_file_types = (".txt" , ".py" , ".json" ,
@@ -53,7 +54,7 @@ def func_highlightRecvText(text:str, isHtml:bool=False):
5354 Cursor .insertText (text )
5455
5556def func_highlightSendText ():
56- """高亮调试窗口的信息"""
57+ """高亮调试窗口的信息【未实现】 """
5758 curs = port_dialog .sendingTextEdit .textCursor ()
5859
5960def bind_methods ():
@@ -107,7 +108,7 @@ def bind_methods():
107108def func_for_show_ports (* args ):
108109 """展示串口的函数"""
109110 fresh_ports ()
110- print (global_options )
111+ # print(global_options)
111112 main_window .port_select .showPopup ()
112113
113114def fresh_ports ():
@@ -134,14 +135,15 @@ def fresh_ports():
134135
135136def func_for_select_port (* args ):
136137 """选择连接到某个串口"""
138+ global global_options
137139 index = args [0 ]
138140 main_window .statusBar .showMessage (f'连接{ global_options ["temp_ports_list" ][index - 1 ]} ' )
139141 if index > 0 :
140142 serial_manager .open_port (global_options ["temp_ports_list" ][index - 1 ])
141143 else :
142144 serial_manager .close_port ()
143145 global_options ["last_port" ] = index
144- global_options [ "MCU_PATH" ] = ""
146+
145147
146148def create_right_menu_MCU ():
147149 """右键菜单"""
@@ -246,24 +248,29 @@ def func_for_fresh_MCU_files(lst:list):
246248 """刷新单片机内的文件"""
247249 global global_options
248250 main_window .MCU_files .clear ()
249- if global_options [ "MCU_PATH" ] :
251+ def mcuListAddItem ( text : str , iconPath : str ) :
250252 a = QListWidgetItem ()
251- a .setText (".. \\ " )
253+ a .setText (text )
252254 icon = QIcon ()
253- icon .addFile (f":/ROOT/icons/backFolder.svg" , QSize (), QIcon .Normal , QIcon .Off )
255+ icon .addFile (iconPath , QSize (), QIcon .Normal , QIcon .Off )
254256 a .setIcon (icon )
255257 main_window .MCU_files .addItem (a )
258+
259+ if global_options ["MCU_PATH" ]:
260+ mcuListAddItem ("..\\ " , f":/ROOT/icons/backFolder.svg" )
261+
262+ files_list = []
263+ global_options ["MCU_folders" ].clear ()
256264 for i in lst :
257- a = QListWidgetItem ()
258- a .setText (i .decode ())
259- icon = QIcon ()
260265 if i .endswith (b"/" ):
261- icon . addFile ( f":/ROOT/icons/folder.svg" , QSize (), QIcon . Normal , QIcon . Off )
266+ global_options [ "MCU_folders" ]. append ( i [: - 1 ]. decode () )
262267 else :
263- _ , ext = split_file_name (i .decode ())
264- icon .addFile (f":/ROOT/icons/{ ext [1 :]} .ico" , QSize (), QIcon .Normal , QIcon .Off )
265- a .setIcon (icon )
266- main_window .MCU_files .addItem (a )
268+ files_list .append (i .decode ())
269+ for i in global_options ["MCU_folders" ]:
270+ mcuListAddItem (i , f":/ROOT/icons/folder.svg" )
271+ for i in files_list :
272+ _ , ext = split_file_name (i )
273+ mcuListAddItem (i , f":/ROOT/icons/{ ext [1 :]} .ico" )
267274 main_window .MCU_files .setCurrentRow (0 )
268275
269276def fresh_PC_files ():
@@ -353,9 +360,9 @@ def remove_file(device:str, file_name:str):
353360 elif device == "MCU" :
354361 if serial_manager .pyb is not None :
355362 try :
356- if file_name . endswith ( '/' ) :
363+ if file_name in global_options [ "MCU_folders" ] :
357364 serial_manager .pyb .enter_raw_repl ()
358- serial_manager .pyb .fs_rmdir (global_options ["MCU_PATH" ]+ file_name [: - 1 ] )
365+ serial_manager .pyb .fs_rmdir (global_options ["MCU_PATH" ]+ file_name )
359366 else :
360367 serial_manager .pyb .enter_raw_repl ()
361368 serial_manager .pyb .fs_rm (global_options ["MCU_PATH" ]+ file_name )
@@ -386,13 +393,13 @@ def open_file(device:str, file_name:str):
386393 try :
387394 if file_name == "..\\ " :
388395 go_pre_folder ("MCU" )
389- elif not file_name . endswith ( "/" ) :
396+ elif not file_name in global_options [ "MCU_folders" ] :
390397 file_transport ("MCU" , file_name , "_" + file_name )
391398 main_window .statusBar .showMessage (codeEditor .open_file (global_options ["PC_PATH" ]+ "_" + file_name ))
392399 file_transport ("PC" , "_" + file_name , file_name )
393400 remove_file ("PC" , "_" + file_name )
394401 else :
395- open_folder ("MCU" , file_name [: - 1 ] )
402+ open_folder ("MCU" , file_name )
396403 except Exception as e :
397404 func_for_serial_erro (str (e ))
398405
0 commit comments