Visitar URL original
ADD #3139: implement "Advanced..." to "Change Attributes" Dialog · doublecmd/doublecmd@4e5a81a · GitHub
Skip to content

Commit 4e5a81a

Browse files
committed
ADD #3139: implement "Advanced..." to "Change Attributes" Dialog
1 parent b8e1ed9 commit 4e5a81a

6 files changed

Lines changed: 285 additions & 49 deletions

‎src/fsetfileproperties.lfm‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,7 @@ object frmSetFileProperties: TfrmSetFileProperties
823823
BorderSpacing.Right = 2
824824
Caption = 'Advanced(&0)...'
825825
TabOrder = 3
826+
OnClick = btnLoadAdvClick
826827
end
827828
end
828829
end

‎src/fsetfileproperties.pas‎

Lines changed: 118 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ interface
2929
uses
3030
Classes, SysUtils, Forms, Controls, ExtCtrls, StdCtrls, Buttons,
3131
uFile, uFileProperty, uFileSourceSetFilePropertyOperation, uFileView,
32-
DCBasicTypes, DateTimePicker;
32+
DCBasicTypes, DCOSUtils, DateTimePicker;
3333

3434
type
3535

@@ -90,6 +90,7 @@ TfrmSetFileProperties = class(TForm)
9090
procedure btnCreationTimeClick(Sender: TObject);
9191
procedure btnLastAccessTimeClick(Sender: TObject);
9292
procedure btnLastWriteTimeClick(Sender: TObject);
93+
procedure btnLoadAdvClick(Sender: TObject);
9394
procedure btnLoadFromClipboardClick(Sender: TObject);
9495
procedure btnLoadFromSourceClick(Sender: TObject);
9596
procedure btnLoadFromTargetClick(Sender: TObject);
@@ -111,6 +112,7 @@ TfrmSetFileProperties = class(TForm)
111112
procedure ZVLastAccessDateTimeClick(Sender: TObject);
112113
private
113114
FOperation: TFileSourceSetFilePropertyOperation;
115+
FSetAttributesOptions: TCopyAttributesOptions;
114116
FSourceFrame: TFileView;
115117
FTargetFrame: TFileView;
116118
FChangeTriggersEnabled: Boolean;
@@ -143,7 +145,8 @@ implementation
143145
uses
144146
LCLType, ImgList, EditBtn,
145147
uFileSource, uFileSystemFileSource, uFileSourceManager,
146-
DCFileAttributes, DCStrUtils, uDCUtils, uKeyboard, uClipboard;
148+
DCFileAttributes, DCStrUtils, uDCUtils, uKeyboard, uClipboard,
149+
fSetFilePropertiesAdvLoad;
147150

