Skip to content

Commit

Permalink
feat: Persistence of window size/sate saved
Browse files Browse the repository at this point in the history
- JSON Prop Storage with Top, Left, Width, Height and WindowState
- Need to enquire about both PairSplitter.Pos

Closes: #8
  • Loading branch information
gcarreno committed Feb 2, 2021
1 parent 0f43694 commit 9369efb
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/application/ljv.application.version.pas
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
interface

const
cVersion = '0.1.4.26';
cVersion = '0.1.5.27';
cVersionMajor = 0;
cVersionMinor = 1;
cVersionRevision = 4;
cVersionBuild = 26;
cVersionRevision = 5;
cVersionBuild = 27;

implementation

Expand Down
8 changes: 8 additions & 0 deletions src/forms/ljv.forms.main.lfm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ object frmMain: TfrmMain
ClientWidth = 1017
OnCreate = FormCreate
OnDestroy = FormDestroy
SessionProperties = 'Top;Left;Height;Width;WindowState'
object psMain: TPairSplitter
Cursor = crDefault
Left = 224
Expand Down Expand Up @@ -118,4 +119,11 @@ object frmMain: TfrmMain
Top = 0
Width = 5
end
object JSONPropStorage: TJSONPropStorage
StoredValues = <>
Formatted = False
Active = False
Left = 768
Top = 400
end
end
20 changes: 19 additions & 1 deletion src/forms/ljv.forms.main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ interface
, Dialogs
, ExtCtrls
, StdCtrls
, PairSplitter
, PairSplitter, JSONPropStorage
, fpjson
, VirtualTrees
;
Expand All @@ -45,6 +45,7 @@ interface
{ TfrmMain }

TfrmMain = class(TForm)
JSONPropStorage: TJSONPropStorage;
lblCount: TLabel;
lblName: TLabel;
lblType: TLabel;
Expand All @@ -70,6 +71,9 @@ TfrmMain = class(TForm)

function FormatBytes(ABytes: Int64): String;

procedure SetupPropStorage;
procedure ShutdownPropStorage;

procedure ClearLabels;
procedure CorrectPSCursor;
procedure ProcessParams;
Expand Down Expand Up @@ -150,6 +154,7 @@ implementation

procedure TfrmMain.FormCreate(Sender: TObject);
begin
SetupPropStorage;
Caption:= Format(rsFormCaption, [cVersion]);
ClearLabels;
CorrectPSCursor;
Expand All @@ -171,6 +176,7 @@ procedure TfrmMain.FormDestroy(Sender: TObject);
begin
FJSON.Free;
end;
ShutdownPropStorage;
end;

procedure TfrmMain.lbFilesSelectionChange(Sender: TObject; User: boolean);
Expand Down Expand Up @@ -493,6 +499,18 @@ function TfrmMain.FormatBytes(ABytes: Int64): String;
end;
end;

procedure TfrmMain.SetupPropStorage;
begin
JSONPropStorage.JSONFileName:= GetAppConfigFile(False);
JSONPropStorage.RootObjectPath:= 'Application';
JSONPropStorage.Active:= True;
end;

procedure TfrmMain.ShutdownPropStorage;
begin
JSONPropStorage.Active:= False;
end;

procedure TfrmMain.CorrectPSCursor;
begin
psMain.Cursor:= crHSplit;
Expand Down
4 changes: 2 additions & 2 deletions src/lazJSONViewer.lpi
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
<VersionInfo>
<UseVersionInfo Value="True"/>
<MinorVersionNr Value="1"/>
<RevisionNr Value="4"/>
<BuildNr Value="26"/>
<RevisionNr Value="5"/>
<BuildNr Value="27"/>
<Language Value="0809"/>
</VersionInfo>
<BuildModes Count="4">
Expand Down
Binary file modified src/lazJSONViewer.res
Binary file not shown.

0 comments on commit 9369efb

Please sign in to comment.