mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-06-20 14:10:51 +10:00
GUI: Set about and quit items
This commit is contained in:
@@ -35,6 +35,7 @@
|
|||||||
- Implement proper UI call backs on long processes
|
- Implement proper UI call backs on long processes
|
||||||
- ex. Root patching
|
- ex. Root patching
|
||||||
- Implement default selections for disks and installers
|
- Implement default selections for disks and installers
|
||||||
|
- Set about and quit items
|
||||||
- Utilize `py-applescript` for authorization prompts
|
- Utilize `py-applescript` for authorization prompts
|
||||||
- Avoids displaying prompts with `osascript` in the title
|
- Avoids displaying prompts with `osascript` in the title
|
||||||
- Due to limitations, only used for installer creation and OpenCore installation
|
- Due to limitations, only used for installer creation and OpenCore installation
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
# About frame, just to sat
|
||||||
|
|
||||||
|
import wx
|
||||||
|
import wx.adv
|
||||||
|
|
||||||
|
from resources import constants
|
||||||
|
|
||||||
|
|
||||||
|
class AboutFrame(wx.Frame):
|
||||||
|
|
||||||
|
def __init__(self, global_constants: constants.Constants) -> None:
|
||||||
|
if wx.FindWindowByName("About"):
|
||||||
|
return
|
||||||
|
|
||||||
|
super(AboutFrame, self).__init__(None, title="About", size=(350, 350), style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX))
|
||||||
|
self.constants: constants.Constants = global_constants
|
||||||
|
self.Centre()
|
||||||
|
self.hyperlink_colour = (25, 179, 231)
|
||||||
|
|
||||||
|
self._generate_elements(self)
|
||||||
|
|
||||||
|
self.Show()
|
||||||
|
|
||||||
|
|
||||||
|
def _generate_elements(self, frame: wx.Frame) -> None:
|
||||||
|
|
||||||
|
# Set title
|
||||||
|
title = wx.StaticText(frame, label="OpenCore Legacy Patcher", pos=(-1, 5))
|
||||||
|
title.SetFont(wx.Font(19, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, ".AppleSystemUIFont"))
|
||||||
|
title.Centre(wx.HORIZONTAL)
|
||||||
|
|
||||||
|
# Set version
|
||||||
|
version = wx.StaticText(frame, label=f"Version: {self.constants.patcher_version}", pos=(-1, title.GetPosition()[1] + title.GetSize()[1] + 5))
|
||||||
|
version.SetFont(wx.Font(11, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont"))
|
||||||
|
version.Centre(wx.HORIZONTAL)
|
||||||
|
|
||||||
|
# Description
|
||||||
|
description = [
|
||||||
|
"Written by a small group of Mac hobbyists who just",
|
||||||
|
"want to keep old machines out of the landfill!",
|
||||||
|
|
||||||
|
]
|
||||||
|
spacer = 5
|
||||||
|
for line in description:
|
||||||
|
desc = wx.StaticText(frame, label=line, pos=(-1, version.GetPosition()[1] + version.GetSize()[1] + 5 + spacer))
|
||||||
|
desc.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont"))
|
||||||
|
desc.Centre(wx.HORIZONTAL)
|
||||||
|
|
||||||
|
spacer += 20
|
||||||
|
|
||||||
|
# Set icon
|
||||||
|
icon_mac = "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/com.apple.macbook-unibody-plastic.icns"
|
||||||
|
icon_mac = wx.StaticBitmap(frame, bitmap=wx.Bitmap(icon_mac, wx.BITMAP_TYPE_ICON), pos=(5, desc.GetPosition()[1] - 15))
|
||||||
|
icon_mac.SetSize((160, 160))
|
||||||
|
icon_mac.Centre(wx.HORIZONTAL)
|
||||||
|
|
||||||
|
icon_path = str(self.constants.app_icon_path)
|
||||||
|
icon = wx.StaticBitmap(frame, bitmap=wx.Bitmap(icon_path, wx.BITMAP_TYPE_ICON), pos=(5, desc.GetPosition()[1] + desc.GetSize()[1] + 17))
|
||||||
|
icon.SetSize((64, 64))
|
||||||
|
icon.Centre(wx.HORIZONTAL)
|
||||||
|
|
||||||
|
# Set frame size
|
||||||
|
frame.SetSize((-1, icon.GetPosition()[1] + icon.GetSize()[1] + 60))
|
||||||
@@ -39,6 +39,7 @@ class EntryPoint:
|
|||||||
|
|
||||||
def _generate_base_data(self) -> None:
|
def _generate_base_data(self) -> None:
|
||||||
self.app = wx.App()
|
self.app = wx.App()
|
||||||
|
self.app.SetAppName(self.constants.patcher_name)
|
||||||
|
|
||||||
|
|
||||||
def start(self, entry: SupportedEntryPoints = gui_main_menu.MainFrame) -> None:
|
def start(self, entry: SupportedEntryPoints = gui_main_menu.MainFrame) -> None:
|
||||||
@@ -60,7 +61,7 @@ class EntryPoint:
|
|||||||
**({"patches": patches} if "--gui_patch" in sys.argv or "--gui_unpatch" in sys.argv else {})
|
**({"patches": patches} if "--gui_patch" in sys.argv or "--gui_unpatch" in sys.argv else {})
|
||||||
)
|
)
|
||||||
if self.frame:
|
if self.frame:
|
||||||
self.frame.SetMenuBar(gui_support.GenerateMenubar().generate())
|
gui_support.GenerateMenubar(self.frame, self.constants).generate()
|
||||||
|
|
||||||
atexit.register(self.OnCloseFrame)
|
atexit.register(self.OnCloseFrame)
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import applescript
|
|||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from resources.wx_gui import gui_about
|
||||||
from resources import constants
|
from resources import constants
|
||||||
from data import model_array, os_data, smbios_data
|
from data import model_array, os_data, smbios_data
|
||||||
|
|
||||||
@@ -23,13 +24,22 @@ class AutoUpdateStages:
|
|||||||
|
|
||||||
class GenerateMenubar:
|
class GenerateMenubar:
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self, frame: wx.Frame, global_constants: constants.Constants) -> None:
|
||||||
self.menubar: wx.MenuBar = None
|
self.frame: wx.Frame = frame
|
||||||
|
self.constants: constants.Constants = global_constants
|
||||||
|
|
||||||
|
|
||||||
def generate(self) -> wx.MenuBar:
|
def generate(self) -> wx.MenuBar:
|
||||||
self.menubar = wx.MenuBar()
|
menubar = wx.MenuBar()
|
||||||
return self.menubar
|
fileMenu = wx.Menu()
|
||||||
|
|
||||||
|
aboutItem = fileMenu.Append(wx.ID_ABOUT, "&About OpenCore Legacy Patcher")
|
||||||
|
fileMenu.AppendSeparator()
|
||||||
|
|
||||||
|
menubar.Append(fileMenu, "&File")
|
||||||
|
self.frame.SetMenuBar(menubar)
|
||||||
|
|
||||||
|
self.frame.Bind(wx.EVT_MENU, lambda event: gui_about.AboutFrame(self.constants), aboutItem)
|
||||||
|
|
||||||
|
|
||||||
class GaugePulseCallback:
|
class GaugePulseCallback:
|
||||||
|
|||||||
Reference in New Issue
Block a user