je-editor 0.0.202__py3-none-any.whl → 0.0.228__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. je_editor/__init__.py +2 -2
  2. je_editor/code_scan/__init__.py +0 -0
  3. je_editor/code_scan/ruff_thread.py +58 -0
  4. je_editor/code_scan/watchdog_implement.py +56 -0
  5. je_editor/code_scan/watchdog_thread.py +78 -0
  6. je_editor/git_client/__init__.py +0 -0
  7. je_editor/git_client/commit_graph.py +77 -0
  8. je_editor/git_client/git_action.py +175 -0
  9. je_editor/git_client/git_cli.py +66 -0
  10. je_editor/pyside_ui/browser/browser_download_window.py +40 -4
  11. je_editor/pyside_ui/browser/browser_serach_lineedit.py +24 -0
  12. je_editor/pyside_ui/browser/browser_view.py +55 -6
  13. je_editor/pyside_ui/browser/browser_widget.py +62 -19
  14. je_editor/pyside_ui/browser/main_browser_widget.py +85 -0
  15. je_editor/pyside_ui/code/auto_save/auto_save_manager.py +33 -1
  16. je_editor/pyside_ui/code/auto_save/auto_save_thread.py +18 -5
  17. je_editor/pyside_ui/code/code_format/pep8_format.py +52 -7
  18. je_editor/pyside_ui/code/code_process/code_exec.py +118 -64
  19. je_editor/pyside_ui/code/plaintext_code_edit/code_edit_plaintext.py +115 -53
  20. je_editor/pyside_ui/code/running_process_manager.py +18 -0
  21. je_editor/pyside_ui/code/shell_process/shell_exec.py +99 -60
  22. je_editor/pyside_ui/code/syntax/python_syntax.py +44 -9
  23. je_editor/pyside_ui/code/syntax/syntax_setting.py +39 -11
  24. je_editor/pyside_ui/code/textedit_code_result/code_record.py +33 -11
  25. je_editor/pyside_ui/code/variable_inspector/__init__.py +0 -0
  26. je_editor/pyside_ui/code/variable_inspector/inspector_gui.py +172 -0
  27. je_editor/pyside_ui/dialog/ai_dialog/__init__.py +0 -0
  28. je_editor/pyside_ui/dialog/ai_dialog/set_ai_dialog.py +71 -0
  29. je_editor/pyside_ui/dialog/file_dialog/create_file_dialog.py +38 -4
  30. je_editor/pyside_ui/dialog/file_dialog/open_file_dialog.py +32 -4
  31. je_editor/pyside_ui/dialog/file_dialog/save_file_dialog.py +25 -2
  32. je_editor/pyside_ui/dialog/search_ui/search_error_box.py +27 -2
  33. je_editor/pyside_ui/dialog/search_ui/search_text_box.py +28 -3
  34. je_editor/pyside_ui/git_ui/__init__.py +0 -0
  35. je_editor/pyside_ui/git_ui/code_diff_compare/__init__.py +0 -0
  36. je_editor/pyside_ui/git_ui/code_diff_compare/code_diff_viewer_widget.py +90 -0
  37. je_editor/pyside_ui/git_ui/code_diff_compare/line_number_code_viewer.py +141 -0
  38. je_editor/pyside_ui/git_ui/code_diff_compare/multi_file_diff_viewer.py +88 -0
  39. je_editor/pyside_ui/git_ui/code_diff_compare/side_by_side_diff_widget.py +284 -0
  40. je_editor/pyside_ui/git_ui/git_client/__init__.py +0 -0
  41. je_editor/pyside_ui/git_ui/git_client/commit_table.py +65 -0
  42. je_editor/pyside_ui/git_ui/git_client/git_branch_tree_widget.py +156 -0
  43. je_editor/pyside_ui/git_ui/git_client/git_client_gui.py +799 -0
  44. je_editor/pyside_ui/git_ui/git_client/graph_view.py +218 -0
  45. je_editor/pyside_ui/main_ui/ai_widget/__init__.py +0 -0
  46. je_editor/pyside_ui/main_ui/ai_widget/ai_config.py +34 -0
  47. je_editor/pyside_ui/main_ui/ai_widget/ask_thread.py +36 -0
  48. je_editor/pyside_ui/main_ui/ai_widget/chat_ui.py +147 -0
  49. je_editor/pyside_ui/main_ui/ai_widget/langchain_interface.py +84 -0
  50. je_editor/pyside_ui/main_ui/console_widget/__init__.py +0 -0
  51. je_editor/pyside_ui/main_ui/console_widget/console_gui.py +162 -0
  52. je_editor/pyside_ui/main_ui/console_widget/qprocess_adapter.py +84 -0
  53. je_editor/pyside_ui/main_ui/dock/destroy_dock.py +32 -1
  54. je_editor/pyside_ui/main_ui/editor/editor_widget.py +113 -23
  55. je_editor/pyside_ui/main_ui/editor/editor_widget_dock.py +33 -6
  56. je_editor/pyside_ui/main_ui/editor/process_input.py +42 -10
  57. je_editor/pyside_ui/main_ui/ipython_widget/rich_jupyter.py +45 -10
  58. je_editor/pyside_ui/main_ui/main_editor.py +189 -49
  59. je_editor/pyside_ui/main_ui/menu/check_style_menu/build_check_style_menu.py +50 -27
  60. je_editor/pyside_ui/main_ui/menu/dock_menu/build_dock_menu.py +141 -30
  61. je_editor/pyside_ui/main_ui/menu/file_menu/build_file_menu.py +67 -17
  62. je_editor/pyside_ui/main_ui/menu/help_menu/build_help_menu.py +33 -3
  63. je_editor/pyside_ui/main_ui/menu/language_menu/build_language_server.py +39 -0
  64. je_editor/pyside_ui/main_ui/menu/python_env_menu/build_venv_menu.py +102 -40
  65. je_editor/pyside_ui/main_ui/menu/run_menu/build_run_menu.py +53 -6
  66. je_editor/pyside_ui/main_ui/menu/run_menu/under_run_menu/build_debug_menu.py +47 -3
  67. je_editor/pyside_ui/main_ui/menu/run_menu/under_run_menu/build_program_menu.py +45 -5
  68. je_editor/pyside_ui/main_ui/menu/run_menu/under_run_menu/build_shell_menu.py +41 -3
  69. je_editor/pyside_ui/main_ui/menu/run_menu/under_run_menu/utils.py +21 -0
  70. je_editor/pyside_ui/main_ui/menu/set_menu_bar.py +37 -11
  71. je_editor/pyside_ui/main_ui/menu/style_menu/build_style_menu.py +42 -6
  72. je_editor/pyside_ui/main_ui/menu/tab_menu/build_tab_menu.py +202 -27
  73. je_editor/pyside_ui/main_ui/menu/text_menu/build_text_menu.py +66 -0
  74. je_editor/pyside_ui/main_ui/save_settings/setting_utils.py +18 -1
  75. je_editor/pyside_ui/main_ui/save_settings/user_color_setting_file.py +32 -2
  76. je_editor/pyside_ui/main_ui/save_settings/user_setting_file.py +37 -10
  77. je_editor/pyside_ui/main_ui/system_tray/extend_system_tray.py +39 -0
  78. je_editor/start_editor.py +25 -0
  79. je_editor/utils/encodings/python_encodings.py +100 -97
  80. je_editor/utils/exception/exception_tags.py +11 -11
  81. je_editor/utils/file/open/open_file.py +35 -19
  82. je_editor/utils/file/save/save_file.py +34 -13
  83. je_editor/utils/json/json_file.py +29 -14
  84. je_editor/utils/json_format/json_process.py +32 -1
  85. je_editor/utils/logging/loggin_instance.py +37 -7
  86. je_editor/utils/multi_language/english.py +102 -6
  87. je_editor/utils/multi_language/multi_language_wrapper.py +28 -3
  88. je_editor/utils/multi_language/traditional_chinese.py +101 -10
  89. je_editor/utils/redirect_manager/redirect_manager_class.py +49 -11
  90. je_editor/utils/venv_check/check_venv.py +37 -14
  91. {je_editor-0.0.202.dist-info → je_editor-0.0.228.dist-info}/METADATA +12 -6
  92. je_editor-0.0.228.dist-info/RECORD +140 -0
  93. {je_editor-0.0.202.dist-info → je_editor-0.0.228.dist-info}/WHEEL +1 -1
  94. je_editor-0.0.202.dist-info/RECORD +0 -108
  95. {je_editor-0.0.202.dist-info → je_editor-0.0.228.dist-info/licenses}/LICENSE +0 -0
  96. {je_editor-0.0.202.dist-info → je_editor-0.0.228.dist-info}/top_level.txt +0 -0
