GUI: Test new main menu

This commit is contained in:
Mykola Grymalyuk
2023-05-19 22:06:14 -06:00
parent fefd651157
commit 58b3748034
16 changed files with 149 additions and 34 deletions

View File

@@ -148,6 +148,14 @@ class CreateBinary:
print(build_result.stderr.decode('utf-8')) print(build_result.stderr.decode('utf-8'))
raise Exception("Build failed") raise Exception("Build failed")
# Next embed support icns into ./Resources
print("- Embedding icns...")
for file in Path("payloads/Icon/AppIcons").glob("*.icns"):
subprocess.run(
["cp", str(file), "./dist/OpenCore-Patcher.app/Contents/Resources/"],
stdout=subprocess.PIPE, stderr=subprocess.PIPE
)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -500,7 +500,7 @@ class Constants:
@property @property
def apple_isight_path(self): def apple_isight_path(self):
return self.payload_kexts_path / Path(f"Misc/LegacyUSBVideoSupport-v{self.apple_isight_version}.zip") return self.payload_kexts_path / Path(f"Misc/LegacyUSBVideoSupport-v{self.apple_isight_version}.zip")
@property @property
def legacy_keyboard_path(self): def legacy_keyboard_path(self):
return self.payload_kexts_path / Path(f"Misc/LegacyKeyboardInjector-v{self.legacy_keyboard}.zip") return self.payload_kexts_path / Path(f"Misc/LegacyKeyboardInjector-v{self.legacy_keyboard}.zip")
@@ -673,6 +673,12 @@ class Constants:
def kdk_download_path(self): def kdk_download_path(self):
return self.payload_path / Path("KDK.dmg") return self.payload_path / Path("KDK.dmg")
@property
def icns_resource_path(self):
if self.launcher_script:
return self.payload_path / Path("Icon/AppIcons")
return Path(self.launcher_binary).parent.parent / Path("Resources")
sbm_values = [ sbm_values = [
"j137ap", # iMacPro1,1 "j137ap", # iMacPro1,1

View File

@@ -20,6 +20,7 @@ class BuildFrame(wx.Frame):
""" """
def __init__(self, parent: wx.Frame, title: str, global_constants: constants.Constants, screen_location: tuple = None) -> None: def __init__(self, parent: wx.Frame, title: str, global_constants: constants.Constants, screen_location: tuple = None) -> None:
super(BuildFrame, self).__init__(parent, title=title, size=(350, 200), style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX)) super(BuildFrame, self).__init__(parent, title=title, size=(350, 200), style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX))
gui_support.GenerateMenubar(self, global_constants).generate()
self.install_button: wx.Button = None self.install_button: wx.Button = None
self.text_box: wx.TextCtrl = None self.text_box: wx.TextCtrl = None
@@ -36,7 +37,7 @@ class BuildFrame(wx.Frame):
if self.constants.update_stage != gui_support.AutoUpdateStages.INACTIVE: if self.constants.update_stage != gui_support.AutoUpdateStages.INACTIVE:
self.constants.update_stage = gui_support.AutoUpdateStages.BUILDING self.constants.update_stage = gui_support.AutoUpdateStages.BUILDING
self.SetPosition(screen_location) if screen_location else self.Centre() self.Centre()
self.frame_modal.ShowWindowModal() self.frame_modal.ShowWindowModal()
self._invoke_build() self._invoke_build()

View File

@@ -13,7 +13,6 @@ class DownloadFrame(wx.Frame):
Update provided frame with download stats Update provided frame with download stats
""" """
def __init__(self, parent: wx.Frame, title: str, global_constants: constants.Constants, download_obj: network_handler.DownloadObject, item_name: str) -> None: def __init__(self, parent: wx.Frame, title: str, global_constants: constants.Constants, download_obj: network_handler.DownloadObject, item_name: str) -> None:
self.constants: constants.Constants = global_constants self.constants: constants.Constants = global_constants
self.title: str = title self.title: str = title
self.parent: wx.Frame = parent self.parent: wx.Frame = parent

View File

