diff --git a/stable.toml b/dev.toml similarity index 96% rename from stable.toml rename to dev.toml index 502dee9..6ffe4bb 100644 --- a/stable.toml +++ b/dev.toml @@ -5,8 +5,8 @@ requires = ["setuptools>=61.0"] build-backend = "setuptools.build_meta" [project] -name = "frontengine" -version = "0.0.42" +name = "frontengine_dev" +version = "0.0.44" authors = [ { name = "JE-Chen", email = "jechenmailman@gmail.com" }, ] diff --git a/frontengine/show/image_generation/image_generation_show.py b/frontengine/show/image_generation/image_generation_show.py index da2f6c3..3836771 100644 --- a/frontengine/show/image_generation/image_generation_show.py +++ b/frontengine/show/image_generation/image_generation_show.py @@ -1,14 +1,43 @@ -from PySide6.QtGui import QPixmap -from PySide6.QtWidgets import QWidget, QLabel, QGridLayout +from pathlib import Path + +import PySide6 +from PySide6.QtGui import QPixmap, QAction, Qt +from PySide6.QtWidgets import QWidget, QLabel, QGridLayout, QFileDialog, QMenu + +from frontengine.utils.multi_language.language_wrapper import language_wrapper class ImageGenerateShow(QWidget): - def __init__(self, pixmap: QPixmap): + def __init__(self, pixmap: QPixmap, title: str): super().__init__() + self.setWindowTitle(title) + self.pixmap = pixmap self.label = QLabel() self.label.setPixmap(pixmap) self.grid_layout = QGridLayout(self) self.grid_layout.setContentsMargins(0, 0, 0, 0) self.grid_layout.addWidget(self.label) self.setLayout(self.grid_layout) + + # Menubar + self.menu = QMenu(self) + self.save_image_action = QAction(language_wrapper.language_word_dict.get("save_generation_image")) + self.save_image_action.triggered.connect(self.save_image) + self.menu.addAction(self.save_image_action) + + def save_image(self): + file_path = QFileDialog().getSaveFileName( + parent=self, + dir=str(Path.cwd()), + filter="Images (*.png;*.jpg;*.webp)" + )[0] + file_path = Path(file_path) + if file_path.is_file(): + self.pixmap.save(str(file_path)) + + def mousePressEvent(self, event: PySide6.QtGui.QMouseEvent) -> None: + if event.button() == Qt.MouseButton.RightButton: + self.menu.move(self.x() + event.x(), self.y() + event.y()) + self.menu.show() + super().mousePressEvent(event) diff --git a/frontengine/ui/setting/image_generation/image_generation_input.py b/frontengine/ui/setting/image_generation/image_generation_input.py index 374c53e..e646281 100644 --- a/frontengine/ui/setting/image_generation/image_generation_input.py +++ b/frontengine/ui/setting/image_generation/image_generation_input.py @@ -50,7 +50,7 @@ def get_image(self): image_response = requests.get(image_link) image = QPixmap() image.loadFromData(image_response.content) - image_show = ImageGenerateShow(image) + image_show = ImageGenerateShow(image, image_link) self.show_list.append(image_show) image_show.show() self.image_panel.appendPlainText(image_link) @@ -59,4 +59,3 @@ def close(self) -> bool: for widget in self.show_list: widget.close() return super().close() - diff --git a/frontengine/utils/multi_language/english.py b/frontengine/utils/multi_language/english.py index b11e42d..34c5703 100644 --- a/frontengine/utils/multi_language/english.py +++ b/frontengine/utils/multi_language/english.py @@ -113,5 +113,6 @@ # Image Generation "image_generation_tab": "Image generation", "start_generate_image": "Star generate", - "input_error": "Please input something" + "input_error": "Please input something", + "save_generation_image": "Save Image", } diff --git a/frontengine/utils/multi_language/traditional_chinese.py b/frontengine/utils/multi_language/traditional_chinese.py index 1813a2b..3b167ab 100644 --- a/frontengine/utils/multi_language/traditional_chinese.py +++ b/frontengine/utils/multi_language/traditional_chinese.py @@ -113,5 +113,6 @@ # Image Generation "image_generation_tab": "圖片產生", "start_generate_image": "開始產生圖片", - "input_error": "請勿無輸入或空格" + "input_error": "請勿無輸入或空格", + "save_generation_image": "儲存圖片", } diff --git a/pyproject.toml b/pyproject.toml index 83e2adc..bfc0659 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ requires = ["setuptools>=61.0"] build-backend = "setuptools.build_meta" [project] -name = "frontengine_dev" +name = "frontengine" version = "0.0.43" authors = [ { name = "JE-Chen", email = "jechenmailman@gmail.com" },