Skip to content

Commit 7193003

Browse files
authored
refactoring(hotkey): removed active hotkey property in items (#191)
1 parent 4c33db6 commit 7193003

12 files changed

+45
-79
lines changed

Frame/Frame.Options.Hotkey.lfm

+10-9
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ inherited frmHotkeyOptionsPage: TfrmHotkeyOptionsPage
3333
Width = 425
3434
BorderSpacing.Bottom = 4
3535
Caption = 'Enable hotkeys'
36-
OnClick = cbHotKeyClick
3736
ParentFont = False
3837
TabOrder = 0
38+
OnClick = cbHotKeyClick
3939
end
4040
object lblHotkeyWindow: TLabel
4141
Left = 4
@@ -153,7 +153,15 @@ inherited frmHotkeyOptionsPage: TfrmHotkeyOptionsPage
153153
DefaultNodeHeight = 32
154154
DragOperations = []
155155
Header.AutoSizeIndex = 0
156-
Header.Columns = <
156+
Header.Options = [hoColumnResize, hoDblClickResize, hoDrag, hoVisible, hoHeaderClickAutoSort, hoAutoResizeInclCaption]
157+
Header.ParentFont = False
158+
ParentFont = False
159+
PopupMenu = pmHotkey
160+
TabOrder = 0
161+
TreeOptions.MiscOptions = [toAcceptOLEDrop, toCheckSupport, toFullRepaintOnResize, toInitOnSave, toToggleOnDblClick, toWheelPanning, toEditOnClick]
162+
TreeOptions.PaintOptions = [toPopupMode, toShowDropmark, toThemeAware, toUseBlendedImages, toUseExplorerTheme]
163+
TreeOptions.SelectionOptions = [toFullRowSelect, toRightClickSelect]
164+
Columns = <
157165
item
158166
Position = 0
159167
Text = 'Name'
@@ -174,13 +182,6 @@ inherited frmHotkeyOptionsPage: TfrmHotkeyOptionsPage
174182
Text = 'Hotkey'
175183
Width = 200
176184
end>
177-
Header.Options = [hoColumnResize, hoDblClickResize, hoDrag, hoVisible, hoHeaderClickAutoSort, hoAutoResizeInclCaption]
178-
ParentFont = False
179-
PopupMenu = pmHotkey
180-
TabOrder = 0
181-
TreeOptions.MiscOptions = [toAcceptOLEDrop, toCheckSupport, toFullRepaintOnResize, toInitOnSave, toToggleOnDblClick, toWheelPanning, toEditOnClick]
182-
TreeOptions.PaintOptions = [toPopupMode, toShowDropmark, toThemeAware, toUseBlendedImages, toUseExplorerTheme]
183-
TreeOptions.SelectionOptions = [toFullRowSelect, toRightClickSelect]
184185
end
185186
end
186187
object pmHotkey: TPopupMenu[2]

Frame/Frame.Options.Hotkey.lrj

-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
{"hash":162766164,"name":"tfrmhotkeyoptionspage.lblhotkeygm.caption","sourcebytes":[83,104,111,119,32,103,114,97,112,104,105,99,32,109,101,110,117,32,119,104,101,110,32,104,111,116,107,101,121,32,105,115,32,112,114,101,115,115,101,100],"value":"Show graphic menu when hotkey is pressed"},
66
{"hash":247070100,"name":"tfrmhotkeyoptionspage.lblhotkeycm.caption","sourcebytes":[83,104,111,119,32,99,108,97,115,115,105,99,32,109,101,110,117,32,119,104,101,110,32,104,111,116,107,101,121,32,105,115,32,112,114,101,115,115,101,100],"value":"Show classic menu when hotkey is pressed"},
77
{"hash":77701492,"name":"tfrmhotkeyoptionspage.grpordersoftware.caption","sourcebytes":[72,111,116,107,101,121,115,32,108,105,115,116],"value":"Hotkeys list"},
8-
{"hash":346165,"name":"tfrmhotkeyoptionspage.vstitems.header.columns[0].text","sourcebytes":[78,97,109,101],"value":"Name"},
9-
{"hash":376933,"name":"tfrmhotkeyoptionspage.vstitems.header.columns[1].text","sourcebytes":[84,121,112,101],"value":"Type"},
10-
{"hash":145482249,"name":"tfrmhotkeyoptionspage.vstitems.header.columns[2].text","sourcebytes":[67,97,116,101,103,111,114,121],"value":"Category"},
11-
{"hash":83276233,"name":"tfrmhotkeyoptionspage.vstitems.header.columns[3].text","sourcebytes":[72,111,116,107,101,121],"value":"Hotkey"},
128
{"hash":114087587,"name":"tfrmhotkeyoptionspage.actproperties.caption","sourcebytes":[80,114,111,112,101,114,116,105,101,115],"value":"Properties"},
139
{"hash":204660201,"name":"tfrmhotkeyoptionspage.actremovehotkey.caption","sourcebytes":[82,101,109,111,118,101,32,72,111,116,107,101,121],"value":"Remove Hotkey"},
1410
{"hash":79503785,"name":"tfrmhotkeyoptionspage.actedithotkey.caption","sourcebytes":[69,100,105,116,32,72,111,116,107,101,121],"value":"Edit Hotkey"}

Frame/Frame.Options.Hotkey.pas

+1-3
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ procedure TfrmHotkeyOptionsPage.actEditHotkeyExecute(Sender: TObject);
110110
if (ShortCut <> '') then
111111
begin
112112
NodeData.Hotkey := TextToShortCut(ShortCut);
113-
NodeData.ActiveHotkey := True;
114113
NodeData.Changed := True;
115114

116115
if (edtHotkeyMF.Text = ShortCut) then
@@ -278,8 +277,7 @@ procedure TfrmHotkeyOptionsPage.SaveInHotkeyItemList(
278277
NodeData := TvCustomRealNodeData(TVirtualTreeMethods.GetNodeItemData(Node, ATree));
279278
if Assigned(NodeData) then
280279
begin
281-
NodeData.ActiveHotkey := ATree.IsVisible[Node];
282-
if NodeData.ActiveHotkey then
280+
if ATree.IsVisible[Node] then
283281
AItemList.AddItem(NodeData)
284282
else
285283
AItemList.RemoveItem(NodeData);

Frame/Frame.Properties.Advanced.lfm

+4-14
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ inherited frmAdvancedPropertyPage: TfrmAdvancedPropertyPage
4242
Width = 130
4343
Constraints.MinWidth = 130
4444
ItemHeight = 15
45-
OnChange = cxSchedulerChange
4645
ParentFont = False
4746
Style = csDropDownList
4847
TabOrder = 0
48+
OnChange = cxSchedulerChange
4949
end
5050
object dtpSchDate: TDateTimePicker
5151
Left = 4
@@ -114,26 +114,16 @@ inherited frmAdvancedPropertyPage: TfrmAdvancedPropertyPage
114114
Font.Style = [fsBold]
115115
ParentFont = False
116116
TabOrder = 1
117-
object cbHotKey: TCheckBox
118-
Left = 4
119-
Height = 19
120-
Top = 4
121-
Width = 194
122-
Caption = 'Active hotkey'
123-
OnClick = cbHotKeyClick
124-
ParentFont = False
125-
TabOrder = 0
126-
end
127117
object edtHotkey: TButtonedEdit
128118
Left = 4
129-
Height = 22
130-
Top = 25
119+
Height = 20
120+
Top = 4
131121
Width = 194
132122
BorderSpacing.Top = 2
133123
CharCase = ecUppercase
134124
ParentFont = False
135125
ReadOnly = True
136-
TabOrder = 1
126+
TabOrder = 0
137127
OnChange = edtHotkeyChange
138128
OnClick = edtHotkeyClick
139129
OnRightButtonClick = edtHotkeyRightButtonClick

Frame/Frame.Properties.Advanced.lrj

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
{"hash":342540,"name":"tfrmadvancedpropertypage.dtpschdate.textfornulldate","sourcebytes":[78,85,76,76],"value":"NULL"},
44
{"hash":342540,"name":"tfrmadvancedpropertypage.dtpschtime.textfornulldate","sourcebytes":[78,85,76,76],"value":"NULL"},
55
{"hash":83276233,"name":"tfrmadvancedpropertypage.grphotkey.caption","sourcebytes":[72,111,116,107,101,121],"value":"Hotkey"},
6-
{"hash":22920697,"name":"tfrmadvancedpropertypage.cbhotkey.caption","sourcebytes":[65,99,116,105,118,101,32,104,111,116,107,101,121],"value":"Active hotkey"},
76
{"hash":90893459,"name":"tfrmadvancedpropertypage.grpothers.caption","sourcebytes":[79,116,104,101,114,115],"value":"Others"},
87
{"hash":227251173,"name":"tfrmadvancedpropertypage.cbhidesoftware.caption","sourcebytes":[72,105,100,101,32,116,104,105,115,32,115,111,102,116,119,97,114,101,32,102,114,111,109,32,109,101,110,117],"value":"Hide this software from menu"},
98
{"hash":153613577,"name":"tfrmadvancedpropertypage.cbdontinsertmru.caption","sourcebytes":[68,111,110,39,116,32,105,110,115,101,114,116,32,116,104,105,115,32,115,111,102,116,119,97,114,101,32,105,110,32,114,101,99,101,110,116,115,32,40,77,82,85,41],"value":"Don't insert this software in recents (MRU)"},

Frame/Frame.Properties.Advanced.pas

+4-14
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,9 @@ TfrmAdvancedPropertyPage = class(TfrmBasePropertyPage)
4444
dtpSchDate: TDateTimePicker;
4545
dtpSchTime: TDateTimePicker;
4646
grpHotkey: TGroupBox;
47-
48-
cbHotKey: TCheckBox;
47+
4948
pnlTop: TPanel;
5049
procedure cxSchedulerChange(Sender: TObject);
51-
procedure cbHotKeyClick(Sender: TObject);
5250
procedure edtHotkeyRightButtonClick(Sender: TObject);
5351
procedure edtHotkeyChange(Sender: TObject);
5452
procedure edtHotkeyClick(Sender: TObject);
@@ -76,11 +74,6 @@ implementation
7674

7775
{ TfrmAdvancedPropertyPage }
7876

79-
procedure TfrmAdvancedPropertyPage.cbHotKeyClick(Sender: TObject);
80-
begin
81-
edtHotkey.Enabled := cbHotKey.Checked;
82-
end;
83-
8477
procedure TfrmAdvancedPropertyPage.cxSchedulerChange(Sender: TObject);
8578
begin
8679
dtpSchDate.Enabled := cxScheduler.ItemIndex = Ord(smOnce);
@@ -115,9 +108,8 @@ function TfrmAdvancedPropertyPage.InternalLoadData: Boolean;
115108
dtpSchTime.Time := CurrentNodeData.SchDateTime;
116109
cxSchedulerChange(Self);
117110
//Hotkey
118-
cbHotKey.Checked := CurrentNodeData.ActiveHotkey;
119-
edtHotkey.Text := ShortCutToText(CurrentNodeData.Hotkey);
120-
cbHotKeyClick(Self);
111+
if (CurrentNodeData.IsHotkeyActive) then
112+
edtHotkey.Text := ShortCutToText(CurrentNodeData.Hotkey);
121113
//Specific file settings
122114
cbHideSoftware.Checked := CurrentNodeData.HideFromMenu;
123115
if CurrentNodeData.IsFileItem then
@@ -154,7 +146,6 @@ function TfrmAdvancedPropertyPage.InternalSaveData: Boolean;
154146
CurrentNodeData.SchDateTime := RecodeSecond(CurrentNodeData.SchDateTime, 0);
155147
//Hotkey
156148
CurrentNodeData.Hotkey := TextToShortCut(edtHotkey.Text);
157-
CurrentNodeData.ActiveHotkey := cbHotKey.Checked;
158149
//Specific file settings
159150
CurrentNodeData.HideFromMenu := cbHideSoftware.Checked;
160151
if CurrentNodeData.IsFileItem then
@@ -191,8 +182,7 @@ procedure TfrmAdvancedPropertyPage.edtHotkeyClick(Sender: TObject);
191182

192183
procedure TfrmAdvancedPropertyPage.edtHotkeyRightButtonClick(Sender: TObject);
193184
begin
194-
if Sender is TButtonedEdit then
195-
TButtonedEdit(Sender).Text := '';
185+
edtHotkey.Text := '';
196186
end;
197187

198188
end.

Library/Database.List.pas

+1-5
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ TSQLtbl_list = class(TOrm) //Table tbl_list
5858
Fscheduler_mode : Byte;
5959
Fscheduler_datetime : TDateTime;
6060
Frun_from_category : Boolean;
61-
FActiveHotkey : Boolean;
6261
Fhotkey : Word;
6362
Fenvironment_vars : RawUTF8;
6463

@@ -103,7 +102,6 @@ TSQLtbl_list = class(TOrm) //Table tbl_list
103102
property autorun_position: Integer read Fautorun_position write Fautorun_position;
104103
property scheduler_mode: Byte read Fscheduler_mode write Fscheduler_mode;
105104
property scheduler_datetime: TDateTime read Fscheduler_datetime write Fscheduler_datetime;
106-
property activehotkey: Boolean read FActiveHotkey write FActiveHotkey;
107105
property hotkey: Word read Fhotkey write Fhotkey;
108106
property run_from_category: Boolean read Frun_from_category write Frun_from_category;
109107
property environment_vars: RawUTF8 read Fenvironment_vars write Fenvironment_vars;
@@ -132,7 +130,7 @@ class procedure TSQLtbl_list.InsertFileRecord(AData: TvBaseNodeData; ADBManager:
132130

133131
//If enabled, register item's hotkey with new ID
134132
if AData is TvCustomRealNodeData then
135-
if TvCustomRealNodeData(AData).ActiveHotkey then
133+
if TvCustomRealNodeData(AData).IsHotkeyActive then
136134
ASuiteManager.ListManager.HotKeyItemList.AddItem(TvCustomRealNodeData(AData));
137135

138136
SQLFilesData.Free;
@@ -178,7 +176,6 @@ class procedure TSQLtbl_list.LoadItemsByParentID(Tree: TBaseVirtualTree; ADBMana
178176
SchMode := TSchedulerMode(SQLItemsData.scheduler_mode);
179177
SchDateTime := SQLItemsData.scheduler_datetime;
180178
Hotkey := SQLItemsData.hotkey;
181-
ActiveHotkey := SQLItemsData.activehotkey;
182179
WindowState := SQLItemsData.window_state;
183180
ActionOnExe := TActionOnExecute(SQLItemsData.onlaunch);
184181
end;
@@ -276,7 +273,6 @@ procedure TSQLtbl_list.LoadDataFromNode(AData: TvBaseNodeData; AIndex, AParentID
276273
Fonlaunch := Ord(ActionOnExe);
277274
Fscheduler_mode := Ord(SchMode);
278275
Fscheduler_datetime := SchDateTime;
279-
FActiveHotkey := ActiveHotkey;
280276
Fhotkey := Hotkey;
281277
end;
282278
//Add file fields

Library/Lists.Manager.pas

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ procedure TListManager.RemoveItemFromLists(AItemData: TvCustomRealNodeData);
9292
FMRUList.RemoveItem(AItemData);
9393
FMFUList.RemoveItem(AItemData);
9494
//Remove item from hotkey list
95-
if AItemData.ActiveHotkey then
95+
if AItemData.IsHotkeyActive then
9696
FHotKeyItemList.RemoveItem(AItemData);
9797
//Remove item from scheduler list
9898
if AItemData.SchMode <> smDisabled then

Library/NodeDataTypes.Custom.pas

+24-21
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ TvCustomRealNodeData = class(TvBaseNodeData)
4040
FAutorunPos : Integer; //Position for ASuiteStartUpApp and ASuiteShutdownApp
4141
FSchMode : TSchedulerMode; //0 Disabled, 1 Once, 2 Hourly, 3 Daily, 4 Weekly
4242
FSchDateTime : TDateTime;
43-
FActiveHotkey : Boolean;
44-
FHotkey : Cardinal;
43+
FHotkey : TShortCut;
4544
FLastAccess : Int64;
4645

46+
function GetIsHotkeyActive: Boolean;
4747
procedure SetAutorun(value: TAutorunType);
48+
procedure SetHotkey(AValue: TShortCut);
4849
procedure SetSchMode(value: TSchedulerMode);
4950
procedure SetSchDateTime(value: TDateTime);
50-
procedure SetActiveHotkey(const Value: Boolean);
5151
function GetPathAbsoluteIcon: String;
5252
procedure RunActionOnExe(Action: TActionOnExecute);
5353
protected
@@ -75,8 +75,8 @@ TvCustomRealNodeData = class(TvBaseNodeData)
7575
property AutorunPos: Integer read FAutorunPos write FAutorunPos;
7676
property SchMode: TSchedulerMode read FSchMode write SetSchMode;
7777
property SchDateTime: TDateTime read FSchDateTime write SetSchDateTime;
78-
property ActiveHotkey: Boolean read FActiveHotkey write SetActiveHotkey;
79-
property Hotkey: Cardinal read FHotkey write FHotkey;
78+
property Hotkey: TShortCut read FHotkey write SetHotkey;
79+
property IsHotkeyActive: Boolean read GetIsHotkeyActive;
8080
end;
8181
PvCustomRealNodeData = ^TvCustomRealNodeData;
8282

@@ -99,7 +99,6 @@ procedure TvCustomRealNodeData.Copy(source: TvBaseNodeData);
9999
Self.WindowState := SourceNodeData.WindowState;
100100
Self.ActionOnExe := SourceNodeData.ActionOnExe;
101101
Self.Hotkey := SourceNodeData.Hotkey;
102-
Self.ActiveHotkey :=SourceNodeData.ActiveHotkey;
103102
Self.Autorun := SourceNodeData.Autorun;
104103
Self.SchMode := SourceNodeData.SchMode;
105104
Self.SchDateTime := SourceNodeData.SchDateTime;
@@ -112,7 +111,6 @@ constructor TvCustomRealNodeData.Create(AType: TvTreeDataType);
112111
FPathIcon := '';
113112
FSchMode := smDisabled;
114113
FSchDateTime := Now;
115-
FActiveHotkey := False;
116114
FHotkey := 0;
117115
FWindowState := 0;
118116
FActionOnExe := aeDefault;
@@ -121,20 +119,6 @@ constructor TvCustomRealNodeData.Create(AType: TvTreeDataType);
121119
FLastAccess := -1;
122120
end;
123121

124-
procedure TvCustomRealNodeData.SetActiveHotkey(const Value: Boolean);
125-
begin
126-
if (Config.ASuiteState <> lsImporting) then
127-
begin
128-
//Old value is true, remove it in HotKeyApp
129-
if (FActiveHotkey) then
130-
ASuiteManager.ListManager.HotKeyItemList.RemoveItem(Self);
131-
//New value is true, add it in HotKeyApp
132-
if (value) then
133-
ASuiteManager.ListManager.HotKeyItemList.AddItem(Self);
134-
end;
135-
FActiveHotkey := Value;
136-
end;
137-
138122
procedure TvCustomRealNodeData.SetSchDateTime(value: TDateTime);
139123
begin
140124
//If value is not a empty TDateTime, set it in FSchDateTime
@@ -268,6 +252,25 @@ procedure TvCustomRealNodeData.SetAutorun(value:TAutorunType);
268252
FAutorun := value;
269253
end;
270254

255+
function TvCustomRealNodeData.GetIsHotkeyActive: Boolean;
256+
begin
257+
Result := Self.Hotkey <> 0;
258+
end;
259+
260+
procedure TvCustomRealNodeData.SetHotkey(AValue: TShortCut);
261+
begin
262+
if (Config.ASuiteState <> lsImporting) then
263+
begin
264+
//Old value is true, remove it in HotKeyApp
265+
if (Self.IsHotkeyActive) then
266+
ASuiteManager.ListManager.HotKeyItemList.RemoveItem(Self);
267+
//New value is true, add it in HotKeyApp
268+
if (AValue <> 0) then
269+
ASuiteManager.ListManager.HotKeyItemList.AddItem(Self);
270+
end;
271+
FHotkey := AValue;
272+
end;
273+
271274
procedure TvCustomRealNodeData.SetLastAccess(const Value: Int64);
272275
begin
273276
FLastAccess := Value;

Library/VirtualTree.Events.pas

-1
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,6 @@ procedure TVirtualTreeEvents.DoLoadNode(Sender: TBaseVirtualTree; Node: PVirtual
746746
//New node can't use same hotkey of old node
747747
if DataDest.Data is TvCustomRealNodeData then
748748
begin
749-
TvCustomRealNodeData(DataDest.Data).ActiveHotkey := False;
750749
TvCustomRealNodeData(DataDest.Data).Hotkey := 0;
751750
end;
752751

Utilities/Utility.XML.pas

-2
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,6 @@ procedure LoadXMLSettings(XMLDoc: TXMLDocument);
372372
//Main Form - Position and size
373373
Config.HoldSize := GetBoolPropertyXML(Node, 'HoldSize', false);
374374
Config.AlwaysOnTop := GetBoolPropertyXML(Node, 'MainOnTop', false);
375-
//Hotkey
376-
Config.HotKey := GetBoolPropertyXML(Node, 'ActiveHotKey',true);
377375
//Window Hotkey
378376
Config.WindowHotkey := ShortCutToText(XMLToShortcut(Node, 'HotKeyCode', 'HotKeyModifier'));
379377
//Menu Hotkey

languages/ASuite.pot

-4
Original file line numberDiff line numberDiff line change
@@ -635,10 +635,6 @@ msgstr ""
635635
msgid "Hide this software from menu"
636636
msgstr ""
637637

638-
#: tfrmadvancedpropertypage.cbhotkey.caption
639-
msgid "Active hotkey"
640-
msgstr ""
641-
642638
#: tfrmadvancedpropertypage.cbshortcutdesktop.caption
643639
msgid "Create shortcut on desktop when ASuite is running"
644640
msgstr ""

0 commit comments

Comments
 (0)