mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 17:29:31 +02:00
IDE: keymapping: restore cleared keys
git-svn-id: trunk@26383 -
This commit is contained in:
parent
846ae78bbe
commit
d8cca3c0ce
@ -3102,15 +3102,19 @@ var
|
|||||||
|
|
||||||
procedure Load(SubPath: string; out Key, DefaultKey: TIDEShortCut);
|
procedure Load(SubPath: string; out Key, DefaultKey: TIDEShortCut);
|
||||||
begin
|
begin
|
||||||
|
DefaultKey:=CleanIDEShortCut;
|
||||||
if XMLConfig.GetValue(SubPath+'Default',True) then begin
|
if XMLConfig.GetValue(SubPath+'Default',True) then begin
|
||||||
Key:=CleanIDEShortCut;
|
Key:=CleanIDEShortCut;
|
||||||
end else begin
|
end else begin
|
||||||
|
// not default
|
||||||
key.Key1:=XMLConfig.GetValue(SubPath+'Key1',VK_UNKNOWN);
|
key.Key1:=XMLConfig.GetValue(SubPath+'Key1',VK_UNKNOWN);
|
||||||
key.Shift1:=CfgStrToShiftState(XMLConfig.GetValue(SubPath+'Shift1',''));
|
key.Shift1:=CfgStrToShiftState(XMLConfig.GetValue(SubPath+'Shift1',''));
|
||||||
key.Key2:=XMLConfig.GetValue(SubPath+'Key2',VK_UNKNOWN);
|
key.Key2:=XMLConfig.GetValue(SubPath+'Key2',VK_UNKNOWN);
|
||||||
key.Shift2:=CfgStrToShiftState(XMLConfig.GetValue(SubPath+'Shift2',''));
|
key.Shift2:=CfgStrToShiftState(XMLConfig.GetValue(SubPath+'Shift2',''));
|
||||||
|
if CompareIDEShortCuts(@Key,@CleanIDEShortCut)=0 then
|
||||||
|
// this key is empty, mark it so that it differs from default
|
||||||
|
key.Shift2:=[ssShift];
|
||||||
end;
|
end;
|
||||||
DefaultKey:=CleanIDEShortCut;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// LoadFromXMLConfig
|
// LoadFromXMLConfig
|
||||||
@ -3121,7 +3125,6 @@ var
|
|||||||
SubPath: String;
|
SubPath: String;
|
||||||
AVLNode: TAvgLvlTreeNode;
|
AVLNode: TAvgLvlTreeNode;
|
||||||
LoadedKey: TLoadedKeyCommand;
|
LoadedKey: TLoadedKeyCommand;
|
||||||
TheKeyA, TheKeyB: TIDEShortCut;
|
|
||||||
begin
|
begin
|
||||||
//debugln('TKeyCommandRelationList.LoadFromXMLConfig A ');
|
//debugln('TKeyCommandRelationList.LoadFromXMLConfig A ');
|
||||||
FileVersion:=XMLConfig.GetValue(Path+'Version/Value',0);
|
FileVersion:=XMLConfig.GetValue(Path+'Version/Value',0);
|
||||||
@ -3129,6 +3132,7 @@ begin
|
|||||||
|
|
||||||
if FileVersion>5 then begin
|
if FileVersion>5 then begin
|
||||||
Cnt:=XMLConfig.GetValue(Path+'Count',0);
|
Cnt:=XMLConfig.GetValue(Path+'Count',0);
|
||||||
|
// load all keys from the config, this may be more than the current relations
|
||||||
for a:=1 to Cnt do begin
|
for a:=1 to Cnt do begin
|
||||||
SubPath:=Path+'Item'+IntToStr(a)+'/';
|
SubPath:=Path+'Item'+IntToStr(a)+'/';
|
||||||
Name:=XMLConfig.GetValue(SubPath+'Name','');
|
Name:=XMLConfig.GetValue(SubPath+'Name','');
|
||||||
@ -3141,9 +3145,6 @@ begin
|
|||||||
LoadedKey:=TLoadedKeyCommand.Create;
|
LoadedKey:=TLoadedKeyCommand.Create;
|
||||||
LoadedKey.Name:=Name;
|
LoadedKey.Name:=Name;
|
||||||
fLoadedKeyCommands.Add(LoadedKey);
|
fLoadedKeyCommands.Add(LoadedKey);
|
||||||
GetDefaultKeyForCommand(Relations[a].Command,TheKeyA,TheKeyB);
|
|
||||||
LoadedKey.DefaultShortcutA:=TheKeyA;
|
|
||||||
LoadedKey.DefaultShortcutB:=TheKeyB;
|
|
||||||
end;
|
end;
|
||||||
Load(SubPath+'KeyA/',LoadedKey.ShortcutA,LoadedKey.DefaultShortcutA);
|
Load(SubPath+'KeyA/',LoadedKey.ShortcutA,LoadedKey.DefaultShortcutA);
|
||||||
Load(SubPath+'KeyB/',LoadedKey.ShortcutB,LoadedKey.DefaultShortcutB);
|
Load(SubPath+'KeyB/',LoadedKey.ShortcutB,LoadedKey.DefaultShortcutB);
|
||||||
@ -3166,7 +3167,7 @@ begin
|
|||||||
else
|
else
|
||||||
Relations[a].ShortcutB:=LoadedKey.ShortcutB;
|
Relations[a].ShortcutB:=LoadedKey.ShortcutB;
|
||||||
end else begin
|
end else begin
|
||||||
// no value in config => restore default
|
// no value in config => use default
|
||||||
Relations[a].ShortcutA:=Relations[a].DefaultShortcutA;
|
Relations[a].ShortcutA:=Relations[a].DefaultShortcutA;
|
||||||
Relations[a].ShortcutB:=Relations[a].DefaultShortcutB;
|
Relations[a].ShortcutB:=Relations[a].DefaultShortcutB;
|
||||||
end;
|
end;
|
||||||
@ -3221,25 +3222,35 @@ function TKeyCommandRelationList.SaveToXMLConfig(
|
|||||||
procedure Store(const SubPath: string; Key, DefaultKey: TIDEShortCut);
|
procedure Store(const SubPath: string; Key, DefaultKey: TIDEShortCut);
|
||||||
var
|
var
|
||||||
IsDefault: boolean;
|
IsDefault: boolean;
|
||||||
|
s: TShiftState;
|
||||||
begin
|
begin
|
||||||
IsDefault:=CompareIDEShortCuts(@Key,@DefaultKey)=0;
|
IsDefault:=CompareIDEShortCuts(@Key,@DefaultKey)=0;
|
||||||
XMLConfig.SetDeleteValue(SubPath+'Default',IsDefault,True);
|
XMLConfig.SetDeleteValue(SubPath+'Default',IsDefault,True);
|
||||||
if IsDefault then begin
|
if IsDefault then begin
|
||||||
|
// clear values
|
||||||
XMLConfig.SetDeleteValue(SubPath+'Key1',0,0);
|
XMLConfig.SetDeleteValue(SubPath+'Key1',0,0);
|
||||||
XMLConfig.SetDeleteValue(SubPath+'Shift1','','');
|
XMLConfig.SetDeleteValue(SubPath+'Shift1','','');
|
||||||
XMLConfig.SetDeleteValue(SubPath+'Key2',0,0);
|
XMLConfig.SetDeleteValue(SubPath+'Key2',0,0);
|
||||||
XMLConfig.SetDeleteValue(SubPath+'Shift2','','');
|
XMLConfig.SetDeleteValue(SubPath+'Shift2','','');
|
||||||
end else begin
|
end else begin
|
||||||
|
// store values
|
||||||
XMLConfig.SetDeleteValue(SubPath+'Key1',key.Key1,VK_UNKNOWN);
|
XMLConfig.SetDeleteValue(SubPath+'Key1',key.Key1,VK_UNKNOWN);
|
||||||
XMLConfig.SetDeleteValue(SubPath+'Shift1',ShiftStateToCfgStr(key.Shift1),ShiftStateToCfgStr([]));
|
if key.Key1=VK_UNKNOWN then
|
||||||
|
s:=[]
|
||||||
|
else
|
||||||
|
s:=key.Shift1;
|
||||||
|
XMLConfig.SetDeleteValue(SubPath+'Shift1',ShiftStateToCfgStr(s),ShiftStateToCfgStr([]));
|
||||||
XMLConfig.SetDeleteValue(SubPath+'Key2',key.Key2,VK_UNKNOWN);
|
XMLConfig.SetDeleteValue(SubPath+'Key2',key.Key2,VK_UNKNOWN);
|
||||||
XMLConfig.SetDeleteValue(SubPath+'Shift2',ShiftStateToCfgStr(key.Shift2),ShiftStateToCfgStr([]));
|
if key.Key2=VK_UNKNOWN then
|
||||||
|
s:=[]
|
||||||
|
else
|
||||||
|
s:=key.Shift2;
|
||||||
|
XMLConfig.SetDeleteValue(SubPath+'Shift2',ShiftStateToCfgStr(s),ShiftStateToCfgStr([]));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var a: integer;
|
var a: integer;
|
||||||
Name: String;
|
Name: String;
|
||||||
TheKeyA, TheKeyB: TIDEShortCut;
|
|
||||||
AVLNode: TAvgLvlTreeNode;
|
AVLNode: TAvgLvlTreeNode;
|
||||||
LoadedKey: TLoadedKeyCommand;
|
LoadedKey: TLoadedKeyCommand;
|
||||||
Cnt: Integer;
|
Cnt: Integer;
|
||||||
@ -3259,14 +3270,14 @@ begin
|
|||||||
LoadedKey:=TLoadedKeyCommand.Create;
|
LoadedKey:=TLoadedKeyCommand.Create;
|
||||||
LoadedKey.Name:=Name;
|
LoadedKey.Name:=Name;
|
||||||
fLoadedKeyCommands.Add(LoadedKey);
|
fLoadedKeyCommands.Add(LoadedKey);
|
||||||
GetDefaultKeyForCommand(Relations[a].Command,TheKeyA,TheKeyB);
|
LoadedKey.DefaultShortcutA:=Relations[a].DefaultShortcutA;
|
||||||
LoadedKey.DefaultShortcutA:=TheKeyA;
|
LoadedKey.DefaultShortcutB:=Relations[a].DefaultShortcutB;
|
||||||
LoadedKey.DefaultShortcutB:=TheKeyB;
|
|
||||||
end;
|
end;
|
||||||
LoadedKey.ShortcutA:=Relations[a].ShortcutA;
|
LoadedKey.ShortcutA:=Relations[a].ShortcutA;
|
||||||
LoadedKey.ShortcutB:=Relations[a].ShortcutB;
|
LoadedKey.ShortcutB:=Relations[a].ShortcutB;
|
||||||
end;
|
end;
|
||||||
// save keys to config
|
// save keys to config (including the one that were read from the last config
|
||||||
|
// and were not used)
|
||||||
Cnt:=0;
|
Cnt:=0;
|
||||||
AVLNode:=fLoadedKeyCommands.FindLowest;
|
AVLNode:=fLoadedKeyCommands.FindLowest;
|
||||||
while AVLNode<>nil do begin
|
while AVLNode<>nil do begin
|
||||||
|
Loading…
Reference in New Issue
Block a user