Changeset 151 for trunk/Core.pas


Ignore:
Timestamp:
Jun 6, 2023, 11:15:57 AM (18 months ago)
Author:
chronos
Message:
  • Added: New file compare dialog with additional normalize options.
  • Modified: Compare action uses external compare tool.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Core.pas

    r149 r151  
    77  LastOpenedList, ApplicationInfo, PersistentForm, ScaleDPI, Common,
    88  Translator, DataFile, VCard, Menus, RegistryEx, Theme, AboutDialog,
    9   Registry;
     9  Registry, VCardFile;
    1010
    1111type
     
    8787    procedure AddItemToLastOpenedList(FileName: string);
    8888    procedure DoDataFileChange;
     89    function GetDefaultCompareTool: string;
    8990  public
    9091    DefaultDataFileClass: TDataFileClass;
     
    9495    LastContactTabIndex: Integer;
    9596    LastContactFileName: string;
    96     LastCompareFileName: string;
    9797    LastPhotoFileName: string;
    9898    LastQrCodeFileName: string;
     
    102102    ToolbarVisible: Boolean;
    103103    DefaultVcardVersion: string;
     104    DefaultPhoneCountryPrefix: string;
     105    CompareTool: string;
    104106    function GetProfileImage: TImage;
     107    function GetTempDir: string;
    105108    procedure FileNew;
    106109    procedure FileOpen(FileName: string);
     
    123126
    124127uses
    125   FormMain, FormSettings, FormFindDuplicity, TestCase,
    126   FormGenerate, FormError, FormFind, FormTest, FormSource, FormCompare,
    127   TestCases, VCardFile;
     128  FormMain, FormSettings, FormFindDuplicity, FormCompare, TestCase,
     129  FormGenerate, FormError, FormFind, FormTest, FormSource, FormCompareSideBySide,
     130  TestCases;
    128131
    129132resourcestring
     
    184187procedure TCore.AFileCompareExecute(Sender: TObject);
    185188var
    186   TempFile: TDataFile;
    187   TempFileName: string;
    188 begin
    189   TempFile := DefaultDataFileClass.Create(nil);
    190   try
    191     OpenDialog1.Filter := TempFile.GetFileFilter;
    192   finally
    193     TempFile.Free;
    194   end;
    195   OpenDialog1.DefaultExt := '';
    196   OpenDialog1.InitialDir := ExtractFileDir(Core.LastCompareFileName);
    197   OpenDialog1.FileName := ExtractFileName(Core.LastCompareFileName);
    198   OpenDialog1.Options := OpenDialog1.Options - [ofAllowMultiSelect];
    199   if OpenDialog1.Execute then begin
    200     with TFormCompare.Create(nil) do
    201     try
    202       TempFileName := GetTempDir + DirectorySeparator + Application.Title +
    203         DirectorySeparator + 'Compare' + VCardFileExt;
    204       ForceDirectories(ExtractFileDir(TempFileName));
    205       TVCardFile(DataFile).SaveToFile(TempFileName);
    206       LoadFileLeft(TempFileName);
    207       LoadFileRight(OpenDialog1.FileName);
    208       ShowModal;
    209     finally
    210       Free;
    211     end;
    212     Core.LastCompareFileName := OpenDialog1.FileName;
     189  FormCompare: TFormCompare;
     190begin
     191  FormCompare := TFormCompare.Create(nil);
     192  try
     193    FormCompare.ShowModal;
     194  finally
     195    FreeAndNil(FormCompare);
    213196  end;
    214197end;
     
    556539    LastPhotoFileName := ReadStringWithDefault('LastPhotoFileName', '');
    557540    LastQrCodeFileName := ReadStringWithDefault('LastQrCodeFileName', '');
    558     LastCompareFileName := ReadStringWithDefault('LastCompareFileName', '');
     541    CompareTool := ReadStringWithDefault('CompareTool', GetDefaultCompareTool);
     542    DefaultPhoneCountryPrefix := ReadStringWithDefault('DefaultPhoneCountryPrefix', DefaultPhoneCountryPrefix);
    559543  finally
    560544    Free;
     
    583567    WriteString('LastPhotoFileName', LastPhotoFileName);
    584568    WriteString('LastQrCodeFileName', LastQrCodeFileName);
    585     WriteString('LastCompareFileName', LastCompareFileName);
     569    WriteString('CompareTool', CompareTool);
     570    WriteString('DefaultPhoneCountryPrefix', DefaultPhoneCountryPrefix);
    586571  finally
    587572    Free;
     
    609594end;
    610595
     596function TCore.GetDefaultCompareTool: string;
     597const
     598  KDiff3 = '/usr/bin/kdiff3';
     599  Kompare = '/usr/bin/kompare';
     600  Meld = '/usr/bin/meld';
     601  Diffuse = '/usr/bin/diffuse';
     602  BeyondCompare = '/usr/bin/bcompare';
     603begin
     604  if FileExists(KDiff3) then Result := KDiff3
     605  else if FileExists(Meld) then Result := Meld
     606  else if FileExists(Kompare) then Result := Kompare
     607  else if FileExists(Diffuse) then Result := Diffuse
     608  else if FileExists(BeyondCompare) then Result := BeyondCompare
     609  else Result := '';
     610end;
     611
    611612function TCore.GetProfileImage: TImage;
    612613begin
     
    617618  end;
    618619  Result := ProfileImage;
     620end;
     621
     622function TCore.GetTempDir: string;
     623begin
     624  Result := SysUtils.GetTempDir + Application.Title;
    619625end;
    620626
Note: See TracChangeset for help on using the changeset viewer.