Skip to content

Commit

Permalink
refactoring(hotkey): removed active hotkey property in items (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
salvadorbs authored Jan 4, 2025
1 parent 4c33db6 commit 7193003
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 79 deletions.
19 changes: 10 additions & 9 deletions Frame/Frame.Options.Hotkey.lfm
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ inherited frmHotkeyOptionsPage: TfrmHotkeyOptionsPage
Width = 425
BorderSpacing.Bottom = 4
Caption = 'Enable hotkeys'
OnClick = cbHotKeyClick
ParentFont = False
TabOrder = 0
OnClick = cbHotKeyClick
end
object lblHotkeyWindow: TLabel
Left = 4
Expand Down Expand Up @@ -153,7 +153,15 @@ inherited frmHotkeyOptionsPage: TfrmHotkeyOptionsPage
DefaultNodeHeight = 32
DragOperations = []
Header.AutoSizeIndex = 0
Header.Columns = <
Header.Options = [hoColumnResize, hoDblClickResize, hoDrag, hoVisible, hoHeaderClickAutoSort, hoAutoResizeInclCaption]
Header.ParentFont = False
ParentFont = False
PopupMenu = pmHotkey
TabOrder = 0
TreeOptions.MiscOptions = [toAcceptOLEDrop, toCheckSupport, toFullRepaintOnResize, toInitOnSave, toToggleOnDblClick, toWheelPanning, toEditOnClick]
TreeOptions.PaintOptions = [toPopupMode, toShowDropmark, toThemeAware, toUseBlendedImages, toUseExplorerTheme]
TreeOptions.SelectionOptions = [toFullRowSelect, toRightClickSelect]
Columns = <
item
Position = 0
Text = 'Name'
Expand All @@ -174,13 +182,6 @@ inherited frmHotkeyOptionsPage: TfrmHotkeyOptionsPage
Text = 'Hotkey'
Width = 200
end>
Header.Options = [hoColumnResize, hoDblClickResize, hoDrag, hoVisible, hoHeaderClickAutoSort, hoAutoResizeInclCaption]
ParentFont = False
PopupMenu = pmHotkey
TabOrder = 0
TreeOptions.MiscOptions = [toAcceptOLEDrop, toCheckSupport, toFullRepaintOnResize, toInitOnSave, toToggleOnDblClick, toWheelPanning, toEditOnClick]
TreeOptions.PaintOptions = [toPopupMode, toShowDropmark, toThemeAware, toUseBlendedImages, toUseExplorerTheme]
TreeOptions.SelectionOptions = [toFullRowSelect, toRightClickSelect]
end
end
object pmHotkey: TPopupMenu[2]
Expand Down
4 changes: 0 additions & 4 deletions Frame/Frame.Options.Hotkey.lrj
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
{"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"},
{"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"},
{"hash":77701492,"name":"tfrmhotkeyoptionspage.grpordersoftware.caption","sourcebytes":[72,111,116,107,101,121,115,32,108,105,115,116],"value":"Hotkeys list"},
{"hash":346165,"name":"tfrmhotkeyoptionspage.vstitems.header.columns[0].text","sourcebytes":[78,97,109,101],"value":"Name"},
{"hash":376933,"name":"tfrmhotkeyoptionspage.vstitems.header.columns[1].text","sourcebytes":[84,121,112,101],"value":"Type"},
{"hash":145482249,"name":"tfrmhotkeyoptionspage.vstitems.header.columns[2].text","sourcebytes":[67,97,116,101,103,111,114,121],"value":"Category"},
{"hash":83276233,"name":"tfrmhotkeyoptionspage.vstitems.header.columns[3].text","sourcebytes":[72,111,116,107,101,121],"value":"Hotkey"},
{"hash":114087587,"name":"tfrmhotkeyoptionspage.actproperties.caption","sourcebytes":[80,114,111,112,101,114,116,105,101,115],"value":"Properties"},
{"hash":204660201,"name":"tfrmhotkeyoptionspage.actremovehotkey.caption","sourcebytes":[82,101,109,111,118,101,32,72,111,116,107,101,121],"value":"Remove Hotkey"},
{"hash":79503785,"name":"tfrmhotkeyoptionspage.actedithotkey.caption","sourcebytes":[69,100,105,116,32,72,111,116,107,101,121],"value":"Edit Hotkey"}
Expand Down
4 changes: 1 addition & 3 deletions Frame/Frame.Options.Hotkey.pas
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ procedure TfrmHotkeyOptionsPage.actEditHotkeyExecute(Sender: TObject);
if (ShortCut <> '') then
begin
NodeData.Hotkey := TextToShortCut(ShortCut);
NodeData.ActiveHotkey := True;
NodeData.Changed := True;

if (edtHotkeyMF.Text = ShortCut) then
Expand Down Expand Up @@ -278,8 +277,7 @@ procedure TfrmHotkeyOptionsPage.SaveInHotkeyItemList(
NodeData := TvCustomRealNodeData(TVirtualTreeMethods.GetNodeItemData(Node, ATree));
if Assigned(NodeData) then
begin
NodeData.ActiveHotkey := ATree.IsVisible[Node];
if NodeData.ActiveHotkey then
if ATree.IsVisible[Node] then
AItemList.AddItem(NodeData)
else
AItemList.RemoveItem(NodeData);
Expand Down
18 changes: 4 additions & 14 deletions Frame/Frame.Properties.Advanced.lfm
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ inherited frmAdvancedPropertyPage: TfrmAdvancedPropertyPage
Width = 130
Constraints.MinWidth = 130
ItemHeight = 15
OnChange = cxSchedulerChange
ParentFont = False
Style = csDropDownList
TabOrder = 0
OnChange = cxSchedulerChange
end
object dtpSchDate: TDateTimePicker
Left = 4
Expand Down Expand Up @@ -114,26 +114,16 @@ inherited frmAdvancedPropertyPage: TfrmAdvancedPropertyPage
Font.Style = [fsBold]
ParentFont = False
TabOrder = 1
object cbHotKey: TCheckBox
Left = 4
Height = 19
Top = 4
Width = 194
Caption = 'Active hotkey'
OnClick = cbHotKeyClick
ParentFont = False
TabOrder = 0
end
object edtHotkey: TButtonedEdit
Left = 4
Height = 22
Top = 25
Height = 20
Top = 4
Width = 194
BorderSpacing.Top = 2
CharCase = ecUppercase
ParentFont = False
ReadOnly = True
TabOrder = 1
TabOrder = 0
OnChange = edtHotkeyChange
OnClick = edtHotkeyClick
OnRightButtonClick = edtHotkeyRightButtonClick
Expand Down
1 change: 0 additions & 1 deletion Frame/Frame.Properties.Advanced.lrj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
{"hash":342540,"name":"tfrmadvancedpropertypage.dtpschdate.textfornulldate","sourcebytes":[78,85,76,76],"value":"NULL"},
{"hash":342540,"name":"tfrmadvancedpropertypage.dtpschtime.textfornulldate","sourcebytes":[78,85,76,76],"value":"NULL"},
{"hash":83276233,"name":"tfrmadvancedpropertypage.grphotkey.caption","sourcebytes":[72,111,116,107,101,121],"value":"Hotkey"},
{"hash":22920697,"name":"tfrmadvancedpropertypage.cbhotkey.caption","sourcebytes":[65,99,116,105,118,101,32,104,111,116,107,101,121],"value":"Active hotkey"},
{"hash":90893459,"name":"tfrmadvancedpropertypage.grpothers.caption","sourcebytes":[79,116,104,101,114,115],"value":"Others"},
{"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"},
{"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)"},
Expand Down
18 changes: 4 additions & 14 deletions Frame/Frame.Properties.Advanced.pas
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,9 @@ TfrmAdvancedPropertyPage = class(TfrmBasePropertyPage)
dtpSchDate: TDateTimePicker;
dtpSchTime: TDateTimePicker;
grpHotkey: TGroupBox;

cbHotKey: TCheckBox;

pnlTop: TPanel;
procedure cxSchedulerChange(Sender: TObject);
procedure cbHotKeyClick(Sender: TObject);
procedure edtHotkeyRightButtonClick(Sender: TObject);
procedure edtHotkeyChange(Sender: TObject);
procedure edtHotkeyClick(Sender: TObject);
Expand Down Expand Up @@ -76,11 +74,6 @@ implementation

{ TfrmAdvancedPropertyPage }

procedure TfrmAdvancedPropertyPage.cbHotKeyClick(Sender: TObject);
begin
edtHotkey.Enabled := cbHotKey.Checked;
end;

procedure TfrmAdvancedPropertyPage.cxSchedulerChange(Sender: TObject);
begin
dtpSchDate.Enabled := cxScheduler.ItemIndex = Ord(smOnce);
Expand Down Expand Up @@ -115,9 +108,8 @@ function TfrmAdvancedPropertyPage.InternalLoadData: Boolean;
dtpSchTime.Time := CurrentNodeData.SchDateTime;
cxSchedulerChange(Self);
//Hotkey
cbHotKey.Checked := CurrentNodeData.ActiveHotkey;
edtHotkey.Text := ShortCutToText(CurrentNodeData.Hotkey);
cbHotKeyClick(Self);
if (CurrentNodeData.IsHotkeyActive) then
edtHotkey.Text := ShortCutToText(CurrentNodeData.Hotkey);
//Specific file settings
cbHideSoftware.Checked := CurrentNodeData.HideFromMenu;
if CurrentNodeData.IsFileItem then
Expand Down Expand Up @@ -154,7 +146,6 @@ function TfrmAdvancedPropertyPage.InternalSaveData: Boolean;
CurrentNodeData.SchDateTime := RecodeSecond(CurrentNodeData.SchDateTime, 0);
//Hotkey
CurrentNodeData.Hotkey := TextToShortCut(edtHotkey.Text);
CurrentNodeData.ActiveHotkey := cbHotKey.Checked;
//Specific file settings
CurrentNodeData.HideFromMenu := cbHideSoftware.Checked;
if CurrentNodeData.IsFileItem then
Expand Down Expand Up @@ -191,8 +182,7 @@ procedure TfrmAdvancedPropertyPage.edtHotkeyClick(Sender: TObject);

procedure TfrmAdvancedPropertyPage.edtHotkeyRightButtonClick(Sender: TObject);
begin
if Sender is TButtonedEdit then
TButtonedEdit(Sender).Text := '';
edtHotkey.Text := '';
end;

end.
6 changes: 1 addition & 5 deletions Library/Database.List.pas
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ TSQLtbl_list = class(TOrm) //Table tbl_list
Fscheduler_mode : Byte;
Fscheduler_datetime : TDateTime;
Frun_from_category : Boolean;
FActiveHotkey : Boolean;
Fhotkey : Word;
Fenvironment_vars : RawUTF8;

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

//If enabled, register item's hotkey with new ID
if AData is TvCustomRealNodeData then
if TvCustomRealNodeData(AData).ActiveHotkey then
if TvCustomRealNodeData(AData).IsHotkeyActive then
ASuiteManager.ListManager.HotKeyItemList.AddItem(TvCustomRealNodeData(AData));

SQLFilesData.Free;
Expand Down Expand Up @@ -178,7 +176,6 @@ class procedure TSQLtbl_list.LoadItemsByParentID(Tree: TBaseVirtualTree; ADBMana
SchMode := TSchedulerMode(SQLItemsData.scheduler_mode);
SchDateTime := SQLItemsData.scheduler_datetime;
Hotkey := SQLItemsData.hotkey;
ActiveHotkey := SQLItemsData.activehotkey;
WindowState := SQLItemsData.window_state;
ActionOnExe := TActionOnExecute(SQLItemsData.onlaunch);
end;
Expand Down Expand Up @@ -276,7 +273,6 @@ procedure TSQLtbl_list.LoadDataFromNode(AData: TvBaseNodeData; AIndex, AParentID
Fonlaunch := Ord(ActionOnExe);
Fscheduler_mode := Ord(SchMode);
Fscheduler_datetime := SchDateTime;
FActiveHotkey := ActiveHotkey;
Fhotkey := Hotkey;
end;
//Add file fields
Expand Down
2 changes: 1 addition & 1 deletion Library/Lists.Manager.pas
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ procedure TListManager.RemoveItemFromLists(AItemData: TvCustomRealNodeData);
FMRUList.RemoveItem(AItemData);
FMFUList.RemoveItem(AItemData);
//Remove item from hotkey list
if AItemData.ActiveHotkey then
if AItemData.IsHotkeyActive then
FHotKeyItemList.RemoveItem(AItemData);
//Remove item from scheduler list
if AItemData.SchMode <> smDisabled then
Expand Down
45 changes: 24 additions & 21 deletions Library/NodeDataTypes.Custom.pas
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ TvCustomRealNodeData = class(TvBaseNodeData)
FAutorunPos : Integer; //Position for ASuiteStartUpApp and ASuiteShutdownApp
FSchMode : TSchedulerMode; //0 Disabled, 1 Once, 2 Hourly, 3 Daily, 4 Weekly
FSchDateTime : TDateTime;
FActiveHotkey : Boolean;
FHotkey : Cardinal;
FHotkey : TShortCut;
FLastAccess : Int64;

function GetIsHotkeyActive: Boolean;
procedure SetAutorun(value: TAutorunType);
procedure SetHotkey(AValue: TShortCut);
procedure SetSchMode(value: TSchedulerMode);
procedure SetSchDateTime(value: TDateTime);
procedure SetActiveHotkey(const Value: Boolean);
function GetPathAbsoluteIcon: String;
procedure RunActionOnExe(Action: TActionOnExecute);
protected
Expand Down Expand Up @@ -75,8 +75,8 @@ TvCustomRealNodeData = class(TvBaseNodeData)
property AutorunPos: Integer read FAutorunPos write FAutorunPos;
property SchMode: TSchedulerMode read FSchMode write SetSchMode;
property SchDateTime: TDateTime read FSchDateTime write SetSchDateTime;
property ActiveHotkey: Boolean read FActiveHotkey write SetActiveHotkey;
property Hotkey: Cardinal read FHotkey write FHotkey;
property Hotkey: TShortCut read FHotkey write SetHotkey;
property IsHotkeyActive: Boolean read GetIsHotkeyActive;
end;
PvCustomRealNodeData = ^TvCustomRealNodeData;

Expand All @@ -99,7 +99,6 @@ procedure TvCustomRealNodeData.Copy(source: TvBaseNodeData);
Self.WindowState := SourceNodeData.WindowState;
Self.ActionOnExe := SourceNodeData.ActionOnExe;
Self.Hotkey := SourceNodeData.Hotkey;
Self.ActiveHotkey :=SourceNodeData.ActiveHotkey;
Self.Autorun := SourceNodeData.Autorun;
Self.SchMode := SourceNodeData.SchMode;
Self.SchDateTime := SourceNodeData.SchDateTime;
Expand All @@ -112,7 +111,6 @@ constructor TvCustomRealNodeData.Create(AType: TvTreeDataType);
FPathIcon := '';
FSchMode := smDisabled;
FSchDateTime := Now;
FActiveHotkey := False;
FHotkey := 0;
FWindowState := 0;
FActionOnExe := aeDefault;
Expand All @@ -121,20 +119,6 @@ constructor TvCustomRealNodeData.Create(AType: TvTreeDataType);
FLastAccess := -1;
end;

procedure TvCustomRealNodeData.SetActiveHotkey(const Value: Boolean);
begin
if (Config.ASuiteState <> lsImporting) then
begin
//Old value is true, remove it in HotKeyApp
if (FActiveHotkey) then
ASuiteManager.ListManager.HotKeyItemList.RemoveItem(Self);
//New value is true, add it in HotKeyApp
if (value) then
ASuiteManager.ListManager.HotKeyItemList.AddItem(Self);
end;
FActiveHotkey := Value;
end;

procedure TvCustomRealNodeData.SetSchDateTime(value: TDateTime);
begin
//If value is not a empty TDateTime, set it in FSchDateTime
Expand Down Expand Up @@ -268,6 +252,25 @@ procedure TvCustomRealNodeData.SetAutorun(value:TAutorunType);
FAutorun := value;
end;

function TvCustomRealNodeData.GetIsHotkeyActive: Boolean;
begin
Result := Self.Hotkey <> 0;
end;

procedure TvCustomRealNodeData.SetHotkey(AValue: TShortCut);
begin
if (Config.ASuiteState <> lsImporting) then
begin
//Old value is true, remove it in HotKeyApp
if (Self.IsHotkeyActive) then
ASuiteManager.ListManager.HotKeyItemList.RemoveItem(Self);
//New value is true, add it in HotKeyApp
if (AValue <> 0) then
ASuiteManager.ListManager.HotKeyItemList.AddItem(Self);
end;
FHotkey := AValue;
end;

procedure TvCustomRealNodeData.SetLastAccess(const Value: Int64);
begin
FLastAccess := Value;
Expand Down
1 change: 0 additions & 1 deletion Library/VirtualTree.Events.pas
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,6 @@ procedure TVirtualTreeEvents.DoLoadNode(Sender: TBaseVirtualTree; Node: PVirtual
//New node can't use same hotkey of old node
if DataDest.Data is TvCustomRealNodeData then
begin
TvCustomRealNodeData(DataDest.Data).ActiveHotkey := False;
TvCustomRealNodeData(DataDest.Data).Hotkey := 0;
end;

Expand Down
2 changes: 0 additions & 2 deletions Utilities/Utility.XML.pas
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,6 @@ procedure LoadXMLSettings(XMLDoc: TXMLDocument);
//Main Form - Position and size
Config.HoldSize := GetBoolPropertyXML(Node, 'HoldSize', false);
Config.AlwaysOnTop := GetBoolPropertyXML(Node, 'MainOnTop', false);
//Hotkey
Config.HotKey := GetBoolPropertyXML(Node, 'ActiveHotKey',true);
//Window Hotkey
Config.WindowHotkey := ShortCutToText(XMLToShortcut(Node, 'HotKeyCode', 'HotKeyModifier'));
//Menu Hotkey
Expand Down
4 changes: 0 additions & 4 deletions languages/ASuite.pot
Original file line number Diff line number Diff line change
Expand Up @@ -635,10 +635,6 @@ msgstr ""
msgid "Hide this software from menu"
msgstr ""

#: tfrmadvancedpropertypage.cbhotkey.caption
msgid "Active hotkey"
msgstr ""

#: tfrmadvancedpropertypage.cbshortcutdesktop.caption
msgid "Create shortcut on desktop when ASuite is running"
msgstr ""
Expand Down

0 comments on commit 7193003

Please sign in to comment.