mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
UPD: Redesign hotkey manager internals (saving temporarily disabled until new file format).
This commit is contained in:
parent
6959f37976
commit
54ea0f6faa
5 changed files with 733 additions and 918 deletions
|
|
@ -147,7 +147,7 @@ implementation
|
|||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
LCLProc, HelpIntfs, uClassesEx, uOSForms, uPixMapManager, uLng,
|
||||
LCLProc, LCLType, HelpIntfs, uClassesEx, uOSForms, uPixMapManager, uLng,
|
||||
uGlobsPaths, uGlobs, uDCUtils, uOSUtils, uHotkeyManager, uKeyboard;
|
||||
|
||||
function ShowConfigToolbar(const aBarFileName: UTF8String; iButtonIndex : Integer = -1): Boolean;
|
||||
|
|
@ -201,23 +201,19 @@ end;
|
|||
|
||||
procedure TfrmConfigToolBar.LoadHotKeyList;
|
||||
var
|
||||
i,j: Integer;
|
||||
lstl:TStringList;
|
||||
i: Integer;
|
||||
HMForm: THMForm;
|
||||
hotkey: THotkey;
|
||||
begin
|
||||
lstl:=TStringList.Create;
|
||||
try
|
||||
for i:=0 to HotMan.HotkeyList.Count - 1 do
|
||||
HMForm := HotMan.Forms.Find('FrmMain');
|
||||
if Assigned(HMForm) then
|
||||
begin
|
||||
for i:=0 to HMForm.Hotkeys.Count - 1 do
|
||||
begin
|
||||
HotMan.GetControlsListBy(HotMan.HotkeyList[i],lstl);
|
||||
for j:=0 to lstl.Count-1 do
|
||||
begin
|
||||
if Assigned(lstl.Objects[j]) then
|
||||
if THotkeyInfoClass(lstl.Objects[j]).ACommand = cHotKeyCommand then
|
||||
FHotKeyList.AddObject(HotMan.HotkeyList[i], lstl.Objects[j]);
|
||||
end; // for j
|
||||
end; // for i
|
||||
finally
|
||||
FreeAndNil(lstl);
|
||||
hotkey := HMForm.Hotkeys[i];
|
||||
if hotkey.Command = cHotKeyCommand then
|
||||
FHotKeyList.AddObject(ShortCutToTextEx(hotkey.Shortcut), hotkey);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
|
@ -272,7 +268,7 @@ begin
|
|||
sHotKey := ktbBar.GetButtonX(IndexButton, MiskX);
|
||||
for i:=0 to FHotKeyList.Count-1 do
|
||||
begin
|
||||
if THotkeyInfoClass(FHotKeyList.Objects[i]).AParams = sHotKey then
|
||||
if THotkey(FHotKeyList.Objects[i]).Params = sHotKey then
|
||||
Result := FHotKeyList.Strings[i];
|
||||
end;
|
||||
end;
|
||||
|
|
@ -529,30 +525,41 @@ begin
|
|||
end;
|
||||
|
||||
procedure TfrmConfigToolBar.btnClearHotKeyClick(Sender: TObject);
|
||||
var
|
||||
HMForm: THMForm;
|
||||
begin
|
||||
edtHotKeys.Text:= EmptyStr;
|
||||
btnClearHotKey.Enabled:= False;
|
||||
ktbBar.SetButtonX(LastToolButton, MiskX, EmptyStr);
|
||||
HotMan.DeleteHotKey(GetHotKey(LastToolButton), 'FrmMain', 'FrmMain');
|
||||
HMForm := HotMan.Forms.Find('FrmMain');
|
||||
if Assigned(HMForm) then
|
||||
HMForm.Hotkeys.Delete(GetHotKey(LastToolButton));
|
||||
end;
|
||||
|
||||
procedure TfrmConfigToolBar.edtHotKeysKeyDown(Sender: TObject; var Key: Word;
|
||||
Shift: TShiftState);
|
||||
var
|
||||
sCommand: String;
|
||||
sShortCut: String;
|
||||
Shortcut: TShortCut;
|
||||
HMForm: THMForm;
|
||||
hotkey: THotkey;
|
||||
begin
|
||||
sShortCut := ShortCutToTextEx(ShortCutEx(Key,GetKeyShiftStateEx));
|
||||
Shortcut := KeyToShortCutEx(Key,GetKeyShiftStateEx);
|
||||
sShortCut := ShortCutToTextEx(Shortcut);
|
||||
edtHotKeys.Text := sShortCut;
|
||||
Key := 0;
|
||||
HintWindow.Hide;
|
||||
if Length(sShortCut) > 0 then
|
||||
if Shortcut <> VK_UNKNOWN then
|
||||
begin
|
||||
// Find hotkey
|
||||
sCommand:= HotMan.FindFirstCommand(sShortCut, 'FrmMain', 'FrmMain');
|
||||
if Length(sCommand) > 0 then
|
||||
HMForm := HotMan.Forms.Find('FrmMain');
|
||||
if Assigned(HMForm) then
|
||||
begin
|
||||
ShowHint(edtHotKeys, Format(rsOptHotkeysShortCutUsedText1, [sShortCut, sCommand]));
|
||||
hotkey := HMForm.Hotkeys.Find(Shortcut);
|
||||
if Assigned(hotkey) then
|
||||
begin
|
||||
ShowHint(edtHotKeys, Format(rsOptHotkeysShortCutUsedText1, [sShortCut, hotkey.Command]));
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
btnClearHotKey.Enabled:= Length(edtHotKeys.Text) <> 0;
|
||||
|
|
@ -566,16 +573,16 @@ end;
|
|||
|
||||
procedure TfrmConfigToolBar.SetButtonHotKey;
|
||||
var
|
||||
sShortCut, sOldCommand: String;
|
||||
sShortCut: String;
|
||||
shortcut: TShortCut;
|
||||
st: TStringList;
|
||||
HMForm: THMForm;
|
||||
hotkey: THotkey;
|
||||
|
||||
//< local function for add hot key,
|
||||
procedure AddHotKeyButton;
|
||||
procedure AddHotKeyButton(Hotkeys: THotkeys);
|
||||
begin
|
||||
HotMan.AddHotKeyEx(sShortCut,
|
||||
cHotKeyCommand,
|
||||
sShortCut,
|
||||
'FrmMain', 'FrmMain');
|
||||
Hotkeys.Add(shortcut, cHotKeyCommand, sShortCut);
|
||||
ktbBar.SetButtonX(LastToolButton, MiskX, edtHotKeys.Text);
|
||||
end;
|
||||
|
||||
|
|
@ -585,25 +592,29 @@ begin
|
|||
else
|
||||
begin
|
||||
sShortCut := edtHotKeys.Text;
|
||||
sOldCommand := HotMan.FindFirstCommand(sShortCut, 'FrmMain', 'FrmMain');
|
||||
if Length(sOldCommand) = 0 then
|
||||
AddHotKeyButton
|
||||
shortCut := TextToShortCutEx(sShortCut);
|
||||
|
||||
HMForm := HotMan.Forms.FindOrCreate('FrmMain');
|
||||
hotkey := HMForm.Hotkeys.Find(shortcut);
|
||||
if not Assigned(hotkey) then
|
||||
begin
|
||||
AddHotKeyButton(HMForm.Hotkeys);
|
||||
end
|
||||
else
|
||||
begin
|
||||
if (sOldCommand = cHotKeyCommand) or
|
||||
(MessageDlg(rsOptHotkeysShortCutUsed,
|
||||
Format(rsOptHotkeysShortCutUsedText1,
|
||||
[sShortCut, sOldCommand]) + LineEnding +
|
||||
Format(rsOptHotkeysShortCutUsedText2,
|
||||
[cHotKeyCommand]),
|
||||
mtConfirmation, mbYesNo, 0) = mrYes) then
|
||||
begin
|
||||
if HotMan.DeleteHotKey(sShortCut, 'FrmMain', 'FrmMain') then
|
||||
begin
|
||||
AddHotKeyButton;
|
||||
end;
|
||||
end;
|
||||
end // Shortcut already used
|
||||
begin
|
||||
// Shortcut already used.
|
||||
if (hotkey.Command = cHotKeyCommand) or
|
||||
(MessageDlg(rsOptHotkeysShortCutUsed,
|
||||
Format(rsOptHotkeysShortCutUsedText1,
|
||||
[sShortCut, hotkey.Command]) + LineEnding +
|
||||
Format(rsOptHotkeysShortCutUsedText2,
|
||||
[cHotKeyCommand]),
|
||||
mtConfirmation, mbYesNo, 0) = mrYes) then
|
||||
begin
|
||||
HMForm.Hotkeys.Delete(shortcut);
|
||||
AddHotKeyButton(HMForm.Hotkeys);
|
||||
end;
|
||||
end;
|
||||
end // Clear shortcut
|
||||
end;
|
||||
|
||||
|
|
|
|||
|
|
@ -756,13 +756,13 @@ begin
|
|||
|
||||
|
||||
{ *HotKeys* }
|
||||
HotMan.RegisterHotkeyManager(Self);
|
||||
HotMan.RegisterHotkeyManager(edtCommand);
|
||||
HotMan.Register(Self);
|
||||
HotMan.Register(edtCommand);
|
||||
|
||||
if (HotMan.HotkeyList.Count = 0) or (CompareText(HotMan.Version, hkVersion) <> 0) then
|
||||
if (HotMan.Forms.Count = 0) or (CompareText(HotMan.Version, hkVersion) <> 0) then
|
||||
LoadDefaultHotkeyBindings;
|
||||
// load shortcuts to action list for showing it in menu
|
||||
HotMan.LoadShortCutToActionList(ActionLst);
|
||||
HotMan.LoadShortCutToActionList(ActionLst, 'FrmMain');
|
||||
|
||||
for i:=0 to actionLst.ActionCount -1 do
|
||||
// Have to cast TContainedAction to TAction here, which may be unsafe.
|
||||
|
|
|
|||
305
src/foptions.pas
305
src/foptions.pas
|
|
@ -33,7 +33,7 @@ interface
|
|||
uses
|
||||
SysUtils, Classes, Graphics, Controls, Forms,
|
||||
Dialogs, StdCtrls, ExtCtrls, ComCtrls, Buttons, Spin, ColorBox,
|
||||
EditBtn, Grids, uGlobs, fOptionsFrame;
|
||||
EditBtn, Grids, uGlobs, fOptionsFrame, uHotkeyManager;
|
||||
|
||||
type
|
||||
|
||||
|
|
@ -414,9 +414,14 @@ type
|
|||
FUpdatingTools: Boolean;
|
||||
|
||||
procedure DeleteHotkeyFromGrid(aHotkey: String);
|
||||
procedure UpdateHotkeysForCommand(HMForm: THMForm; RowNr: Integer);
|
||||
procedure ShowExternalToolOptions(ExtTool: TExternalTool);
|
||||
procedure FillSCFilesList;
|
||||
procedure CreateOptionsEditorList;
|
||||
{en
|
||||
Return hotkeys assigned for command for the form and its controls.
|
||||
}
|
||||
procedure GetHotKeyList(HMForm: THMForm; Command: String; HotkeysList: TStringList);
|
||||
public
|
||||
procedure FillLngListBox;
|
||||
procedure FillFontLists;
|
||||
|
|
@ -427,8 +432,6 @@ type
|
|||
procedure LoadConfig;
|
||||
procedure SaveConfig;
|
||||
procedure FillCommandList(lstFilter:string);// fill stringgrid
|
||||
// return assigned hotkey for command
|
||||
function getHotKeyListByCommand(command:string; const res:TStringList):integer;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
|
@ -438,7 +441,7 @@ implementation
|
|||
uses
|
||||
uLng, uGlobsPaths, uPixMapManager, fMain, LCLProc, LCLVersion,
|
||||
uColorExt, uDCUtils, uOSUtils, fColumnsSetConf, uShowMsg, uShowForm,
|
||||
uHotkeyManager, uTypes, StrUtils, uFindEx, uKeyboard,
|
||||
uTypes, StrUtils, uFindEx, uKeyboard,
|
||||
fMaskInputDlg, uSearchTemplate, uMultiArc, uFile, uDebug,
|
||||
fOptionsPlugins, fOptionsToolTips, fOptionsColors;
|
||||
|
||||
|
|
@ -585,18 +588,21 @@ begin
|
|||
end;
|
||||
|
||||
procedure TfrmOptions.btSetHotKeyClick(Sender: TObject);
|
||||
var i: integer;
|
||||
st:TStringList;
|
||||
sForm, sOldCommand, sCommand: string;
|
||||
lslHotKeys:TStringList;
|
||||
sShortCut, sParam: String;
|
||||
procedure lAddHotKey;
|
||||
//< local function for add hot key,
|
||||
begin
|
||||
HotMan.AddHotKey(sShortCut,
|
||||
stgCommands.Cells[stgCmdCommandIndex,stgCommands.Row],
|
||||
sParam,
|
||||
sForm, sForm);
|
||||
var
|
||||
i: integer;
|
||||
sForm, sOldCommand, sCommand: string;
|
||||
lslHotKeys:TStringList;
|
||||
sShortCut, sParam: String;
|
||||
HMForm: THMForm;
|
||||
sc: TShortCut;
|
||||
hotkey: THotkey;
|
||||
|
||||
procedure AddHotKey(hotkeys: THotkeys);
|
||||
//< local function for add hot key,
|
||||
begin
|
||||
hotkeys.Add(sc,
|
||||
stgCommands.Cells[stgCmdCommandIndex,stgCommands.Row],
|
||||
sParam);
|
||||
|
||||
stgHotkeys.RowCount := stgHotkeys.RowCount + 1;
|
||||
stgHotkeys.Cells[0, stgHotkeys.RowCount - 1] := sShortCut;
|
||||
|
|
@ -607,80 +613,60 @@ begin
|
|||
btSetHotKey.Enabled:=false;
|
||||
btClearHotKey.Enabled:=false;
|
||||
|
||||
// refresh selected cell with hotkey
|
||||
lslHotKeys:=TStringList.Create;
|
||||
// set new hotkey string to stringgrid
|
||||
getHotKeyListByCommand(stgCommands.Cells[stgCmdCommandIndex,stgCommands.Row],lslHotKeys);
|
||||
stgCommands.Cells[stgCmdHotkeysIndex, stgCommands.Row]:=StListToStr(';',lslHotKeys);
|
||||
lslHotKeys.Free;
|
||||
UpdateHotkeysForCommand(HMForm, stgCommands.Row);
|
||||
|
||||
// Select the new shortcut in the hotkeys table.
|
||||
stgHotkeys.Row := stgHotkeys.Cols[0].IndexOf(sShortCut);
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
// ToDo: Black list HotKey which can't use
|
||||
//TODO: Realize full version of hotkey's using. Allow to bind hotkeys to any controls.
|
||||
|
||||
if lbxCategories.ItemIndex=-1 then exit;
|
||||
if stgCommands.Row<1 then exit;
|
||||
if lbxCategories.ItemIndex=-1 then exit;
|
||||
if stgCommands.Row<1 then exit;
|
||||
|
||||
sShortCut := edHotKey.Text;
|
||||
sParam := edtParam.Text;
|
||||
sCommand := stgCommands.Cells[stgCmdCommandIndex, stgCommands.Row];
|
||||
sShortCut := edHotKey.Text;
|
||||
sc := TextToShortCutEx(sShortCut);
|
||||
sParam := edtParam.Text;
|
||||
sCommand := stgCommands.Cells[stgCmdCommandIndex, stgCommands.Row];
|
||||
sForm := 'Frm' + lbxCategories.Items[lbxCategories.ItemIndex];
|
||||
|
||||
sForm := 'Frm'+ lbxCategories.Items[lbxCategories.ItemIndex];
|
||||
i:=HotMan.GetHotKeyIndex(sShortCut); // check if this shortcut exists at all
|
||||
if i=-1 then
|
||||
HMForm := HotMan.Forms.FindOrCreate(sForm);
|
||||
|
||||
// Check the form hotkey.
|
||||
hotkey := HMForm.Hotkeys.Find(sc);
|
||||
if not Assigned(hotkey) then
|
||||
begin
|
||||
lAddHotKey; // if not, then save it
|
||||
AddHotKey(HMForm.Hotkeys);
|
||||
end
|
||||
else
|
||||
begin
|
||||
st:=TStringList.Create;
|
||||
HotMan.GetControlsListBy(sShortCut,st); // if it exists, then set list of its forms and objects (categories)
|
||||
begin
|
||||
// Shortcut already used.
|
||||
sOldCommand := hotkey.Command;
|
||||
|
||||
if st.IndexOf(sForm)>-1 then // if exists list of forms then we should delete from it
|
||||
begin
|
||||
// Shortcut already used.
|
||||
// Delete the old shortcut.
|
||||
// If it was assigned to a different command then ask user for confirmation.
|
||||
if (sOldCommand = sCommand) or
|
||||
(MessageDlg(rsOptHotkeysShortCutUsed, // delete command on assigned shortcut
|
||||
Format(rsOptHotkeysShortCutUsedText1, // if another was applied
|
||||
[sShortCut, sOldCommand]) + LineEnding +
|
||||
Format(rsOptHotkeysShortCutUsedText2,
|
||||
[sCommand]),
|
||||
mtConfirmation, mbYesNo, 0) = mrYes) then
|
||||
begin
|
||||
HMForm.Hotkeys.Remove(hotkey);
|
||||
lbPressedHotKeyCommand.Caption:='';// clear message "used by ..."
|
||||
// delete hotkey from hotkeylist
|
||||
DeleteHotkeyFromGrid(sShortCut);
|
||||
|
||||
HotMan.GetCommandsListBy(sShortCut,st); // get string of commands on this sgortcut
|
||||
sOldCommand := Copy(st[0], pos('=',st[0]) + 1, Length(st[0]) - pos('=', st[0])); // select command after '='
|
||||
|
||||
// Delete the old shortcut.
|
||||
// If it was assigned to a different command then ask user for confirmation.
|
||||
if (sOldCommand = sCommand) or
|
||||
(MessageDlg(rsOptHotkeysShortCutUsed, // delete command on assigned shortcut
|
||||
Format(rsOptHotkeysShortCutUsedText1, // if another was applied
|
||||
[sShortCut, sOldCommand]) + LineEnding +
|
||||
Format(rsOptHotkeysShortCutUsedText2,
|
||||
[sCommand]),
|
||||
mtConfirmation, mbYesNo, 0) = mrYes) then
|
||||
begin
|
||||
//** delete hotkey
|
||||
HotMan.DeleteHotKey(sShortCut,sForm,sForm);
|
||||
lbPressedHotKeyCommand.Caption:='';// clear message "used by ..."
|
||||
// delete hotkey from hotkeylist
|
||||
DeleteHotkeyFromGrid(sShortCut);
|
||||
|
||||
// find row in stringgrid where need delete hotkey
|
||||
i:=stgCommands.Cols[stgCmdCommandIndex].IndexOf(sOldCommand);
|
||||
if i>0 then
|
||||
begin
|
||||
lslHotKeys:=TStringList.Create;
|
||||
getHotKeyListByCommand(sOldCommand, lslHotKeys);
|
||||
stgCommands.Cells[stgCmdHotkeysIndex,i]:=StListToStr(';',lslHotKeys);
|
||||
lslHotKeys.Free;
|
||||
end;
|
||||
//** add
|
||||
lAddHotKey;
|
||||
end;
|
||||
end // end if st.IndexOf('frmMain')>-1
|
||||
else
|
||||
begin // add hotkey
|
||||
lAddHotKey;
|
||||
end; //end else if st.IndexOf('frmMain')>-1
|
||||
st.free;
|
||||
end; //end else if i=-1; i:=HotMan.GetHotKeyIndex(sShortCut);
|
||||
// find row in stringgrid where need delete hotkey
|
||||
i := stgCommands.Cols[stgCmdCommandIndex].IndexOf(sOldCommand);
|
||||
if i > 0 then
|
||||
UpdateHotkeysForCommand(HMForm, i);
|
||||
AddHotKey(HMForm.Hotkeys);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrmOptions.cbColorBoxChange(Sender: TObject);
|
||||
|
|
@ -878,34 +864,28 @@ end;
|
|||
|
||||
procedure TfrmOptions.edHotKeyKeyDown(Sender: TObject; var Key: Word;
|
||||
Shift: TShiftState);
|
||||
//<
|
||||
var
|
||||
i: LongInt;
|
||||
st: TStringList;
|
||||
sShortCut: String;
|
||||
vShortCut: TShortCut;
|
||||
ShortCut: TShortCut;
|
||||
HMForm: THMForm;
|
||||
hotkey: THotkey;
|
||||
begin
|
||||
vShortCut := ShortCutEx(Key,GetKeyShiftStateEx);
|
||||
sShortCut := ShortCutToTextEx(vShortCut);
|
||||
edHotKey.Text := sShortCut;
|
||||
ShortCut := KeyToShortCutEx(Key,GetKeyShiftStateEx);
|
||||
edHotKey.Text := ShortCutToTextEx(ShortCut);
|
||||
Key := 0;
|
||||
btSetHotKey.Enabled := (edHotKey.Text <> '');
|
||||
lbPressedHotKeyCommand.Caption:='';
|
||||
|
||||
// find hotkey
|
||||
i:=HotMan.GetHotKeyIndex(sShortCut);
|
||||
if i<>-1 then
|
||||
HMForm := HotMan.Forms.Find('Frm' + lbxCategories.Items[lbxCategories.ItemIndex]);
|
||||
if Assigned(HMForm) then
|
||||
begin
|
||||
st:=TStringList.Create;
|
||||
if HotMan.GetControlsListBy(sShortCut,st)>0 then
|
||||
begin
|
||||
HotMan.GetCommandsListBy(sShortCut,st);
|
||||
lbPressedHotKeyCommand.Caption := rsOptHotkeysUsedBy + ' ' + st[0];
|
||||
btClearHotKey.Enabled := (edHotKey.Text <> '');
|
||||
end;
|
||||
st.free;
|
||||
hotkey := HMForm.Hotkeys.Find(ShortCut);
|
||||
if Assigned(hotkey) then
|
||||
begin
|
||||
// Hotkey already used.
|
||||
lbPressedHotKeyCommand.Caption := rsOptHotkeysUsedBy + ' ' + hotkey.Command;
|
||||
btClearHotKey.Enabled := (edHotKey.Text <> '');
|
||||
end;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
procedure TfrmOptions.FormDestroy(Sender: TObject);
|
||||
|
|
@ -971,6 +951,8 @@ procedure TfrmOptions.stgCommandsSelectCell(Sender: TObject; aCol,
|
|||
var st:TStringList;
|
||||
selcmd: String;
|
||||
i: Integer;
|
||||
sForm: String;
|
||||
HMForm: THMForm;
|
||||
begin
|
||||
|
||||
// clears all controls
|
||||
|
|
@ -981,18 +963,23 @@ begin
|
|||
stgHotkeys.RowCount := stgHotkeys.FixedRows;
|
||||
if aRow<1 then exit;
|
||||
|
||||
selcmd:=stgCommands.Cells[stgCmdCommandIndex,aRow];// get selected command
|
||||
if selcmd<>'' then
|
||||
sForm := 'Frm' + lbxCategories.Items[lbxCategories.ItemIndex];
|
||||
HMForm := HotMan.Forms.Find(sForm);
|
||||
if Assigned(HMForm) then
|
||||
begin
|
||||
st:=TStringList.Create;
|
||||
getHotKeyListByCommand(selcmd,st);
|
||||
stgHotkeys.RowCount := stgHotkeys.RowCount + st.Count;
|
||||
for i := 0 to st.Count - 1 do
|
||||
selcmd:=stgCommands.Cells[stgCmdCommandIndex,aRow];// get selected command
|
||||
if selcmd<>'' then
|
||||
begin
|
||||
stgHotkeys.Cells[0, stgHotkeys.FixedRows + i] := st.Strings[i];
|
||||
stgHotkeys.Cells[1, stgHotkeys.FixedRows + i] := THotkeyInfoClass(st.Objects[i]).AParams;
|
||||
st:=TStringList.Create;
|
||||
GetHotKeyList(HMForm, selcmd, st);
|
||||
stgHotkeys.RowCount := stgHotkeys.RowCount + st.Count;
|
||||
for i := 0 to st.Count - 1 do
|
||||
begin
|
||||
stgHotkeys.Cells[0, stgHotkeys.FixedRows + i] := st.Strings[i];
|
||||
stgHotkeys.Cells[1, stgHotkeys.FixedRows + i] := THotkey(st.Objects[i]).Params;
|
||||
end;
|
||||
st.Free;
|
||||
end;
|
||||
st.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
|
@ -1164,12 +1151,14 @@ var
|
|||
slTmp,slFiltered,slAllCommands,slComments,slHotKey:TStringList;
|
||||
lstr: String;
|
||||
i: Integer;
|
||||
|
||||
HMForm: THMForm;
|
||||
sForm: String;
|
||||
begin
|
||||
slAllCommands:=TStringList.Create();
|
||||
slFiltered:=TStringList.Create();
|
||||
slHotKey:=TStringList.Create();
|
||||
slTmp:=TStringList.Create();
|
||||
sForm:='Frm' + lbxCategories.items.Strings[lbxCategories.ItemIndex];
|
||||
|
||||
Actions.GetCommandsByCategory(lbxCategories.items.Strings[lbxCategories.ItemIndex],slAllCommands);
|
||||
if lstFilter<>'' then // if filter not empty
|
||||
|
|
@ -1196,8 +1185,12 @@ begin
|
|||
|
||||
slTmp.Clear;
|
||||
// getting list of assigned hot key
|
||||
getHotKeyListByCommand(slFiltered.Strings[i],slTmp);
|
||||
slHotKey.add(StListToStr(';',slTmp)); //add to hotkey list created string
|
||||
HMForm := HotMan.Forms.Find(sForm);
|
||||
if Assigned(HMForm) then
|
||||
begin
|
||||
GetHotKeyList(HMForm,slFiltered.Strings[i],slTmp);
|
||||
slHotKey.add(StListToStr(';',slTmp)); //add to hotkey list created string
|
||||
end;
|
||||
end;
|
||||
// add to list NAMES of columns
|
||||
slFiltered.Insert(0, rsOptHotkeysCommands);
|
||||
|
|
@ -1218,27 +1211,23 @@ begin
|
|||
slTmp.Free;
|
||||
end;
|
||||
|
||||
function TfrmOptions.getHotKeyListByCommand(command: string; const res:TStringList):INTEGER;
|
||||
var
|
||||
i,j: Integer;
|
||||
lstl:TStringList;
|
||||
begin
|
||||
lstl:=TStringList.Create;
|
||||
try
|
||||
for i:=0 to HotMan.HotkeyList.Count - 1 do
|
||||
procedure TfrmOptions.GetHotKeyList(HMForm: THMForm; Command: String; HotkeysList: TStringList);
|
||||
procedure AddHotkeys(hotkeys: THotkeys);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
for i := 0 to hotkeys.Count - 1 do
|
||||
begin
|
||||
HotMan.GetControlsListBy(HotMan.HotkeyList[i],lstl);
|
||||
for j:=0 to lstl.Count-1 do
|
||||
begin
|
||||
if Assigned(lstl.Objects[j]) then
|
||||
if command = THotkeyInfoClass(lstl.Objects[j]).ACommand then
|
||||
Res.AddObject(HotMan.HotkeyList[i], lstl.Objects[j]);
|
||||
end; // for j
|
||||
end; // for i
|
||||
finally
|
||||
FreeAndNil(lstl);
|
||||
if hotkeys[i].Command = Command then
|
||||
HotkeysList.AddObject(ShortCutToTextEx(hotkeys[i].Shortcut), hotkeys[i]);
|
||||
end;
|
||||
end;
|
||||
Result:=res.Count;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
AddHotkeys(HMForm.Hotkeys);
|
||||
for i := 0 to HMForm.Controls.Count - 1 do
|
||||
AddHotkeys(HMForm.Controls[i].Hotkeys);
|
||||
end;
|
||||
|
||||
procedure TfrmOptions.FillSCFilesList;
|
||||
|
|
@ -1598,6 +1587,9 @@ var st:TStringList;
|
|||
lstr: String;
|
||||
lslHotKeys: TStringList;
|
||||
sShortCut: String;
|
||||
HMForm: THMForm;
|
||||
hotkey: THotkey;
|
||||
shortCut: TShortCut;
|
||||
begin
|
||||
|
||||
//TODO: delete hotkey.
|
||||
|
|
@ -1606,42 +1598,25 @@ begin
|
|||
if lbxCategories.ItemIndex=-1 then exit;
|
||||
cat:=lbxCategories.Items[lbxCategories.ItemIndex];
|
||||
sShortCut := stgHotkeys.Cells[0, stgHotkeys.Row];
|
||||
if cat='Main' then
|
||||
shortcut := TextToShortCutEx(sShortCut);
|
||||
HMForm := HotMan.Forms.Find('Frm' + cat);
|
||||
if Assigned(HMForm) then
|
||||
begin
|
||||
i:=HotMan.GetHotKeyIndex(sShortCut);
|
||||
if i=-1 then exit; // no hotkey in hotkey manager
|
||||
hotkey := HMForm.Hotkeys.Find(shortcut);
|
||||
if Assigned(hotkey) then
|
||||
begin
|
||||
HMForm.Hotkeys.Remove(hotkey);
|
||||
edtParam.Text:='';
|
||||
edHotKey.Text:='';
|
||||
btClearHotKey.Enabled:=false;
|
||||
btSetHotKey.Enabled:=false;
|
||||
lbPressedHotKeyCommand.Caption:='';
|
||||
|
||||
st:=TStringList.Create;
|
||||
if HotMan.GetControlsListBy(sShortCut,st)>0 then
|
||||
begin
|
||||
// get command assigned for sShortCut
|
||||
HotMan.GetCommandsListBy(sShortCut,st);
|
||||
// if hotkey in hotkeylist, delete him
|
||||
DeleteHotkeyFromGrid(sShortCut);
|
||||
|
||||
HotMan.DeleteHotKey(sShortCut,frmMain);
|
||||
edtParam.Text:='';
|
||||
edHotKey.Text:='';
|
||||
btClearHotKey.Enabled:=false;
|
||||
btSetHotKey.Enabled:=false;
|
||||
lbPressedHotKeyCommand.Caption:='';
|
||||
|
||||
// if hotkey in hotkeylist, delete him
|
||||
DeleteHotkeyFromGrid(sShortCut);
|
||||
|
||||
// if exist assigned command for sShortCut then refresh stringgrid
|
||||
if st.Count>0 then
|
||||
begin
|
||||
lstr:=copy(st[0],pos('=',st[0])+1,Length(st[0])-pos('=',st[0]));
|
||||
i:=stgCommands.Cols[0].IndexOf(lstr);
|
||||
if i>0 then
|
||||
begin
|
||||
lslHotKeys:=TStringList.Create;
|
||||
getHotKeyListByCommand(stgCommands.Cells[stgCmdCommandIndex,i],lslHotKeys);
|
||||
stgCommands.Cells[2,i]:=StListToStr(';',lslHotKeys);
|
||||
lslHotKeys.Free;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
st.free;
|
||||
UpdateHotkeysForCommand(HMForm, stgCommands.Row);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
|
@ -2152,6 +2127,16 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
procedure TfrmOptions.UpdateHotkeysForCommand(HMForm: THMForm; RowNr: Integer);
|
||||
var
|
||||
lslHotKeys:TStringList;
|
||||
begin
|
||||
lslHotKeys:=TStringList.Create;
|
||||
GetHotKeyList(HMForm, stgCommands.Cells[stgCmdCommandIndex,RowNr],lslHotKeys);
|
||||
stgCommands.Cells[stgCmdHotkeysIndex,RowNr]:=StListToStr(';',lslHotKeys);
|
||||
lslHotKeys.Free;
|
||||
end;
|
||||
|
||||
procedure TfrmOptions.ShowExternalToolOptions(ExtTool: TExternalTool);
|
||||
begin
|
||||
with tmpExternalTools[ExtTool] do
|
||||
|
|
|
|||
154
src/uglobs.pas
154
src/uglobs.pas
|
|
@ -322,85 +322,89 @@ uses
|
|||
uDCUtils, fMultiRename, uFile, uDCVersion, uDebug, uFileFunctions;
|
||||
|
||||
procedure LoadDefaultHotkeyBindings;
|
||||
var
|
||||
HMForm: THMForm;
|
||||
begin
|
||||
// Note: Update hkVersion if you change default hotkeys list
|
||||
with HotMan do
|
||||
|
||||
HMForm := HotMan.Forms.FindOrCreate('FrmMain');
|
||||
with HMForm.Hotkeys do
|
||||
begin
|
||||
AddHotKeyEx('Alt+X','cm_Exit','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('F1','cm_About','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('F2','cm_RenameOnly','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('F3','cm_View','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('F4','cm_Edit','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('F5','cm_Copy','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('F6','cm_Rename','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('F7','cm_MakeDir','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('F8','cm_Delete','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Shift+F8','cm_Delete','recyclesettingrev','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Del','cm_Delete','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Shift+Del','cm_Delete','recyclesettingrev','FrmMain','FrmMain');
|
||||
AddHotKeyEx('F9','cm_RunTerm','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+A','cm_MarkMarkAll','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+R','cm_Refresh','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Alt+F7','cm_Search','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+D','cm_DirHotList','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+F3','cm_SortByName','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+F4','cm_SortByExt','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+F6','cm_SortBySize','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+F5','cm_SortByDate','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+M','cm_MultiRename','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Shift+F5','cm_CopySamePanel','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Shift+F6','cm_RenameOnly','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Shift+F4','cm_EditNew','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Shift+F10','cm_ContextMenu','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+H','cm_DirHistory','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+7','cm_ShowCmdLineHistory','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+L','cm_CalculateSpace','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Alt+Shift+F9','cm_TestArchive','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Alt+Shift+Enter','cm_CountDirContent','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Alt+Enter','cm_FileProperties','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+T','cm_NewTab','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+W','cm_RemoveTab','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+Z','cm_EditComment','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+Q','cm_QuickView','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Alt+F5','cm_PackFiles','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Alt+F9','cm_ExtractFiles','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Alt+F1','cm_LeftOpenDrives','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Alt+F2','cm_RightOpenDrives','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+P','cm_AddPathToCmdLine','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Shift+F2','cm_FocusCmdLine','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+Left','cm_TransferLeft','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+Right','cm_TransferRight','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+PgDn','cm_OpenArchive','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+S','cm_QuickSearch','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+F','cm_QuickFilter','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Shift+Ctrl+X','cm_CopyNamesToClip','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Shift+Ctrl+C','cm_CopyFullNamesToClip','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Alt+Z','cm_TargetEqualSource','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+U','cm_Exchange','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Alt+Del','cm_Wipe','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+Tab','cm_NextTab','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Shift+Ctrl+Tab','cm_PrevTab','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+X','cm_CutToClipboard','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+C','cm_CopyToClipboard','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+V','cm_PasteFromClipboard','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+\','cm_ChangeDirToRoot','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+PgUp','cm_ChangeDirToParent','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+Up','cm_OpenDirInNewTab','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+Down','cm_ShowCmdLineHistory','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Ctrl+Enter','cm_AddFilenameToCmdLine','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Shift+Ctrl+Enter','cm_AddPathAndFilenameToCmdLine','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Alt+Left','cm_ViewHistoryPrev','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Alt+Right','cm_ViewHistoryNext','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Alt+Down','cm_DirHistory','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Shift+Ctrl+H','cm_HorizontalFilePanels','','FrmMain','FrmMain');
|
||||
AddHotKeyEx('Alt+V','cm_OperationsViewer','','FrmMain','FrmMain');
|
||||
|
||||
// AddHotKeyEx('','cm_','','FrmMain','FrmMain');
|
||||
|
||||
// Viewer
|
||||
AddHotKeyEx('F1','cm_Viewer_About','','FrmViewer','FrmViewer');
|
||||
AddHotKeyEx('F1','cm_Viewer_DeleteFile','','FrmViewer','FrmViewer');
|
||||
AddIfNotExists('Alt+X','cm_Exit','');
|
||||
AddIfNotExists('F1','cm_About','');
|
||||
AddIfNotExists('F2','cm_RenameOnly','');
|
||||
AddIfNotExists('F3','cm_View','');
|
||||
AddIfNotExists('F4','cm_Edit','');
|
||||
AddIfNotExists('F5','cm_Copy','');
|
||||
AddIfNotExists('F6','cm_Rename','');
|
||||
AddIfNotExists('F7','cm_MakeDir','');
|
||||
AddIfNotExists('F8','cm_Delete','');
|
||||
AddIfNotExists('Shift+F8','cm_Delete','recyclesettingrev');
|
||||
AddIfNotExists('Del','cm_Delete','');
|
||||
AddIfNotExists('Shift+Del','cm_Delete','recyclesettingrev');
|
||||
AddIfNotExists('F9','cm_RunTerm','');
|
||||
AddIfNotExists('Ctrl+A','cm_MarkMarkAll','');
|
||||
AddIfNotExists('Ctrl+R','cm_Refresh','');
|
||||
AddIfNotExists('Alt+F7','cm_Search','');
|
||||
AddIfNotExists('Ctrl+D','cm_DirHotList','');
|
||||
AddIfNotExists('Ctrl+F3','cm_SortByName','');
|
||||
AddIfNotExists('Ctrl+F4','cm_SortByExt','');
|
||||
AddIfNotExists('Ctrl+F6','cm_SortBySize','');
|
||||
AddIfNotExists('Ctrl+F5','cm_SortByDate','');
|
||||
AddIfNotExists('Ctrl+M','cm_MultiRename','');
|
||||
AddIfNotExists('Shift+F5','cm_CopySamePanel','');
|
||||
AddIfNotExists('Shift+F6','cm_RenameOnly','');
|
||||
AddIfNotExists('Shift+F4','cm_EditNew','');
|
||||
AddIfNotExists('Shift+F10','cm_ContextMenu','');
|
||||
AddIfNotExists('Ctrl+H','cm_DirHistory','');
|
||||
AddIfNotExists('Ctrl+7','cm_ShowCmdLineHistory','');
|
||||
AddIfNotExists('Ctrl+L','cm_CalculateSpace','');
|
||||
AddIfNotExists('Alt+Shift+F9','cm_TestArchive','');
|
||||
AddIfNotExists('Alt+Shift+Enter','cm_CountDirContent','');
|
||||
AddIfNotExists('Alt+Enter','cm_FileProperties','');
|
||||
AddIfNotExists('Ctrl+T','cm_NewTab','');
|
||||
AddIfNotExists('Ctrl+W','cm_RemoveTab','');
|
||||
AddIfNotExists('Ctrl+Z','cm_EditComment','');
|
||||
AddIfNotExists('Ctrl+Q','cm_QuickView','');
|
||||
AddIfNotExists('Alt+F5','cm_PackFiles','');
|
||||
AddIfNotExists('Alt+F9','cm_ExtractFiles','');
|
||||
AddIfNotExists('Alt+F1','cm_LeftOpenDrives','');
|
||||
AddIfNotExists('Alt+F2','cm_RightOpenDrives','');
|
||||
AddIfNotExists('Ctrl+P','cm_AddPathToCmdLine','');
|
||||
AddIfNotExists('Shift+F2','cm_FocusCmdLine','');
|
||||
AddIfNotExists('Ctrl+Left','cm_TransferLeft','');
|
||||
AddIfNotExists('Ctrl+Right','cm_TransferRight','');
|
||||
AddIfNotExists('Ctrl+PgDn','cm_OpenArchive','');
|
||||
AddIfNotExists('Ctrl+S','cm_QuickSearch','');
|
||||
AddIfNotExists('Ctrl+F','cm_QuickFilter','');
|
||||
AddIfNotExists('Shift+Ctrl+X','cm_CopyNamesToClip','');
|
||||
AddIfNotExists('Shift+Ctrl+C','cm_CopyFullNamesToClip','');
|
||||
AddIfNotExists('Alt+Z','cm_TargetEqualSource','');
|
||||
AddIfNotExists('Ctrl+U','cm_Exchange','');
|
||||
AddIfNotExists('Alt+Del','cm_Wipe','');
|
||||
AddIfNotExists('Ctrl+Tab','cm_NextTab','');
|
||||
AddIfNotExists('Shift+Ctrl+Tab','cm_PrevTab','');
|
||||
AddIfNotExists('Ctrl+X','cm_CutToClipboard','');
|
||||
AddIfNotExists('Ctrl+C','cm_CopyToClipboard','');
|
||||
AddIfNotExists('Ctrl+V','cm_PasteFromClipboard','');
|
||||
AddIfNotExists('Ctrl+\','cm_ChangeDirToRoot','');
|
||||
AddIfNotExists('Ctrl+PgUp','cm_ChangeDirToParent','');
|
||||
AddIfNotExists('Ctrl+Up','cm_OpenDirInNewTab','');
|
||||
AddIfNotExists('Ctrl+Down','cm_ShowCmdLineHistory','');
|
||||
AddIfNotExists('Ctrl+Enter','cm_AddFilenameToCmdLine','');
|
||||
AddIfNotExists('Shift+Ctrl+Enter','cm_AddPathAndFilenameToCmdLine','');
|
||||
AddIfNotExists('Alt+Left','cm_ViewHistoryPrev','');
|
||||
AddIfNotExists('Alt+Right','cm_ViewHistoryNext','');
|
||||
AddIfNotExists('Alt+Down','cm_DirHistory','');
|
||||
AddIfNotExists('Shift+Ctrl+H','cm_HorizontalFilePanels','');
|
||||
AddIfNotExists('Alt+V','cm_OperationsViewer','');
|
||||
end;
|
||||
|
||||
HMForm := HotMan.Forms.FindOrCreate('FrmViewer');
|
||||
with HMForm.Hotkeys do
|
||||
begin
|
||||
AddIfNotExists('F1','cm_Viewer_About','');
|
||||
AddIfNotExists('F1','cm_Viewer_DeleteFile','');
|
||||
end;
|
||||
end;
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue