mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
UPD: the buttons can be auto enabled/disabled in Differ Form native ToolBar on macOS
This commit is contained in:
parent
fcba5ce8ee
commit
931f24fcdb
2 changed files with 67 additions and 1 deletions
|
|
@ -37,6 +37,10 @@ type
|
|||
|
||||
TStatusBar = class(TKASStatusBar);
|
||||
|
||||
{ state update notify }
|
||||
|
||||
TDifferFormOnUpdateHandler = procedure ( const form: TCustomForm );
|
||||
|
||||
{ TfrmDiffer }
|
||||
|
||||
TfrmDiffer = class(TAloneForm, IFormCommands)
|
||||
|
|
@ -239,7 +243,8 @@ type
|
|||
FCommands: TFormCommands;
|
||||
FLeftLen, FRightLen: Integer;
|
||||
FSearchOptions: TEditSearchOptions;
|
||||
private
|
||||
FOnUpdate: TDifferFormOnUpdateHandler;
|
||||
private
|
||||
procedure ShowDialog;
|
||||
procedure ShowIdentical;
|
||||
procedure ShowTextIdentical;
|
||||
|
|
@ -262,6 +267,7 @@ private
|
|||
procedure ShowFirstDifference(Data: PtrInt);
|
||||
procedure SynDiffEditLeftStatusChange(Sender: TObject; Changes: TSynStatusChanges);
|
||||
procedure SynDiffEditRightStatusChange(Sender: TObject; Changes: TSynStatusChanges);
|
||||
procedure DoOnUpdate;
|
||||
|
||||
property Commands: TFormCommands read FCommands implements IFormCommands;
|
||||
protected
|
||||
|
|
@ -270,6 +276,8 @@ private
|
|||
constructor Create(TheOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
procedure AfterConstruction; override;
|
||||
|
||||
property OnUpdate: TDifferFormOnUpdateHandler write FOnUpdate;
|
||||
published
|
||||
procedure cm_CopyLeftToRight(const Params: array of string);
|
||||
procedure cm_CopyRightToLeft(const Params: array of string);
|
||||
|
|
@ -376,6 +384,7 @@ begin
|
|||
|
||||
BinaryCompare.OnFinish:= @BinaryCompareFinish;
|
||||
BinaryCompare.Start;
|
||||
DoOnUpdate;
|
||||
end;
|
||||
end
|
||||
else begin
|
||||
|
|
@ -394,6 +403,7 @@ begin
|
|||
|
||||
actStartCompare.Enabled := False;
|
||||
actCancelCompare.Enabled := True;
|
||||
DoOnUpdate;
|
||||
|
||||
Diff.Execute(
|
||||
PInteger(@HashListLeft[0]),
|
||||
|
|
@ -438,6 +448,7 @@ begin
|
|||
actCancelCompare.Enabled := False;
|
||||
Screen.EndWaitCursor;
|
||||
Dec(ScrollLock);
|
||||
DoOnUpdate;
|
||||
end;
|
||||
if actLineDifferences.Checked then
|
||||
begin
|
||||
|
|
@ -636,6 +647,7 @@ begin
|
|||
BinaryCompare:= nil;
|
||||
end;
|
||||
end;
|
||||
DoOnUpdate;
|
||||
end;
|
||||
|
||||
procedure TfrmDiffer.actAboutExecute(Sender: TObject);
|
||||
|
|
@ -878,6 +890,7 @@ begin
|
|||
actStartCompare.Enabled := True;
|
||||
actCancelCompare.Enabled := False;
|
||||
actBinaryCompare.Enabled := True;
|
||||
DoOnUpdate;
|
||||
if FShowIdentical then
|
||||
begin
|
||||
CloseProgressDialog;
|
||||
|
|
@ -1725,6 +1738,12 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
procedure TfrmDiffer.doOnUpdate;
|
||||
begin
|
||||
if FOnUpdate <> nil then
|
||||
FOnUpdate(self);
|
||||
end;
|
||||
|
||||
procedure TfrmDiffer.CMThemeChanged(var Message: TLMessage);
|
||||
begin
|
||||
with gColors.Differ^ do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,38 @@
|
|||
procedure differFormOnUpdate( const form: TCustomForm );
|
||||
var
|
||||
differForm: TfrmDiffer absolute form;
|
||||
item: NSToolbarItem;
|
||||
isText: Boolean;
|
||||
begin
|
||||
item:= TCocoaToolBarUtils.findItemByIdentifier( form, 'DifferForm.Compare' );
|
||||
item.setEnabled( differForm.actStartCompare.Enabled );
|
||||
item:= TCocoaToolBarUtils.findItemByIdentifier( form, 'DifferForm.Cancel' );
|
||||
item.setEnabled( differForm.actCancelCompare.Enabled );
|
||||
|
||||
isText:= NOT differForm.actBinaryCompare.Checked;
|
||||
item:= TCocoaToolBarUtils.findItemByIdentifier( form, 'DifferForm.Save' );
|
||||
item.setEnabled( isText );
|
||||
item:= TCocoaToolBarUtils.findItemByIdentifier( form, 'DifferForm.SaveAs' );
|
||||
item.setEnabled( isText );
|
||||
item:= TCocoaToolBarUtils.findItemByIdentifier( form, 'DifferForm.NextDifference' );
|
||||
item.setEnabled( isText );
|
||||
item:= TCocoaToolBarUtils.findItemByIdentifier( form, 'DifferForm.PrevDifference' );
|
||||
item.setEnabled( isText );
|
||||
item:= TCocoaToolBarUtils.findItemByIdentifier( form, 'DifferForm.LastDifference' );
|
||||
item.setEnabled( isText );
|
||||
item:= TCocoaToolBarUtils.findItemByIdentifier( form, 'DifferForm.FirstDifference' );
|
||||
item.setEnabled( isText );
|
||||
item:= TCocoaToolBarUtils.findItemByIdentifier( form, 'DifferForm.CopyRightToLeft' );
|
||||
item.setEnabled( isText );
|
||||
item:= TCocoaToolBarUtils.findItemByIdentifier( form, 'DifferForm.CopyLeftToRight' );
|
||||
item.setEnabled( isText );
|
||||
end;
|
||||
|
||||
procedure differFormOnCreate( const form: TCustomForm );
|
||||
begin
|
||||
TfrmDiffer(form).OnUpdate:= @differFormOnUpdate;
|
||||
end;
|
||||
|
||||
function getCurrentDifferForm: TfrmDiffer;
|
||||
var
|
||||
form: TCustomForm;
|
||||
|
|
@ -123,6 +158,7 @@ const
|
|||
identifier: 'DifferForm.Save';
|
||||
priority: NSToolbarItemVisibilityPriorityStandard;
|
||||
navigational: False;
|
||||
appValidates: True;
|
||||
iconName: 'square.and.arrow.down';
|
||||
title: 'Save';
|
||||
tips: 'Save';
|
||||
|
|
@ -134,6 +170,7 @@ const
|
|||
identifier: 'DifferForm.SaveAs';
|
||||
priority: NSToolbarItemVisibilityPriorityStandard;
|
||||
navigational: False;
|
||||
appValidates: True;
|
||||
iconName: 'square.and.arrow.down.on.square';
|
||||
title: 'Save as';
|
||||
tips: 'Save as...';
|
||||
|
|
@ -145,6 +182,7 @@ const
|
|||
identifier: 'DifferForm.Compare';
|
||||
priority: NSToolbarItemVisibilityPriorityStandard;
|
||||
navigational: False;
|
||||
appValidates: True;
|
||||
iconName: 'play.fill';
|
||||
title: 'Compare';
|
||||
tips: 'Compare';
|
||||
|
|
@ -156,6 +194,7 @@ const
|
|||
identifier: 'DifferForm.Cancel';
|
||||
priority: NSToolbarItemVisibilityPriorityStandard;
|
||||
navigational: False;
|
||||
appValidates: True;
|
||||
iconName: 'stop.circle.fill';
|
||||
title: 'Cancel';
|
||||
tips: 'Cancel';
|
||||
|
|
@ -167,6 +206,7 @@ const
|
|||
identifier: 'DifferForm.NextDifference';
|
||||
priority: NSToolbarItemVisibilityPriorityStandard;
|
||||
navigational: False;
|
||||
appValidates: True;
|
||||
iconName: 'arrow.down';
|
||||
title: 'Next Difference';
|
||||
tips: 'Next Difference';
|
||||
|
|
@ -178,6 +218,7 @@ const
|
|||
identifier: 'DifferForm.PrevDifference';
|
||||
priority: NSToolbarItemVisibilityPriorityStandard;
|
||||
navigational: False;
|
||||
appValidates: True;
|
||||
iconName: 'arrow.up';
|
||||
title: 'Previous Difference';
|
||||
tips: 'Previous Difference';
|
||||
|
|
@ -189,6 +230,7 @@ const
|
|||
identifier: 'DifferForm.LastDifference';
|
||||
priority: NSToolbarItemVisibilityPriorityStandard;
|
||||
navigational: False;
|
||||
appValidates: True;
|
||||
iconName: 'arrow.down.to.line';
|
||||
title: 'Last Difference';
|
||||
tips: 'Last Difference';
|
||||
|
|
@ -200,6 +242,7 @@ const
|
|||
identifier: 'DifferForm.FirstDifference';
|
||||
priority: NSToolbarItemVisibilityPriorityStandard;
|
||||
navigational: False;
|
||||
appValidates: True;
|
||||
iconName: 'arrow.up.to.line';
|
||||
title: 'First Difference';
|
||||
tips: 'First Difference';
|
||||
|
|
@ -211,6 +254,7 @@ const
|
|||
identifier: 'DifferForm.CopyRightToLeft';
|
||||
priority: NSToolbarItemVisibilityPriorityStandard;
|
||||
navigational: False;
|
||||
appValidates: True;
|
||||
iconName: 'arrowshape.turn.up.left';
|
||||
title: 'Copy Block Left';
|
||||
tips: 'Copy Block Left';
|
||||
|
|
@ -222,6 +266,7 @@ const
|
|||
identifier: 'DifferForm.CopyLeftToRight';
|
||||
priority: NSToolbarItemVisibilityPriorityStandard;
|
||||
navigational: False;
|
||||
appValidates: True;
|
||||
iconName: 'arrowshape.turn.up.right';
|
||||
title: 'Copy Block Right';
|
||||
tips: 'Copy Block Right';
|
||||
|
|
@ -281,6 +326,8 @@ const
|
|||
);
|
||||
itemCreator: nil; // default item Creator
|
||||
);
|
||||
|
||||
onCreate: @differFormOnCreate;
|
||||
);
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue