diff --git a/src/ui/about_window.py b/src/ui/about_window.py new file mode 100644 index 0000000..674c1fd --- /dev/null +++ b/src/ui/about_window.py @@ -0,0 +1,74 @@ +import os +import sys + +from PyQt6.QtCore import Qt +from PyQt6.QtGui import QPixmap +from PyQt6.QtWidgets import QDialog, QVBoxLayout, QLabel, QDialogButtonBox, QHBoxLayout + +from version import * + + +class AboutDialog(QDialog): + def __init__(self): + super().__init__() + self.setWindowTitle(f"About {APP_NAME}") + + # Create the layout + layout = QVBoxLayout() + + # App Icon + icon_name = 'Server.png' # todo: temp icon - replace with final later + icon_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), + 'resources', icon_name) + icon_label = QLabel(self) + icon_pixmap = QPixmap(icon_path) + icon_label.setPixmap(icon_pixmap) + icon_layout = QHBoxLayout() + icon_layout.addStretch() + icon_layout.addWidget(icon_label) + icon_layout.addStretch() + layout.addLayout(icon_layout) + + # Application name + name_label = QLabel(f"

{APP_NAME}

") + layout.addWidget(name_label) + + # Description + description_label = QLabel(APP_DESCRIPTION) + layout.addWidget(description_label) + + # Version + version_label = QLabel(f"Version: {APP_VERSION}") + layout.addWidget(version_label) + + # Contributors + contributors_label = QLabel(f"Copyright © {APP_COPYRIGHT_YEAR} {APP_AUTHOR}") + layout.addWidget(contributors_label) + + # License + license_label = QLabel(f"Released under {APP_LICENSE}") + layout.addWidget(license_label) + + # Add an "OK" button to close the dialog + button_box = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok) + button_box.accepted.connect(self.accept) + layout.addWidget(button_box) + + # Set the layout for the dialog + self.setLayout(layout) + + # Make the dialog non-resizable + self.setWindowFlags(self.windowFlags() & ~Qt.WindowType.WindowContextHelpButtonHint) + self.setFixedSize(self.sizeHint()) + + +if __name__ == '__main__': + # lazy load GUI frameworks + from PyQt6.QtWidgets import QApplication + + # load application + app: QApplication = QApplication(sys.argv) + window: AboutDialog = AboutDialog() + window.show() + + app.exec() diff --git a/src/ui/widgets/menubar.py b/src/ui/widgets/menubar.py index 0cdb6cc..fcff6cb 100644 --- a/src/ui/widgets/menubar.py +++ b/src/ui/widgets/menubar.py @@ -1,5 +1,8 @@ ''' app/ui/widgets/menubar.py ''' -from PyQt6.QtWidgets import QMenuBar +import sys + +from PyQt6.QtGui import QAction +from PyQt6.QtWidgets import QMenuBar, QApplication class MenuBar(QMenuBar): @@ -12,12 +15,43 @@ class MenuBar(QMenuBar): def __init__(self, parent=None) -> None: super().__init__(parent) + + # setup menus file_menu = self.addMenu("File") # edit_menu = self.addMenu("Edit") # view_menu = self.addMenu("View") - # help_menu = self.addMenu("Help") + help_menu = self.addMenu("Help") - # Add actions to the menus - # file_menu.addAction(self.parent().topbar.actions_call["Open"]) # type: ignore - # file_menu.addAction(self.parent().topbar.actions_call["Save"]) # type: ignore - # file_menu.addAction(self.parent().topbar.actions_call["Exit"]) # type: ignore + # --file menu-- + # new job + new_job_action = QAction("New Job...", self) + new_job_action.setShortcut(f'Ctrl+N') + new_job_action.triggered.connect(self.new_job) + file_menu.addAction(new_job_action) + # settings + settings_action = QAction("Settings...", self) + settings_action.triggered.connect(self.show_settings) + settings_action.setShortcut(f'Ctrl+,') + # file_menu.addAction(settings_action) # todo: enable once we have a setting screen + # exit + exit_action = QAction('&Exit', self) + exit_action.setShortcut('Ctrl+Q') + exit_action.triggered.connect(QApplication.instance().quit) + file_menu.addAction(exit_action) + + # --help menu-- + about_action = QAction("About", self) + about_action.triggered.connect(self.show_about) + help_menu.addAction(about_action) + + def new_job(self): + self.parent().new_job() + + def show_settings(self): + pass + + @staticmethod + def show_about(): + from src.ui.about_window import AboutDialog + dialog = AboutDialog() + dialog.exec() diff --git a/version.py b/version.py index 7d33e41..40038b8 100644 --- a/version.py +++ b/version.py @@ -1,3 +1,6 @@ APP_NAME = "Zordon" APP_VERSION = "0.0.1" APP_AUTHOR = "Brett Williams" +APP_DESCRIPTION = "Distributed Render Farm Tools" +APP_COPYRIGHT_YEAR = "2024" +APP_LICENSE = "MIT License"