Ignore:
Timestamp:
Dec 13, 2021, 8:47:20 PM (3 years ago)
Author:
chronos
Message:
  • Fixed: Properties with just BASE64 instead of ENCODING=BASE64 was not decoded using Base64 and so contact photos were not loaded correctly.
  • Added: Allow to save from file and load to file contact property values in All fields tab.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormProperties.pas

    r54 r72  
    1616    AAdd: TAction;
    1717    AClone: TAction;
     18    ASaveValueToFile: TAction;
     19    ALoadValueFromFile: TAction;
    1820    ASelectAll: TAction;
    1921    ARemove: TAction;
     
    2830    MenuItem4: TMenuItem;
    2931    MenuItem5: TMenuItem;
     32    MenuItem6: TMenuItem;
     33    MenuItem7: TMenuItem;
     34    MenuItem8: TMenuItem;
     35    OpenDialog1: TOpenDialog;
    3036    PopupMenuField: TPopupMenu;
     37    SaveDialog1: TSaveDialog;
    3138    StatusBar1: TStatusBar;
    3239    ToolBar1: TToolBar;
     
    3542    ToolButton3: TToolButton;
    3643    ToolButton4: TToolButton;
     44    ToolButton5: TToolButton;
     45    ToolButton6: TToolButton;
     46    ToolButton7: TToolButton;
    3747    procedure AAddExecute(Sender: TObject);
    3848    procedure ACloneExecute(Sender: TObject);
     49    procedure ALoadValueFromFileExecute(Sender: TObject);
    3950    procedure AModifyExecute(Sender: TObject);
    4051    procedure ARemoveExecute(Sender: TObject);
     52    procedure ASaveValueToFileExecute(Sender: TObject);
    4153    procedure ASelectAllExecute(Sender: TObject);
    4254    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
     
    7082
    7183uses
    72   UFormProperty, UCore;
     84  UFormProperty, UCore, UCommon;
    7385
    7486resourcestring
     
    7890  SFiltered = 'Filtered';
    7991  SSelected = 'Selected';
     92  SAllFiles = 'All files';
     93  STextFiles = 'Text files';
     94  SValue = 'Value';
     95
     96const
     97  TextFileExt = '.txt';
    8098
    8199{ TFormProperties }
     
    247265end;
    248266
     267procedure TFormProperties.ALoadValueFromFileExecute(Sender: TObject);
     268begin
     269  if Assigned(ListView1.Selected) then begin
     270    OpenDialog1.Filter := STextFiles + '|*' + TextFileExt + '|' + SAllFiles + '|*.*';
     271    OpenDialog1.DefaultExt := TextFileExt;
     272    OpenDialog1.InitialDir := ExtractFileDir(Core.LastPropertyValueFileName);
     273    OpenDialog1.FileName := ExtractFileName(Core.LastPropertyValueFileName);
     274    if OpenDialog1.Execute then begin
     275      TContactProperty(ListView1.Selected.Data).Value := LoadFileToStr(OpenDialog1.FileName);
     276      Core.LastPropertyValueFileName := OpenDialog1.FileName;
     277      ReloadList;
     278    end;
     279  end;
     280end;
     281
    249282procedure TFormProperties.AModifyExecute(Sender: TObject);
    250283var
     
    289322end;
    290323
     324procedure TFormProperties.ASaveValueToFileExecute(Sender: TObject);
     325begin
     326  if Assigned(ListView1.Selected) then begin
     327    SaveDialog1.Filter := STextFiles + '|*' + TextFileExt + '|' + SAllFiles + '|*.*';
     328    SaveDialog1.DefaultExt := TextFileExt;
     329    SaveDialog1.InitialDir := ExtractFileDir(Core.LastPropertyValueFileName);
     330    SaveDialog1.FileName := SValue + TextFileExt;
     331    if SaveDialog1.Execute then begin
     332      SaveStringToFile(TContactProperty(ListView1.Selected.Data).Value, SaveDialog1.FileName);
     333      Core.LastPropertyValueFileName := SaveDialog1.FileName;
     334    end;
     335  end;
     336end;
     337
    291338procedure TFormProperties.ASelectAllExecute(Sender: TObject);
    292339begin
     
    324371  AAdd.Enabled := Assigned(Properties);
    325372  AModify.Enabled := Assigned(Properties) and Assigned(ListView1.Selected);
     373  AClone.Enabled := Assigned(Properties) and Assigned(ListView1.Selected);;
    326374  ARemove.Enabled := Assigned(Properties) and Assigned(ListView1.Selected);
     375  ALoadValueFromFile.Enabled := Assigned(Properties) and Assigned(ListView1.Selected);
     376  ASaveValueToFile.Enabled := Assigned(Properties) and Assigned(ListView1.Selected);
     377  ASelectAll.Enabled := ListView1.Items.Count > 0;
    327378
    328379  Text := '';
Note: See TracChangeset for help on using the changeset viewer.