mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-28 10:02:14 +00:00
FIX: Selecting drive buttons when one is prefix of another.
This commit is contained in:
parent
947d515bdb
commit
4e9e11f87d
2 changed files with 50 additions and 38 deletions
|
|
@ -583,6 +583,7 @@ type
|
|||
procedure SaveWindowState;
|
||||
procedure SaveMainToolBar;
|
||||
function IsCommandLineVisible: Boolean;
|
||||
function FindMatchingDrive(Path: UTF8String): Integer;
|
||||
procedure UpdateDriveToolbarSelection(DriveToolbar: TKAStoolBar; FileView: TFileView);
|
||||
procedure UpdateDriveButtonSelection(DriveButton: TSpeedButton; FileView: TFileView);
|
||||
procedure UpdateSelectedDrive(ANoteBook: TFileViewNotebook);
|
||||
|
|
@ -4054,62 +4055,65 @@ begin
|
|||
Result := (edtCommand.Visible and pnlCommand.Visible);
|
||||
end;
|
||||
|
||||
procedure TfrmMain.UpdateDriveToolbarSelection(DriveToolbar: TKAStoolBar; FileView: TFileView);
|
||||
function TfrmMain.FindMatchingDrive(Path: UTF8String): Integer;
|
||||
var
|
||||
i : Integer;
|
||||
ToolButtonPath : String;
|
||||
Path: String;
|
||||
LongestPathLen: Integer = 0;
|
||||
DrivePath: UTF8String;
|
||||
DrivePathLen: PtrInt;
|
||||
begin
|
||||
Result := -1;
|
||||
|
||||
if Assigned(DrivesList) then
|
||||
begin
|
||||
Path := UTF8UpperCase(Path);
|
||||
|
||||
for i := 0 to DrivesList.Count - 1 do
|
||||
begin
|
||||
DrivePath := UTF8UpperCase(DrivesList[i]^.Path);
|
||||
DrivePathLen := UTF8Length(DrivePath);
|
||||
if (DrivePathLen > LongestPathLen) and IsInPath(DrivePath, Path, True) then
|
||||
begin
|
||||
LongestPathLen := DrivePathLen;
|
||||
Result := i;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrmMain.UpdateDriveToolbarSelection(DriveToolbar: TKAStoolBar; FileView: TFileView);
|
||||
var
|
||||
DriveIndex: Integer;
|
||||
begin
|
||||
if not gDriveBar1 and not gDriveBar2 then
|
||||
Exit;
|
||||
|
||||
Path := FileView.CurrentPath;
|
||||
|
||||
for i := 0 to DriveToolbar.ButtonCount - 1 do
|
||||
begin
|
||||
ToolButtonPath := DriveToolbar.Commands[i];
|
||||
if IsInPath(UTF8UpperCase(ToolButtonPath), UTF8UpperCase(Path), True) then
|
||||
begin
|
||||
DriveToolbar.Buttons[i].Down := True;
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
// Path not found in toolbar.
|
||||
|
||||
DriveToolbar.UncheckAllButtons;
|
||||
DriveIndex := FindMatchingDrive(FileView.CurrentPath);
|
||||
if DriveIndex >= 0 then
|
||||
DriveToolbar.Buttons[DriveIndex].Down := True
|
||||
else
|
||||
// Path not found in toolbar.
|
||||
DriveToolbar.UncheckAllButtons;
|
||||
end;
|
||||
|
||||
procedure TfrmMain.UpdateDriveButtonSelection(DriveButton: TSpeedButton; FileView: TFileView);
|
||||
var
|
||||
i : Integer;
|
||||
BitmapTmp: Graphics.TBitmap = nil;
|
||||
DriveIndex: Integer;
|
||||
Drive: PDrive;
|
||||
Path: String;
|
||||
Found: Boolean = False;
|
||||
begin
|
||||
if not gDriveMenuButton then
|
||||
Exit;
|
||||
|
||||
Path := FileView.CurrentPath;
|
||||
|
||||
for i := 0 to FDrivesListPopup.DrivesCount - 1 do
|
||||
DriveIndex := FindMatchingDrive(FileView.CurrentPath);
|
||||
if DriveIndex >= 0 then
|
||||
begin
|
||||
Drive := DrivesList.Items[i];
|
||||
|
||||
if IsInPath(UTF8UpperCase(Drive^.Path), UTF8UpperCase(Path), True) then
|
||||
begin
|
||||
DriveButton.Caption := Drive^.DisplayName;
|
||||
DriveButton.Tag := i;
|
||||
|
||||
BitmapTmp := PixMapManager.GetDriveIcon(Drive, 22, DriveButton.Color);
|
||||
Found := True;
|
||||
Break;
|
||||
end;
|
||||
end;
|
||||
|
||||
// Path not found in menu.
|
||||
if not Found then
|
||||
Drive := DrivesList[DriveIndex];
|
||||
DriveButton.Caption := Drive^.DisplayName;
|
||||
DriveButton.Tag := DriveIndex;
|
||||
BitmapTmp := PixMapManager.GetDriveIcon(Drive, 22, DriveButton.Color);
|
||||
end
|
||||
else
|
||||
begin
|
||||
DriveButton.Caption := '';
|
||||
DriveButton.Tag := -1;
|
||||
|
|
|
|||
|
|
@ -613,7 +613,9 @@ begin
|
|||
if CheckMountEntry(pme) then
|
||||
begin
|
||||
DeviceFile := StrPas(pme^.mnt_fsname);
|
||||
MountPoint := ExcludeTrailingPathDelimiter(StrPas(pme^.mnt_dir));
|
||||
MountPoint := StrPas(pme^.mnt_dir);
|
||||
if MountPoint <> PathDelim then
|
||||
MountPoint := ExcludeTrailingPathDelimiter(MountPoint);
|
||||
|
||||
if HaveUDisksDevices then
|
||||
begin
|
||||
|
|
@ -649,7 +651,10 @@ begin
|
|||
begin
|
||||
UDisksDeviceToDrive(UDisksDevice, Drive);
|
||||
Drive^.Path := MountPoint;
|
||||
Drive^.DisplayName := ExtractFileName(Drive^.Path);
|
||||
if MountPoint <> PathDelim then
|
||||
Drive^.DisplayName := ExtractFileName(MountPoint)
|
||||
else
|
||||
Drive^.DisplayName := PathDelim;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
|
@ -663,7 +668,10 @@ begin
|
|||
begin
|
||||
DeviceId := DeviceFile;
|
||||
Path := MountPoint;
|
||||
DisplayName := ExtractFileName(Path);
|
||||
if MountPoint <> PathDelim then
|
||||
DisplayName := ExtractFileName(Path)
|
||||
else
|
||||
DisplayName := PathDelim;
|
||||
DriveLabel := Path;
|
||||
|
||||
if IsPartOfString(['ISO9660', 'CDROM', 'CDRW', 'DVD'], UpperCase(pme^.mnt_type)) then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue