Skip to content

Commit 1f19d00

Browse files
committed
enhance: make file exit action OS friendly
Sets default shortcut Ctrl+Q and Quit caption in Linux. Also, move the predefined shortcut from the main menu item to the underlying action item, where it belongs. Closes #2277
1 parent 49b31aa commit 1f19d00

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

source/main.lfm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3607,7 +3607,6 @@ object MainForm: TMainForm
36073607
end
36083608
object FileExitItem: TMenuItem
36093609
Action = actExitApplication
3610-
ShortCut = 32883
36113610
end
36123611
end
36133612
object MainMenuEdit: TMenuItem
@@ -3921,6 +3920,7 @@ object MainForm: TMainForm
39213920
Caption = 'E&xit'
39223921
Hint = 'Exit|Exit application'
39233922
ImageIndex = 26
3923+
ShortCut = 32883
39243924
OnExecute = actExitApplicationExecute
39253925
end
39263926
object actFollowForeignKey: TAction

source/main.pas

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2046,12 +2046,25 @@ procedure TMainForm.FormCreate(Sender: TObject);
20462046
if AppSettings.ReadBool(asDoubleClickInsertsNodeText) then
20472047
menuDoubleClickInsertsNodeText.Click;
20482048

2049-
// Shortcuts
2050-
FActionList1DefaultCaptions := TStringList.Create;
2051-
FActionList1DefaultHints := TStringList.Create;
2049+
// Make exit action OS friendly
2050+
{$IFDEF UNIX}
2051+
actExitApplication.Caption := '&Quit';
2052+
actExitApplication.ShortCut := KeyToShortCut(VK_Q, [ssCtrl]);
2053+
{$ENDIF}
2054+
{$IFDEF WINDOWS}
2055+
actExitApplication.Caption := 'E&xit';
2056+
actExitApplication.ShortCut := KeyToShortCut(VK_F4, [ssAlt]);
2057+
{$ENDIF}
2058+
// Customized keyboard shortcuts
20522059
for i:=0 to ActionList1.ActionCount-1 do begin
20532060
Action := TAction(ActionList1.Actions[i]);
20542061
Action.ShortCut := AppSettings.ReadInt(asActionShortcut1, Action.Name, Action.ShortCut);
2062+
end;
2063+
2064+
// Keep a list of untranslated captions and hints of actions
2065+
FActionList1DefaultCaptions := TStringList.Create;
2066+
FActionList1DefaultHints := TStringList.Create;
2067+
for i:=0 to ActionList1.ActionCount-1 do begin
20552068
FActionList1DefaultCaptions.Insert(i, Action.Caption);
20562069
FActionList1DefaultHints.Insert(i, Action.Hint);
20572070
end;

0 commit comments

Comments
 (0)