@@ -29,7 +29,7 @@ interface
2929uses
3030 Classes, SysUtils, Forms, Controls, ExtCtrls, StdCtrls, Buttons,
3131 uFile, uFileProperty, uFileSourceSetFilePropertyOperation, uFileView,
32- DCBasicTypes, DateTimePicker;
32+ DCBasicTypes, DCOSUtils, DateTimePicker;
3333
3434type
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
143145uses
144146 LCLType, ImgList, EditBtn,
145147 uFileSource, uFileSystemFileSource, uFileSourceManager,
146- DCFileAttributes, DCStrUtils, uDCUtils, uKeyboard, uClipboard;
148+ DCFileAttributes, DCStrUtils, uDCUtils, uKeyboard, uClipboard,
149+ fSetFilePropertiesAdvLoad;
147150
148151function ShowChangeFilePropertiesDialog (
149152 const aOperation: TFileSourceSetFilePropertyOperation;
@@ -398,52 +401,62 @@ function TfrmSetFileProperties.GetAttrFromForm(out ExcludeAttrs: TFileAttrs): TF
398401end ;
399402
400403procedure 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 ;
447460end ;
448461
449462function TfrmSetFileProperties.CreateNewProperties (const f: TFile): TFileProperties;
@@ -470,6 +483,7 @@ constructor TfrmSetFileProperties.Create(
470483begin
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);
494508end ;
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+
496565procedure TfrmSetFileProperties.btnLoadFromClipboardClick (Sender: TObject);
497566var
498- ClipboardOp: TClipboardOperation;
499- filenamesList: TStringList;
567+ path: String;
500568 f: TFile;
501569 fs: IFileSource;
502570begin
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);
0 commit comments