@@ -1,33 +1,63 @@
1
+ # 匯入未來功能,允許延遲型別註解 (Python 3.7+ 常用)
2
+ # Import future feature: postponed evaluation of type annotations
1
3
  from __future__ import annotations
2
4
 
5
+ # 僅用於型別檢查,避免循環匯入
6
+ # For type checking only (avoids circular imports)
3
7
  from typing import TYPE_CHECKING
4
8
 
9
+ # 匯入 Qt 動作
10
+ # Import QAction
5
11
  from PySide6.QtGui import QAction
6
12
 
13
+ # 匯入程式執行管理器 (ExecManager)
14
+ # Import ExecManager for running code
7
15
  from je_editor.pyside_ui.code.code_process.code_exec import ExecManager
16
+ # 匯入檔案儲存對話框
17
+ # Import file save dialog
8
18
  from je_editor.pyside_ui.dialog.file_dialog.save_file_dialog import choose_file_get_save_file_path
19
+ # 匯入編輯器元件
20
+ # Import EditorWidget
9
21
  from je_editor.pyside_ui.main_ui.editor.editor_widget import EditorWidget
22
+ # 匯入輸入處理 (用於程式輸入)
23
+ # Import ProcessInput for handling program input
10
24
  from je_editor.pyside_ui.main_ui.editor.process_input import ProcessInput
25
+ # 匯入工具函式:顯示「請先關閉目前執行中的程式」訊息框
26
+ # Import utility: show message box if a program is already running
11
27
  from je_editor.pyside_ui.main_ui.menu.run_menu.under_run_menu.utils import please_close_current_running_messagebox
28
+ # 匯入日誌紀錄器
29
+ # Import logger instance
12
30
  from je_editor.utils.logging.loggin_instance import jeditor_logger
31
+ # 匯入多語言包裝器
32
+ # Import multi-language wrapper for UI localization
13
33
  from je_editor.utils.multi_language.multi_language_wrapper import language_wrapper
14
34
 
35
+ # 僅在型別檢查時匯入 EditorMain,避免循環依賴
36
+ # Import EditorMain only for type checking (avoids circular dependency)
15
37
  if TYPE_CHECKING:
16
38
  from je_editor.pyside_ui.main_ui.main_editor import EditorMain
17
39
 
18
40
 
41
+ # 設定「執行程式」選單
42
+ # Set up the "Run Program" menu
19
43
  def set_program_menu(ui_we_want_to_set: EditorMain) -> None:
20
44
  jeditor_logger.info(f"build_program_menu.py set_program_menu ui_we_want_to_set: {ui_we_want_to_set}")
45
+ # 在 Run 選單下建立 Program 子選單
46
+ # Create Program submenu under Run menu
21
47
  ui_we_want_to_set.run_program_menu = ui_we_want_to_set.run_menu.addMenu(
22
48
  language_wrapper.language_word_dict.get("run_menu_run_program_label"))
23
- # Run program
49
+
50
+ # 建立「執行程式」動作
51
+ # Add "Run Program" action
24
52
  ui_we_want_to_set.run_program_menu.run_program_action = QAction(
25
53
  language_wrapper.language_word_dict.get("run_menu_run_program_label"))
