mirror of
https://github.com/blw1138/Zordon.git
synced 2025-12-17 08:48:13 +00:00
Add About window and basic commands to MenuBar (#113)
* Initial commit for about_window.py * Add some basic actions to the MenuBar * Fix keyboard shortcuts * Fix path to icon for Windows
This commit is contained in:
74
src/ui/about_window.py
Normal file
74
src/ui/about_window.py
Normal file
@@ -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"<h2>{APP_NAME}</h2>")
|
||||||
|
layout.addWidget(name_label)
|
||||||
|
|
||||||
|
# Description
|
||||||
|
description_label = QLabel(APP_DESCRIPTION)
|
||||||
|
layout.addWidget(description_label)
|
||||||
|
|
||||||
|
# Version
|
||||||
|
version_label = QLabel(f"<strong>Version:</strong> {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()
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
''' app/ui/widgets/menubar.py '''
|
''' 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):
|
class MenuBar(QMenuBar):
|
||||||
@@ -12,12 +15,43 @@ class MenuBar(QMenuBar):
|
|||||||
|
|
||||||
def __init__(self, parent=None) -> None:
|
def __init__(self, parent=None) -> None:
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
|
||||||
|
# setup menus
|
||||||
file_menu = self.addMenu("File")
|
file_menu = self.addMenu("File")
|
||||||
# edit_menu = self.addMenu("Edit")
|
# edit_menu = self.addMenu("Edit")
|
||||||
# view_menu = self.addMenu("View")
|
# view_menu = self.addMenu("View")
|
||||||
# help_menu = self.addMenu("Help")
|
help_menu = self.addMenu("Help")
|
||||||
|
|
||||||
# Add actions to the menus
|
# --file menu--
|
||||||
# file_menu.addAction(self.parent().topbar.actions_call["Open"]) # type: ignore
|
# new job
|
||||||
# file_menu.addAction(self.parent().topbar.actions_call["Save"]) # type: ignore
|
new_job_action = QAction("New Job...", self)
|
||||||
# file_menu.addAction(self.parent().topbar.actions_call["Exit"]) # type: ignore
|
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()
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
APP_NAME = "Zordon"
|
APP_NAME = "Zordon"
|
||||||
APP_VERSION = "0.0.1"
|
APP_VERSION = "0.0.1"
|
||||||
APP_AUTHOR = "Brett Williams"
|
APP_AUTHOR = "Brett Williams"
|
||||||
|
APP_DESCRIPTION = "Distributed Render Farm Tools"
|
||||||
|
APP_COPYRIGHT_YEAR = "2024"
|
||||||
|
APP_LICENSE = "MIT License"
|
||||||
|
|||||||
Reference in New Issue
Block a user