mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 18:39:10 +02:00
IDE: adding Export/Import key mapping, issue #39797
This commit is contained in:
parent
59fbc4f9ee
commit
0b9dbd2a6d
@ -208,6 +208,34 @@ object EditorKeymappingOptionsFrame: TEditorKeymappingOptionsFrame
|
|||||||
Caption = 'CommandLabel'
|
Caption = 'CommandLabel'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
|
object ExportButton: TButton
|
||||||
|
AnchorSideLeft.Control = ClearButton
|
||||||
|
AnchorSideLeft.Side = asrBottom
|
||||||
|
AnchorSideTop.Control = ClearButton
|
||||||
|
AnchorSideTop.Side = asrCenter
|
||||||
|
Left = 288
|
||||||
|
Height = 25
|
||||||
|
Top = 0
|
||||||
|
Width = 75
|
||||||
|
BorderSpacing.Left = 20
|
||||||
|
Caption = 'ExportButton'
|
||||||
|
OnClick = ExportButtonClick
|
||||||
|
TabOrder = 3
|
||||||
|
end
|
||||||
|
object ImportButton: TButton
|
||||||
|
AnchorSideLeft.Control = ExportButton
|
||||||
|
AnchorSideLeft.Side = asrBottom
|
||||||
|
AnchorSideTop.Control = ExportButton
|
||||||
|
AnchorSideTop.Side = asrCenter
|
||||||
|
Left = 369
|
||||||
|
Height = 25
|
||||||
|
Top = 0
|
||||||
|
Width = 75
|
||||||
|
BorderSpacing.Left = 6
|
||||||
|
Caption = 'ImportButton'
|
||||||
|
OnClick = ImportButtonClick
|
||||||
|
TabOrder = 4
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
object PopupMenu1: TPopupMenu
|
object PopupMenu1: TPopupMenu
|
||||||
|
@ -37,7 +37,7 @@ uses
|
|||||||
IDEOptEditorIntf, IDEImagesIntf, SrcEditorIntf, IDECommands,
|
IDEOptEditorIntf, IDEImagesIntf, SrcEditorIntf, IDECommands,
|
||||||
// IDE
|
// IDE
|
||||||
EditorOptions, LazarusIDEStrConsts, editor_general_options,
|
EditorOptions, LazarusIDEStrConsts, editor_general_options,
|
||||||
KeymapSchemeDlg, KeyMapping, KeyMapShortCutDlg;
|
KeymapSchemeDlg, KeyMapping, KeyMapShortCutDlg, Laz2_XMLCfg;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -45,6 +45,8 @@ type
|
|||||||
|
|
||||||
TEditorKeymappingOptionsFrame = class(TAbstractIDEOptionsEditor)
|
TEditorKeymappingOptionsFrame = class(TAbstractIDEOptionsEditor)
|
||||||
BtnPanel: TPanel;
|
BtnPanel: TPanel;
|
||||||
|
ExportButton: TButton;
|
||||||
|
ImportButton: TButton;
|
||||||
ChooseSchemeButton: TBitBtn;
|
ChooseSchemeButton: TBitBtn;
|
||||||
ClearButton: TBitBtn;
|
ClearButton: TBitBtn;
|
||||||
EditButton: TBitBtn;
|
EditButton: TBitBtn;
|
||||||
@ -67,6 +69,8 @@ type
|
|||||||
procedure EditMenuItemClick(Sender: TObject);
|
procedure EditMenuItemClick(Sender: TObject);
|
||||||
procedure ChooseSchemeButtonClick(Sender: TObject);
|
procedure ChooseSchemeButtonClick(Sender: TObject);
|
||||||
procedure ClearButtonClick(Sender: TObject);
|
procedure ClearButtonClick(Sender: TObject);
|
||||||
|
procedure ExportButtonClick(Sender: TObject);
|
||||||
|
procedure ImportButtonClick(Sender: TObject);
|
||||||
procedure FilterEditAfterFilter(Sender: TObject);
|
procedure FilterEditAfterFilter(Sender: TObject);
|
||||||
function FilterEditFilterItem(ItemData: Pointer; out Done: Boolean): Boolean;
|
function FilterEditFilterItem(ItemData: Pointer; out Done: Boolean): Boolean;
|
||||||
procedure FilterEditKeyPress(Sender: TObject; var {%H-}Key: char);
|
procedure FilterEditKeyPress(Sender: TObject; var {%H-}Key: char);
|
||||||
@ -229,6 +233,72 @@ begin
|
|||||||
ClearCommandMapping(TreeView.Selected)
|
ClearCommandMapping(TreeView.Selected)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TEditorKeymappingOptionsFrame.ExportButtonClick(Sender: TObject);
|
||||||
|
var
|
||||||
|
dlg : TSaveDialog;
|
||||||
|
xml : TXMLConfig;
|
||||||
|
exp : TKeyCommandRelationList;
|
||||||
|
i : integer;
|
||||||
|
begin
|
||||||
|
xml := nil;
|
||||||
|
dlg := TSaveDialog.Create(Self);
|
||||||
|
exp := TKeyCommandRelationList.Create;
|
||||||
|
try
|
||||||
|
if not dlg.Execute then Exit;
|
||||||
|
xml := TXMLConfig.CreateClean(dlg.FileName);
|
||||||
|
exp.Assign(FEditingKeyMap);
|
||||||
|
for i:=0 to exp.RelationCount-1 do begin
|
||||||
|
exp.Relations[i].SkipSaving := false;
|
||||||
|
// default must be reset to zero, otherwise it will not be saved by SaveToXmlConfig
|
||||||
|
// aveToXMLConfig omits any shortcuts matching defaults
|
||||||
|
exp.Relations[i].DefaultShortcutA := CleanIDEShortCut;
|
||||||
|
exp.Relations[i].DefaultShortcutB := CleanIDEShortCut;
|
||||||
|
end;
|
||||||
|
exp.SaveToXMLConfig(xml, 'KeyMapping/');
|
||||||
|
finally
|
||||||
|
exp.Free;
|
||||||
|
dlg.Free;
|
||||||
|
xml.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TEditorKeymappingOptionsFrame.ImportButtonClick(Sender: TObject);
|
||||||
|
var
|
||||||
|
dlg : TOpenDialog;
|
||||||
|
xml : TXMLConfig;
|
||||||
|
exp : TKeyCommandRelationList;
|
||||||
|
src : TKeyCommandRelation;
|
||||||
|
dst : TKeyCommandRelation;
|
||||||
|
i : integer;
|
||||||
|
begin
|
||||||
|
xml := nil;
|
||||||
|
dlg := TSaveDialog.Create(Self);
|
||||||
|
exp := TKeyCommandRelationList.Create;
|
||||||
|
try
|
||||||
|
if not dlg.Execute then Exit;
|
||||||
|
xml := TXMLConfig.Create(dlg.FileName);
|
||||||
|
exp.DefineCommandCategories; // default Relations
|
||||||
|
exp.LoadFromXMLConfig(xml, 'KeyMapping/');
|
||||||
|
for i:=0 to exp.RelationCount-1 do begin
|
||||||
|
src := exp.Relations[i];
|
||||||
|
dst := FEditingKeyMap.FindByCommand(src.Command);
|
||||||
|
if Assigned(dst) then begin
|
||||||
|
dst.ShortcutA := src.ShortcutA;
|
||||||
|
dst.ShortcutB := src.ShortcutB;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
FillKeyMappingTreeView;
|
||||||
|
fModified:=True;
|
||||||
|
UpdateSchemeLabel;
|
||||||
|
UpdateConflictTree;
|
||||||
|
finally
|
||||||
|
exp.Free;
|
||||||
|
dlg.Free;
|
||||||
|
xml.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TEditorKeymappingOptionsFrame.FilterEditFilterItem(ItemData: Pointer;
|
function TEditorKeymappingOptionsFrame.FilterEditFilterItem(ItemData: Pointer;
|
||||||
out Done: Boolean): Boolean;
|
out Done: Boolean): Boolean;
|
||||||
var
|
var
|
||||||
@ -388,6 +458,8 @@ begin
|
|||||||
ClearButton.Caption := lisClear;
|
ClearButton.Caption := lisClear;
|
||||||
EditMenuItem.Caption := lisEdit;
|
EditMenuItem.Caption := lisEdit;
|
||||||
ClearMenuItem.Caption := lisClear;
|
ClearMenuItem.Caption := lisClear;
|
||||||
|
ImportButton.Caption := lisImport;
|
||||||
|
ExportButton.Caption := lisExport;
|
||||||
|
|
||||||
TreeView.Images := IDEImages.Images_16;
|
TreeView.Images := IDEImages.Images_16;
|
||||||
ConflictsTreeView.Images := IDEImages.Images_16;
|
ConflictsTreeView.Images := IDEImages.Images_16;
|
||||||
|
Loading…
Reference in New Issue
Block a user