2022-07-20 12:29:04 +00:00
|
|
|
unit main;
|
|
|
|
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, ubarcodes;
|
|
|
|
|
|
|
|
type
|
|
|
|
|
|
|
|
{ TMainForm }
|
|
|
|
|
|
|
|
TMainForm = class(TForm)
|
|
|
|
Timer: TTimer;
|
|
|
|
procedure FormCreate(Sender: TObject);
|
|
|
|
procedure TimerTimer(Sender: TObject);
|
|
|
|
private
|
2022-07-20 13:20:59 +00:00
|
|
|
BarcodeQR: TBarcodeQR;
|
|
|
|
function GetNowText: String;
|
2022-07-20 12:29:04 +00:00
|
|
|
|
|
|
|
public
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
var
|
|
|
|
MainForm: TMainForm;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
{$R *.lfm}
|
|
|
|
|
|
|
|
{ TMainForm }
|
|
|
|
|
|
|
|
procedure TMainForm.TimerTimer(Sender: TObject);
|
|
|
|
begin
|
2022-07-20 13:20:59 +00:00
|
|
|
BarcodeQR.Text := GetNowText;
|
|
|
|
Caption := 'QRClock: ' + StringReplace(BarcodeQR.Text, LineEnding, ' - ', []);
|
2022-07-20 12:29:04 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TMainForm.FormCreate(Sender: TObject);
|
|
|
|
var
|
|
|
|
w: Integer = 0;
|
|
|
|
h: Integer = 0;
|
|
|
|
begin
|
2022-07-20 13:20:59 +00:00
|
|
|
BarcodeQR := TBarcodeQR.Create(self);
|
|
|
|
BarcodeQR.Parent := self;
|
|
|
|
BarcodeQR.Scale := 16;
|
|
|
|
BarcodeQR.Text := GetNowText;
|
2022-07-20 12:29:04 +00:00
|
|
|
BarcodeQR.GetPreferredSize(w, h);
|
2022-07-20 13:20:59 +00:00
|
|
|
BarcodeQR.SetBounds(0, 0, w, h);
|
|
|
|
ClientWidth := w;
|
|
|
|
ClientHeight := h;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TMainForm.GetNowText: String;
|
|
|
|
var
|
|
|
|
dt: TDateTime;
|
|
|
|
sd, st: String;
|
|
|
|
begin
|
|
|
|
dt := Now();
|
|
|
|
sd := FormatDateTime('dddddd', dt);
|
|
|
|
st := FormatDateTime('hh:nn:ss', dt);
|
|
|
|
Result := sd + LineEnding + st;
|
2022-07-20 12:29:04 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|
|
|
|
|