Add administrator restart support on macOS

Note:
1. some shortcuts are not working
2. copy & paste not working, clipboard may not be useable

Signed-off-by: Loren Eteval <loren.eteval@proton.me>
This commit is contained in:
Loren Eteval
2025-12-01 22:55:54 +08:00
parent 5181714ea4
commit 72ebffe3b5
2 changed files with 29 additions and 14 deletions
+5 -1
View File
@@ -232,7 +232,11 @@ class GuiTUNSettings(GuiEditorWidgetQDialog):
super().__init__(*args, tabTranslatable=tabTranslatable, style=style, **kwargs)
self.setTabText(_('Customize TUN Settings'))
self.setFixedSize(int(480 * GOLDEN_RATIO), int(480))
if PLATFORM == 'Darwin':
self.setFixedSize(int(550 * GOLDEN_RATIO), int(550))
else:
self.setFixedSize(int(480 * GOLDEN_RATIO), int(480))
# Shallow copy
config = Storage.UserTUNSettings()
+24 -13
View File
@@ -238,19 +238,6 @@ class AppMainWindow(AppQMainWindow):
),
]
if PLATFORM == 'Darwin':
openAppFolderAction = []
else:
openAppFolderAction = [
AppQAction(
_('Open Application Folder'),
icon=bootstrapIcon('folder2.svg'),
checkable=False,
callback=lambda: self.openApplicationFolder(),
),
AppQSeperator(),
]
if PLATFORM == 'Windows' or PLATFORM == 'Darwin':
customizeTUNSettingsAction = [
AppQAction(
@@ -281,6 +268,21 @@ class AppMainWindow(AppQMainWindow):
else:
restartAsAdminAction = []
if PLATFORM == 'Darwin':
openAppFolderAction = [
AppQSeperator(),
]
else:
openAppFolderAction = [
AppQAction(
_('Open Application Folder'),
icon=bootstrapIcon('folder2.svg'),
checkable=False,
callback=lambda: self.openApplicationFolder(),
),
AppQSeperator(),
]
toolsActions = [
*customizeTUNSettingsAction,
*restartAsAdminAction,
@@ -503,6 +505,15 @@ class AppMainWindow(AppQMainWindow):
f'\'{AppCommands.RunAs.value}\' -Verb runAs',
],
)
elif PLATFORM == 'Darwin':
process.startDetached(
'osascript',
arguments=[
'-e',
f'do shell script \"{APP().applicationFilePath()} '
f'{AppCommands.RunAs.value}\" with administrator privileges',
],
)
else:
mbox = AppQMessageBox(icon=AppQMessageBox.Icon.Information)
mbox.setWindowTitle(_(APPLICATION_NAME))