je-editor 0.0.222__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 (75) hide show
  1. je_editor/__init__.py +2 -2
  2. je_editor/git_client/commit_graph.py +7 -7
  3. je_editor/git_client/git_action.py +0 -7
  4. je_editor/pyside_ui/browser/browser_view.py +16 -4
  5. je_editor/pyside_ui/browser/browser_widget.py +43 -29
  6. je_editor/pyside_ui/browser/main_browser_widget.py +85 -0
  7. je_editor/pyside_ui/code/auto_save/auto_save_manager.py +34 -2
  8. je_editor/pyside_ui/code/auto_save/auto_save_thread.py +19 -6
  9. je_editor/pyside_ui/code/code_format/pep8_format.py +53 -9
  10. je_editor/pyside_ui/code/code_process/code_exec.py +88 -52
  11. je_editor/pyside_ui/code/plaintext_code_edit/code_edit_plaintext.py +116 -55
  12. je_editor/pyside_ui/code/running_process_manager.py +19 -1
  13. je_editor/pyside_ui/code/shell_process/shell_exec.py +71 -48
  14. je_editor/pyside_ui/code/syntax/python_syntax.py +45 -10
  15. je_editor/pyside_ui/code/syntax/syntax_setting.py +40 -12
  16. je_editor/pyside_ui/code/textedit_code_result/code_record.py +34 -12
  17. je_editor/pyside_ui/code/variable_inspector/inspector_gui.py +53 -6
  18. je_editor/pyside_ui/dialog/ai_dialog/set_ai_dialog.py +30 -3
  19. je_editor/pyside_ui/dialog/file_dialog/create_file_dialog.py +35 -2
  20. je_editor/pyside_ui/dialog/file_dialog/open_file_dialog.py +33 -5
  21. je_editor/pyside_ui/dialog/file_dialog/save_file_dialog.py +25 -3
  22. je_editor/pyside_ui/dialog/search_ui/search_error_box.py +26 -1
  23. je_editor/pyside_ui/dialog/search_ui/search_text_box.py +26 -1
  24. je_editor/pyside_ui/git_ui/code_diff_compare/code_diff_viewer_widget.py +11 -11
  25. je_editor/pyside_ui/git_ui/git_client/commit_table.py +46 -8
  26. je_editor/pyside_ui/git_ui/git_client/git_branch_tree_widget.py +49 -15
  27. je_editor/pyside_ui/git_ui/git_client/git_client_gui.py +81 -16
  28. je_editor/pyside_ui/git_ui/git_client/graph_view.py +64 -20
  29. je_editor/pyside_ui/main_ui/ai_widget/ai_config.py +20 -5
  30. je_editor/pyside_ui/main_ui/ai_widget/ask_thread.py +20 -1
  31. je_editor/pyside_ui/main_ui/ai_widget/chat_ui.py +56 -41
  32. je_editor/pyside_ui/main_ui/ai_widget/langchain_interface.py +45 -6
  33. je_editor/pyside_ui/main_ui/console_widget/console_gui.py +44 -12
  34. je_editor/pyside_ui/main_ui/console_widget/qprocess_adapter.py +34 -13
  35. je_editor/pyside_ui/main_ui/dock/destroy_dock.py +33 -2
  36. je_editor/pyside_ui/main_ui/editor/editor_widget.py +104 -20
  37. je_editor/pyside_ui/main_ui/editor/editor_widget_dock.py +34 -7
  38. je_editor/pyside_ui/main_ui/editor/process_input.py +38 -11
  39. je_editor/pyside_ui/main_ui/ipython_widget/rich_jupyter.py +46 -11
  40. je_editor/pyside_ui/main_ui/main_editor.py +180 -42
  41. je_editor/pyside_ui/main_ui/menu/check_style_menu/build_check_style_menu.py +51 -28
  42. je_editor/pyside_ui/main_ui/menu/dock_menu/build_dock_menu.py +83 -36
  43. je_editor/pyside_ui/main_ui/menu/file_menu/build_file_menu.py +70 -17
  44. je_editor/pyside_ui/main_ui/menu/help_menu/build_help_menu.py +35 -4
  45. je_editor/pyside_ui/main_ui/menu/language_menu/build_language_server.py +41 -1
  46. je_editor/pyside_ui/main_ui/menu/python_env_menu/build_venv_menu.py +100 -42
  47. je_editor/pyside_ui/main_ui/menu/run_menu/build_run_menu.py +57 -7
  48. je_editor/pyside_ui/main_ui/menu/run_menu/under_run_menu/build_debug_menu.py +50 -4
  49. je_editor/pyside_ui/main_ui/menu/run_menu/under_run_menu/build_program_menu.py +52 -6
  50. je_editor/pyside_ui/main_ui/menu/run_menu/under_run_menu/build_shell_menu.py +44 -4
  51. je_editor/pyside_ui/main_ui/menu/run_menu/under_run_menu/utils.py +23 -1
  52. je_editor/pyside_ui/main_ui/menu/set_menu_bar.py +37 -12
  53. je_editor/pyside_ui/main_ui/menu/style_menu/build_style_menu.py +44 -7
  54. je_editor/pyside_ui/main_ui/menu/tab_menu/build_tab_menu.py +127 -44
  55. je_editor/pyside_ui/main_ui/menu/text_menu/build_text_menu.py +65 -1
  56. je_editor/pyside_ui/main_ui/save_settings/setting_utils.py +18 -1
  57. je_editor/pyside_ui/main_ui/save_settings/user_color_setting_file.py +33 -3
  58. je_editor/pyside_ui/main_ui/save_settings/user_setting_file.py +38 -11
  59. je_editor/pyside_ui/main_ui/system_tray/extend_system_tray.py +39 -2
  60. je_editor/start_editor.py +26 -1
  61. je_editor/utils/encodings/python_encodings.py +101 -98
  62. je_editor/utils/file/open/open_file.py +36 -19
  63. je_editor/utils/file/save/save_file.py +35 -14
  64. je_editor/utils/json/json_file.py +29 -14
  65. je_editor/utils/json_format/json_process.py +33 -2
  66. je_editor/utils/logging/loggin_instance.py +38 -8
  67. je_editor/utils/multi_language/multi_language_wrapper.py +29 -4
  68. je_editor/utils/redirect_manager/redirect_manager_class.py +49 -11
  69. je_editor/utils/venv_check/check_venv.py +45 -15
  70. {je_editor-0.0.222.dist-info → je_editor-0.0.224.dist-info}/METADATA +1 -1
  71. {je_editor-0.0.222.dist-info → je_editor-0.0.224.dist-info}/RECORD +74 -74
  72. je_editor/git_client/github.py +0 -81
  73. {je_editor-0.0.222.dist-info → je_editor-0.0.224.dist-info}/WHEEL +0 -0
  74. {je_editor-0.0.222.dist-info → je_editor-0.0.224.dist-info}/licenses/LICENSE +0 -0
  75. {je_editor-0.0.222.dist-info → je_editor-0.0.224.dist-info}/top_level.txt +0 -0