26
54
  ui_we_want_to_set.run_program_menu.run_program_action.triggered.connect(
27
55
  lambda: run_program(ui_we_want_to_set)
28
56
  )
29
57
  ui_we_want_to_set.run_program_menu.addAction(ui_we_want_to_set.run_program_menu.run_program_action)
30
- # Show shell input
58
+
59
+ # 建立「顯示程式輸入」動作
60
+ # Add "Show Program Input" action
31
61
  ui_we_want_to_set.run_program_menu.show_shell_input = QAction(
32
62
  language_wrapper.language_word_dict.get("show_program_input"))
33
63
  ui_we_want_to_set.run_program_menu.show_shell_input.triggered.connect(
@@ -36,23 +66,33 @@ def set_program_menu(ui_we_want_to_set: EditorMain) -> None:
36
66
  ui_we_want_to_set.run_program_menu.addAction(ui_we_want_to_set.run_program_menu.show_shell_input)
37
67
 
38
68
 
69
+ # 執行程式
70
+ # Run program
39
71
  def run_program(ui_we_want_to_set: EditorMain) -> None:
40
72
  jeditor_logger.info(f"build_program_menu.py run_program ui_we_want_to_set: {ui_we_want_to_set}")
41
73
  widget = ui_we_want_to_set.tab_widget.currentWidget()
42
74
  if isinstance(widget, EditorWidget):
75
+ # 確保沒有正在執行的程式
76
+ # Ensure no program is already running
43
77
  if widget.exec_program is None:
44
78
  widget.python_compiler = ui_we_want_to_set.python_compiler
79
+ # 要求使用者選擇儲存檔案路徑
80
+ # Ask user to choose save file path
45
81
  if choose_file_get_save_file_path(ui_we_want_to_set):
82
+ # 建立程式執行管理器並執行程式
83
+ # Create ExecManager and run program
46
84
  code_exec = ExecManager(widget, program_encoding=ui_we_want_to_set.encoding)
47
85
  code_exec.later_init()
48
- code_exec.exec_code(
49
- widget.current_file
50
- )
86
+ code_exec.exec_code(widget.current_file)
51
87
  widget.exec_program = code_exec
52
88
  else:
89
+ # 如果已有程式在執行,顯示提示訊息
90
+ # If a program is already running, show message
53
91
  please_close_current_running_messagebox(ui_we_want_to_set)
54
92
 
55
93
 
94
+ # 顯示程式輸入介面
95
+ # Show program input interface
56
96
  def show_program_input(ui_we_want_to_set: EditorMain) -> None:
57
97
  jeditor_logger.info(f"build_program_menu.py show_program_input ui_we_want_to_set: {ui_we_want_to_set}")
58
98
  widget = ui_we_want_to_set.tab_widget.currentWidget()
@@ -1,32 +1,60 @@
1
+ # 匯入未來功能,允許延遲型別註解 (Python 3.7+ 常用)
2
+ # Import future feature: postponed evaluation of type annotations
1
3
  from __future__ import annotations
2
4
 
5
+ # 僅用於型別檢查,避免循環匯入
6
+ # For type checking only (avoids circular imports)
3
7
  from typing import TYPE_CHECKING
4
8
 
9
+ # 匯入編輯器元件與輸入處理
10
+ # Import EditorWidget and ProcessInput
5
11
  from je_editor.pyside_ui.main_ui.editor.editor_widget import EditorWidget
6
12
  from je_editor.pyside_ui.main_ui.editor.process_input import ProcessInput
13
+ # 匯入工具函式:顯示「請先關閉目前執行中的程式」訊息框
14
+ # Import utility: show message box if a program is already running
7
15
  from je_editor.pyside_ui.main_ui.menu.run_menu.under_run_menu.utils import please_close_current_running_messagebox
16
+ # 匯入日誌紀錄器
17
+ # Import logger instance
8
18
  from je_editor.utils.logging.loggin_instance import jeditor_logger
9
19
 
20
+ # 僅在型別檢查時匯入 EditorMain,避免循環依賴
21
+ # Import EditorMain only for type checking (avoids circular dependency)
10
22
  if TYPE_CHECKING:
11
23
  from je_editor.pyside_ui.main_ui.main_editor import EditorMain
24
+
25
+ # 匯入 Qt 動作
26
+ # Import QAction
12
27
  from PySide6.QtGui import QAction
13
28
 
29
+ # 匯入 ShellManager,用於執行系統命令
30
+ # Import ShellManager for executing shell commands
14
31
  from je_editor.pyside_ui.code.shell_process.shell_exec import ShellManager
32
+
33
+ # 匯入多語言包裝器
34
+ # Import multi-language wrapper for UI localization
15
35
  from je_editor.utils.multi_language.multi_language_wrapper import language_wrapper
16
36
 
17
37
 
38
+ # 設定 Shell 選單
39
+ # Set up the Shell menu
18
40
  def set_shell_menu(ui_we_want_to_set: EditorMain) -> None:
19
41
  jeditor_logger.info(f"build_shell_menu.py set_shell_menu ui_we_want_to_set: {ui_we_want_to_set}")
42
+ # 在 Run 選單下建立 Shell 子選單
43
+ # Create Shell submenu under Run menu
20
44
  ui_we_want_to_set.run_shell_menu = ui_we_want_to_set.run_menu.addMenu(
21
45
  language_wrapper.language_word_dict.get("run_menu_run_on_shell_label"))
22
- # Run on shell
46
+
47
+ # 建立「在 Shell 執行」動作
48
+ # Add "Run on Shell" action
23
49
  ui_we_want_to_set.run_shell_menu.run_on_shell_action = QAction(
24
50
  language_wrapper.language_word_dict.get("run_menu_run_on_shell_label"))
25
51
  ui_we_want_to_set.run_shell_menu.run_on_shell_action.triggered.connect(
26
52
  lambda: shell_exec(ui_we_want_to_set)
27
53
  )
28
54
  ui_we_want_to_set.run_shell_menu.addAction(ui_we_want_to_set.run_shell_menu.run_on_shell_action)
29
- # Show shell input
55
+
56
+ # 建立「顯示 Shell 輸入」動作
57
+ # Add "Show Shell Input" action
30
58
  ui_we_want_to_set.run_shell_menu.show_shell_input = QAction(
31
59
  language_wrapper.language_word_dict.get("show_shell_input"))
32
60
  ui_we_want_to_set.run_shell_menu.show_shell_input.triggered.connect(
@@ -35,23 +63,33 @@ def set_shell_menu(ui_we_want_to_set: EditorMain) -> None:
35
63
  ui_we_want_to_set.run_shell_menu.addAction(ui_we_want_to_set.run_shell_menu.show_shell_input)
36
64
 
37
65
 
66
+ # 在 Shell 中執行程式碼
67
+ # Execute code in Shell
38
68
  def shell_exec(ui_we_want_to_set: EditorMain) -> None:
39
69
  jeditor_logger.info(f"build_shell_menu.py shell_exec ui_we_want_to_set: {ui_we_want_to_set}")
40
70
  widget = ui_we_want_to_set.tab_widget.currentWidget()
41
71
  if isinstance(widget, EditorWidget):
72
+ # 確保沒有正在執行的 Shell 程式
73
+ # Ensure no shell process is already running
42
74
  if widget.exec_shell is None:
75
+ # 建立 ShellManager 並執行當前編輯器中的程式碼
76
+ # Create ShellManager and execute current editor code
43
77
  shell_command = ShellManager(
44
78
  main_window=widget,
45
79
  shell_encoding=ui_we_want_to_set.encoding)
46
80
  shell_command.later_init()
47
81
  shell_command.exec_shell(
48
- widget.code_edit.toPlainText()
82
+ widget.code_edit.toPlainText() # 直接執行編輯器中的文字
49
83
  )
50
84
  widget.exec_shell = shell_command
51
85
  else:
86
+ # 如果已有 Shell 在執行,顯示提示訊息
87
+ # If a shell process is already running, show message
52
88
  please_close_current_running_messagebox(ui_we_want_to_set)
53
89
 
54
90
 
91
+ # 顯示 Shell 輸入介面
92
+ # Show Shell input interface
55
93
  def show_shell_input(ui_we_want_to_set: EditorMain) -> None:
56
94
  jeditor_logger.info(f"build_shell_menu.py show_shell_input ui_we_want_to_set: {ui_we_want_to_set}")
57
95
  widget = ui_we_want_to_set.tab_widget.currentWidget()
@@ -2,19 +2,40 @@ from __future__ import annotations
2
2
 
3
3
  from typing import TYPE_CHECKING
4
4
 
5
+ # 匯入 Qt 訊息框
6
+ # Import QMessageBox for showing message dialogs
5
7
  from PySide6.QtWidgets import QMessageBox
6
8
 
9
+ # 匯入日誌紀錄器
10
+ # Import logger instance
7
11
  from je_editor.utils.logging.loggin_instance import jeditor_logger
12
+ # 匯入多語言包裝器,用於多語言顯示
13
+ # Import multi-language wrapper for UI localization
8
14
  from je_editor.utils.multi_language.multi_language_wrapper import language_wrapper
9
15
 
16
+ # 僅在型別檢查時匯入 EditorMain,避免循環依賴
17
+ # Import EditorMain only for type checking (avoids circular dependency)
10
18
  if TYPE_CHECKING:
11
19
  from je_editor.pyside_ui.main_ui.main_editor import EditorMain
12
20
 
13
21
 
22
+ # 顯示「請先關閉目前執行中的程式」訊息框
23
+ # Show a message box: "Please stop the currently running program first"
14
24
  def please_close_current_running_messagebox(ui_we_want_to_set: EditorMain):
25
+ # 紀錄日誌,方便除錯
26
+ # Log info for debugging
15
27
  jeditor_logger.info(f"utils.py please_close_current_running_messagebox ui_we_want_to_set: {ui_we_want_to_set}")
28
+
29
+ # 建立訊息框,父視窗為主編輯器
30
+ # Create a message box with the main editor as parent
16
31
  please_stop_current_running_program_messagebox = QMessageBox(ui_we_want_to_set)
32
+
33
+ # 設定訊息框文字,從多語言字典取得對應語言的提示
34
+ # Set message text, retrieved from multi-language dictionary
17
35
  please_stop_current_running_program_messagebox.setText(
18
36
  language_wrapper.language_word_dict.get("please_stop_current_running_program")
19
37
  )
38
+
39
+ # 顯示訊息框
40
+ # Show the message box
20
41
  please_stop_current_running_program_messagebox.show()
@@ -2,6 +2,8 @@ from __future__ import annotations
2
2
 
3
3
  from typing import TYPE_CHECKING
4
4
 
5
+ # 匯入各種子選單的建構函式
6
+ # Import functions to build different sub-menus
5
7
  from je_editor.pyside_ui.main_ui.menu.dock_menu.build_dock_menu import set_dock_menu
6
8
  from je_editor.pyside_ui.main_ui.menu.language_menu.build_language_server import set_language_menu
7
9
  from je_editor.pyside_ui.main_ui.menu.style_menu.build_style_menu import set_style_menu
@@ -9,10 +11,22 @@ from je_editor.pyside_ui.main_ui.menu.tab_menu.build_tab_menu import set_tab_men
9
11
  from je_editor.pyside_ui.main_ui.menu.text_menu.build_text_menu import set_text_menu
10
12
  from je_editor.utils.logging.loggin_instance import jeditor_logger
11
13
 
14
+ # 啟用未來註解功能,允許型別提示使用字串前向參照
15
+ # Enable future annotations, allowing forward references in type hints
16
+ # TYPE_CHECKING 用於避免在執行時載入不必要的模組
17
+ # TYPE_CHECKING prevents unnecessary imports at runtime
18
+
12
19
  if TYPE_CHECKING:
13
20
  from je_editor.pyside_ui.main_ui.main_editor import EditorMain
21
+ # 僅在型別檢查時匯入 EditorMain,避免循環依賴
22
+ # Import EditorMain only for type checking
23
+
14
24
  from PySide6.QtWidgets import QMenuBar
25
+ # 匯入 QMenuBar,用於建立選單列
26
+ # Import QMenuBar to create the menu bar
15
27
 
28
+ # 其他子選單建構函式
29
+ # Other sub-menu builders
16
30
  from je_editor.pyside_ui.main_ui.menu.check_style_menu.build_check_style_menu import set_check_menu
17
31
  from je_editor.pyside_ui.main_ui.menu.file_menu.build_file_menu import set_file_menu
18
32
  from je_editor.pyside_ui.main_ui.menu.help_menu.build_help_menu import set_help_menu
@@ -21,17 +35,29 @@ from je_editor.pyside_ui.main_ui.menu.python_env_menu.build_venv_menu import set
21
35
 
22
36
 
23
37
  def set_menu_bar(ui_we_want_to_set: EditorMain) -> None:
38
+ """
39
+ 建立主選單列,並依序加入各種子選單
40
+ Build the main menu bar and add all sub-menus in order
41
+ """
24
42
  jeditor_logger.info(f"set_menu_bar.py set_menu_bar ui_we_want_to_set: {ui_we_want_to_set}")
25
- # set menu
43
+
44
+ # 建立一個新的選單列
45
+ # Create a new menu bar
26
46
  ui_we_want_to_set.menu = QMenuBar()
27
- set_file_menu(ui_we_want_to_set)
28
- set_run_menu(ui_we_want_to_set)
29
- set_text_menu(ui_we_want_to_set)
30
- set_check_menu(ui_we_want_to_set)
31
- set_help_menu(ui_we_want_to_set)
32
- set_venv_menu(ui_we_want_to_set)
33
- set_tab_menu(ui_we_want_to_set)
34
- set_dock_menu(ui_we_want_to_set)
35
- set_style_menu(ui_we_want_to_set)
36
- set_language_menu(ui_we_want_to_set)
47
+
48
+ # === 加入各種子選單 ===
49
+ # === Add different sub-menus ===
50
+ set_file_menu(ui_we_want_to_set) # 檔案選單 / File menu
51
+ set_run_menu(ui_we_want_to_set) # 執行選單 / Run menu
52
+ set_text_menu(ui_we_want_to_set) # 文字設定選單 / Text menu
53
+ set_check_menu(ui_we_want_to_set) # 程式碼檢查選單 / Code style check menu
54
+ set_help_menu(ui_we_want_to_set) # 幫助選單 / Help menu
55
+ set_venv_menu(ui_we_want_to_set) # Python 虛擬環境選單 / Python venv menu
56
+ set_tab_menu(ui_we_want_to_set) # 分頁選單 / Tab menu
57
+ set_dock_menu(ui_we_want_to_set) # Dock 視窗選單 / Dock menu
58
+ set_style_menu(ui_we_want_to_set) # 介面樣式選單 / Style menu
59
+ set_language_menu(ui_we_want_to_set) # 語言選單 / Language menu
60
+
61
+ # 將選單列設定到主視窗
62
+ # Attach the menu bar to the main editor window
37
63
  ui_we_want_to_set.setMenuBar(ui_we_want_to_set.menu)
@@ -2,36 +2,72 @@ from __future__ import annotations
2
2
 
3
3
  from typing import TYPE_CHECKING
4
4
 
5
+ # 匯入 Qt 動作
6
+ # Import QAction
5
7
  from PySide6.QtGui import QAction
6
8
 
9
+ # 匯入使用者設定字典,用來保存 UI 樣式設定
10
+ # Import user settings dictionary for saving UI style preferences
7
11
  from je_editor.pyside_ui.main_ui.save_settings.user_setting_file import user_setting_dict
12
+ # 匯入日誌紀錄器
13
+ # Import logger instance
8
14
  from je_editor.utils.logging.loggin_instance import jeditor_logger
9
15
 
10
16
  if TYPE_CHECKING:
17
+ # 僅在型別檢查時匯入 EditorMain,避免循環依賴
18
+ # Import EditorMain only for type checking (avoids circular dependency)
11
19
  from je_editor.pyside_ui.main_ui.main_editor import EditorMain
12
20
 
21
+ # 匯入多語言包裝器,用於 UI 多語言顯示
22
+ # Import multi-language wrapper for UI localization
13
23
  from je_editor.utils.multi_language.multi_language_wrapper import language_wrapper
14
24
 
15
25
 
26
+ # 設定 Style 選單
27
+ # Set up the Style menu
16
28
  def set_style_menu(ui_we_want_to_set: EditorMain) -> None:
17
29
  jeditor_logger.info(f"build_style_menu.py set_style_menu ui_we_want_to_set: {ui_we_want_to_set}")
30
+
31
+ # 在主選單中新增「Style」子選單
32
+ # Add "Style" submenu under the main menu
18
33
  ui_we_want_to_set.menu.style_menu = ui_we_want_to_set.menu.addMenu(
19
34
  language_wrapper.language_word_dict.get("style_menu_label")
20
35
  )
21
- for style in ['dark_amber.xml', 'dark_blue.xml', 'dark_cyan.xml', 'dark_lightgreen.xml',
22
- 'dark_pink.xml', 'dark_purple.xml', 'dark_red.xml', 'dark_teal.xml',
23
- 'dark_yellow.xml', 'light_amber.xml', 'light_blue.xml', 'light_cyan.xml',
24
- 'light_cyan_500.xml', 'light_lightgreen.xml', 'light_pink.xml', 'light_purple.xml'
25
- ]:
36
+
37
+ # 預設提供的樣式清單 (深色/淺色不同配色)
38
+ # Predefined style list (dark/light themes with different colors)
39
+ for style in [
40
+ 'dark_amber.xml', 'dark_blue.xml', 'dark_cyan.xml', 'dark_lightgreen.xml',
41
+ 'dark_pink.xml', 'dark_purple.xml', 'dark_red.xml', 'dark_teal.xml',
42
+ 'dark_yellow.xml', 'light_amber.xml', 'light_blue.xml', 'light_cyan.xml',
43
+ 'light_cyan_500.xml', 'light_lightgreen.xml', 'light_pink.xml', 'light_purple.xml'
44
+ ]:
45
+ # 建立一個 QAction,名稱為樣式檔名
46
+ # Create an QAction with the style filename as label
26
47
  change_style_action = QAction(style, parent=ui_we_want_to_set.menu.style_menu)
48
+
49
+ # 綁定觸發事件,呼叫 set_style 來套用樣式
50
+ # Connect action to set_style function
27
51
  change_style_action.triggered.connect(
28
- lambda checked=False, action=change_style_action: set_style(ui_we_want_to_set, action))
52
+ lambda checked=False, action=change_style_action: set_style(ui_we_want_to_set, action)
53
+ )
54
+
55
+ # 將動作加入 Style 選單
56
+ # Add action to the Style menu
29
57
  ui_we_want_to_set.menu.style_menu.addAction(change_style_action)
30
58
 
31
59
 
60
+ # 套用選擇的樣式
61
+ # Apply the selected style
32
62
  def set_style(ui_we_want_to_set: EditorMain, action: QAction) -> None:
33
63
  jeditor_logger.info("build_style_menu.py set_style "
34
64
  f"ui_we_want_to_set: {ui_we_want_to_set} "
35
65
  f"action: {action}")
66
+
67
+ # 呼叫主視窗的 apply_stylesheet 方法,套用選擇的樣式
68
+ # Call main window's apply_stylesheet method to apply the chosen style
36
69
  ui_we_want_to_set.apply_stylesheet(ui_we_want_to_set, action.text())
70
+
71
+ # 更新使用者設定,保存目前選擇的樣式
72
+ # Update user settings dictionary to persist the chosen style
37
73
  user_setting_dict.update({"ui_style": action.text()})