@@ -60,8 +60,6 @@ class EntryPoint:
screen_location=None, screen_location=None,
**({"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:
gui_support.GenerateMenubar(self.frame, self.constants).generate()
atexit.register(self.OnCloseFrame) atexit.register(self.OnCloseFrame)

View File

@@ -13,6 +13,7 @@ class InstallOCFrame(wx.Frame):
""" """
def __init__(self, parent: wx.Frame, title: str, global_constants: constants.Constants, screen_location: tuple = None): def __init__(self, parent: wx.Frame, title: str, global_constants: constants.Constants, screen_location: tuple = None):
super(InstallOCFrame, self).__init__(parent, title=title, size=(300, 120), style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX)) super(InstallOCFrame, self).__init__(parent, title=title, size=(300, 120), style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX))
gui_support.GenerateMenubar(self, global_constants).generate()
self.constants: constants.Constants = global_constants self.constants: constants.Constants = global_constants
self.title: str = title self.title: str = title
@@ -30,7 +31,7 @@ class InstallOCFrame(wx.Frame):
if self.constants.update_stage != gui_support.AutoUpdateStages.INACTIVE: if self.constants.update_stage != gui_support.AutoUpdateStages.INACTIVE:
self.constants.update_stage = gui_support.AutoUpdateStages.INSTALLING self.constants.update_stage = gui_support.AutoUpdateStages.INSTALLING
self.SetPosition(screen_location) if screen_location else self.Centre() self.Centre()
self.Show() self.Show()
self._display_disks() self._display_disks()

View File

@@ -81,7 +81,8 @@ class macOSInstallerDownloadFrame(wx.Frame):
Generate frame to display available installers Generate frame to display available installers
""" """
super(macOSInstallerDownloadFrame, self).__init__(None, title=self.title, size=(300, 200), style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX)) super(macOSInstallerDownloadFrame, self).__init__(None, title=self.title, size=(300, 200), style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX))
self.SetPosition((self.parent.GetPosition()[0], self.parent.GetPosition()[1])) gui_support.GenerateMenubar(self, self.constants).generate()
self.Centre()
# Title: Pulling installer catalog # Title: Pulling installer catalog
title_label = wx.StaticText(self, label="Pulling installer catalog", pos=(-1,5)) title_label = wx.StaticText(self, label="Pulling installer catalog", pos=(-1,5))

View File

@@ -23,6 +23,7 @@ class macOSInstallerFlashFrame(wx.Frame):
def __init__(self, parent: wx.Frame, title: str, global_constants: constants.Constants, screen_location: tuple = None): def __init__(self, parent: wx.Frame, title: str, global_constants: constants.Constants, screen_location: tuple = None):
super(macOSInstallerFlashFrame, self).__init__(parent, title=title, size=(350, 200), style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX)) super(macOSInstallerFlashFrame, self).__init__(parent, title=title, size=(350, 200), style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX))
gui_support.GenerateMenubar(self, global_constants).generate()
self.constants: constants.Constants = global_constants self.constants: constants.Constants = global_constants
self.title: str = title self.title: str = title
@@ -37,7 +38,7 @@ class macOSInstallerFlashFrame(wx.Frame):
self._generate_elements() self._generate_elements()
self.SetPosition(screen_location) if screen_location else self.Centre() self.Centre()
self.Show() self.Show()
self._populate_installers() self._populate_installers()

View File

@@ -23,7 +23,8 @@ from data import os_data
class MainFrame(wx.Frame): class MainFrame(wx.Frame):
def __init__(self, parent: wx.Frame, title: str, global_constants: constants.Constants, screen_location: tuple = None): def __init__(self, parent: wx.Frame, title: str, global_constants: constants.Constants, screen_location: tuple = None):
super(MainFrame, self).__init__(parent, title=title, size=(350, 300), style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX)) super(MainFrame, self).__init__(parent, title=title, size=(600, 400), style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX))
gui_support.GenerateMenubar(self, global_constants).generate()
self.constants: constants.Constants = global_constants self.constants: constants.Constants = global_constants
self.title: str = title self.title: str = title
@@ -35,7 +36,7 @@ class MainFrame(wx.Frame):
self._generate_elements() self._generate_elements()
self.SetPosition(screen_location) if screen_location else self.Centre() self.Centre()
self.Show() self.Show()
self._preflight_checks() self._preflight_checks()
@@ -58,31 +59,102 @@ class MainFrame(wx.Frame):
""" """
# Title label: OpenCore Legacy Patcher v{X.Y.Z} # Title label: OpenCore Legacy Patcher v{X.Y.Z}
title_label = wx.StaticText(self, label=f"OpenCore Legacy Patcher v{self.constants.patcher_version}", pos=(-1,1)) title_label = wx.StaticText(self, label=f"OpenCore Legacy Patcher v{self.constants.patcher_version}", pos=(-1,10))
title_label.SetFont(wx.Font(19, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, ".AppleSystemUIFont")) title_label.SetFont(wx.Font(19, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, ".AppleSystemUIFont"))
title_label.Centre(wx.HORIZONTAL) title_label.Centre(wx.HORIZONTAL)
# Text: Model: {Build or Host Model} # Text: Model: {Build or Host Model}
model_label = wx.StaticText(self, label=f"Model: {self.constants.custom_model or self.constants.computer.real_model}", pos=(-1,30)) model_label = wx.StaticText(self, label=f"Model: {self.constants.custom_model or self.constants.computer.real_model}", pos=(-1, title_label.GetPosition()[1] + 25
))
model_label.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont")) model_label.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont"))
model_label.Centre(wx.HORIZONTAL) model_label.Centre(wx.HORIZONTAL)
self.model_label = model_label self.model_label = model_label
# Buttons: # Buttons:
menu_buttons = { menu_buttons = {
"Build and Install OpenCore": self.on_build_and_install, "Build and Install OpenCore": {
"Post-Install Root Patch": self.on_post_install_root_patch, "function": self.on_build_and_install,
"Create macOS Installer": self.on_create_macos_installer, "description": [
"Settings": self.on_settings, "Prepares provided drive to be able",
"Help": self.on_help "to boot unsupported OSes.",
"Use on installers or internal drives."
],
"icon": str(self.constants.icns_resource_path / "OC-Build.icns"),
},
"Create macOS Installer": {
"function": self.on_create_macos_installer,
"description": [
"Download and flash a macOS",
"Installer for your system.",
],
"icon": str(self.constants.icns_resource_path / "OC-Installer.icns"),
},
"Settings ⚙️": {
"function": self.on_settings,
"description": [
],
},
"Post-Install Root Patch": {
"function": self.on_post_install_root_patch,
"description": [
"Installs hardware drivers and",
"patches for your system after",
"installing a new version of macOS.",
],
"icon": str(self.constants.icns_resource_path / "OC-Patch.icns"),
},
"Support": {
"function": self.on_help,
"description": [
"Resources for OpenCore Legacy",
"Patcher.",
],
"icon": str(self.constants.icns_resource_path / "OC-Support.icns"),
},
} }
button_y = model_label.GetPosition()[1] + 20 button_x = 30
button_y = model_label.GetPosition()[1] + 30
rollover = len(menu_buttons) / 2
if rollover % 1 != 0:
rollover = int(rollover) + 1
index = 0
max_height = 0
for button_name, button_function in menu_buttons.items(): for button_name, button_function in menu_buttons.items():
button = wx.Button(self, label=button_name, pos=(-1, button_y), size=(200, 30)) # place icon
button.Bind(wx.EVT_BUTTON, button_function) if "icon" in button_function:
button.Centre(wx.HORIZONTAL) icon_mac = wx.StaticBitmap(self, bitmap=wx.Bitmap(button_function["icon"], wx.BITMAP_TYPE_ICON), pos=(button_x - 10, button_y), size=(64, 64))
if button_name == "Post-Install Root Patch":
icon_mac.SetPosition((-1, button_y + 7))
if button_name == "Create macOS Installer":
icon_mac.SetPosition((button_x - 5, button_y + 3))
if button_name == "Support":
# icon_mac.SetSize((80, 80))
icon_mac.SetPosition((button_x - 7, button_y + 3))
if button_name == "Build and Install OpenCore":
icon_mac.SetSize((70, 70))
if button_name == "Settings ⚙️":
button_y += 5
button = wx.Button(self, label=button_name, pos=(button_x + 70, button_y), size=(180, 30))
button.Bind(wx.EVT_BUTTON, lambda event, function=button_function["function"]: function(event))
button_y += 30 button_y += 30
# # Text: Description
description_label = wx.StaticText(self, label='\n'.join(button_function["description"]), pos=(button_x + 75, button.GetPosition()[1] + button.GetSize()[1] + 3))
description_label.SetFont(wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont"))
# button_y += 15
for i, line in enumerate(button_function["description"]):
if line == "":
continue
if i == 0:
button_y += 11
else:
button_y += 13
button_y += 25
if button_name == "Build and Install OpenCore": if button_name == "Build and Install OpenCore":
self.build_button = button self.build_button = button
if gui_support.CheckProperties(self.constants).host_can_build() is False: if gui_support.CheckProperties(self.constants).host_can_build() is False:
@@ -90,14 +162,25 @@ class MainFrame(wx.Frame):
elif button_name == "Post-Install Root Patch": elif button_name == "Post-Install Root Patch":
if self.constants.detected_os < os_data.os_data.big_sur: if self.constants.detected_os < os_data.os_data.big_sur:
button.Disable() button.Disable()
elif button_name == "Settings ⚙️":
button.SetSize((100, -1))
button.Centre(wx.HORIZONTAL)
description_label.Centre(wx.HORIZONTAL)
index += 1
if index == rollover:
max_height = button_y
button_x = 320
button_y = model_label.GetPosition()[1] + 30
# Text: Copyright # Text: Copyright
copy_label = wx.StaticText(self, label=self.constants.copyright_date, pos=(-1, button_y + 10)) copy_label = wx.StaticText(self, label=self.constants.copyright_date, pos=(-1, max_height - 15))
copy_label.SetFont(wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont")) copy_label.SetFont(wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont"))
copy_label.Centre(wx.HORIZONTAL) copy_label.Centre(wx.HORIZONTAL)
# Set window size # Set window size
self.SetSize((350, copy_label.GetPosition()[1] + 50)) self.SetSize((-1, copy_label.GetPosition()[1] + 50))
def _preflight_checks(self): def _preflight_checks(self):
@@ -195,14 +278,12 @@ class MainFrame(wx.Frame):
def on_post_install_root_patch(self, event: wx.Event = None): def on_post_install_root_patch(self, event: wx.Event = None):
self.Hide()
gui_sys_patch.SysPatchFrame( gui_sys_patch.SysPatchFrame(
parent=None, parent=self,
title=self.title, title=self.title,
global_constants=self.constants, global_constants=self.constants,
screen_location=self.GetPosition() screen_location=self.GetPosition()
) )
self.Destroy()
def on_create_macos_installer(self, event: wx.Event = None): def on_create_macos_installer(self, event: wx.Event = None):

View File

@@ -357,6 +357,8 @@ class SettingsFrame(wx.Frame):
"Disabled by default due to", "Disabled by default due to",
"performance degradation", "performance degradation",
"on some systems from wake.", "on some systems from wake.",
"Only applies to BCM943224, 331,",
"360 and 3602 chipsets.",
], ],
}, },
"Disable Thunderbolt": { "Disable Thunderbolt": {

View File

@@ -33,7 +33,7 @@ class SysPatchFrame(wx.Frame):
Uses a Modal Dialog for smoother transition from other frames Uses a Modal Dialog for smoother transition from other frames
""" """
def __init__(self, parent: wx.Frame, title: str, global_constants: constants.Constants, screen_location: tuple = None, patches: dict = {}): def __init__(self, parent: wx.Frame, title: str, global_constants: constants.Constants, screen_location: tuple = None, patches: dict = {}):
super(SysPatchFrame, self).__init__(parent, title=title, size=(350, 260), style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX)) self.frame = parent
self.title = title self.title = title
self.constants: constants.Constants = global_constants self.constants: constants.Constants = global_constants
@@ -41,8 +41,7 @@ class SysPatchFrame(wx.Frame):
self.return_button: wx.Button = None self.return_button: wx.Button = None
self.available_patches: bool = False self.available_patches: bool = False
self.frame_modal = wx.Dialog(self, title=title, size=(360, 200)) self.frame_modal = wx.Dialog(self.frame, title=title, size=(360, 200))
self.SetPosition(screen_location) if screen_location else self.Centre()
if patches: if patches:
return return
@@ -52,7 +51,7 @@ class SysPatchFrame(wx.Frame):
if self.constants.update_stage != gui_support.AutoUpdateStages.INACTIVE: if self.constants.update_stage != gui_support.AutoUpdateStages.INACTIVE:
if self.available_patches is False: if self.available_patches is False:
gui_support.RestartHost(self).restart(message="No root patch updates needed!\n\nWould you like to reboot to apply the new OpenCore build?") gui_support.RestartHost(self.frame).restart(message="No root patch updates needed!\n\nWould you like to reboot to apply the new OpenCore build?")
def _kdk_download(self, frame: wx.Frame = None) -> bool: def _kdk_download(self, frame: wx.Frame = None) -> bool:
@@ -249,7 +248,7 @@ class SysPatchFrame(wx.Frame):
# Button: Return to Main Menu # Button: Return to Main Menu
return_button = wx.Button(frame, label="Return to Main Menu", pos=(10, revert_button.GetPosition().y + revert_button.GetSize().height), size=(150, 30)) return_button = wx.Button(frame, label="Return to Main Menu", pos=(10, revert_button.GetPosition().y + revert_button.GetSize().height), size=(150, 30))
return_button.Bind(wx.EVT_BUTTON, self.on_return_to_main_menu) return_button.Bind(wx.EVT_BUTTON, self.on_return_dismiss)
return_button.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont")) return_button.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont"))
return_button.Centre(wx.HORIZONTAL) return_button.Centre(wx.HORIZONTAL)
self.return_button = return_button self.return_button = return_button
@@ -356,6 +355,12 @@ class SysPatchFrame(wx.Frame):
def start_root_patching(self, patches: dict): def start_root_patching(self, patches: dict):
self.frame.Close() if self.frame else None
super(SysPatchFrame, self).__init__(None, title=self.title, size=(350, 260), style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX))
gui_support.GenerateMenubar(self, self.constants).generate()
self.Centre()
self.return_button.Bind(wx.EVT_BUTTON, self.on_return_to_main_menu) if self.return_button else None
logging.info("Starting root patching") logging.info("Starting root patching")
while gui_support.PayloadMount(self.constants, self).is_unpack_finished() is False: while gui_support.PayloadMount(self.constants, self).is_unpack_finished() is False:
@@ -391,6 +396,12 @@ class SysPatchFrame(wx.Frame):
def revert_root_patching(self, patches: dict): def revert_root_patching(self, patches: dict):
self.frame.Close() if self.frame else None
super(SysPatchFrame, self).__init__(None, title=self.title, size=(350, 260), style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX))
gui_support.GenerateMenubar(self, self.constants).generate()
self.Centre()
self.return_button.Bind(wx.EVT_BUTTON, self.on_return_to_main_menu) if self.return_button else None
logging.info("Reverting root patches") logging.info("Reverting root patches")
self._generate_modal(patches, "Revert Root Patches") self._generate_modal(patches, "Revert Root Patches")
self.return_button.Disable() self.return_button.Disable()
@@ -422,11 +433,16 @@ class SysPatchFrame(wx.Frame):
None, None,
title=self.title, title=self.title,
global_constants=self.constants, global_constants=self.constants,
screen_location=self.GetScreenPosition() screen_location=self.GetScreenPosition() if not self.frame else self.frame.GetScreenPosition(),
) )
main_menu_frame.Show() main_menu_frame.Show()
self.frame_modal.Destroy() self.frame_modal.Destroy()
self.Destroy() self.Destroy() if not self.frame else self.frame.Destroy()
def on_return_dismiss(self, event: wx.Event = None):
self.frame_modal.Hide()
self.frame_modal.Destroy()
def _post_patch(self): def _post_patch(self):

View File

@@ -9,7 +9,7 @@ import subprocess
from pathlib import Path from pathlib import Path
from resources.wx_gui import gui_download from resources.wx_gui import gui_download, gui_support
from resources import ( from resources import (
constants, constants,
network_handler, network_handler,
@@ -30,6 +30,7 @@ class UpdateFrame(wx.Frame):
parent.Hide() parent.Hide()
else: else:
super(UpdateFrame, self).__init__(parent, title=title, size=(350, 300), style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX)) super(UpdateFrame, self).__init__(parent, title=title, size=(350, 300), style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX))
gui_support.GenerateMenubar(self, global_constants).generate()
self.title: str = title self.title: str = title
self.constants: constants.Constants = global_constants self.constants: constants.Constants = global_constants