@@ -1,31 +1,69 @@
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
 
5
9
  from PySide6.QtGui import QAction
10
+ # 匯入 QAction,用於建立選單動作
11
+ # Import QAction for creating menu actions
6
12
 
7
13
  from je_editor.pyside_ui.main_ui.editor.editor_widget import EditorWidget
14
+ # 匯入編輯器元件
15
+ # Import the Editor widget
16
+
8
17
  from je_editor.pyside_ui.main_ui.save_settings.user_setting_file import user_setting_dict
18
+ # 匯入使用者設定字典,用於儲存字型與字體大小
19
+ # Import user setting dictionary to save font and size
20
+
9
21
  from je_editor.utils.logging.loggin_instance import jeditor_logger
22
+ # 匯入日誌工具
23
+ # Import logger
10
24
 
11
25
  if TYPE_CHECKING:
12
26
  from je_editor.pyside_ui.main_ui.main_editor import EditorMain
27
+ # 僅在型別檢查時匯入 EditorMain,避免循環依賴
28
+ # Import EditorMain only for type checking
29
+
13
30
  from je_editor.utils.multi_language.multi_language_wrapper import language_wrapper
31
+ # 匯入多語言包裝器,用於多語系 UI
32
+ # Import language wrapper for multilingual UI
14
33
 
15
34
 
16
35
  def set_text_menu(ui_we_want_to_set: EditorMain):
36
+ """
37
+ 建立文字選單,包含字型與字體大小的子選單
38
+ Create the text menu, including font and font size submenus
39
+ """
17
40
  jeditor_logger.info(f"build_text_menu.py set_text_menu ui_we_want_to_set: {ui_we_want_to_set}")
41
+
42
+ # 建立 Text Menu
43
+ # Create Text Menu
18
44
  ui_we_want_to_set.text_menu = ui_we_want_to_set.menu.addMenu(
19
45
  language_wrapper.language_word_dict.get("text_menu_label"))
46
+
47
+ # === 字型選單 (Font Menu) ===
48
+ # === Font Menu ===
20
49
  ui_we_want_to_set.text_menu.font_menu = ui_we_want_to_set.text_menu.addMenu(
21
50
  language_wrapper.language_word_dict.get("text_menu_label_font"))
51
+
52
+ # 將系統支援的字型加入選單
53
+ # Add available system fonts into the menu
22
54
  for family in ui_we_want_to_set.font_database.families():
23
55
  font_action = QAction(family, parent=ui_we_want_to_set.text_menu.font_menu)
24
56
  font_action.triggered.connect(
25
57
  lambda checked=False, action=font_action: set_font(ui_we_want_to_set, action))
26
58
  ui_we_want_to_set.text_menu.font_menu.addAction(font_action)
59
+
60
+ # === 字體大小選單 (Font Size Menu) ===
61
+ # === Font Size Menu ===
27
62
  ui_we_want_to_set.text_menu.font_size_menu = ui_we_want_to_set.text_menu.addMenu(
28
63
  language_wrapper.language_word_dict.get("text_menu_label_font_size"))
64
+
65
+ # 提供 12 ~ 36 pt 的字體大小選項 (每次增加 2)
66
+ # Provide font sizes from 12 to 36 pt (step = 2)
29
67
  for size in range(12, 38, 2):
30
68
  font_action = QAction(str(size), parent=ui_we_want_to_set.text_menu.font_size_menu)
