Merge pull request #1067 from dortania/gui-main-demo

Implement new main menu UI
This commit is contained in:
Mykola Grymalyuk
2023-05-20 11:28:56 -07:00
committed by GitHub
17 changed files with 188 additions and 60 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 = 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.SetPosition((-1, button_y + 7))
if button_name == "Create macOS Installer":
icon.SetPosition((button_x - 5, button_y + 3))
if button_name == "Support":
# icon_mac.SetSize((80, 80))
icon.SetPosition((button_x - 7, button_y + 3))
if button_name == "Build and Install OpenCore":
icon.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

@@ -62,14 +62,14 @@ class SettingsFrame(wx.Frame):
model_label.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, ".AppleSystemUIFont")) model_label.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, ".AppleSystemUIFont"))
sizer.Add(model_label, 0, wx.ALIGN_CENTER | wx.ALL, 5) sizer.Add(model_label, 0, wx.ALIGN_CENTER | wx.ALL, 5)
model_choice = wx.Choice(frame, choices=model_array.SupportedSMBIOS + ["Host Model"], pos=(-1, -1)) model_choice = wx.Choice(frame, choices=model_array.SupportedSMBIOS + ["Host Model"], pos=(-1, -1), size=(150, -1))
model_choice.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont")) model_choice.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont"))
model_choice.Bind(wx.EVT_CHOICE, lambda event: self.on_model_choice(event, model_choice)) model_choice.Bind(wx.EVT_CHOICE, lambda event: self.on_model_choice(event, model_choice))
selection = self.constants.custom_model if self.constants.custom_model else "Host Model" selection = self.constants.custom_model if self.constants.custom_model else "Host Model"
model_choice.SetSelection(model_choice.FindString(selection)) model_choice.SetSelection(model_choice.FindString(selection))
sizer.Add(model_choice, 0, wx.ALIGN_CENTER | wx.ALL, 5) sizer.Add(model_choice, 0, wx.ALIGN_CENTER | wx.ALL, 5)
model_description = wx.StaticText(frame, label="Overrides Mac Model Patcher will build for.", pos=(-1, -1)) model_description = wx.StaticText(frame, label="Overrides Mac Model the Patcher will build for.", pos=(-1, -1))
model_description.SetFont(wx.Font(11, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont")) model_description.SetFont(wx.Font(11, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont"))
sizer.Add(model_description, 0, wx.ALIGN_CENTER | wx.ALL, 5) sizer.Add(model_description, 0, wx.ALIGN_CENTER | wx.ALL, 5)
@@ -166,20 +166,20 @@ class SettingsFrame(wx.Frame):
# Add label next to spinctrl # Add label next to spinctrl
label = wx.StaticText(panel, label=setting, pos=(spinctrl.GetSize()[0] + width - 16, spinctrl.GetPosition()[1])) label = wx.StaticText(panel, label=setting, pos=(spinctrl.GetSize()[0] + width - 16, spinctrl.GetPosition()[1]))
label.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, ".AppleSystemUIFont")) label.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, ".AppleSystemUIFont"))
elif setting_info["type"] == "combobox": elif setting_info["type"] == "choice":
# Title # Title
title = wx.StaticText(panel, label=setting, pos=(width + 30, 10 + height)) title = wx.StaticText(panel, label=setting, pos=(width + 30, 10 + height))
title.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, ".AppleSystemUIFont")) title.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, ".AppleSystemUIFont"))
height += title.GetSize()[1] + 10 height += title.GetSize()[1] + 10
# Add combobox, and description underneath # Add combobox, and description underneath
combobox = wx.ComboBox(panel, value=setting_info["value"], pos=(width + 25, 10 + height), choices=setting_info["choices"], size = (150,-1)) choice = wx.Choice(panel, pos=(width + 25, 10 + height), choices=setting_info["choices"], size = (150,-1))
combobox.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, ".AppleSystemUIFont")) choice.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont"))
# combobox.Bind(wx.EVT_COMBOBOX, lambda event, variable=setting: self.on_combobox(event, variable)) choice.SetSelection(choice.FindString(setting_info["value"]))
if "override_function" in setting_info: if "override_function" in setting_info:
combobox.Bind(wx.EVT_COMBOBOX, lambda event, variable=setting: self.settings[tab][variable]["override_function"](event)) choice.Bind(wx.EVT_CHOICE, lambda event, variable=setting: self.settings[tab][variable]["override_function"](event))
else: else:
combobox.Bind(wx.EVT_COMBOBOX, lambda event, variable=setting: self.on_combobox(event, variable)) choice.Bind(wx.EVT_CHOICE, lambda event, variable=setting: self.on_choice(event, variable))
height += 10 height += 10
elif setting_info["type"] == "button": elif setting_info["type"] == "button":
button = wx.Button(panel, label=setting, pos=(width + 25, 10 + height), size = (200,-1)) button = wx.Button(panel, label=setting, pos=(width + 25, 10 + height), size = (200,-1))
@@ -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": {
@@ -464,7 +466,7 @@ class SettingsFrame(wx.Frame):
"type": "wrap_around", "type": "wrap_around",
}, },
"FeatureUnlock": { "FeatureUnlock": {
"type": "combobox", "type": "choice",
"choices": [ "choices": [
"Enabled", "Enabled",
"Partial", "Partial",
@@ -521,7 +523,7 @@ class SettingsFrame(wx.Frame):
"type": "wrap_around", "type": "wrap_around",
}, },
"Graphics Override": { "Graphics Override": {
"type": "combobox", "type": "choice",
"choices": [ "choices": [
"None", "None",
"Nvidia Kepler", "Nvidia Kepler",
@@ -595,7 +597,7 @@ class SettingsFrame(wx.Frame):
"type": "title", "type": "title",
}, },
"SMBIOS Spoof Level": { "SMBIOS Spoof Level": {
"type": "combobox", "type": "choice",
"choices": [ "choices": [
"None", "None",
"Minimal", "Minimal",
@@ -614,7 +616,7 @@ class SettingsFrame(wx.Frame):
}, },
"SMBIOS Spoof Model": { "SMBIOS Spoof Model": {
"type": "combobox", "type": "choice",
"choices": models + ["Default"], "choices": models + ["Default"],
"value": self.constants.override_smbios, "value": self.constants.override_smbios,
"variable": "override_smbios", "variable": "override_smbios",
@@ -1062,10 +1064,10 @@ Hardware Information:
self.sip_configured_label.SetLabel(f"Currently configured SIP: {hex(self.sip_value)}") self.sip_configured_label.SetLabel(f"Currently configured SIP: {hex(self.sip_value)}")
def on_combobox(self, event: wx.Event, label: str) -> None: def on_choice(self, event: wx.Event, label: str) -> None:
""" """
""" """
value = event.GetEventObject().GetValue() value = event.GetString()
self._update_setting(self.settings[self._find_parent_for_key(label)][label]["variable"], value) self._update_setting(self.settings[self._find_parent_for_key(label)][label]["variable"], value)
@@ -1092,13 +1094,13 @@ Hardware Information:
def _populate_fu_override(self, panel: wx.Panel) -> None: def _populate_fu_override(self, panel: wx.Panel) -> None:
gpu_combo_box: wx.ComboBox = None gpu_combo_box: wx.Choice = None
for child in panel.GetChildren(): for child in panel.GetChildren():
if isinstance(child, wx.ComboBox): if isinstance(child, wx.Choice):
gpu_combo_box = child gpu_combo_box = child
break break
gpu_combo_box.Bind(wx.EVT_COMBOBOX, self.fu_selection_click) gpu_combo_box.Bind(wx.EVT_CHOICE, self.fu_selection_click)
if self.constants.fu_status is False: if self.constants.fu_status is False:
gpu_combo_box.SetStringSelection("Disabled") gpu_combo_box.SetStringSelection("Disabled")
elif self.constants.fu_arguments is None: elif self.constants.fu_arguments is None:
@@ -1110,31 +1112,34 @@ Hardware Information:
def fu_selection_click(self, event: wx.Event) -> None: def fu_selection_click(self, event: wx.Event) -> None:
value = event.GetEventObject().GetStringSelection() value = event.GetEventObject().GetStringSelection()
if value == "Enabled": if value == "Enabled":
logging.info("Updating FU Status: Enabled")
self.constants.fu_status = True self.constants.fu_status = True
self.constants.fu_arguments = None self.constants.fu_arguments = None
return return
if value == "Partial": if value == "Partial":
logging.info("Updating FU Status: Partial")
self.constants.fu_status = True self.constants.fu_status = True
self.constants.fu_arguments = " -disable_sidecar_mac" self.constants.fu_arguments = " -disable_sidecar_mac"
return return
logging.info("Updating FU Status: Disabled")
self.constants.fu_status = False self.constants.fu_status = False
self.constants.fu_arguments = None self.constants.fu_arguments = None
def _populate_graphics_override(self, panel: wx.Panel) -> None: def _populate_graphics_override(self, panel: wx.Panel) -> None:
gpu_combo_box: wx.ComboBox = None gpu_combo_box: wx.Choice = None
index = 0 index = 0
for child in panel.GetChildren(): for child in panel.GetChildren():
if isinstance(child, wx.ComboBox): if isinstance(child, wx.Choice):
if index == 0: if index == 0:
index = index + 1 index = index + 1
continue continue
gpu_combo_box = child gpu_combo_box = child
break break
gpu_combo_box.Bind(wx.EVT_COMBOBOX, self.gpu_selection_click) gpu_combo_box.Bind(wx.EVT_CHOICE, self.gpu_selection_click)
gpu_combo_box.SetStringSelection(f"{self.constants.imac_vendor} {self.constants.imac_model}") gpu_combo_box.SetStringSelection(f"{self.constants.imac_vendor} {self.constants.imac_model}")
socketed_gpu_models = ["iMac9,1", "iMac10,1", "iMac11,1", "iMac11,2", "iMac11,3", "iMac12,1", "iMac12,2"] socketed_gpu_models = ["iMac9,1", "iMac10,1", "iMac11,1", "iMac11,2", "iMac11,3", "iMac12,1", "iMac12,2"]

View File

@@ -265,10 +265,10 @@ class RelaunchApplicationAsRoot:
] ]
self.frame.DestroyChildren() self.frame.DestroyChildren()
self.frame.SetSize(400, 300) self.frame.SetSize(300, 300)
# Header # Header
header = wx.StaticText(self.frame, label="Relaunching as root") header = wx.StaticText(self.frame, label="Relaunching as root", pos=(-1, 5))
header.SetFont(wx.Font(19, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, ".AppleSystemUIFont")) header.SetFont(wx.Font(19, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, ".AppleSystemUIFont"))
header.Centre(wx.HORIZONTAL) header.Centre(wx.HORIZONTAL)

View File

@@ -33,7 +33,14 @@ 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.initiated_with_parent = False
if not self.frame:
super(SysPatchFrame, self).__init__(parent, title=title, size=(350, 200), style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX))
self.frame = self
self.frame.Centre()
else:
self.initiated_with_parent = True
self.title = title self.title = title
self.constants: constants.Constants = global_constants self.constants: constants.Constants = global_constants
@@ -41,8 +48,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 +58,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 +255,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 if self.initiated_with_parent else self.on_return_to_main_menu)
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
@@ -351,11 +357,17 @@ class SysPatchFrame(wx.Frame):
# Set frame size # Set frame size
dialog.SetSize((-1, return_button.GetPosition().y + return_button.GetSize().height + 33)) dialog.SetSize((-1, return_button.GetPosition().y + return_button.GetSize().height + 33))
self.frame_modal = dialog
dialog.ShowWindowModal() dialog.ShowWindowModal()
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 +403,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()
@@ -417,16 +435,24 @@ class SysPatchFrame(wx.Frame):
def on_return_to_main_menu(self, event: wx.Event = None): def on_return_to_main_menu(self, event: wx.Event = None):
self.frame_modal.Hide() # Get frame from event
frame_modal: wx.Dialog = event.GetEventObject().GetParent()
frame: wx.Frame = frame_modal.Parent
frame_modal.Hide()
frame.Hide()
main_menu_frame = gui_main_menu.MainFrame( main_menu_frame = gui_main_menu.MainFrame(
None, None,
title=self.title, title=self.title,
global_constants=self.constants, global_constants=self.constants,
screen_location=self.GetScreenPosition()
) )
main_menu_frame.Show() main_menu_frame.Show()
frame.Destroy()
def on_return_dismiss(self, event: wx.Event = None):
self.frame_modal.Hide()
self.frame_modal.Destroy() self.frame_modal.Destroy()
self.Destroy()
def _post_patch(self): def _post_patch(self):
@@ -434,11 +460,11 @@ class SysPatchFrame(wx.Frame):
return return
if self.constants.needs_to_open_preferences is False: if self.constants.needs_to_open_preferences is False:
gui_support.RestartHost(self).restart(message="Root Patcher finished successfully!\n\nWould you like to reboot now?") gui_support.RestartHost(self.frame_modal).restart(message="Root Patcher finished successfully!\n\nWould you like to reboot now?")
return return
if self.constants.detected_os >= os_data.os_data.ventura: if self.constants.detected_os >= os_data.os_data.ventura:
gui_support.RestartHost(self).restart(message="Root Patcher finished successfully!\nIf you were prompted to open System Settings to authorize new kexts, this can be ignored. Your system is ready once restarted.\n\nWould you like to reboot now?") gui_support.RestartHost(self.frame_modal).restart(message="Root Patcher finished successfully!\nIf you were prompted to open System Settings to authorize new kexts, this can be ignored. Your system is ready once restarted.\n\nWould you like to reboot now?")
return return
# Create dialog box to open System Preferences -> Security and Privacy # Create dialog box to open System Preferences -> Security and Privacy

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