1 | unit UFormKeyShortcuts;
|
---|
2 |
|
---|
3 | {$mode delphi}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
---|
9 | ComCtrls, ActnList, LCLProc, Menus;
|
---|
10 |
|
---|
11 | type
|
---|
12 |
|
---|
13 | { TFormKeyShortcuts }
|
---|
14 |
|
---|
15 | TFormKeyShortcuts = class(TForm)
|
---|
16 | ListView1: TListView;
|
---|
17 | MenuItem1: TMenuItem;
|
---|
18 | PopupMenu1: TPopupMenu;
|
---|
19 | procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
---|
20 | procedure FormCreate(Sender: TObject);
|
---|
21 | procedure FormShow(Sender: TObject);
|
---|
22 | procedure MenuItem1Click(Sender: TObject);
|
---|
23 | private
|
---|
24 | public
|
---|
25 | procedure LoadFromComponent(C: TComponent);
|
---|
26 | end;
|
---|
27 |
|
---|
28 | var
|
---|
29 | FormKeyShortcuts: TFormKeyShortcuts;
|
---|
30 |
|
---|
31 | implementation
|
---|
32 |
|
---|
33 | uses
|
---|
34 | UFormMain, UCore;
|
---|
35 |
|
---|
36 | resourcestring
|
---|
37 | SMainForm = 'Main window';
|
---|
38 | SGlobal = 'Global';
|
---|
39 |
|
---|
40 | { TFormKeyShortcuts }
|
---|
41 |
|
---|
42 | procedure TFormKeyShortcuts.FormShow(Sender: TObject);
|
---|
43 | begin
|
---|
44 | Core.PersistentForm.Load(Self);
|
---|
45 | try
|
---|
46 | ListView1.BeginUpdate;
|
---|
47 | ListView1.Clear;
|
---|
48 | LoadFromComponent(Core);
|
---|
49 | LoadFromComponent(FormMain);
|
---|
50 | finally
|
---|
51 | ListView1.EndUpdate;
|
---|
52 | end;
|
---|
53 | end;
|
---|
54 |
|
---|
55 | procedure TFormKeyShortcuts.MenuItem1Click(Sender: TObject);
|
---|
56 | begin
|
---|
57 | if Assigned(ListView1.Selected) then
|
---|
58 | TAction(ListView1.Selected.Data).Execute;
|
---|
59 | end;
|
---|
60 |
|
---|
61 | procedure TFormKeyShortcuts.FormClose(Sender: TObject;
|
---|
62 | var CloseAction: TCloseAction);
|
---|
63 | begin
|
---|
64 | Core.PersistentForm.Save(Self);
|
---|
65 | end;
|
---|
66 |
|
---|
67 | procedure TFormKeyShortcuts.FormCreate(Sender: TObject);
|
---|
68 | begin
|
---|
69 | Core.CoolTranslator1.TranslateComponentRecursive(Self);
|
---|
70 | end;
|
---|
71 |
|
---|
72 | procedure TFormKeyShortcuts.LoadFromComponent(C: TComponent);
|
---|
73 | var
|
---|
74 | I: Integer;
|
---|
75 | NewItem: TListItem;
|
---|
76 | begin
|
---|
77 | if C is TActionList then
|
---|
78 | with TActionList(C) do begin
|
---|
79 | for I := 0 to ActionCount - 1 do
|
---|
80 | if Actions[I] is TAction then
|
---|
81 | with TAction(Actions[I]) do
|
---|
82 | //if ShortCut > 0 then
|
---|
83 | begin
|
---|
84 | NewItem := ListView1.Items.Add;
|
---|
85 | NewItem.Caption := Caption;
|
---|
86 | NewItem.ImageIndex := ImageIndex;
|
---|
87 | NewItem.Data := TAction(Actions[I]);
|
---|
88 | with NewItem.SubItems do begin
|
---|
89 | if C.Owner is TFormMain then Add(SMainForm)
|
---|
90 | else if C.Owner is TDataModule then Add(SGlobal)
|
---|
91 | else if C.Owner is TForm then Add(TForm(C.Owner).Caption)
|
---|
92 | else Add(C.Name);
|
---|
93 | Add(ShortCutToText(ShortCut));
|
---|
94 | end;
|
---|
95 | end;
|
---|
96 | end;
|
---|
97 | for I := 0 to C.ComponentCount - 1 do
|
---|
98 | LoadFromComponent(C.Components[I]);
|
---|
99 | end;
|
---|
100 |
|
---|
101 | initialization
|
---|
102 | {$I UFormKeyShortcuts.lrs}
|
---|
103 |
|
---|
104 | end.
|
---|
105 |
|
---|