mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-27 19:42:28 +02:00
IDE, Keymapping Options: removed key scheme Import
button and related functionality (it was impossible to correctly load such a scheme after IDE restart), last part of issue #40559.
Instead, `Export` button now opens file save dialog in user key scheme subdirectory ('userkeyschemes') of Lazarus settings directory. This behavior is similar to how color schemes are handled. Thus, user is able to edit scheme, export it and then immediately select it if desired (even without IDE restart). To load an external scheme, user should put it to key scheme subdirectory of Lazarus settings directory and select it in Lazarus settings (no IDE restart needed).
This commit is contained in:
parent
18bec6520a
commit
190dc4c999
@ -1872,6 +1872,7 @@ procedure RepairEditorFontSize(var FontSize: integer);
|
|||||||
function BuildBorlandDCIFile(ACustomSynAutoComplete: TCustomSynAutoComplete): Boolean;
|
function BuildBorlandDCIFile(ACustomSynAutoComplete: TCustomSynAutoComplete): Boolean;
|
||||||
function HighlighterList: TEditOptLangList;
|
function HighlighterList: TEditOptLangList;
|
||||||
function ColorSchemeFactory: TColorSchemeFactory;
|
function ColorSchemeFactory: TColorSchemeFactory;
|
||||||
|
function UserKeySchemeDirectory(CreateIfNotExists: Boolean): String;
|
||||||
function UserSchemeDirectory(CreateIfNotExists: Boolean = False): String;
|
function UserSchemeDirectory(CreateIfNotExists: Boolean = False): String;
|
||||||
procedure InitLocale;
|
procedure InitLocale;
|
||||||
|
|
||||||
@ -2597,6 +2598,13 @@ begin
|
|||||||
Result := Singleton;
|
Result := Singleton;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function UserKeySchemeDirectory(CreateIfNotExists: Boolean): String;
|
||||||
|
begin
|
||||||
|
Result := AppendPathDelim(GetPrimaryConfigPath) + KeyMappingSchemeConfigDirName;
|
||||||
|
If CreateIfNotExists and (not DirectoryExistsUTF8(Result)) then
|
||||||
|
CreateDirUTF8(Result);
|
||||||
|
end;
|
||||||
|
|
||||||
function UserSchemeDirectory(CreateIfNotExists: Boolean): String;
|
function UserSchemeDirectory(CreateIfNotExists: Boolean): String;
|
||||||
begin
|
begin
|
||||||
Result := AppendPathDelim(GetPrimaryConfigPath) + 'userschemes';
|
Result := AppendPathDelim(GetPrimaryConfigPath) + 'userschemes';
|
||||||
|
@ -46,8 +46,8 @@ object EditorKeymappingOptionsFrame: TEditorKeymappingOptionsFrame
|
|||||||
BorderSpacing.Left = 24
|
BorderSpacing.Left = 24
|
||||||
BorderSpacing.Right = 2
|
BorderSpacing.Right = 2
|
||||||
Caption = 'FindKeyButton'
|
Caption = 'FindKeyButton'
|
||||||
OnClick = FindKeyButtonClick
|
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
|
OnClick = FindKeyButtonClick
|
||||||
end
|
end
|
||||||
object ResetKeyFilterBtn: TSpeedButton
|
object ResetKeyFilterBtn: TSpeedButton
|
||||||
AnchorSideTop.Control = FindKeyButton
|
AnchorSideTop.Control = FindKeyButton
|
||||||
@ -95,8 +95,8 @@ object EditorKeymappingOptionsFrame: TEditorKeymappingOptionsFrame
|
|||||||
RowSelect = True
|
RowSelect = True
|
||||||
ScrollBars = ssAutoBoth
|
ScrollBars = ssAutoBoth
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
OnMouseDown = ConflictsTreeViewMouseDown
|
|
||||||
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoRightClickSelect, tvoRowSelect, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw]
|
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoRightClickSelect, tvoRowSelect, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw]
|
||||||
|
OnMouseDown = ConflictsTreeViewMouseDown
|
||||||
end
|
end
|
||||||
object KeyMapSplitter: TSplitter
|
object KeyMapSplitter: TSplitter
|
||||||
Cursor = crVSplit
|
Cursor = crVSplit
|
||||||
@ -105,8 +105,8 @@ object EditorKeymappingOptionsFrame: TEditorKeymappingOptionsFrame
|
|||||||
Top = 247
|
Top = 247
|
||||||
Width = 574
|
Width = 574
|
||||||
Align = alBottom
|
Align = alBottom
|
||||||
OnMoved = KeyMapSplitterMoved
|
|
||||||
ResizeAnchor = akBottom
|
ResizeAnchor = akBottom
|
||||||
|
OnMoved = KeyMapSplitterMoved
|
||||||
end
|
end
|
||||||
object TreeView: TTreeView
|
object TreeView: TTreeView
|
||||||
Left = 0
|
Left = 0
|
||||||
@ -122,10 +122,10 @@ object EditorKeymappingOptionsFrame: TEditorKeymappingOptionsFrame
|
|||||||
RowSelect = True
|
RowSelect = True
|
||||||
ScrollBars = ssAutoBoth
|
ScrollBars = ssAutoBoth
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
|
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoRightClickSelect, tvoRowSelect, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw]
|
||||||
OnDblClick = TreeViewDblClick
|
OnDblClick = TreeViewDblClick
|
||||||
OnKeyPress = TreeViewKeyPress
|
OnKeyPress = TreeViewKeyPress
|
||||||
OnSelectionChanged = TreeViewSelectionChanged
|
OnSelectionChanged = TreeViewSelectionChanged
|
||||||
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoRightClickSelect, tvoRowSelect, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw]
|
|
||||||
end
|
end
|
||||||
object BtnPanel: TPanel
|
object BtnPanel: TPanel
|
||||||
Left = 0
|
Left = 0
|
||||||
@ -149,8 +149,8 @@ object EditorKeymappingOptionsFrame: TEditorKeymappingOptionsFrame
|
|||||||
Width = 171
|
Width = 171
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
Caption = 'ChooseSchemeButton'
|
Caption = 'ChooseSchemeButton'
|
||||||
OnClick = ChooseSchemeButtonClick
|
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
|
OnClick = ChooseSchemeButtonClick
|
||||||
end
|
end
|
||||||
object SchemeLabel: TLabel
|
object SchemeLabel: TLabel
|
||||||
AnchorSideLeft.Control = ChooseSchemeButton
|
AnchorSideLeft.Control = ChooseSchemeButton
|
||||||
@ -163,7 +163,6 @@ object EditorKeymappingOptionsFrame: TEditorKeymappingOptionsFrame
|
|||||||
Width = 88
|
Width = 88
|
||||||
BorderSpacing.Around = 8
|
BorderSpacing.Around = 8
|
||||||
Caption = 'SchemeLabel'
|
Caption = 'SchemeLabel'
|
||||||
Color = clDefault
|
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object ClearButton: TBitBtn
|
object ClearButton: TBitBtn
|
||||||
@ -180,8 +179,8 @@ object EditorKeymappingOptionsFrame: TEditorKeymappingOptionsFrame
|
|||||||
BorderSpacing.Left = 8
|
BorderSpacing.Left = 8
|
||||||
BorderSpacing.Bottom = 8
|
BorderSpacing.Bottom = 8
|
||||||
Caption = 'ClearButton'
|
Caption = 'ClearButton'
|
||||||
OnClick = ClearButtonClick
|
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
|
OnClick = ClearButtonClick
|
||||||
end
|
end
|
||||||
object EditButton: TBitBtn
|
object EditButton: TBitBtn
|
||||||
AnchorSideLeft.Control = CommandLabel
|
AnchorSideLeft.Control = CommandLabel
|
||||||
@ -196,8 +195,8 @@ object EditorKeymappingOptionsFrame: TEditorKeymappingOptionsFrame
|
|||||||
BorderSpacing.Right = 8
|
BorderSpacing.Right = 8
|
||||||
BorderSpacing.Bottom = 8
|
BorderSpacing.Bottom = 8
|
||||||
Caption = 'EditButton'
|
Caption = 'EditButton'
|
||||||
OnClick = EditButtonClick
|
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
|
OnClick = EditButtonClick
|
||||||
end
|
end
|
||||||
object CommandLabel: TLabel
|
object CommandLabel: TLabel
|
||||||
AnchorSideLeft.Control = BtnPanel
|
AnchorSideLeft.Control = BtnPanel
|
||||||
@ -209,7 +208,6 @@ object EditorKeymappingOptionsFrame: TEditorKeymappingOptionsFrame
|
|||||||
Width = 105
|
Width = 105
|
||||||
BorderSpacing.Right = 8
|
BorderSpacing.Right = 8
|
||||||
Caption = 'CommandLabel'
|
Caption = 'CommandLabel'
|
||||||
Color = clDefault
|
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object ExportButton: TButton
|
object ExportButton: TButton
|
||||||
@ -224,23 +222,8 @@ object EditorKeymappingOptionsFrame: TEditorKeymappingOptionsFrame
|
|||||||
AutoSize = True
|
AutoSize = True
|
||||||
BorderSpacing.Left = 25
|
BorderSpacing.Left = 25
|
||||||
Caption = 'ExportButton'
|
Caption = 'ExportButton'
|
||||||
OnClick = ExportButtonClick
|
|
||||||
TabOrder = 3
|
TabOrder = 3
|
||||||
end
|
OnClick = ExportButtonClick
|
||||||
object ImportButton: TButton
|
|
||||||
AnchorSideLeft.Control = ExportButton
|
|
||||||
AnchorSideLeft.Side = asrBottom
|
|
||||||
AnchorSideTop.Control = ExportButton
|
|
||||||
AnchorSideTop.Side = asrCenter
|
|
||||||
Left = 467
|
|
||||||
Height = 30
|
|
||||||
Top = 0
|
|
||||||
Width = 115
|
|
||||||
AutoSize = True
|
|
||||||
BorderSpacing.Left = 8
|
|
||||||
Caption = 'ImportButton'
|
|
||||||
OnClick = ImportButtonClick
|
|
||||||
TabOrder = 4
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -47,7 +47,6 @@ type
|
|||||||
TEditorKeymappingOptionsFrame = class(TAbstractIDEOptionsEditor)
|
TEditorKeymappingOptionsFrame = class(TAbstractIDEOptionsEditor)
|
||||||
BtnPanel: TPanel;
|
BtnPanel: TPanel;
|
||||||
ExportButton: TButton;
|
ExportButton: TButton;
|
||||||
ImportButton: TButton;
|
|
||||||
ChooseSchemeButton: TBitBtn;
|
ChooseSchemeButton: TBitBtn;
|
||||||
ClearButton: TBitBtn;
|
ClearButton: TBitBtn;
|
||||||
EditButton: TBitBtn;
|
EditButton: TBitBtn;
|
||||||
@ -71,7 +70,6 @@ type
|
|||||||
procedure ChooseSchemeButtonClick(Sender: TObject);
|
procedure ChooseSchemeButtonClick(Sender: TObject);
|
||||||
procedure ClearButtonClick(Sender: TObject);
|
procedure ClearButtonClick(Sender: TObject);
|
||||||
procedure ExportButtonClick(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);
|
||||||
@ -245,6 +243,7 @@ begin
|
|||||||
dlg := TSaveDialog.Create(Self);
|
dlg := TSaveDialog.Create(Self);
|
||||||
exp := TKeyCommandRelationList.Create;
|
exp := TKeyCommandRelationList.Create;
|
||||||
try
|
try
|
||||||
|
dlg.InitialDir := UserKeySchemeDirectory(True);
|
||||||
dlg.DefaultExt:='xml';
|
dlg.DefaultExt:='xml';
|
||||||
dlg.Filter := dlgFilterXML + '|*.xml|' + dlgFilterAll +'|'+GetAllFilesMask;
|
dlg.Filter := dlgFilterXML + '|*.xml|' + dlgFilterAll +'|'+GetAllFilesMask;
|
||||||
dlg.FilterIndex := 0;
|
dlg.FilterIndex := 0;
|
||||||
@ -266,49 +265,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TEditorKeymappingOptionsFrame.ImportButtonClick(Sender: TObject);
|
|
||||||
var
|
|
||||||
dlg : TOpenDialog;
|
|
||||||
xml : TXMLConfig;
|
|
||||||
exp : TKeyCommandRelationList;
|
|
||||||
src : TKeyCommandRelation;
|
|
||||||
dst : TKeyCommandRelation;
|
|
||||||
i : integer;
|
|
||||||
nm : string;
|
|
||||||
begin
|
|
||||||
xml := nil;
|
|
||||||
dlg := TOpenDialog.Create(Self);
|
|
||||||
exp := TKeyCommandRelationList.Create;
|
|
||||||
try
|
|
||||||
dlg.Filter := dlgFilterXML + '|*.xml|' + dlgFilterAll +'|'+GetAllFilesMask;
|
|
||||||
dlg.FilterIndex := 0;
|
|
||||||
if not dlg.Execute then Exit;
|
|
||||||
xml := TXMLConfig.Create(dlg.FileName);
|
|
||||||
exp.DefineCommandCategories; // default Relations
|
|
||||||
nm := xml.GetValue('Name/Value','');
|
|
||||||
if nm = '' then nm := ExtractFileName(xml.FileName);
|
|
||||||
exp.LoadFromXMLConfig(xml, 'KeyMapping/', false);
|
|
||||||
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;
|
|
||||||
EditorOpts.KeyMappingScheme := Format(lisImported, [nm]);
|
|
||||||
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
|
||||||
@ -468,7 +424,6 @@ 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;
|
ExportButton.Caption := lisExport;
|
||||||
|
|
||||||
TreeView.Images := IDEImages.Images_16;
|
TreeView.Images := IDEImages.Images_16;
|
||||||
|
@ -3035,7 +3035,6 @@ resourcestring
|
|||||||
lisThereAreNoConflictingKeys = 'There are no conflicting keys.';
|
lisThereAreNoConflictingKeys = 'There are no conflicting keys.';
|
||||||
srkmEditForCmd = 'Edit keys of command';
|
srkmEditForCmd = 'Edit keys of command';
|
||||||
lisChooseAKey = 'Choose a key ...';
|
lisChooseAKey = 'Choose a key ...';
|
||||||
lisImported = '%s (imported)';
|
|
||||||
|
|
||||||
//Commands
|
//Commands
|
||||||
srkmecLeft = 'Move cursor left';
|
srkmecLeft = 'Move cursor left';
|
||||||
|
Loading…
Reference in New Issue
Block a user