je-editor 0.0.223__py3-none-any.whl → 0.0.224__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.

Potentially problematic release.


This version of je-editor might be problematic. Click here for more details.

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