mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
UPD: the Backward/Forward buttons can be enabled or disabled based on history
(cherry picked from commit d0d51b6474)
This commit is contained in:
parent
a76f871895
commit
99ae5e5725
3 changed files with 69 additions and 14 deletions
|
|
@ -518,7 +518,9 @@ type
|
|||
var DropParams: TDropParams); virtual abstract;
|
||||
|
||||
procedure GoToHistoryIndex(aFileSourceIndex, aPathIndex: Integer);
|
||||
function hasPrevHistory: Boolean;
|
||||
procedure GoToPrevHistory;
|
||||
function hasNextHistory: Boolean;
|
||||
procedure GoToNextHistory;
|
||||
|
||||
procedure SetDragCursor(Shift: TShiftState); virtual; abstract;
|
||||
|
|
@ -3589,6 +3591,15 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
function TFileView.hasPrevHistory: Boolean;
|
||||
begin
|
||||
Result:= False;
|
||||
if FHistory.CurrentPathIndex > 0 then
|
||||
Result:= True
|
||||
else if FHistory.CurrentFileSourceIndex > 0 then
|
||||
Result:= True;
|
||||
end;
|
||||
|
||||
procedure TFileView.GoToPrevHistory;
|
||||
var
|
||||
aFileSourceIndex, aPathIndex: Integer;
|
||||
|
|
@ -3609,6 +3620,17 @@ begin
|
|||
GoToHistoryIndex(aFileSourceIndex, aPathIndex);
|
||||
end;
|
||||
|
||||
function TFileView.hasNextHistory: Boolean;
|
||||
begin
|
||||
Result:= False;
|
||||
if FHistory.CurrentFileSourceIndex >= 0 then begin
|
||||
if FHistory.CurrentPathIndex < FHistory.PathsCount[FHistory.CurrentFileSourceIndex] - 1 then
|
||||
Result:= True
|
||||
else if FHistory.CurrentFileSourceIndex < FHistory.Count - 1 then
|
||||
Result:= True;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TFileView.GoToNextHistory;
|
||||
var
|
||||
aFileSourceIndex, aPathIndex: Integer;
|
||||
|
|
|
|||
|
|
@ -4822,6 +4822,9 @@ begin
|
|||
ANoteBook.Hint := FileView.CurrentPath;
|
||||
end;
|
||||
|
||||
if Assigned(onFileViewUpdated) then
|
||||
onFileViewUpdated(FileView);
|
||||
|
||||
{if (fspDirectAccess in FileView.FileSource.GetProperties) then
|
||||
begin
|
||||
if gTermWindow and Assigned(Cons) then
|
||||
|
|
|
|||
|
|
@ -55,21 +55,49 @@ begin
|
|||
end;
|
||||
|
||||
procedure onFileViewUpdated( const fileView: TFileView );
|
||||
var
|
||||
itemGroup: NSToolbarItemGroup;
|
||||
itemGroupWrapper: TCocoaToolBarItemGroupWrapper;
|
||||
begin
|
||||
itemGroup:= NSToolbarItemGroup( TCocoaToolBarUtils.findItemByIdentifier( frmMain, 'MainForm.ShowMode' ) );
|
||||
if NOT Assigned(itemGroup) then
|
||||
Exit;
|
||||
itemGroupWrapper:= TCocoaToolBarItemGroupWrapper( itemGroup.target );
|
||||
|
||||
if fileView is TColumnsFileView then
|
||||
itemGroupWrapper.lclSetSelectedIndex( 1 )
|
||||
else if fileView is TBriefFileView then
|
||||
itemGroupWrapper.lclSetSelectedIndex( 0 )
|
||||
else if fileView is TThumbFileView then
|
||||
itemGroupWrapper.lclSetSelectedIndex( 2 );
|
||||
procedure updateShowMode;
|
||||
var
|
||||
itemGroup: NSToolbarItemGroup;
|
||||
itemGroupWrapper: TCocoaToolBarItemGroupWrapper;
|
||||
begin
|
||||
itemGroup:= NSToolbarItemGroup( TCocoaToolBarUtils.findItemByIdentifier( frmMain, 'MainForm.ShowMode' ) );
|
||||
if NOT Assigned(itemGroup) then
|
||||
Exit;
|
||||
itemGroupWrapper:= TCocoaToolBarItemGroupWrapper( itemGroup.target );
|
||||
|
||||
if fileView is TColumnsFileView then
|
||||
itemGroupWrapper.lclSetSelectedIndex( 1 )
|
||||
else if fileView is TBriefFileView then
|
||||
itemGroupWrapper.lclSetSelectedIndex( 0 )
|
||||
else if fileView is TThumbFileView then
|
||||
itemGroupWrapper.lclSetSelectedIndex( 2 );
|
||||
end;
|
||||
|
||||
procedure updateBackward;
|
||||
var
|
||||
item: NSToolbarItem;
|
||||
begin
|
||||
item:= TCocoaToolBarUtils.findItemByIdentifier( frmMain, 'MainForm.GoBackward' );
|
||||
if NOT Assigned(item) then
|
||||
Exit;
|
||||
item.setEnabled( fileView.hasPrevHistory );
|
||||
end;
|
||||
|
||||
procedure updateForward;
|
||||
var
|
||||
item: NSToolbarItem;
|
||||
begin
|
||||
item:= TCocoaToolBarUtils.findItemByIdentifier( frmMain, 'MainForm.GoForward' );
|
||||
if NOT Assigned(item) then
|
||||
Exit;
|
||||
item.setEnabled( fileView.hasNextHistory );
|
||||
end;
|
||||
|
||||
begin
|
||||
updateShowMode;
|
||||
updateBackward;
|
||||
updateForward;
|
||||
end;
|
||||
|
||||
function onGetSharingItems( item: NSToolBarItem ): TStringArray;
|
||||
|
|
@ -452,6 +480,7 @@ const
|
|||
identifier: 'MainForm.GoBackward';
|
||||
priority: NSToolbarItemVisibilityPriorityStandard;
|
||||
navigational: False;
|
||||
appValidates: True;
|
||||
iconName: 'chevron.backward';
|
||||
title: rsMFSTBIGoBackwardTitle;
|
||||
tips: rsMFSTBIGoBackwardTips;
|
||||
|
|
@ -463,6 +492,7 @@ const
|
|||
identifier: 'MainForm.GoForward';
|
||||
priority: NSToolbarItemVisibilityPriorityStandard;
|
||||
navigational: False;
|
||||
appValidates: True;
|
||||
iconName: 'chevron.forward';
|
||||
title: rsMFSTBIGoForwardTitle;
|
||||
tips: rsMFSTBIGoForwardTips;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue