Skip to content

Commit

Permalink
Merge pull request #64 from Integration-Automation/dev
Browse files Browse the repository at this point in the history
Now FrontEngine extendable
  • Loading branch information
JE-Chen authored Aug 10, 2023
2 parents 091ffce + 7355b02 commit b2dd30d
Show file tree
Hide file tree
Showing 17 changed files with 65 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/front_engine_dev_python3_10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ jobs:
pip install -r dev_requirements.txt
- name: Start FrontEngine
run: python ./tests/unit_test/start/start_front_engine.py
- name: Extend FrontEngine
run: python ./tests/unit_test/start/extend_front_engine.py
2 changes: 2 additions & 0 deletions .github/workflows/front_engine_dev_python3_11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ jobs:
pip install -r dev_requirements.txt
- name: Start FrontEngine
run: python ./tests/unit_test/start/start_front_engine.py
- name: Extend FrontEngine
run: python ./tests/unit_test/start/extend_front_engine.py
2 changes: 2 additions & 0 deletions .github/workflows/front_engine_dev_python3_8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ jobs:
pip install -r dev_requirements.txt
- name: Start FrontEngine
run: python ./tests/unit_test/start/start_front_engine.py
- name: Extend FrontEngine
run: python ./tests/unit_test/start/extend_front_engine.py
2 changes: 2 additions & 0 deletions .github/workflows/front_engine_dev_python3_9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ jobs:
pip install -r dev_requirements.txt
- name: Start FrontEngine
run: python ./tests/unit_test/start/start_front_engine.py
- name: Extend FrontEngine
run: python ./tests/unit_test/start/extend_front_engine.py
4 changes: 3 additions & 1 deletion .github/workflows/front_engine_stable_python3_10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ jobs:
python -m pip install --upgrade pip wheel
pip install -r requirements.txt
- name: Start FrontEngine
run: python ./tests/unit_test/start/start_front_engine.py
run: python ./tests/unit_test/start/start_front_engine.py
- name: Extend FrontEngine
run: python ./tests/unit_test/start/extend_front_engine.py
4 changes: 3 additions & 1 deletion .github/workflows/front_engine_stable_python3_11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ jobs:
python -m pip install --upgrade pip wheel
pip install -r requirements.txt
- name: Start FrontEngine
run: python ./tests/unit_test/start/start_front_engine.py
run: python ./tests/unit_test/start/start_front_engine.py
- name: Extend FrontEngine
run: python ./tests/unit_test/start/extend_front_engine.py
4 changes: 3 additions & 1 deletion .github/workflows/front_engine_stable_python3_8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ jobs:
python -m pip install --upgrade pip wheel
pip install -r requirements.txt
- name: Start FrontEngine
run: python ./tests/unit_test/start/start_front_engine.py
run: python ./tests/unit_test/start/start_front_engine.py
- name: Extend FrontEngine
run: python ./tests/unit_test/start/extend_front_engine.py
4 changes: 3 additions & 1 deletion .github/workflows/front_engine_stable_python3_9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ jobs:
python -m pip install --upgrade pip wheel
pip install -r requirements.txt
- name: Start FrontEngine
run: python ./tests/unit_test/start/start_front_engine.py
run: python ./tests/unit_test/start/start_front_engine.py
- name: Extend FrontEngine
run: python ./tests/unit_test/start/extend_front_engine.py
2 changes: 1 addition & 1 deletion dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "frontengine_dev"
version = "0.0.39"
version = "0.0.40"
authors = [
{ name = "JE-Chen", email = "[email protected]" },
]
Expand Down
3 changes: 2 additions & 1 deletion frontengine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
from frontengine.ui.main.main_ui import FrontEngineMainUI
from frontengine.ui.setting.scene_setting.scene_setting_ui import SceneControlSettingUI
from frontengine.ui.setting.chat_scene.chat_scene_setting import ChatSceneUI
from frontengine.ui.main.main_ui import EDITOR_EXTEND_TAB

__all__ = [
"start_front_engine", "GifWidget", "SoundPlayer", "SoundEffectWidget", "TextWidget",
"WebWidget", "ImageWidget", "VideoWidget", "language_wrapper", "load_extend_ui_file", "load_ui_file",
"TextSettingUI", "WEBSettingUI", "GIFSettingUI", "ImageSettingUI", "SoundPlayerSettingUI",
"VideoSettingUI", "ControlCenterUI", "SceneSettingUI", "FrontEngineMainUI", "SceneControlSettingUI",
"ChatSceneUI"
"ChatSceneUI", "EDITOR_EXTEND_TAB"
]
2 changes: 1 addition & 1 deletion frontengine/ui/chat/chat_scene_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ def check_error(self):
gpt_error_messagebox.show()

def close(self) -> bool:
self.deleteLater()
self.get_message_timer.stop()
self.check_error_timer.stop()
return super().close()
8 changes: 7 additions & 1 deletion frontengine/ui/main/main_ui.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import os
import sys
from pathlib import Path
from typing import Dict, Type

from PySide6.QtCore import QTimer
from PySide6.QtGui import QIcon, QAction
from PySide6.QtWidgets import QMainWindow, QApplication, QGridLayout, QTabWidget, QMenuBar
from PySide6.QtWidgets import QMainWindow, QApplication, QGridLayout, QTabWidget, QMenuBar, QWidget
from qt_material import apply_stylesheet, QtStyleTools

from frontengine.ui.main.language_menu import build_language_menu
Expand All @@ -21,6 +22,8 @@
from frontengine.user_setting.user_setting_file import write_user_setting, read_user_setting, user_setting_dict
from frontengine.utils.multi_language.language_wrapper import language_wrapper

EDITOR_EXTEND_TAB: Dict[str, Type[QWidget]] = {}


class FrontEngineMainUI(QMainWindow, QtStyleTools):

Expand Down Expand Up @@ -93,6 +96,8 @@ def __init__(self, debug: bool = False):
self.control_center_ui,
language_wrapper.language_word_dict.get("tab_control_center_text")
)
for widget_name, widget in EDITOR_EXTEND_TAB.items():
self.tab_widget.addTab(widget(), widget_name)
self.setCentralWidget(self.tab_widget)
# Set Icon
self.icon_path = Path(os.getcwd() + "/je_driver_icon.ico")
Expand All @@ -103,6 +108,7 @@ def __init__(self, debug: bool = False):
self.system_tray = ExtendSystemTray(main_window=self)
self.system_tray.setIcon(self.icon)
self.system_tray.show()
self.system_tray.setToolTip("FrontEngine")
if debug:
self.debug_timer = QTimer()
self.debug_timer.setInterval(10000)
Expand Down
5 changes: 5 additions & 0 deletions frontengine/ui/main/system_tray/extend_system_tray.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ def __init__(self, main_window: FrontEngineMainUI):
self.close_main_window_action.triggered.connect(self.close_all)
self.menu.addAction(self.close_main_window_action)
self.setContextMenu(self.menu)
self.activated.connect(self.clicked)

def close_all(self):
self.setVisible(False)
self.main_window.close()
sys.exit(0)

def clicked(self, reason):
if reason == self.ActivationReason.DoubleClick:
self.main_window.showMaximized()
1 change: 1 addition & 0 deletions frontengine/ui/setting/chat_scene/chat_scene_setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def new_topic(self):

def close_chat_ui(self):
self.chat_input.close()
self.chat_input = None
self.chat_list.clear()
self.close_scene()

Expand Down
1 change: 0 additions & 1 deletion frontengine/ui/setting/text/text_setting_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class TextSettingUI(QWidget):

def __init__(self):
super().__init__()
self.grid_layout = QGridLayout()
self.grid_layout = QGridLayout(self)
self.grid_layout.setContentsMargins(0, 0, 0, 0)
self.grid_layout.setContentsMargins(0, 0, 0, 0)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "frontengine"
version = "0.0.38"
version = "0.0.39"
authors = [
{ name = "JE-Chen", email = "[email protected]" },
]
Expand Down
27 changes: 27 additions & 0 deletions tests/unit_test/start/extend_front_engine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from PySide6.QtWidgets import QWidget, QGridLayout, QLineEdit, QPushButton, QLabel

from frontengine import start_front_engine, EDITOR_EXTEND_TAB


class TestUI(QWidget):

def __init__(self):
super().__init__()
self.grid_layout = QGridLayout(self)
self.grid_layout.setContentsMargins(0, 0, 0, 0)
self.grid_layout.setContentsMargins(0, 0, 0, 0)
self.label = QLabel("")
self.line_edit = QLineEdit()
self.submit_button = QPushButton("Submit")
self.submit_button.clicked.connect(self.show_input_text)
self.grid_layout.addWidget(self.label, 0, 0)
self.grid_layout.addWidget(self.line_edit, 1, 0)
self.grid_layout.addWidget(self.submit_button, 2, 0)

def show_input_text(self):
self.label.setText(self.line_edit.text())


EDITOR_EXTEND_TAB.update({"test": TestUI})

start_front_engine(debug=True)

0 comments on commit b2dd30d

Please sign in to comment.