mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
UDP: getOtherAppFromDialog() refactored in uShellContextMenu on macOS
(cherry picked from commit 64d65252c1)
This commit is contained in:
parent
e8c11b02ba
commit
f0dcb021b7
1 changed files with 24 additions and 15 deletions
|
|
@ -421,27 +421,36 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
// Context Menu / Open with / Other...
|
||||
function getOtherAppFromDialog(): String;
|
||||
var
|
||||
appDialog: TOpenDialog;
|
||||
begin
|
||||
Result:= '';
|
||||
appDialog:= TOpenDialog.Create(nil);
|
||||
appDialog.DefaultExt:= 'app';
|
||||
appDialog.InitialDir:= '/Applications';
|
||||
appDialog.Filter:= rsOpenWithMacOSFilter;
|
||||
if appDialog.Execute and (NOT appDialog.FileName.IsEmpty) then begin
|
||||
Result:= appDialog.FileName;
|
||||
end;
|
||||
FreeAndNil( appDialog );
|
||||
end;
|
||||
|
||||
procedure TShellContextMenu.OpenWithMenuItemSelect(Sender: TObject);
|
||||
var
|
||||
ExecCmd: String;
|
||||
appDialog: TOpenDialog;
|
||||
appPath: String;
|
||||
launchParam: LSLaunchURLSpec;
|
||||
begin
|
||||
ExecCmd := (Sender as TMenuItem).Hint;
|
||||
appPath := (Sender as TMenuItem).Hint;
|
||||
|
||||
if ExecCmd.IsEmpty then begin
|
||||
// Context Menu / Open with / Other...
|
||||
appDialog:= TOpenDialog.Create(self);
|
||||
appDialog.DefaultExt:= 'app';
|
||||
appDialog.InitialDir:= '/Applications';
|
||||
appDialog.Filter:= rsOpenWithMacOSFilter;
|
||||
if appDialog.Execute and (NOT appDialog.FileName.IsEmpty) then begin
|
||||
ExecCmd:= QuoteStr(appDialog.FileName);
|
||||
end;
|
||||
FreeAndNil(appDialog);
|
||||
if appPath.IsEmpty then begin
|
||||
appPath:= getOtherAppFromDialog;
|
||||
if appPath.IsEmpty then
|
||||
Exit;
|
||||
end;
|
||||
|
||||
launchParam.appURL:= CFURLRef( NSUrl.fileURLWithPath(StringToNSString(ExecCmd)) );
|
||||
launchParam.appURL:= CFURLRef( NSUrl.fileURLWithPath(StringToNSString(appPath)) );
|
||||
launchParam.itemURLs:= CFArrayRef( filesToNSUrlArray(FFiles) );
|
||||
launchParam.launchFlags:= 0;
|
||||
launchParam.asyncRefCon:= nil;
|
||||
|
|
@ -516,7 +525,7 @@ begin
|
|||
appUrl:= NSURL( appArray.objectAtIndex(I) );
|
||||
mi:= TMenuItem.Create( miOpenWith );
|
||||
mi.Caption:= NSFileManager.defaultManager.displayNameAtPath(appUrl.path).UTF8String;
|
||||
mi.Hint := QuoteStr(appUrl.path.UTF8String);
|
||||
mi.Hint := appUrl.path.UTF8String;
|
||||
ImageIndex:= PixMapManager.GetApplicationBundleIcon(appUrl.path.UTF8String, -1);
|
||||
if ImageIndex >= 0 then begin
|
||||
bmpTemp:= PixMapManager.GetBitmap(ImageIndex);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue