Changeset 48 for trunk/UCore.pas


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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UCore.pas

    r43 r48  
    66
    77uses
    8   Classes, SysUtils, FileUtil, Controls, ActnList, Forms, Dialogs,
     8  Classes, SysUtils, FileUtil, Controls, ActnList, Forms, Dialogs, ExtCtrls,
    99  ULastOpenedList, UApplicationInfo, UPersistentForm, UScaleDPI, UCommon,
    1010  UTranslator, UDataFile, Menus, URegistry, UTheme, UAboutDialog, Registry;
     
    6969    InitializeFinished: Boolean;
    7070    LoadErrors: string;
     71    ProfileImage: TImage;
    7172    procedure FileModified(Sender: TObject);
    7273    function FindFirstNonOption: string;
     
    8182    ReopenLastFileOnStart: Boolean;
    8283    ToolbarVisible: Boolean;
     84    function GetProfileImage: TImage;
    8385    procedure FileNew;
    8486    procedure FileOpen(FileName: string);
     
    294296  FileClose;
    295297  SaveConfig;
     298  if Assigned(ProfileImage) then
     299    FreeAndNil(ProfileImage);
    296300end;
    297301
     
    454458end;
    455459
     460function TCore.GetProfileImage: TImage;
     461const
     462  ProfilePhotoFileName = 'Images/Profile.png';
     463begin
     464  if not Assigned(ProfileImage) then begin
     465    ProfileImage := TImage.Create(nil);
     466    ProfileImage.Picture.LoadFromFile(ProfilePhotoFileName);
     467    if FileExists(ProfilePhotoFileName) then
     468      ProfileImage.Picture.LoadFromFile(ProfilePhotoFileName);
     469  end;
     470  Result := ProfileImage;
     471end;
     472
    456473procedure TCore.UpdateInterface;
    457474begin
Note: See TracChangeset for help on using the changeset viewer.