148151
function ShowChangeFilePropertiesDialog(
149152
const aOperation: TFileSourceSetFilePropertyOperation;
@@ -398,52 +401,62 @@ function TfrmSetFileProperties.GetAttrFromForm(out ExcludeAttrs: TFileAttrs): TF
398401
end;
399402

400403
procedure TfrmSetFileProperties.LoadProperties(const checked: Boolean);
401-
begin
402-
// Enable only supported file properties
403-
with FOperation do
404+
procedure loadAttributes;
404405
begin
405-
if fpAttributes in SupportedProperties then
406-
begin
407-
UpdateAllowGrayed((TargetFiles.Count > 1) or TargetFiles[0].IsDirectory);
408-
if NewProperties[fpAttributes] is TNtfsFileAttributesProperty then
409-
begin
410-
if TargetFiles.Count = 1 then
411-
ShowAttr((NewProperties[fpAttributes] as TNtfsFileAttributesProperty).Value);
412-
gbWinAttributes.Show;
413-
end;
414-
if NewProperties[fpAttributes] is TUnixFileAttributesProperty then
415-
begin
416-
if TargetFiles.Count = 1 then
417-
ShowMode((NewProperties[fpAttributes] as TUnixFileAttributesProperty).Value);
418-
gbUnixAttributes.Show;
419-
end;
420-
end;
421-
if (fpCreationTime in SupportedProperties) and Assigned(NewProperties[fpCreationTime]) then
422-
begin
423-
ZVCreationDateTime.DateTime:= (NewProperties[fpCreationTime] as TFileCreationDateTimeProperty).Value;
424-
ZVCreationDateTime.Enabled:= True;
425-
chkCreationTime.Enabled:= True;
426-
btnCreationTime.Enabled:= True;
427-
end;
428-
if (fpModificationTime in SupportedProperties) and Assigned(NewProperties[fpModificationTime]) then
429-
begin
430-
ZVLastWriteDateTime.DateTime:= (NewProperties[fpModificationTime] as TFileModificationDateTimeProperty).Value;
431-
ZVLastWriteDateTime.Enabled:= True;
432-
chkLastWriteTime.Enabled:= True;
433-
btnLastWriteTime.Enabled:= True;
434-
end;
435-
if (fpLastAccessTime in SupportedProperties) and Assigned(NewProperties[fpLastAccessTime]) then
436-
begin
437-
ZVLastAccessDateTime.DateTime:= (NewProperties[fpLastAccessTime] as TFileLastAccessDateTimeProperty).Value;
438-
ZVLastAccessDateTime.Enabled:= True;
439-
chkLastAccessTime.Enabled:= True;
440-
btnLastAccessTime.Enabled:= True;
441-
end;
406+
if NOT (fpAttributes in FOperation.SupportedProperties) then
407+
Exit;
408+
UpdateAllowGrayed((FOperation.TargetFiles.Count > 1) or FOperation.TargetFiles[0].IsDirectory);
409+
if FOperation.NewProperties[fpAttributes] is TNtfsFileAttributesProperty then
410+
begin
411+
if FOperation.TargetFiles.Count = 1 then
412+
ShowAttr((FOperation.NewProperties[fpAttributes] as TNtfsFileAttributesProperty).Value);
413+
gbWinAttributes.Show;
414+
end;
415+
if FOperation.NewProperties[fpAttributes] is TUnixFileAttributesProperty then
416+
begin
417+
if FOperation.TargetFiles.Count = 1 then
418+
ShowMode((FOperation.NewProperties[fpAttributes] as TUnixFileAttributesProperty).Value);
419+
gbUnixAttributes.Show;
420+
end;
421+
end;
422+
423+
procedure loadDateTime;
424+
begin
425+
if (fpCreationTime in FOperation.SupportedProperties) and Assigned(FOperation.NewProperties[fpCreationTime]) then
426+
begin
427+
ZVCreationDateTime.DateTime:= (FOperation.NewProperties[fpCreationTime] as TFileCreationDateTimeProperty).Value;
428+
ZVCreationDateTime.Enabled:= True;
429+
chkCreationTime.Enabled:= True;
430+
btnCreationTime.Enabled:= True;
431+
end;
432+
if (fpModificationTime in FOperation.SupportedProperties) and Assigned(FOperation.NewProperties[fpModificationTime]) then
433+
begin
434+
ZVLastWriteDateTime.DateTime:= (FOperation.NewProperties[fpModificationTime] as TFileModificationDateTimeProperty).Value;
435+
ZVLastWriteDateTime.Enabled:= True;
436+
chkLastWriteTime.Enabled:= True;
437+
btnLastWriteTime.Enabled:= True;
438+
end;
439+
if (fpLastAccessTime in FOperation.SupportedProperties) and Assigned(FOperation.NewProperties[fpLastAccessTime]) then
440+
begin
441+
ZVLastAccessDateTime.DateTime:= (FOperation.NewProperties[fpLastAccessTime] as TFileLastAccessDateTimeProperty).Value;
442+
ZVLastAccessDateTime.Enabled:= True;
443+
chkLastAccessTime.Enabled:= True;
444+
btnLastAccessTime.Enabled:= True;
445+
end;
442446
end;
443447

444-
chkCreationTime.Checked:= checked;
445-
chkLastWriteTime.Checked:= checked;
446-
chkLastAccessTime.Checked:= checked;
448+
begin
449+
if caoCopyAttributes in FSetAttributesOptions then
450+
loadAttributes;
451+
452+
if caoCopyTime in FSetAttributesOptions then
453+
loadDateTime;
454+
455+
if (checked=False) or (caoCopyTime in FSetAttributesOptions) then begin
456+
chkCreationTime.Checked:= checked;
457+
chkLastWriteTime.Checked:= checked;
458+
chkLastAccessTime.Checked:= checked;
459+
end;
447460
end;
448461

449462
function TfrmSetFileProperties.CreateNewProperties(const f: TFile): TFileProperties;
@@ -470,6 +483,7 @@ constructor TfrmSetFileProperties.Create(
470483
begin
471484
inherited Create(aOwner);
472485
FOperation:= aOperation;
486+
FSetAttributesOptions:= [caoCopyTime, caoCopyAttributes];
473487
FSourceFrame:= aSourceFrame;
474488
FTargetFrame:= aTargetFrame;
475489
FChangeTriggersEnabled:= True;
@@ -493,18 +507,73 @@ procedure TfrmSetFileProperties.btnLastWriteTimeClick(Sender: TObject);
493507
if ssCtrl in GetKeyShiftStateEx then SetOtherDateLikeThis(ZVLastWriteDateTime);
494508
end;
495509

510+
procedure TfrmSetFileProperties.btnLoadAdvClick(Sender: TObject);
511+
var
512+
dialog: TfrmSetFilePropertiesAdvLoad;
513+
ret: Integer;
514+
515+
procedure initDialog;
516+
var
517+
filename: String;
518+
begin
519+
filename:= FSourceFrame.GetActiveFileName;
520+
if filename <> EmptyStr then
521+
dialog.rgLoadFrom.Items[0]:= dialog.rgLoadFrom.Items[0] + ': ' + filename
522+
else
523+
dialog.rgLoadFrom.Buttons[0].Enabled:= False;
524+
525+
filename:= FTargetFrame.GetActiveFileName;
526+
if filename <> EmptyStr then
527+
dialog.rgLoadFrom.Items[1]:= dialog.rgLoadFrom.Items[1] + ': ' + filename
528+
else
529+
dialog.rgLoadFrom.Buttons[1].Enabled:= False;
530+
531+
filename:= GetFirstFilenameInClipboard;
532+
if filename <> EmptyStr then
533+
dialog.rgLoadFrom.Items[2]:= dialog.rgLoadFrom.Items[2] + ': ' + filename
534+
else
535+
dialog.rgLoadFrom.Buttons[2].Enabled:= False;
536+
537+
dialog.frmProperties.chkTime.Checked:= caoCopyTime in FSetAttributesOptions;
538+
dialog.frmProperties.chkAttributes.Checked:= caoCopyAttributes in FSetAttributesOptions
539+
end;
540+
541+
procedure doAdvancedAction;
542+
begin
543+
FSetAttributesOptions:= [];
544+
if dialog.frmProperties.chkTime.Checked then
545+
Include(FSetAttributesOptions, caoCopyTime);
546+
if dialog.frmProperties.chkAttributes.Checked then
547+
Include(FSetAttributesOptions, caoCopyAttributes);
548+
549+
case dialog.rgLoadFrom.ItemIndex of
550+
0: self.btnLoadFromSourceClick(nil);
551+
1: self.btnLoadFromTargetClick(nil);
552+
2: self.btnLoadFromClipboardClick(nil);
553+
end;
554+
end;
555+
556+
begin
557+
dialog:= TfrmSetFilePropertiesAdvLoad.Create(nil);
558+
initDialog;
559+
ret:= dialog.ShowModal;
560+
if ret = mrOK then
561+
doAdvancedAction;
562+
dialog.Free;
563+
end;
564+
496565
procedure TfrmSetFileProperties.btnLoadFromClipboardClick(Sender: TObject);
497566
var
498-
ClipboardOp: TClipboardOperation;
499-
filenamesList: TStringList;
567+
path: String;
500568
f: TFile;
501569
fs: IFileSource;
502570
begin
503-
if NOT PasteFromClipboard(ClipboardOp, filenamesList) then
571+
path:= GetFirstFilenameInClipboard;
572+
if path = EmptyStr then
504573
Exit;
505574

506575
f:= TFile.Create(EmptyStr);
507-
f.FullPath:= filenamesList[0];
576+
f.FullPath:= path;
508577
fs:= FileSourceManager.Find(TFileSystemFileSource, EmptyStr);
509578
fs.RetrieveProperties(f, [fpAttributes,fpModificationTime,fpCreationTime,fpLastAccessTime,fpChangeTime], []);
510579
FOperation.NewProperties:= self.CreateNewProperties(f);

‎src/fsetfilepropertiesadvload.lfm‎

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
object frmSetFilePropertiesAdvLoad: TfrmSetFilePropertiesAdvLoad
2+
Left = 487
3+
Height = 294
4+
Top = 250
5+
Width = 502
6+
AutoSize = True
7+
ClientHeight = 294
8+
ClientWidth = 502
9+
Constraints.MaxWidth = 1000
10+
Constraints.MinWidth = 400
11+
Position = poOwnerFormCenter
12+
LCLVersion = '5.99.0.0'
13+
object rgLoadFrom: TRadioGroup
14+
AnchorSideLeft.Control = Owner
15+
AnchorSideTop.Control = Owner
16+
AnchorSideRight.Control = Owner
17+
AnchorSideRight.Side = asrBottom
18+
Left = 8
19+
Height = 97
20+
Top = 8
21+
Width = 486
22+
Anchors = [akTop, akLeft, akRight]
23+
AutoFill = True
24+
AutoSize = True
25+
BorderSpacing.Left = 8
26+
BorderSpacing.Top = 8
27+
BorderSpacing.Right = 8
28+
Caption = 'Load attributes from'
29+
ChildSizing.LeftRightSpacing = 6
30+
ChildSizing.TopBottomSpacing = 6
31+
ChildSizing.VerticalSpacing = 6
32+
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
33+
ChildSizing.EnlargeVertical = crsHomogenousChildResize
34+
ChildSizing.ShrinkHorizontal = crsScaleChilds
35+
ChildSizing.ShrinkVertical = crsScaleChilds
36+
ChildSizing.Layout = cclLeftToRightThenTopToBottom
37+
ChildSizing.ControlsPerLine = 1
38+
ClientHeight = 78
39+
ClientWidth = 476
40+
ItemIndex = 1
41+
Items.Strings = (
42+
'Active panel (source)'
43+
'Inactive panel (target)'
44+
'Clipboard'
45+
)
46+
TabOrder = 2
47+
TabStop = True
48+
end
49+
object gbLoadAttributes: TGroupBox
50+
AnchorSideLeft.Control = Owner
51+
AnchorSideTop.Control = rgLoadFrom
52+
AnchorSideTop.Side = asrBottom
53+
AnchorSideRight.Control = Owner
54+
AnchorSideRight.Side = asrBottom
55+
Left = 8
56+
Height = 137
57+
Top = 113
58+
Width = 486
59+
Anchors = [akTop, akLeft, akRight]
60+
AutoSize = True
61+
BorderSpacing.Left = 8
62+
BorderSpacing.Top = 8
63+
BorderSpacing.Right = 8
64+
BorderSpacing.Bottom = 8
65+
Caption = 'Load these attributes'
66+
ClientHeight = 118
67+
ClientWidth = 476
68+
TabOrder = 0
69+
inline frmProperties: TfrmSelectFileProperties
70+
AnchorSideLeft.Control = gbLoadAttributes
71+
AnchorSideTop.Control = gbLoadAttributes
72+
AnchorSideRight.Control = gbLoadAttributes
73+
Left = 8
74+
Height = 102
75+
Top = 8
76+
Width = 169
77+
BorderSpacing.Left = 8
78+
BorderSpacing.Top = 8
79+
BorderSpacing.Bottom = 8
80+
ClientHeight = 102
81+
ClientWidth = 169
82+
inherited chkTime: TCheckBox
83+
AnchorSideLeft.Control = frmProperties
84+
AnchorSideTop.Control = frmProperties
85+
Checked = True
86+
State = cbChecked
87+
end
88+
inherited chkAttributes: TCheckBox
89+
Checked = True
90+
State = cbChecked
91+
end
92+
inherited chkPermissions: TCheckBox
93+
Visible = False
94+
end
95+
inherited chkXAttributes: TCheckBox
96+
Visible = False
97+
end
98+
end
99+
end
100+
object ButtonPanel1: TButtonPanel
101+
AnchorSideTop.Control = gbLoadAttributes
102+
AnchorSideTop.Side = asrBottom
103+
Left = 6
104+
Height = 30
105+
Top = 258
106+
Width = 490
107+
Anchors = [akTop, akLeft, akRight, akBottom]
108+
OKButton.Name = 'OKButton'
109+
OKButton.DefaultCaption = True
110+
HelpButton.Name = 'HelpButton'
111+
HelpButton.DefaultCaption = True
112+
CloseButton.Name = 'CloseButton'
113+
CloseButton.DefaultCaption = True
114+
CancelButton.Name = 'CancelButton'
115+
CancelButton.DefaultCaption = True
116+
ButtonOrder = boCloseOKCancel
117+
TabOrder = 1
118+
ShowButtons = [pbOK, pbCancel]
119+
ShowBevel = False
120+
end
121+
end

‎src/fsetfilepropertiesadvload.lrj‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{"version":1,"strings":[
2+
{"hash":45034109,"name":"tfrmsetfilepropertiesadvload.rgloadfrom.caption","sourcebytes":[76,111,97,100,32,97,116,116,114,105,98,117,116,101,115,32,102,114,111,109],"value":"Load attributes from"},
3+
{"hash":115916003,"name":"tfrmsetfilepropertiesadvload.gbloadattributes.caption","sourcebytes":[76,111,97,100,32,116,104,101,115,101,32,97,116,116,114,105,98,117,116,101,115],"value":"Load these attributes"}
4+
]}

‎src/fsetfilepropertiesadvload.pas‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
unit fSetFilePropertiesAdvLoad;
2+
3+
{$mode ObjFPC}{$H+}
4+
5+
interface
6+
7+
uses
8+
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
9+
ButtonPanel, fSelectFileProperties;
10+
11+
type
12+
13+
{ TfrmSetFilePropertiesAdvLoad }
14+
15+
TfrmSetFilePropertiesAdvLoad = class(TForm)
16+
ButtonPanel1: TButtonPanel;
17+
frmProperties: TfrmSelectFileProperties;
18+
gbLoadAttributes: TGroupBox;
19+
rgLoadFrom: TRadioGroup;
20+
end;
21+
22+
var
23+
frmSetFilePropertiesAdvLoad: TfrmSetFilePropertiesAdvLoad;
24+
25+
implementation
26+
27+
{$R *.lfm}
28+
29+
end.
30+

0 commit comments

Comments
 (0)