mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-06-19 22:00:00 +10:00
gui.py: Add Cmd+Q support
This commit is contained in:
+19
-5
@@ -26,6 +26,8 @@ class wx_python_gui:
|
|||||||
self.stock_stdout = sys.stdout
|
self.stock_stdout = sys.stdout
|
||||||
self.stock_stderr = sys.stderr
|
self.stock_stderr = sys.stderr
|
||||||
|
|
||||||
|
current_uid = os.getuid()
|
||||||
|
|
||||||
# Define Window Size
|
# Define Window Size
|
||||||
self.WINDOW_WIDTH_MAIN = 350
|
self.WINDOW_WIDTH_MAIN = 350
|
||||||
self.WINDOW_HEIGHT_MAIN = 220
|
self.WINDOW_HEIGHT_MAIN = 220
|
||||||
@@ -45,12 +47,24 @@ class wx_python_gui:
|
|||||||
self.frame.Show()
|
self.frame.Show()
|
||||||
self.frame.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
|
self.frame.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
|
||||||
|
|
||||||
|
# Create Menubar (allows Cmd+Q usage)
|
||||||
|
self.menubar = wx.MenuBar()
|
||||||
|
self.file_menu = wx.Menu()
|
||||||
|
self.file_menu.Append(wx.ID_EXIT, "Quit", "Quit Application" )
|
||||||
|
self.file_menu.Append(wx.ID_REDO, f"Relaunch as Root (UID: {int(current_uid)})", "Relaunch OpenCore Legacy Patcher as Root")
|
||||||
|
self.menubar.Append(self.file_menu, "File")
|
||||||
|
self.frame.Bind(wx.EVT_MENU, self.OnCloseFrame, id=wx.ID_EXIT)
|
||||||
|
self.frame.Bind(wx.EVT_MENU, self.relaunch_as_root, id=wx.ID_REDO)
|
||||||
|
self.frame.SetMenuBar(self.menubar)
|
||||||
|
|
||||||
|
if current_uid == 0:
|
||||||
|
self.file_menu.Enable(wx.ID_REDO, False)
|
||||||
|
|
||||||
self.main_menu(None)
|
self.main_menu(None)
|
||||||
|
|
||||||
wx.CallAfter(self.frame.Close)
|
wx.CallAfter(self.frame.Close)
|
||||||
|
|
||||||
def OnCloseFrame(self, event):
|
def OnCloseFrame(self, event):
|
||||||
print("Cleaning up on close")
|
|
||||||
self.frame.DestroyChildren()
|
self.frame.DestroyChildren()
|
||||||
self.frame.Destroy()
|
self.frame.Destroy()
|
||||||
self.app.ExitMainLoop()
|
self.app.ExitMainLoop()
|
||||||
@@ -80,15 +94,15 @@ class wx_python_gui:
|
|||||||
if self.dialog.ShowModal() == wx.ID_YES:
|
if self.dialog.ShowModal() == wx.ID_YES:
|
||||||
print("Relaunching as root")
|
print("Relaunching as root")
|
||||||
if self.constants.launcher_script is None:
|
if self.constants.launcher_script is None:
|
||||||
args_string = f"{self.constants.launcher_binary}"""
|
args_string = f"'{self.constants.launcher_binary}'"
|
||||||
else:
|
else:
|
||||||
args_string = f"{self.constants.launcher_binary} {self.constants.launcher_script}"
|
args_string = f"{self.constants.launcher_binary} {self.constants.launcher_script}"
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
"osascript",
|
"osascript",
|
||||||
"-e",
|
"-e",
|
||||||
f'''do shell script "'{args_string}'"'''
|
f'''do shell script "{args_string}"'''
|
||||||
' with prompt "OpenCore Legacy Patcher needs administrator privileges to mount your EFI."'
|
' with prompt "OpenCore Legacy Patcher needs administrator privileges to relaunch as admin."'
|
||||||
" with administrator privileges"
|
" with administrator privileges"
|
||||||
" without altering line endings",
|
" without altering line endings",
|
||||||
]
|
]
|
||||||
@@ -183,7 +197,7 @@ class wx_python_gui:
|
|||||||
self.reset_window()
|
self.reset_window()
|
||||||
|
|
||||||
# Set header text
|
# Set header text
|
||||||
self.frame.SetTitle(f"OpenCore Legacy Patcher v{self.constants.patcher_version}")
|
self.frame.SetTitle(f"OpenCore Legacy Patcher")
|
||||||
# Header
|
# Header
|
||||||
self.header = wx.StaticText(self.frame, label=f"OpenCore Legacy Patcher v{self.constants.patcher_version}")
|
self.header = wx.StaticText(self.frame, label=f"OpenCore Legacy Patcher v{self.constants.patcher_version}")
|
||||||
self.header.SetFont(wx.Font(18, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
|
self.header.SetFont(wx.Font(18, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
|
||||||
|
|||||||
Reference in New Issue
Block a user