44from pathlib import Path
55from typing import List , Dict , Type
66
7+ from automation_ide .utils .logging .logger import automation_ide_logger
8+
79environ ["LOCUST_SKIP_MONKEY_PATCH" ] = "1"
810
911from PySide6 .QtCore import QTimer , QCoreApplication
2426
2527class AutomationEditor (EditorMain ):
2628
27- def __init__ (self , debug_mode : bool = False , show_system_tray_ray : bool = False ):
28- super ().__init__ (debug_mode , show_system_tray_ray )
29+ def __init__ (self , debug_mode : bool = False , show_system_tray_ray : bool = False , extend : bool = False ) -> None :
30+ super ().__init__ (debug_mode , show_system_tray_ray , extend = True )
31+
2932 self .current_run_code_window : List [QWidget ] = list ()
3033 # Project compiler if user not choose this will use which to find
3134 self .python_compiler = None
3235 # Delete JEditor help
3336 if self .help_menu :
3437 self .help_menu .deleteLater ()
35- # System tray change
36- if self .show_system_tray_ray :
37- self .system_tray .main_window = self
38- self .system_tray .setToolTip (language_wrapper .language_word_dict .get ("automation_editor_application_name" ))
38+
3939 # Update language_dict
4040 update_language_dict ()
41+
42+ # Title
43+ self .setWindowTitle (language_wrapper .language_word_dict .get ("automation_editor_application_name" ))
44+ self .setToolTip (language_wrapper .language_word_dict .get ("automation_editor_application_name" ))
45+
46+ # Windows 系統專用:設定應用程式 ID
47+ # Windows only: set application ID
48+ if not extend :
49+ self .id = language_wrapper .language_word_dict .get ("automation_editor_application_name" )
50+ if sys .platform in ["win32" , "cygwin" , "msys" ]:
51+ from ctypes import windll
52+ windll .shell32 .SetCurrentProcessExplicitAppUserModelID (self .id )
53+
54+ # Icon
55+ if not extend :
56+ self .icon_path = Path (os .getcwd () + "/automation_ide.ico" )
57+ self .icon = QIcon (str (self .icon_path ))
58+ if not self .icon .isNull ():
59+ self .setWindowIcon (self .icon )
60+
4161 # Menu
4262 add_menu_to_menubar (self )
4363 syntax_extend_package (self )
64+
4465 # Tab
4566 for widget_name , widget in EDITOR_EXTEND_TAB .items ():
4667 self .tab_widget .addTab (widget (), widget_name )
47- # Icon
48- self .icon_path = Path (os .getcwd () + "/AutomationIDE_Icon.ico" )
49- self .icon = QIcon (str (self .icon_path ))
50- self .system_tray = QSystemTrayIcon ()
51- self .system_tray .setIcon (self .icon )
52- # Title
53- self .setWindowTitle (language_wrapper .language_word_dict .get ("automation_editor_application_name" ))
68+
5469 if debug_mode :
5570 close_timer = QTimer (self )
5671 close_timer .setInterval (10000 )
@@ -76,14 +91,14 @@ def start_editor(debug_mode: bool = False, **kwargs) -> None:
7691 Start editor instance
7792 :return: None
7893 """
79- new_editor = QCoreApplication .instance ()
80- if new_editor is None :
81- new_editor = QApplication (sys .argv )
94+ new_ide = QCoreApplication .instance ()
95+ if new_ide is None :
96+ new_ide = QApplication (sys .argv )
8297 window = AutomationEditor (debug_mode = debug_mode , ** kwargs )
83- apply_stylesheet (new_editor , theme = "dark_amber.xml" )
98+ apply_stylesheet (new_ide , theme = "dark_amber.xml" )
8499 window .showMaximized ()
85100 try :
86101 window .startup_setting ()
87102 except Exception as error :
88103 print (repr (error ))
89- sys .exit (new_editor .exec ())
104+ sys .exit (new_ide .exec ())
0 commit comments