ADD: Map Network Drive command (fixes #1720)

This commit is contained in:
Alexander Koblov 2024-06-19 21:05:41 +03:00
commit 6e187ef760
7 changed files with 69 additions and 48 deletions

View file

@ -2850,6 +2850,12 @@ object frmMain: TfrmMain
Hint = 'Show list of all open tabs'
OnExecute = actExecute
end
object actMapNetworkDrive: TAction
Tag = 6
Category = 'Network'
Caption = 'Map Network Drive...'
OnExecute = actExecute
end
end
object pmHotList: TPopupMenu
Images = imgLstDirectoryHotlist

View file

@ -261,6 +261,7 @@
{"hash":230704005,"name":"tfrmmain.actsavefiledetailstofile.caption","sourcebytes":[83,97,118,101,32,97,108,108,32,115,104,111,119,110,32,99,111,108,117,109,110,115,32,116,111,32,102,105,108,101],"value":"Save all shown columns to file"},
{"hash":104763204,"name":"tfrmmain.actshowtabslist.caption","sourcebytes":[83,104,111,119,32,84,97,98,115,32,76,105,115,116],"value":"Show Tabs List"},
{"hash":154792195,"name":"tfrmmain.actshowtabslist.hint","sourcebytes":[83,104,111,119,32,108,105,115,116,32,111,102,32,97,108,108,32,111,112,101,110,32,116,97,98,115],"value":"Show list of all open tabs"},
{"hash":255983166,"name":"tfrmmain.actmapnetworkdrive.caption","sourcebytes":[77,97,112,32,78,101,116,119,111,114,107,32,68,114,105,118,101,46,46,46],"value":"Map Network Drive..."},
{"hash":310020,"name":"tfrmmain.tbedit.caption","sourcebytes":[69,100,105,116],"value":"Edit"},
{"hash":78392485,"name":"tfrmmain.tbdelete.caption","sourcebytes":[68,101,108,101,116,101],"value":"Delete"},
{"hash":1140,"name":"tfrmmain.tbchangedir.caption","sourcebytes":[67,68],"value":"CD"},

View file

@ -69,6 +69,7 @@ type
TfrmMain = class(TAloneForm, IFormCommands)
actAddPlugin: TAction;
actMapNetworkDrive: TAction;
actShowTabsList: TAction;
actSaveFileDetailsToFile: TAction;
actLoadList: TAction;

View file

@ -122,6 +122,7 @@ function GetControlHandle(AWindow: TWinControl): HWND;
function GetWindowHandle(AWindow: TWinControl): HWND; overload;
function GetWindowHandle(AHandle: HWND): HWND; overload;
procedure CopyNetNamesToClip;
procedure MapNetworkDrive;
function DarkStyle: Boolean;
implementation
@ -153,6 +154,7 @@ uses
, uDCReadRSVG, uMagickWand, uGio, uGioFileSource, uVfsModule, uVideoThumb
, uDCReadWebP, uFolderThumb, uAudioThumb, uDefaultTerminal, uDCReadHEIF
, uTrashFileSource, uFileManager, uFileSystemFileSource, fOpenWith
, uFileSourceUtil
{$ENDIF}
{$IF DEFINED(LINUX)}
, uFlatpak
@ -496,32 +498,11 @@ end;
procedure MenuHandler(Self, Sender: TObject);
var
Ret: DWORD;
Res: TNetResourceA;
CDS: TConnectDlgStruct;
begin
if (Sender as TMenuItem).Tag = 0 then
begin
ZeroMemory(@Res, SizeOf(TNetResourceA));
Res.dwType := RESOURCETYPE_DISK;
CDS.cbStructure := SizeOf(TConnectDlgStruct);
CDS.hwndOwner := frmMain.Handle;
CDS.lpConnRes := @Res;
CDS.dwFlags := 0;
Ret:= WNetConnectionDialog1(CDS);
if Ret = NO_ERROR then
begin
SetFileSystemPath(frmMain.ActiveFrame, AnsiChar(Int64(CDS.dwDevNum) + Ord('a') - 1) + ':\');
end
else if Ret <> DWORD(-1) then begin
MessageDlg(mbSysErrorMessage(Ret), mtError, [mbOK], 0);
end;
end
else begin
Ret:= WNetDisconnectDialog(fmain.frmMain.Handle, RESOURCETYPE_DISK);
case Ret of
NO_ERROR, DWORD(-1): ;
else MessageDlg(mbSysErrorMessage(Ret), mtError, [mbOK], 0);
end;
Ret:= WNetDisconnectDialog(fmain.frmMain.Handle, RESOURCETYPE_DISK);
case Ret of
NO_ERROR, DWORD(-1): ;
else MessageDlg(mbSysErrorMessage(Ret), mtError, [mbOK], 0);
end;
end;
@ -586,17 +567,7 @@ end;
{$ENDIF}
{$IF DEFINED(DARWIN)}
procedure MenuHandler(Self, Sender: TObject);
var
Address: String = '';
begin
if ShowInputQuery(Application.Title, rsMsgURL, False, Address) then
MountNetworkDrive(Address);
end;
{$ELSEIF DEFINED(LCLGTK2)}
{$IF DEFINED(LCLGTK2)}
procedure OnThemeChange; cdecl;
begin
@ -678,14 +649,11 @@ begin
mnuNetwork.Add(MenuItem);
MenuItem:= TMenuItem.Create(mnuMain);
MenuItem.Caption:= rsMnuMapNetworkDrive;
MenuItem.Tag:= 0;
MenuItem.OnClick:= TNotifyEvent(Handler);
MenuItem.Action:= actMapNetworkDrive;
mnuNetwork.Add(MenuItem);
MenuItem:= TMenuItem.Create(mnuMain);
MenuItem.Caption:= rsMnuDisconnectNetworkDrive;
MenuItem.Tag:= 1;
MenuItem.OnClick:= TNotifyEvent(Handler);
mnuNetwork.Add(MenuItem);
@ -705,11 +673,12 @@ begin
end;
end;
{$ELSE}
{$IF DEFINED(LCLQT) or DEFINED(LCLQT5) or DEFINED(LCLQT6) or DEFINED(LCLGTK2) or DEFINED(DARWIN)}
{$IF DEFINED(LCLQT) or DEFINED(LCLQT5) or DEFINED(LCLQT6) or DEFINED(LCLGTK2)}
var
Handler: TMethod;
{$ENDIF}
{$IF DEFINED(DARWIN)}
var
MenuItem: TMenuItem;
{$ENDIF}
begin
@ -753,16 +722,12 @@ begin
begin
with frmMain do
begin
Handler.Code:= @MenuHandler;
Handler.Data:= MainForm;
MenuItem:= TMenuItem.Create(mnuMain);
MenuItem.Caption:= '-';
mnuNetwork.Add(MenuItem);
MenuItem:= TMenuItem.Create(mnuMain);
MenuItem.Caption:= rsMnuMapNetworkDrive;
MenuItem.OnClick:= TNotifyEvent(Handler);
MenuItem.Action:= actMapNetworkDrive;
mnuNetwork.Add(MenuItem);
end;
end;
@ -1045,6 +1010,47 @@ begin
end;
{$ENDIF}
procedure MapNetworkDrive;
{$IF DEFINED(MSWINDOWS)}
var
Ret: DWORD;
Res: TNetResourceA;
CDS: TConnectDlgStruct;
begin
ZeroMemory(@Res, SizeOf(TNetResourceA));
Res.dwType := RESOURCETYPE_DISK;
CDS.cbStructure := SizeOf(TConnectDlgStruct);
CDS.hwndOwner := frmMain.Handle;
CDS.lpConnRes := @Res;
CDS.dwFlags := 0;
Ret:= WNetConnectionDialog1(CDS);
if Ret = NO_ERROR then
begin
SetFileSystemPath(frmMain.ActiveFrame, AnsiChar(Int64(CDS.dwDevNum) + Ord('a') - 1) + ':\');
end
else if Ret <> DWORD(-1) then begin
MessageDlg(mbSysErrorMessage(Ret), mtError, [mbOK], 0);
end;
end;
{$ELSEIF DEFINED(UNIX) AND NOT DEFINED(HAIKU)}
var
Address: String = '';
begin
if ShowInputQuery(Application.Title, rsMsgURL, False, Address) then
begin
{$IF DEFINED(DARWIN)}
MountNetworkDrive(Address);
{$ELSE}
ChooseFileSource(frmMain.ActiveFrame, Address);
{$ENDIF}
end;
end;
{$ELSE}
begin
msgWarning(rsMsgErrNotSupported);
end;
{$ENDIF}
function DarkStyle: Boolean;
{$IF DEFINED(DARKWIN)}
begin

View file

@ -173,7 +173,7 @@ type
const
{ Default hotkey list version number }
hkVersion = 63;
hkVersion = 64;
// 54 - In "Viewer" context, added the "W" for "cm_WrapText", "4" for "cm_ShowAsDec", "8" for "cm_ShowOffice".
// 53 - In "Main" context, change shortcut "Alt+`" to "Alt+0" for the "cm_ActivateTabByIndex".
// 52 - In "Main" context, add shortcut "Ctrl+Shift+B" for "cm_FlatViewSel".
@ -1183,6 +1183,8 @@ begin
if Assigned(HMHotKey) and HMHotKey.SameShortcuts(['Ctrl+Z']) then
Remove(HMHotKey);
end;
AddIfNotExists(VK_K, [ssModifier], 'cm_MapNetworkDrive');
end;
HMControl := HMForm.Controls.FindOrCreate('Files Panel');

View file

@ -377,7 +377,6 @@ resourcestring
rsOpenWithMacOSFilter = 'Applications (*.app)|*.app|All files (*)|*';
// for main menu
rsMnuCreateShortcut = 'Create Shortcut...';
rsMnuMapNetworkDrive = 'Map Network Drive...';
rsMnuDisconnectNetworkDrive = 'Disconnect Network Drive...';
// for dock emnu
rsMnuNewWindow = 'New Window';

View file

@ -335,6 +335,7 @@ type
procedure cm_NetworkConnect(const Params: array of string);
procedure cm_NetworkDisconnect(const Params: array of string);
procedure cm_CopyNetNamesToClip(const Params: array of string);
procedure cm_MapNetworkDrive(const Params: array of string);
procedure cm_HorizontalFilePanels(const Params: array of string);
procedure cm_OperationsViewer(const Params: array of string);
procedure cm_CompareDirectories(const Params: array of string);
@ -4563,6 +4564,11 @@ begin
CopyNetNamesToClip;
end;
procedure TMainCommands.cm_MapNetworkDrive(const Params: array of string);
begin
MapNetworkDrive;
end;
procedure TMainCommands.cm_HorizontalFilePanels(const Params: array of string);
var
sParamValue:string;