unit FormAbout;

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus,
  StdCtrls, ExtCtrls, ApplicationInfo, Common, FormEx;

type
  { TFormAbout }

  TFormAbout = class(TFormEx)
    ButtonClose: TButton;
    ButtonHomePage: TButton;
    ImageLogo: TImage;
    LabelAppName: TLabel;
    LabelDescription: TLabel;
    LabelContent: TLabel;
    PanelTop: TPanel;
    PanelButtons: TPanel;
    procedure ButtonHomePageClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    FApplicationInfo: TApplicationInfo;
  public
    procedure UpdateInterface;
    property ApplicationInfo: TApplicationInfo read FApplicationInfo write
      FApplicationInfo;
  end;


implementation

{$R *.lfm}

resourcestring
  SVersion = 'Version';
  SReleaseDate = 'Release date';
  SLicense = 'License';
  // TODO: https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41095
  {$hints off}
  SHomePage = 'Home page';
  SClose = 'Close';

{ TFormAbout }

procedure TFormAbout.FormShow(Sender: TObject);
begin
  if Assigned(ApplicationInfo) then
  with ApplicationInfo do begin
    LabelAppName.Caption := AppName;
    LabelContent.Caption := SVersion + ': ' + Version + LineEnding +
      SReleaseDate + ': ' + DateToStr(ReleaseDate) + LineEnding +
      SLicense + ': ' + License;
    LabelDescription.Caption := Description;
    ImageLogo.Picture.Bitmap.Assign(Icon);
  end;
  UpdateInterface;
end;

procedure TFormAbout.UpdateInterface;
begin
  ButtonHomePage.Enabled := Assigned(ApplicationInfo);
end;

procedure TFormAbout.ButtonHomePageClick(Sender: TObject);
begin
  OpenWebPage(ApplicationInfo.HomePage);
end;

end.
