Changeset 48 for trunk/Forms


Ignore:
Timestamp:
Dec 3, 2021, 2:07:27 PM (3 years ago)
Author:
chronos
Message:
  • Added: Show default profile photo if contact image is not specified.
Location:
trunk/Forms
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormContact.lfm

    r47 r48  
    137137        Top = 16
    138138        Width = 207
     139        Center = True
    139140        PopupMenu = PopupMenuPhoto
    140141        Proportional = True
  • trunk/Forms/UFormContact.pas

    r47 r48  
    147147    FOnPrevious: TNotifyEvent;
    148148    FormProperties: TFormProperties;
     149    ProfilePhotoActive: Boolean;
     150    procedure DefaultPhoto;
    149151    procedure SetContact(AValue: TContact);
    150152    procedure ReloadAllPropertiesTab;
     
    210212
    211213  // Photo
    212   if (ImagePhoto.Picture.Bitmap.Width <> 0) and (ImagePhoto.Picture.Bitmap.Height <> 0) then begin
     214  if ProfilePhotoActive then begin
    213215    PhotoProperty := Contact.GetProperty(cfPhoto);
    214216    if not Assigned(PhotoProperty) then begin
     
    292294              ImagePhoto.Picture.Bitmap.SetSize(JpegImage.Width, JpegImage.Height);
    293295              ImagePhoto.Picture.Bitmap.Canvas.Draw(0, 0, JpegImage);
     296              ProfilePhotoActive := True;
    294297            except
     298              DefaultPhoto;
    295299            end;
    296300          finally
     
    300304          try
    301305            ImagePhoto.Picture.LoadFromStream(Stream);
     306            ProfilePhotoActive := True;
    302307          except
     308            DefaultPhoto;
    303309          end;
    304310        end;
     
    306312        Stream.Free;
    307313      end;
    308     end;
    309   end;
     314    end else DefaultPhoto;
     315  end else DefaultPhoto;
    310316end;
    311317
     
    400406end;
    401407
     408procedure TFormContact.DefaultPhoto;
     409begin
     410  ProfilePhotoActive := False;
     411  ImagePhoto.Picture.Assign(Core.GetProfileImage.Picture);
     412end;
     413
    402414procedure TFormContact.SetContact(AValue: TContact);
    403415begin
     
    458470procedure TFormContact.UpdateInterface;
    459471begin
    460   APhotoSave.Enabled := (ImagePhoto.Picture.Bitmap.Width <> 0) and
    461     (ImagePhoto.Picture.Bitmap.Height <> 0);
     472  APhotoSave.Enabled := ProfilePhotoActive;
    462473end;
    463474
Note: See TracChangeset for help on using the changeset viewer.