Skip to content

Commit

Permalink
Merge pull request #153 from Integration-Automation/dev
Browse files Browse the repository at this point in the history
Edit QTimer setInterval time
  • Loading branch information
JE-Chen authored Feb 11, 2025
2 parents b604157 + 4d6da75 commit d0d0b71
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 33 deletions.
11 changes: 5 additions & 6 deletions stable.toml → dev.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Rename to build stable version
# This is stable version
# Rename to build dev version
# This is dev version
[build-system]
requires = ["setuptools>=61.0"]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "je_editor"
version = "0.0.193"
name = "je_editor_dev"
version = "0.0.214"
authors = [
{ name = "JE-Chen", email = "jechenmailman@gmail.com" },
]
Expand All @@ -26,7 +26,6 @@ classifiers = [
"Operating System :: OS Independent"
]


[project.urls]
Homepage = "https://github.com/JE-Chen/je_editor"
Documentation = "https://je-editor.readthedocs.io/en/latest/"
Expand Down
2 changes: 1 addition & 1 deletion exe/a.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
print("你好")
print("Hello World")
6 changes: 5 additions & 1 deletion je_editor/pyside_ui/code/auto_save/auto_save_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def __init__(
self.still_run: bool = True
# set daemon
self.daemon = True
self.skip_this_round: bool = False

def run(self) -> None:
"""
Expand All @@ -37,6 +38,9 @@ def run(self) -> None:
while path.is_file() and self.editor is not None:
time.sleep(5)
if self.still_run:
write_file(self.file, self.editor.toPlainText())
if self.skip_this_round:
pass
else:
write_file(self.file, self.editor.toPlainText())
else:
break
2 changes: 1 addition & 1 deletion je_editor/pyside_ui/code/code_process/code_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def exec_code(self, exec_file_name, exec_prefix: Union[str, list] = None) -> Non
# start tkinter_ui update
# start timer
self.timer = QTimer(self.main_window)
self.timer.setInterval(50)
self.timer.setInterval(10)
self.timer.timeout.connect(self.pull_text)
self.timer.start()
except Exception as error:
Expand Down
2 changes: 1 addition & 1 deletion je_editor/pyside_ui/code/shell_process/shell_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def exec_shell(self, shell_command: [str, list]) -> None:
self.read_program_error_output_from_thread.start()
# start timer
self.timer = QTimer(self.main_window)
self.timer.setInterval(50)
self.timer.setInterval(10)
self.timer.timeout.connect(self.pull_text)
self.timer.start()
except Exception as error:
Expand Down
29 changes: 15 additions & 14 deletions je_editor/pyside_ui/main_ui/editor/editor_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
from pathlib import Path
from typing import Union

from PySide6.QtCore import Qt, QFileInfo, QDir, QTimer
from PySide6.QtWidgets import QWidget, QGridLayout, QSplitter, QScrollArea, QFileSystemModel, QTreeView, QTabWidget
from PySide6.QtCore import Qt, QFileInfo, QDir
from PySide6.QtWidgets import QWidget, QGridLayout, QSplitter, QScrollArea, QFileSystemModel, QTreeView, QTabWidget, \
QMessageBox

from je_editor.pyside_ui.code.auto_save.auto_save_manager import auto_save_manager_dict, init_new_auto_save_thread, \
file_is_open_manager_dict
Expand Down Expand Up @@ -106,11 +107,6 @@ def __init__(self, main_window: EditorMain):
)
# Add to layout
self.grid_layout.addWidget(self.full_splitter)
# Check format time
self.check_format_timer = QTimer()
self.check_format_timer.setInterval(50)
self.check_format_timer.timeout.connect(self.check_file_format)
self.check_format_timer.start()

def set_project_treeview(self) -> None:
jeditor_logger.info("EditorWidget set_project_treeview")
Expand Down Expand Up @@ -154,6 +150,7 @@ def open_an_file(self, path: Path) -> bool:
jeditor_logger.info(f"EditorWidget open_an_file path: {path}")
if not self.check_is_open(path):
return False
self.code_save_thread.skip_this_round = True
file, file_content = read_file(str(path))
self.code_edit.setPlainText(
file_content
Expand All @@ -166,6 +163,7 @@ def open_an_file(self, path: Path) -> bool:
init_new_auto_save_thread(self.current_file, self)
else:
self.code_save_thread.file = self.current_file
self.code_save_thread.skip_this_round = False
self.rename_self_tab()
return True

Expand All @@ -185,21 +183,24 @@ def rename_self_tab(self):
self.setObjectName(str(Path(self.current_file)))

def check_file_format(self):
jeditor_logger.info("EditorWidget check_file_format")
if self.current_file:
if self.checker is None:
jeditor_logger.info("EditorWidget check_file_format")
suffix_checker = Path(self.current_file).suffix
if suffix_checker == ".py":
self.checker = PEP8FormatChecker(self.current_file)
elif self.checker.current_file != self.current_file:
self.checker = PEP8FormatChecker(self.current_file)
else:
self.checker.check_all_format()
self.format_check_result.clear()
self.format_check_result.setPlainText("")
for error in self.checker.error_list:
self.format_check_result.append(error)
self.checker.error_list.clear()
else:
message_box = QMessageBox()
message_box.setText(
language_wrapper.language_word_dict.get("python_format_checker_only_support_python_message"))
message_box.exec_()

def close(self) -> bool:
jeditor_logger.info("EditorWidget close")
self.check_format_timer.stop()
if self.code_save_thread is not None:
self.code_save_thread.still_run = False
self.code_save_thread = None
Expand Down
4 changes: 2 additions & 2 deletions je_editor/pyside_ui/main_ui/main_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(self, debug_mode: bool = False, show_system_tray_ray: bool = False)
self.tab_widget.tabCloseRequested.connect(self.close_tab)
# Timer to redirect error or message
self.redirect_timer = QTimer(self)
self.redirect_timer.setInterval(50)
self.redirect_timer.setInterval(10)
self.redirect_timer.start()
self.setWindowTitle(language_wrapper.language_word_dict.get("application_name"))
self.setToolTip(language_wrapper.language_word_dict.get("application_name"))
Expand All @@ -100,7 +100,7 @@ def __init__(self, debug_mode: bool = False, show_system_tray_ray: bool = False)
redirect_manager_instance.set_redirect()
# Timer to redirect error or message
self.redirect_timer = QTimer(self)
self.redirect_timer.setInterval(50)
self.redirect_timer.setInterval(10)
self.redirect_timer.timeout.connect(self.redirect)
self.redirect_timer.start()
# TAB Add
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ def set_check_menu(ui_we_want_to_set: EditorMain) -> None:
)
)
ui_we_want_to_set.check_menu.addAction(ui_we_want_to_set.check_menu.reformat_json_action)
# Python formate check
ui_we_want_to_set.check_menu.check_python_format = QAction(
language_wrapper.language_word_dict.get("python_format_checker"))
ui_we_want_to_set.check_menu.check_python_format.setShortcut("Ctrl+Alt+p")
ui_we_want_to_set.check_menu.check_python_format.triggered.connect(
lambda: check_python_format(
ui_we_want_to_set
)
)
ui_we_want_to_set.check_menu.addAction(ui_we_want_to_set.check_menu.check_python_format)


def yapf_check_python_code(ui_we_want_to_set: EditorMain) -> None:
Expand All @@ -62,3 +72,10 @@ def reformat_json_text(ui_we_want_to_set: EditorMain) -> None:
code_text = widget.code_edit.toPlainText()
widget.code_result.setPlainText("")
widget.code_edit.setPlainText(reformat_json(code_text))


def check_python_format(ui_we_want_to_set: EditorMain) -> None:
jeditor_logger.info(f"build_check_style_menu.py check_python_format ui_we_want_to_set: {ui_we_want_to_set}")
widget = ui_we_want_to_set.tab_widget.currentWidget()
if isinstance(widget, EditorWidget):
widget.check_file_format()
3 changes: 2 additions & 1 deletion je_editor/utils/multi_language/english.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
# Check Code Style Menu
"check_code_style_menu_label": "Check Code Style",
"yapf_reformat_label": "yapf",
"black_reformat_label": "Black",
"python_format_checker": "Python format check",
"reformat_json_label": "Reformat JSON",
"python_format_checker_only_support_python_message": "Only support python file",
# Dock Menu
"dock_menu_label": "Dock",
"dock_browser_label": "New Dock Browser",
Expand Down
3 changes: 2 additions & 1 deletion je_editor/utils/multi_language/traditional_chinese.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
# Check Code Style Menu
"check_code_style_menu_label": "程式碼格式檢查器",
"yapf_reformat_label": "yapf",
"black_reformat_label": "Black",
"python_format_checker": "Python 格式檢查",
"python_format_checker_only_support_python_message": "只支援 Python 檔案",
"reformat_json_label": "重新格式化 JSON",
# Dock Menu
"dock_menu_label": "區域",
Expand Down
11 changes: 6 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Rename to build dev version
# This is dev version
# Rename to build stable version
# This is stable version
[build-system]
requires = ["setuptools"]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "je_editor_dev"
version = "0.0.213"
name = "je_editor"
version = "0.0.194"
authors = [
{ name = "JE-Chen", email = "jechenmailman@gmail.com" },
]
Expand All @@ -26,6 +26,7 @@ classifiers = [
"Operating System :: OS Independent"
]


[project.urls]
Homepage = "https://github.com/JE-Chen/je_editor"
Documentation = "https://je-editor.readthedocs.io/en/latest/"
Expand Down

0 comments on commit d0d0b71

Please sign in to comment.