31
69
  font_action.triggered.connect(
@@ -34,36 +72,62 @@ def set_text_menu(ui_we_want_to_set: EditorMain):
34
72
 
35
73
 
36
74
  def set_font(ui_we_want_to_set: EditorMain, action: QAction) -> None:
75
+ """
76
+ 設定編輯器的字型
77
+ Set the font family for the editor
78
+ """
37
79
  jeditor_logger.info("build_text_menu.py set_font "
38
80
  f"ui_we_want_to_set: {ui_we_want_to_set} "
39
81
  f"action: {action}")
82
+
83
+ # 遍歷所有分頁,找到 EditorWidget 並套用字型
84
+ # Iterate through all tabs, apply font to EditorWidget
40
85
  for code_editor in range(ui_we_want_to_set.tab_widget.count()):
41
86
  widget = ui_we_want_to_set.tab_widget.widget(code_editor)
42
87
  if isinstance(widget, EditorWidget):
88
+ # 設定程式碼編輯區字型
89
+ # Set font for code editor
43
90
  widget.code_edit.setStyleSheet(
44
91
  f"font-size: {widget.code_edit.font().pointSize()}pt;"
45
92
  f"font-family: {action.text()};"
46
93
  )
94
+ # 設定輸出結果區字型
95
+ # Set font for result display
47
96
  widget.code_result.setStyleSheet(
48
97
  f"font-size: {widget.code_result.font().pointSize()}pt;"
49
98
  f"font-family: {action.text()};"
50
99
  )
100
+ # 更新使用者設定
101
+ # Update user settings
51
102
  user_setting_dict.update({"font": action.text()})
52
103
 
53
104
 
54
105
  def set_font_size(ui_we_want_to_set: EditorMain, action: QAction) -> None:
106
+ """
107
+ 設定編輯器的字體大小
108
+ Set the font size for the editor
109
+ """
55
110
  jeditor_logger.info("build_text_menu.py set_font_size "
56
111
  f"ui_we_want_to_set: {ui_we_want_to_set} "
57
112
  f"action: {action}")
113
+
114
+ # 遍歷所有分頁,找到 EditorWidget 並套用字體大小
115
+ # Iterate through all tabs, apply font size to EditorWidget
58
116
  for code_editor in range(ui_we_want_to_set.tab_widget.count()):
59
117
  widget = ui_we_want_to_set.tab_widget.widget(code_editor)
60
118
  if type(widget) is EditorWidget:
119
+ # 設定程式碼編輯區字體大小
120
+ # Set font size for code editor
61
121
  widget.code_edit.setStyleSheet(
62
122
  f"font-size: {int(action.text())}pt;"
63
123
  f"font-family: {widget.code_edit.font().family()};"
64
124
  )
125
+ # 設定輸出結果區字體大小
126
+ # Set font size for result display
65
127
  widget.code_result.setStyleSheet(
66
128
  f"font-size: {int(action.text())}pt;"
67
129
  f"font-family: {widget.code_result.font().family()};"
68
130
  )
69
- user_setting_dict.update({"font_size": int(action.text())})
131
+ # 更新使用者設定
132
+ # Update user settings
133
+ user_setting_dict.update({"font_size": int(action.text())})
@@ -6,11 +6,28 @@ from je_editor.utils.logging.loggin_instance import jeditor_logger
6
6
 
7
7
 
8
8
  def write_setting(save_dict: dict, file_name: str) -> None:
9
+ """
10
+ 將設定資料寫入 JSON 檔案
11
+ Write settings dictionary into a JSON file
12
+ """
13
+ # 紀錄日誌,方便除錯與追蹤
14
+ # Log the action for debugging and tracking
9
15
  jeditor_logger.info("setting_utils.py write_setting "
10
16
  f"save_dict: {save_dict} "
11
17
  f"file_name: {file_name}")
18
+
19
+ # 建立儲存設定的資料夾路徑:當前工作目錄下的 `.jeditor`
20
+ # Create the save directory path: `.jeditor` under current working directory
12
21
  save_dir = Path(getcwd() + "/.jeditor")
22
+
23
+ # 如果資料夾不存在就自動建立 (parents=True 表示可遞迴建立多層資料夾)
24
+ # Create the directory if it does not exist (parents=True allows nested dirs)
13
25
  save_dir.mkdir(parents=True, exist_ok=True)
26
+
27
+ # 建立完整的檔案路徑,例如 `.jeditor/settings.json`
28
+ # Create the full file path, e.g., `.jeditor/settings.json`
14
29
  save_file = Path(getcwd() + f"/.jeditor/{file_name}")
15
- write_json(str(save_file), save_dict)
16
30
 
31
+ # 將設定字典寫入 JSON 檔案
32
+ # Write the dictionary into the JSON file
33
+ write_json(str(save_file), save_dict)
@@ -10,34 +10,47 @@ from je_editor.utils.logging.loggin_instance import jeditor_logger
10
10
 
11
11
 
12
12
  def update_actually_color_dict():
13
+ """
14
+ 更新實際使用的顏色字典 (actually_color_dict),
15
+ 將 user_setting_color_dict 中的 RGB 值轉換成 QColor 物件。
16
+ Update the actual color dictionary (actually_color_dict),
17
+ converting RGB values from user_setting_color_dict into QColor objects.
18
+ """
13
19
  jeditor_logger.info(f"user_color_setting_file.py update_actually_color_dict")
20
+
14
21
  actually_color_dict.update(
15
22
  {
23
+ # 行號顏色 / Line number color
16
24
  "line_number_color": QColor(
17
25
  user_setting_color_dict.get("line_number_color")[0],
18
26
  user_setting_color_dict.get("line_number_color")[1],
19
27
  user_setting_color_dict.get("line_number_color")[2],
20
28
  ),
29
+ # 行號背景顏色 / Line number background color
21
30
  "line_number_background_color": QColor(
22
31
  user_setting_color_dict.get("line_number_background_color")[0],
23
32
  user_setting_color_dict.get("line_number_background_color")[1],
24
33
  user_setting_color_dict.get("line_number_background_color")[2],
25
34
  ),
35
+ # 當前行顏色 / Current line highlight color
26
36
  "current_line_color": QColor(
27
37
  user_setting_color_dict.get("current_line_color")[0],
28
38
  user_setting_color_dict.get("current_line_color")[1],
29
39
  user_setting_color_dict.get("current_line_color")[2],
30
40
  ),
41
+ # 一般輸出顏色 / Normal output color
31
42
  "normal_output_color": QColor(
32
43
  user_setting_color_dict.get("normal_output_color")[0],
33
44
  user_setting_color_dict.get("normal_output_color")[1],
34
45
  user_setting_color_dict.get("normal_output_color")[2],
35
46
  ),
47
+ # 錯誤輸出顏色 / Error output color
36
48
  "error_output_color": QColor(
37
49
  user_setting_color_dict.get("error_output_color")[0],
38
50
  user_setting_color_dict.get("error_output_color")[1],
39
51
  user_setting_color_dict.get("error_output_color")[2],
40
52
  ),
53
+ # 警告輸出顏色 / Warning output color
41
54
  "warning_output_color": QColor(
42
55
  user_setting_color_dict.get("warning_output_color")[0],
43
56
  user_setting_color_dict.get("warning_output_color")[1],
@@ -47,6 +60,8 @@ def update_actually_color_dict():
47
60
  )
48
61
 
49
62
 
63
+ # 使用者設定的顏色字典 (以 RGB list 表示)
64
+ # User-defined color dictionary (stored as RGB lists)
50
65
  user_setting_color_dict: Dict[str, list] = {
51
66
  "line_number_color": [255, 255, 255],
52
67
  "line_number_background_color": [179, 179, 179],
@@ -56,18 +71,33 @@ user_setting_color_dict: Dict[str, list] = {
56
71
  "warning_output_color": [204, 204, 0]
57
72
  }
58
73
 
59
- actually_color_dict: Dict[str, QColor] = {
60
- }
74
+ # 實際使用的顏色字典 (以 QColor 表示)
75
+ # Actual color dictionary (stored as QColor objects)
76
+ actually_color_dict: Dict[str, QColor] = {}
77
+
78
+ # 初始化時先更新一次
79
+ # Update once at initialization
61
80
  update_actually_color_dict()
62
81
 
63
82
 
64
83
  def write_user_color_setting() -> None:
84
+ """
85
+ 將使用者顏色設定寫入 JSON 檔案
86
+ Write user color settings into a JSON file
87
+ """
65
88
  jeditor_logger.info("user_color_setting_file.py write_user_color_setting")
66
89
  write_setting(user_setting_color_dict, "user_color_setting.json")
67
90
 
68
91
 
69
92
  def read_user_color_setting() -> None:
93
+ """
94
+ 從 JSON 檔案讀取使用者顏色設定,並更新 user_setting_color_dict
95
+ Read user color settings from JSON file and update user_setting_color_dict
96
+ """
70
97
  jeditor_logger.info("user_color_setting_file.py read_user_color_setting")
71
98
  user_color_setting_file = Path(getcwd() + "/.jeditor/user_color_setting.json")
99
+
100
+ # 如果檔案存在,就讀取並更新設定
101
+ # If the file exists, read and update the settings
72
102
  if user_color_setting_file.exists() and user_color_setting_file.is_file():
73
- user_setting_color_dict.update(read_json(str(user_color_setting_file)))
103
+ user_setting_color_dict.update(read_json(str(user_color_setting_file)))
@@ -2,30 +2,57 @@ from os import getcwd
2
2
  from pathlib import Path
3
3
 
4
4
  from je_editor.pyside_ui.main_ui.save_settings.setting_utils import write_setting
5
+ # 匯入通用的設定寫入工具
6
+ # Import utility function to write settings
7
+
5
8
  from je_editor.utils.json.json_file import read_json
9
+ # 匯入 JSON 讀取工具
10
+ # Import JSON reader utility
11
+
6
12
  from je_editor.utils.logging.loggin_instance import jeditor_logger
13
+ # 匯入日誌工具
14
+ # Import logger
15
+
7
16
 
17
+ # 使用者設定字典,包含 UI 與編輯器的偏好
18
+ # User settings dictionary, storing UI and editor preferences
8
19
  user_setting_dict = {
9
- "ui_font": "Lato",
10
- "ui_font_size": 12,
11
- "language": "English",
12
- "ui_style": "dark_amber.xml",
13
- "font": "Lato",
14
- "font_size": 12,
15
- "encoding": "utf-8",
16
- "last_file": None,
17
- "python_compiler": None,
18
- "max_line_of_output": 200000,
20
+ "ui_font": "Lato", # UI 字型 / UI font
21
+ "ui_font_size": 12, # UI 字體大小 / UI font size
22
+ "language": "English", # 語言設定 / Language setting
23
+ "ui_style": "dark_amber.xml", # UI 樣式檔 / UI style file
24
+ "font": "Lato", # 編輯器字型 / Editor font
25
+ "font_size": 12, # 編輯器字體大小 / Editor font size
26
+ "encoding": "utf-8", # 檔案編碼 / File encoding
27
+ "last_file": None, # 上次開啟的檔案 / Last opened file
28
+ "python_compiler": None, # Python 編譯器路徑 / Python compiler path
29
+ "max_line_of_output": 200000, # 最大輸出行數限制 / Max lines of output
19
30
  }
20
31
 
21
32
 
22
33
  def write_user_setting() -> None:
34
+ """
35
+ 將使用者設定寫入 JSON 檔案
36
+ Write user settings into a JSON file
37
+ """
23
38
  jeditor_logger.info("user_setting_file.py write_user_setting")
39
+ # 呼叫通用工具,將 user_setting_dict 寫入 `.jeditor/user_setting.json`
40
+ # Use utility to write user_setting_dict into `.jeditor/user_setting.json`
24
41
  write_setting(user_setting_dict, "user_setting.json")
25
42
 
26
43
 
27
44
  def read_user_setting() -> None:
45
+ """
46
+ 從 JSON 檔案讀取使用者設定,並更新 user_setting_dict
47
+ Read user settings from JSON file and update user_setting_dict
48
+ """
28
49
  jeditor_logger.info("user_setting_file.py read_user_setting")
50
+
51
+ # 設定檔路徑:當前工作目錄下的 `.jeditor/user_setting.json`
52
+ # File path: `.jeditor/user_setting.json` under current working directory
29
53
  user_setting_file = Path(getcwd() + "/.jeditor/user_setting.json")
54
+
55
+ # 如果檔案存在,就讀取並更新設定字典
56
+ # If the file exists, read and update the settings dictionary
30
57
  if user_setting_file.exists() and user_setting_file.is_file():
31
- user_setting_dict.update(read_json(str(user_setting_file)))
58
+ user_setting_dict.update(read_json(str(user_setting_file)))
@@ -1,11 +1,15 @@
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
4
-
5
6
  from je_editor.utils.logging.loggin_instance import jeditor_logger
6
7
 
7
8
  if TYPE_CHECKING:
8
9
  from je_editor.pyside_ui.main_ui.main_editor import EditorMain
10
+ # 僅在型別檢查時匯入 EditorMain,避免循環依賴
11
+ # Import EditorMain only for type checking
12
+
9
13
  import sys
10
14
 
11
15
  from PySide6.QtGui import QAction
@@ -14,38 +18,71 @@ from je_editor.utils.multi_language.multi_language_wrapper import language_wrapp
14
18
 
15
19
 
16
20
  class ExtendSystemTray(QSystemTrayIcon):
21
+ """
22
+ 擴充系統匣功能,提供隱藏、最大化、還原、關閉等操作
23
+ Extend system tray functionality with hide, maximize, restore, and close actions
24
+ """
17
25
 
18
26
  def __init__(self, main_window: EditorMain):
27
+ # 初始化並記錄日誌
28
+ # Initialize and log
19
29
  jeditor_logger.info(f"Init ExtendSystemTray main_window: {main_window}")
20
30
  super().__init__(parent=main_window)
31
+
32
+ # 建立右鍵選單
33
+ # Create context menu
21
34
  self.menu = QMenu()
22
35
  self.main_window = main_window
36
+
37
+ # === 隱藏主視窗 / Hide main window ===
23
38
  self.hide_main_window_action = QAction(
24
39
  language_wrapper.language_word_dict.get("system_tray_hide"))
25
40
  self.hide_main_window_action.triggered.connect(self.main_window.hide)
26
41
  self.menu.addAction(self.hide_main_window_action)
42
+
43
+ # === 最大化主視窗 / Maximize main window ===
27
44
  self.maximized_main_window_action = QAction(
28
45
  language_wrapper.language_word_dict.get("system_tray_maximized"))
29
46
  self.maximized_main_window_action.triggered.connect(self.main_window.showMaximized)
30
47
  self.menu.addAction(self.maximized_main_window_action)
48
+
49
+ # === 還原主視窗 / Restore main window ===
31
50
  self.normal_main_window_action = QAction(
32
51
  language_wrapper.language_word_dict.get("system_tray_normal"))
33
52
  self.normal_main_window_action.triggered.connect(self.main_window.showNormal)
34
53
  self.menu.addAction(self.normal_main_window_action)
54
+
55
+ # === 關閉應用程式 / Close application ===
35
56
  self.close_main_window_action = QAction(
36
57
  language_wrapper.language_word_dict.get("system_tray_close"))
37
58
  self.close_main_window_action.triggered.connect(self.close_all)
38
59
  self.menu.addAction(self.close_main_window_action)
60
+
61
+ # 設定選單到系統匣圖示
62
+ # Attach menu to system tray icon
39
63
  self.setContextMenu(self.menu)
64
+
65
+ # 綁定點擊事件 (例如雙擊)
66
+ # Connect click events (e.g., double-click)
40
67
  self.activated.connect(self.clicked)
41
68
 
42
69
  def close_all(self):
70
+ """
71
+ 關閉應用程式:隱藏圖示、關閉主視窗並結束程式
72
+ Close the application: hide tray icon, close main window, and exit program
73
+ """
43
74
  jeditor_logger.info("ExtendSystemTray close_all")
44
75
  self.setVisible(False)
45
76
  self.main_window.close()
46
77
  sys.exit(0)
47
78
 
48
79
  def clicked(self, reason):
80
+ """
81
+ 處理系統匣點擊事件
82
+ Handle system tray click events
83
+ """
49
84
  if reason == self.ActivationReason.DoubleClick:
85
+ # 如果是雙擊,最大化主視窗
86
+ # If double-click, maximize the main window
50
87
  jeditor_logger.info("ExtendSystemTray DoubleClick")
51
- self.main_window.showMaximized()
88
+ self.main_window.showMaximized()
je_editor/start_editor.py CHANGED
@@ -8,10 +8,35 @@ from je_editor.pyside_ui.main_ui.main_editor import EditorMain
8
8
 
9
9
 
10
10
  def start_editor(debug_mode: bool = False) -> None:
11
+ """
12
+ 功能說明 (Function Description):
13
+ 啟動編輯器主程式,建立 QApplication 實例,套用主題,並顯示主視窗。
14
+ Start the main editor application, create QApplication instance, apply theme, and show main window.
15
+
16
+ :param debug_mode: 是否啟用除錯模式 / whether to enable debug mode
17
+ """
18
+
19
+ # 嘗試取得現有的 QCoreApplication 實例
20
+ # Try to get an existing QCoreApplication instance
11
21
  new_editor = QCoreApplication.instance()
22
+
23
+ # 如果沒有現有實例,建立新的 QApplication
24
+ # If no instance exists, create a new QApplication
12
25
  if new_editor is None:
13
26
  new_editor = QApplication(sys.argv)
27
+
28
+ # 建立主視窗,傳入 debug_mode
29
+ # Create the main editor window, passing debug_mode
14
30
  window = EditorMain(debug_mode)
31
+
32
+ # 套用 qt-material 主題 (dark amber)
33
+ # Apply qt-material theme (dark amber)
15
34
  apply_stylesheet(new_editor, theme='dark_amber.xml')
35
+
36
+ # 最大化顯示主視窗
37
+ # Show the main window maximized
16
38
  window.showMaximized()
17
- sys.exit(new_editor.exec())
39
+
40
+ # 啟動事件迴圈,並在結束時退出程式
41
+ # Start the event loop and exit the program when it ends
42
+ sys.exit(new_editor.exec())
@@ -1,99 +1,102 @@
1
+ # 定義一個 Python 支援的文字編碼清單
2
+ # Define a list of text encodings supported by Python
3
+
1
4
  python_encodings_list = [
2
- 'ascii',
3
- 'big5',
4
- 'big5hkscs',
5
- 'cp037',
6
- 'cp273',
7
- 'cp424',
8
- 'cp437',
9
- 'cp500',
10
- 'cp720',
11
- 'cp737',
12
- 'cp775',
13
- 'cp850',
14
- 'cp852',
15
- 'cp855',
16
- 'cp856',
17
- 'cp857',
18
- 'cp858',
19
- 'cp860',
20
- 'cp861',
21
- 'cp862',
22
- 'cp863',
23
- 'cp864',
24
- 'cp865',
25
- 'cp866',
26
- 'cp869',
27
- 'cp874',
28
- 'cp875',
29
- 'cp932',
30
- 'cp949',
31
- 'cp950',
32
- 'cp1006',
33
- 'cp1026',
34
- 'cp1125',
35
- 'cp1140',
36
- 'cp1250',
37
- 'cp1251',
38
- 'cp1252',
39
- 'cp1253',
40
- 'cp1254',
41
- 'cp1255',
42
- 'cp1256',
43
- 'cp1257',
44
- 'cp1258',
45
- 'euc_jp',
46
- 'euc_jis_2004',
47
- 'euc_jisx0213',
48
- 'euc_kr',
49
- 'gb2312',
50
- 'gbk',
51
- 'gb18030',
52
- 'hz',
53
- 'iso2022_jp',
54
- 'iso2022_jp_1',
55
- 'iso2022_jp_2',
56
- 'iso2022_jp_2004',
57
- 'iso2022_jp_3',
58
- 'iso2022_jp_ext',
59
- 'iso2022_kr',
60
- 'latin_1',
61
- 'iso8859_2',
62
- 'iso8859_3',
63
- 'iso8859_4',
64
- 'iso8859_5',
65
- 'iso8859_6',
66
- 'iso8859_7',
67
- 'iso8859_8',
68
- 'iso8859_9',
69
- 'iso8859_10',
70
- 'iso8859_11',
71
- 'iso8859_13',
72
- 'iso8859_14',
73
- 'iso8859_15',
74
- 'iso8859_16',
75
- 'johab',
76
- 'koi8_r',
77
- 'koi8_t',
78
- 'koi8_u',
79
- 'kz1048',
80
- 'mac_cyrillic',
81
- 'mac_greek',
82
- 'mac_iceland',
83
- 'mac_latin2',
84
- 'mac_roman',
85
- 'mac_turkish',
86
- 'ptcp154',
87
- 'shift_jis',
88
- 'shift_jis_2004',
89
- 'shift_jisx0213',
90
- 'utf_32',
91
- 'utf_32_be',
92
- 'utf_32_le',
93
- 'utf_16',
94
- 'utf_16_be',
95
- 'utf_16_le',
96
- 'utf_7',
97
- 'utf_8',
98
- 'utf_8_sig'
99
- ]
5
+ 'ascii', # ASCII 編碼 (基本的英文字符集, 7-bit) / Basic English character set
6
+ 'big5', # Big5 編碼 (繁體中文常用, 台灣/香港) / Traditional Chinese encoding (Taiwan/HK)
7
+ 'big5hkscs', # Big5-HKSCS (香港增補字集) / Big5 with Hong Kong Supplementary Character Set
8
+ 'cp037', # IBM EBCDIC US/Canada / IBM mainframe encoding
9
+ 'cp273', # IBM EBCDIC Germany / 德國 EBCDIC 編碼
10
+ 'cp424', # IBM EBCDIC Hebrew / 希伯來文編碼
11
+ 'cp437', # 原始 IBM PC 編碼 (DOS Latin US) / Original IBM PC encoding
12
+ 'cp500', # IBM EBCDIC International / 國際版 EBCDIC
13
+ 'cp720', # 阿拉伯文 (DOS) / Arabic (DOS)
14
+ 'cp737', # 希臘文 (DOS) / Greek (DOS)
15
+ 'cp775', # 波羅的海語系 (DOS) / Baltic languages (DOS)
16
+ 'cp850', # 西歐語系 (DOS) / Western Europe (DOS)
17
+ 'cp852', # 中歐語系 (DOS) / Central Europe (DOS)
18
+ 'cp855', # 西里爾字母 (DOS) / Cyrillic (DOS)
19
+ 'cp856', # 希伯來文 (DOS) / Hebrew (DOS)
20
+ 'cp857', # 土耳其文 (DOS) / Turkish (DOS)
21
+ 'cp858', # 西歐語系 (含歐元符號) / Western Europe with Euro sign
22
+ 'cp860', # 葡萄牙文 (DOS) / Portuguese (DOS)
23
+ 'cp861', # 冰島文 (DOS) / Icelandic (DOS)
24
+ 'cp862', # 希伯來文 (DOS) / Hebrew (DOS)
25
+ 'cp863', # 加拿大法文 (DOS) / Canadian French (DOS)
26
+ 'cp864', # 阿拉伯文 (DOS) / Arabic (DOS)
27
+ 'cp865', # 北歐語系 (DOS) / Nordic languages (DOS)
28
+ 'cp866', # 俄文 (DOS) / Russian (DOS)
29
+ 'cp869', # 希臘文 (DOS) / Greek (DOS)
30
+ 'cp874', # 泰文 (Windows) / Thai (Windows)
31
+ 'cp875', # IBM EBCDIC Greek / 希臘文 EBCDIC
32
+ 'cp932', # 日文 Shift_JIS (Windows) / Japanese Shift_JIS (Windows)
33
+ 'cp949', # 韓文 (Windows) / Korean (Windows)
34
+ 'cp950', # 繁體中文 Big5 (Windows) / Traditional Chinese Big5 (Windows)
35
+ 'cp1006', # 烏爾都文 (Urdu) / Urdu
36
+ 'cp1026', # IBM EBCDIC Turkish / 土耳其文 EBCDIC
37
+ 'cp1125', # 烏克蘭文 (DOS) / Ukrainian (DOS)
38
+ 'cp1140', # EBCDIC with Euro / EBCDIC 含歐元符號
39
+ 'cp1250', # 中歐語系 (Windows) / Central Europe (Windows)
40
+ 'cp1251', # 西里爾字母 (Windows) / Cyrillic (Windows)
41
+ 'cp1252', # 西歐語系 (Windows, 常見) / Western Europe (Windows, very common)
42
+ 'cp1253', # 希臘文 (Windows) / Greek (Windows)
43
+ 'cp1254', # 土耳其文 (Windows) / Turkish (Windows)
44
+ 'cp1255', # 希伯來文 (Windows) / Hebrew (Windows)
45
+ 'cp1256', # 阿拉伯文 (Windows) / Arabic (Windows)
46
+ 'cp1257', # 波羅的海語系 (Windows) / Baltic (Windows)
47
+ 'cp1258', # 越南文 (Windows) / Vietnamese (Windows)
48
+ 'euc_jp', # 日文 EUC 編碼 / Japanese EUC encoding
49
+ 'euc_jis_2004', # 日文 EUC (JIS 2004) / Japanese EUC (JIS 2004)
50
+ 'euc_jisx0213', # 日文 EUC (JIS X 0213) / Japanese EUC (JIS X 0213)
51
+ 'euc_kr', # 韓文 EUC 編碼 / Korean EUC encoding
52
+ 'gb2312', # 簡體中文 (舊標準) / Simplified Chinese (older standard)
53
+ 'gbk', # 簡體中文 (擴展) / Simplified Chinese (extended)
54
+ 'gb18030', # 簡體中文 (最新國標) / Simplified Chinese (latest national standard)
55
+ 'hz', # HZ-GB-2312 (簡體中文, 郵件常用) / Simplified Chinese (email encoding)
56
+ 'iso2022_jp', # 日文 ISO-2022-JP / Japanese ISO-2022-JP
57
+ 'iso2022_jp_1', # 日文 ISO-2022-JP-1 / Japanese ISO-2022-JP-1
58
+ 'iso2022_jp_2', # 日文 ISO-2022-JP-2 / Japanese ISO-2022-JP-2
59
+ 'iso2022_jp_2004', # 日文 ISO-2022-JP-2004 / Japanese ISO-2022-JP-2004
60
+ 'iso2022_jp_3', # 日文 ISO-2022-JP-3 / Japanese ISO-2022-JP-3
61
+ 'iso2022_jp_ext', # 日文 ISO-2022-JP-EXT / Japanese ISO-2022-JP-EXT
62
+ 'iso2022_kr', # 韓文 ISO-2022-KR / Korean ISO-2022-KR
63
+ 'latin_1', # ISO-8859-1 (西歐語系, 常見) / Western Europe (very common)
64
+ 'iso8859_2', # 中歐語系 / Central Europe
65
+ 'iso8859_3', # 南歐語系 / South Europe
66
+ 'iso8859_4', # 北歐語系 / North Europe
67
+ 'iso8859_5', # 西里爾字母 / Cyrillic
68
+ 'iso8859_6', # 阿拉伯文 / Arabic
69
+ 'iso8859_7', # 希臘文 / Greek
70
+ 'iso8859_8', # 希伯來文 / Hebrew
71
+ 'iso8859_9', # 土耳其文 / Turkish
72
+ 'iso8859_10', # 北歐語系 / Nordic
73
+ 'iso8859_11', # 泰文 / Thai
74
+ 'iso8859_13', # 波羅的海語系 / Baltic
75
+ 'iso8859_14', # 凱爾特語 / Celtic
76
+ 'iso8859_15', # 西歐語系 (含歐元) / Western Europe with Euro
77
+ 'iso8859_16', # 東歐語系 / Eastern Europe
78
+ 'johab', # 韓文 Johab 編碼 / Korean Johab encoding
79
+ 'koi8_r', # 俄文 KOI8-R / Russian KOI8-R
80
+ 'koi8_t', # 塔吉克文 KOI8-T / Tajik KOI8-T
81
+ 'koi8_u', # 烏克蘭文 KOI8-U / Ukrainian KOI8-U
82
+ 'kz1048', # 哈薩克文 / Kazakh
83
+ 'mac_cyrillic', # Mac OS 西里爾字母 / Mac Cyrillic
84
+ 'mac_greek', # Mac OS 希臘文 / Mac Greek
85
+ 'mac_iceland', # Mac OS 冰島文 / Mac Icelandic
86
+ 'mac_latin2', # Mac OS 中歐語系 / Mac Central Europe
87
+ 'mac_roman', # Mac OS 西歐語系 / Mac Roman
88
+ 'mac_turkish', # Mac OS 土耳其文 / Mac Turkish
89
+ 'ptcp154', # 中亞語系 (西里爾字母) / Central Asian Cyrillic
90
+ 'shift_jis', # 日文 Shift JIS 編碼 (常見於 Windows 與網頁) / Japanese Shift JIS encoding (commonly used in Windows & web)
91
+ 'shift_jis_2004', # 日文 Shift JIS (JIS 2004 標準) / Japanese Shift JIS (JIS 2004 standard)
92
+ 'shift_jisx0213', # 日文 Shift JIS (JIS X 0213 擴展) / Japanese Shift JIS (JIS X 0213 extension)
93
+ 'utf_32', # UTF-32 (依平台大小端序, 4 bytes per char) / UTF-32 (platform-dependent endianness, 4 bytes per char)
94
+ 'utf_32_be', # UTF-32 Big Endian / UTF-32 大端序
95
+ 'utf_32_le', # UTF-32 Little Endian / UTF-32 小端序
96
+ 'utf_16', # UTF-16 (依平台大小端序, 2 or 4 bytes per char) / UTF-16 (platform-dependent endianness)
97
+ 'utf_16_be', # UTF-16 Big Endian / UTF-16 大端序
98
+ 'utf_16_le', # UTF-16 Little Endian / UTF-16 小端序
99
+ 'utf_7', # UTF-7 (為電子郵件設計, 已過時) / UTF-7 (designed for email, obsolete)
100
+ 'utf_8', # UTF-8 (最常用, 網頁與跨平台標準) / UTF-8 (most common, web & cross-platform standard)
101
+ 'utf_8_sig' # UTF-8 with BOM (Byte Order Mark) / UTF-8 含 BOM 標記
102
+ ]