Skip to content

Commit

Permalink
feat: Keys to exit implemented
Browse files Browse the repository at this point in the history
- The Escape key for all platforms
- For Linux: Ctrl+Q
- For Windows: Alt+X

Closes: #16
  • Loading branch information
gcarreno committed Feb 3, 2021
1 parent 1ccc197 commit 8765a6f
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 9 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 @@ -27,11 +27,11 @@
interface

const
cVersion = '0.1.7.30';
cVersion = '0.1.8.31';
cVersionMajor = 0;
cVersionMinor = 1;
cVersionRevision = 7;
cVersionBuild = 30;
cVersionRevision = 8;
cVersionBuild = 31;

implementation

Expand Down
12 changes: 10 additions & 2 deletions src/forms/ljv.forms.main.lfm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ object frmMain: TfrmMain
OnDestroy = FormDestroy
OnDropFiles = FormDropFiles
SessionProperties = 'Top;Left;Height;Width;WindowState'
LCLVersion = '2.1.0.0'
object psMain: TPairSplitter
Cursor = crDefault
Left = 224
Expand Down Expand Up @@ -39,7 +38,7 @@ object frmMain: TfrmMain
Header.Columns = <
item
Position = 0
Width = 400
Width = 398
end>
Header.Options = [hoAutoResize, hoColumnResize, hoDrag, hoShowSortGlyphs]
TabOrder = 0
Expand Down Expand Up @@ -154,4 +153,13 @@ object frmMain: TfrmMain
Left = 80
Top = 464
end
object alMain: TActionList
Left = 80
Top = 400
object actFileExit: TFileExit
Category = 'File'
Caption = 'E&xit'
Hint = 'Exit'
end
end
end
4 changes: 3 additions & 1 deletion src/forms/ljv.forms.main.lrj
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
{"hash":43075653,"name":"tfrmmain.lblname.caption","sourcebytes":[108,98,108,78,97,109,101],"value":"lblName"},
{"hash":151678324,"name":"tfrmmain.lblcount.caption","sourcebytes":[108,98,108,67,111,117,110,116],"value":"lblCount"},
{"hash":152863893,"name":"tfrmmain.lblvalue.caption","sourcebytes":[108,98,108,86,97,108,117,101],"value":"lblValue"},
{"hash":43083992,"name":"tfrmmain.lblpath.caption","sourcebytes":[108,98,108,80,97,116,104],"value":"lblPath"}
{"hash":43083992,"name":"tfrmmain.lblpath.caption","sourcebytes":[108,98,108,80,97,116,104],"value":"lblPath"},
{"hash":4710148,"name":"tfrmmain.actfileexit.caption","sourcebytes":[69,38,120,105,116],"value":"E&xit"},
{"hash":315140,"name":"tfrmmain.actfileexit.hint","sourcebytes":[69,120,105,116],"value":"Exit"}
]}
19 changes: 18 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, JSONPropStorage
, PairSplitter, JSONPropStorage, ActnList, StdActns
, fpjson
, VirtualTrees
;
Expand All @@ -45,6 +45,8 @@ interface
{ TfrmMain }

TfrmMain = class(TForm)
alMain: TActionList;
actFileExit: TFileExit;
lblPath: TLabel;
lblValue: TLabel;
panPath: TPanel;
Expand Down Expand Up @@ -73,6 +75,8 @@ TfrmMain = class(TForm)
FJSON: TJSONData;
FFileList: Array of String;

procedure SetupShortcuts;

procedure AddFile(const AFilename: String);
procedure ClearTree;
function FormatBytes(ABytes: Int64): String;
Expand Down Expand Up @@ -103,6 +107,7 @@ implementation
uses
StrUtils
, DateUtils
, LCLType
, LJV.Application.Version
, LJV.JSON.Utils
, LJV.Tree.Nodes
Expand Down Expand Up @@ -163,6 +168,7 @@ implementation
procedure TfrmMain.FormCreate(Sender: TObject);
begin
SetupPropStorage;
SetupShortcuts;
Caption:= Format(rsFormCaption, [cVersion]);
lblValue.Caption:= rsCaptionValue;
ClearLabels;
Expand Down Expand Up @@ -487,6 +493,17 @@ procedure TfrmMain.vstJSONGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
end;
end;

procedure TfrmMain.SetupShortcuts;
begin
actFileExit.SecondaryShortCuts.Add('Esc');
{$IFDEF LINUX}
actFileExit.ShortCut := KeyToShortCut(VK_Q, [ssCtrl]);
{$ENDIF}
{$IFDEF WINDOWS}
actFileExit.ShortCut := KeyToShortCut(VK_X, [ssAlt]);
{$ENDIF}
end;

function TfrmMain.FormatBytes(ABytes: Int64): String;
var
dSize: Double;
Expand Down
8 changes: 8 additions & 0 deletions src/i18n/lazJSONViewer.pot
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@ msgctxt "ljv.forms.main.rsvstunknown"
msgid "Unknown"
msgstr ""

#: tfrmmain.actfileexit.caption
msgid "E&xit"
msgstr ""

#: tfrmmain.actfileexit.hint
msgid "Exit"
msgstr ""

#: tfrmmain.caption
msgid "frmMain"
msgstr ""
Expand Down
8 changes: 8 additions & 0 deletions src/i18n/lazJSONViewer.pt.po
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,14 @@ msgctxt "ljv.forms.main.rsvstunknown"
msgid "Unknown"
msgstr "Desconhecido"

#: tfrmmain.actfileexit.caption
msgid "E&xit"
msgstr "&Sair"

#: tfrmmain.actfileexit.hint
msgid "Exit"
msgstr "Sair"

#: tfrmmain.caption
msgid "frmMain"
msgstr "frmMain"
Expand Down
8 changes: 8 additions & 0 deletions src/i18n/lazJSONViewer.pt_PT.po
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,14 @@ msgctxt "ljv.forms.main.rsvstunknown"
msgid "Unknown"
msgstr "Desconhecido"

#: tfrmmain.actfileexit.caption
msgid "E&xit"
msgstr "&Sair"

#: tfrmmain.actfileexit.hint
msgid "Exit"
msgstr "Sair"

#: tfrmmain.caption
msgid "frmMain"
msgstr "frmMain"
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="7"/>
<BuildNr Value="30"/>
<RevisionNr Value="8"/>
<BuildNr Value="31"/>
<Language Value="0809"/>
</VersionInfo>
<BuildModes Count="4">
Expand Down

0 comments on commit 8765a6f

Please sign in to comment.