ADD: Synchronize directories - additional context menu actions

This commit is contained in:
Alexander Koblov 2018-03-10 18:48:09 +00:00
commit 1264aea66f
2 changed files with 198 additions and 60 deletions

View file

@ -14,15 +14,15 @@ object frmSyncDirsDlg: TfrmSyncDirsDlg
Position = poScreenCenter
SessionProperties = 'Height;Left;Top;Width;WindowState'
ShowInTaskBar = stAlways
LCLVersion = '1.6.0.4'
LCLVersion = '1.9.0.0'
object edPath1: TEdit
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = btnSelDir1
Left = 3
Height = 27
Height = 23
Top = 3
Width = 254
Width = 252
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 3
TabOrder = 1
@ -33,9 +33,9 @@ object frmSyncDirsDlg: TfrmSyncDirsDlg
AnchorSideTop.Control = Owner
AnchorSideRight.Control = btnSelDir2
Left = 407
Height = 27
Height = 23
Top = 3
Width = 251
Width = 249
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 3
BorderSpacing.Around = 3
@ -46,11 +46,11 @@ object frmSyncDirsDlg: TfrmSyncDirsDlg
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Owner
Left = 290
Height = 27
Height = 23
Top = 3
Width = 111
BorderSpacing.Top = 3
ItemHeight = 0
ItemHeight = 17
ItemIndex = 0
Items.Strings = (
'*.*'
@ -62,10 +62,10 @@ object frmSyncDirsDlg: TfrmSyncDirsDlg
AnchorSideTop.Control = edPath1
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = cbExtFilter
Left = 260
Height = 27
Top = 3
Width = 24
Left = 258
Height = 29
Top = 0
Width = 26
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Right = 3
@ -80,10 +80,10 @@ object frmSyncDirsDlg: TfrmSyncDirsDlg
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 661
Height = 27
Top = 3
Width = 24
Left = 659
Height = 29
Top = 0
Width = 26
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Right = 3
@ -99,33 +99,33 @@ object frmSyncDirsDlg: TfrmSyncDirsDlg
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 86
Top = 33
Height = 90
Top = 32
Width = 691
Anchors = [akTop, akLeft, akRight]
AutoSize = True
ClientHeight = 86
ClientHeight = 90
ClientWidth = 691
TabOrder = 5
object LeftPanel1: TPanel
AnchorSideLeft.Control = TopPanel
AnchorSideTop.Control = TopPanel
Left = 1
Height = 74
Height = 77
Top = 1
Width = 107
Width = 106
AutoSize = True
BevelOuter = bvNone
ClientHeight = 74
ClientWidth = 107
ClientHeight = 77
ClientWidth = 106
TabOrder = 0
object btnCompare: TButton
AnchorSideLeft.Control = LeftPanel1
AnchorSideTop.Control = LeftPanel1
Left = 3
Height = 27
Height = 29
Top = 3
Width = 65
Width = 64
AutoSize = True
BorderSpacing.Around = 3
Caption = 'Compare'
@ -138,9 +138,9 @@ object frmSyncDirsDlg: TfrmSyncDirsDlg
AnchorSideTop.Control = btnCompare
AnchorSideTop.Side = asrBottom
Left = 3
Height = 21
Top = 33
Width = 101
Height = 22
Top = 35
Width = 100
BorderSpacing.Around = 3
Caption = 'only selected'
Enabled = False
@ -152,10 +152,10 @@ object frmSyncDirsDlg: TfrmSyncDirsDlg
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = chkOnlySelected
AnchorSideTop.Side = asrBottom
Left = 2
Left = 3
Height = 17
Top = 57
Width = 102
Top = 60
Width = 100
Caption = '(in main window)'
Enabled = False
ParentColor = False
@ -166,23 +166,23 @@ object frmSyncDirsDlg: TfrmSyncDirsDlg
AnchorSideLeft.Control = LeftPanel1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = TopPanel
Left = 113
Height = 84
Left = 112
Height = 88
Top = 1
Width = 93
Width = 92
AutoSize = True
BorderSpacing.Left = 5
BevelOuter = bvNone
ClientHeight = 84
ClientWidth = 93
ClientHeight = 88
ClientWidth = 92
TabOrder = 1
object chkAsymmetric: TCheckBox
AnchorSideLeft.Control = LeftPanel2
AnchorSideTop.Control = LeftPanel2
Left = 0
Height = 21
Height = 22
Top = 0
Width = 93
Width = 92
Caption = 'asymmetric'
Enabled = False
TabOrder = 0
@ -192,8 +192,8 @@ object frmSyncDirsDlg: TfrmSyncDirsDlg
AnchorSideTop.Control = chkAsymmetric
AnchorSideTop.Side = asrBottom
Left = 0
Height = 21
Top = 21
Height = 22
Top = 22
Width = 68
Caption = 'Subdirs'
TabOrder = 1
@ -203,9 +203,9 @@ object frmSyncDirsDlg: TfrmSyncDirsDlg
AnchorSideTop.Control = chkSubDirs
AnchorSideTop.Side = asrBottom
Left = 0
Height = 21
Top = 42
Width = 88
Height = 22
Top = 44
Width = 87
Caption = 'by content'
TabOrder = 2
end
@ -214,8 +214,8 @@ object frmSyncDirsDlg: TfrmSyncDirsDlg
AnchorSideTop.Control = chkByContent
AnchorSideTop.Side = asrBottom
Left = 0
Height = 21
Top = 63
Height = 22
Top = 66
Width = 91
Caption = 'ignore date'
TabOrder = 3
@ -225,8 +225,8 @@ object frmSyncDirsDlg: TfrmSyncDirsDlg
AnchorSideLeft.Control = LeftPanel2
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = TopPanel
Left = 211
Height = 64
Left = 209
Height = 66
Top = 1
Width = 202
AutoSize = True
@ -335,7 +335,7 @@ object frmSyncDirsDlg: TfrmSyncDirsDlg
AnchorSideRight.Control = TopPanel
AnchorSideRight.Side = asrBottom
Left = 601
Height = 27
Height = 29
Top = 7
Width = 83
Anchors = [akTop, akRight]
@ -353,8 +353,8 @@ object frmSyncDirsDlg: TfrmSyncDirsDlg
AnchorSideRight.Control = btnSynchronize
AnchorSideRight.Side = asrBottom
Left = 601
Height = 27
Top = 40
Height = 29
Top = 42
Width = 83
Anchors = [akTop, akLeft, akRight]
AutoSize = True
@ -366,8 +366,8 @@ object frmSyncDirsDlg: TfrmSyncDirsDlg
end
object StatusBar1: TStatusBar
Left = 0
Height = 21
Top = 417
Height = 22
Top = 416
Width = 691
Panels = <
item
@ -384,7 +384,7 @@ object frmSyncDirsDlg: TfrmSyncDirsDlg
AnchorSideRight.Side = asrBottom
Left = 0
Height = 20
Top = 119
Top = 122
Width = 691
Anchors = [akTop, akLeft, akRight]
AutoFillColumns = True
@ -451,8 +451,8 @@ object frmSyncDirsDlg: TfrmSyncDirsDlg
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = StatusBar1
Left = 0
Height = 278
Top = 139
Height = 274
Top = 142
Width = 691
Anchors = [akTop, akLeft, akRight, akBottom]
AutoFillColumns = True
@ -704,6 +704,21 @@ object frmSyncDirsDlg: TfrmSyncDirsDlg
object pmGridMenu: TPopupMenu
left = 121
top = 217
object miSelectCopyDefault: TMenuItem
Action = actSelectCopyDefault
end
object miSelectClear: TMenuItem
Action = actSelectClear
end
object miSelectCopyLeftToRight: TMenuItem
Action = actSelectCopyLeftToRight
end
object miSelectCopyRightToLeft: TMenuItem
Action = actSelectCopyRightToLeft
end
object miSeparator1: TMenuItem
Caption = '-'
end
object MenuItemViewLeft: TMenuItem
Caption = 'View left'
ShortCut = 114
@ -720,4 +735,24 @@ object frmSyncDirsDlg: TfrmSyncDirsDlg
OnClick = MainDrawGridDblClick
end
end
object ActionList: TActionList
left = 376
top = 208
object actSelectCopyLeftToRight: TAction
Caption = 'Select for copying -> (left to right)'
OnExecute = actExecute
end
object actSelectCopyRightToLeft: TAction
Caption = 'Select for copying <- (right to left)'
OnExecute = actExecute
end
object actSelectCopyDefault: TAction
Caption = 'Select for copying (default direction)'
OnExecute = actExecute
end
object actSelectClear: TAction
Caption = 'Remove selection'
OnExecute = actExecute
end
end
end

View file

@ -4,7 +4,7 @@
Directories synchronization utility (specially for DC)
Copyright (C) 2013 Anton Panferov (ast.a_s@mail.ru)
Copyright (C) 2014-2016 Alexander Koblov (alexx2000@mail.ru)
Copyright (C) 2014-2018 Alexander Koblov (alexx2000@mail.ru)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -30,8 +30,9 @@ interface
uses
Classes, SysUtils, FileUtil, Masks, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls, Buttons, ComCtrls, Grids, Menus, uFileView, uFileSource,
uFileSourceCopyOperation, uFile, uFileSourceOperationMessageBoxesUI;
StdCtrls, ExtCtrls, Buttons, ComCtrls, Grids, Menus, ActnList, uFileView,
uFileSource, uFileSourceCopyOperation, uFile,
uFileSourceOperationMessageBoxesUI, uFormCommands, uHotkeyManager;
type
@ -40,7 +41,12 @@ type
{ TfrmSyncDirsDlg }
TfrmSyncDirsDlg = class(TForm)
TfrmSyncDirsDlg = class(TForm, IFormCommands)
actSelectClear: TAction;
actSelectCopyLeftToRight: TAction;
actSelectCopyRightToLeft: TAction;
actSelectCopyDefault: TAction;
ActionList: TActionList;
btnSelDir1: TButton;
btnSelDir2: TButton;
btnCompare: TButton;
@ -61,6 +67,11 @@ type
Label1: TLabel;
LeftPanel1: TPanel;
LeftPanel2: TPanel;
miSeparator1: TMenuItem;
miSelectCopyLeftToRight: TMenuItem;
miSelectCopyRightToLeft: TMenuItem;
miSelectCopyDefault: TMenuItem;
miSelectClear: TMenuItem;
MenuItemCompare: TMenuItem;
MenuItemViewRight: TMenuItem;
MenuItemViewLeft: TMenuItem;
@ -73,6 +84,7 @@ type
sbSingles: TSpeedButton;
StatusBar1: TStatusBar;
TopPanel: TPanel;
procedure actExecute(Sender: TObject);
procedure btnCloseClick(Sender: TObject);
procedure btnSelDir1Click(Sender: TObject);
procedure btnCompareClick(Sender: TObject);
@ -92,6 +104,8 @@ type
const aIndex, aSize: Integer);
procedure FilterSpeedButtonClick(Sender: TObject);
procedure MenuItemViewClick(Sender: TObject);
private
FCommands: TFormCommands;
private
{ private declarations }
FCancel: Boolean;
@ -120,12 +134,19 @@ type
procedure SortFoundItems(sl: TStringList);
procedure UpdateStatusBar;
procedure StopCheckContentThread;
procedure SetSyncRecState(AState: TSyncRecState);
property SortIndex: Integer read FSortIndex write SetSortIndex;
property Commands: TFormCommands read FCommands implements IFormCommands;
public
{ public declarations }
constructor Create(AOwner: TComponent;
FileView1, FileView2: TFileView); reintroduce;
destructor Destroy; override;
published
procedure cm_SelectClear(const {%H-}Params:array of string);
procedure cm_SelectCopyDefault(const {%H-}Params:array of string);
procedure cm_SelectCopyLeftToRight(const {%H-}Params:array of string);
procedure cm_SelectCopyRightToLeft(const {%H-}Params:array of string);
end;
resourcestring
@ -327,6 +348,15 @@ end;
{ TfrmSyncDirsDlg }
procedure TfrmSyncDirsDlg.actExecute(Sender: TObject);
var
cmd: string;
begin
cmd := (Sender as TAction).Name;
cmd := 'cm_' + Copy(cmd, 4, Length(cmd) - 3);
Commands.ExecuteCommand(cmd, []);
end;
procedure TfrmSyncDirsDlg.btnCloseClick(Sender: TObject);
begin
Close
@ -616,6 +646,8 @@ begin
sbSingles.Down := gSyncDirsShowFilterSingles;
cbExtFilter.Items.Assign(glsMaskHistory);
cbExtFilter.Text := gSyncDirsFileMask;
FCommands := TFormCommands.Create(Self, ActionList);
end;
procedure TfrmSyncDirsDlg.MainDrawGridDblClick(Sender: TObject);
@ -698,8 +730,14 @@ var
ca: TSyncRecState;
begin
MainDrawGrid.MouseToCell(X, Y, c, r);
if (r < 0) or (r >= FVisibleItems.Count)
or (x - 2 < hCols[3].Left)
if (r < 0) or (r >= FVisibleItems.Count) then
Exit;
if Button = mbRight then
begin
MainDrawGrid.Row:= r;
Exit;
end;
if (x - 2 < hCols[3].Left)
or (x - 2 > hCols[3].Left + hCols[3].Width)
then
Exit;
@ -1234,6 +1272,51 @@ begin
end;
end;
procedure TfrmSyncDirsDlg.SetSyncRecState(AState: TSyncRecState);
var
R: Integer;
SyncRec: TFileSyncRec;
procedure UpdateAction(NewAction: TSyncRecState);
begin
case NewAction of
srsUnknown:
NewAction:= SyncRec.FState;
srsCopyLeft:
begin
if not Assigned(SyncRec.FFileR) then
NewAction:= srsDoNothing;
end;
srsCopyRight:
begin
if not Assigned(SyncRec.FFileL) then
NewAction:= srsDoNothing;
end;
end;
SyncRec.FAction:= NewAction;
MainDrawGrid.InvalidateRow(R);
end;
begin
R := MainDrawGrid.Row;
if (R < 0) or (R >= FVisibleItems.Count) then Exit;
SyncRec := TFileSyncRec(FVisibleItems.Objects[r]);
if Assigned(SyncRec) then
begin
UpdateAction(AState);
end
else begin
Inc(R);
while R < FVisibleItems.Count do
begin
SyncRec := TFileSyncRec(FVisibleItems.Objects[R]);
if (SyncRec = nil) then Break;
UpdateAction(AState);
Inc(R);
end;
end;
end;
constructor TfrmSyncDirsDlg.Create(AOwner: TComponent; FileView1,
FileView2: TFileView);
begin
@ -1273,5 +1356,25 @@ begin
inherited Destroy;
end;
procedure TfrmSyncDirsDlg.cm_SelectClear(const Params: array of string);
begin
SetSyncRecState(srsDoNothing);
end;
procedure TfrmSyncDirsDlg.cm_SelectCopyDefault(const Params: array of string);
begin
SetSyncRecState(srsUnknown);
end;
procedure TfrmSyncDirsDlg.cm_SelectCopyLeftToRight(const Params: array of string);
begin
SetSyncRecState(srsCopyRight);
end;
procedure TfrmSyncDirsDlg.cm_SelectCopyRightToLeft(const Params: array of string);
begin
SetSyncRecState(srsCopyLeft);
end;
end.