Changeset 385 for trunk/LocalPlayer/UKeyBindings.pas
- Timestamp:
- Apr 27, 2021, 6:42:29 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LocalPlayer/UKeyBindings.pas
r293 r385 17 17 ShortCut: TShortCut; 18 18 ShortCut2: TShortCut; 19 DefaultShortCut: TShortCut; 20 DefaultShortCut2: TShortCut; 19 21 function Test(AShortCut: TShortCut): Boolean; 22 procedure Assign(Source: TKeyBinding); 23 procedure SetDefault; 20 24 end; 21 25 … … 23 27 24 28 TKeyBindings = class(TFPGObjectList<TKeyBinding>) 29 private 25 30 public 26 31 function AddItem(const ShortName, FullName: string; ShortCut: TShortCut; ShortCut2: TShortCut = 0): TKeyBinding; overload; … … 29 34 procedure LoadFromRegistry(RootKey: HKEY; Key: string); 30 35 procedure SaveToRegistry(RootKey: HKEY; Key: string); 36 procedure LoadToStrings(Strings: TStrings); 37 procedure Assign(Source: TKeyBindings); 38 procedure ResetToDefault; 31 39 end; 32 40 … … 123 131 end; 124 132 133 procedure TKeyBinding.Assign(Source: TKeyBinding); 134 begin 135 ShortName := Source.ShortName; 136 FullName := Source.FullName; 137 ShortCut := Source.ShortCut; 138 ShortCut2 := Source.ShortCut2; 139 DefaultShortCut := Source.DefaultShortCut; 140 DefaultShortCut2 := Source.DefaultShortCut2; 141 end; 142 143 procedure TKeyBinding.SetDefault; 144 begin 145 ShortCut := DefaultShortCut; 146 ShortCut2 := DefaultShortCut2; 147 end; 148 125 149 { TKeyBindings } 126 150 … … 133 157 Result.ShortCut := ShortCut; 134 158 Result.ShortCut2 := ShortCut2; 159 Result.DefaultShortCut := ShortCut; 160 Result.DefaultShortCut2 := ShortCut2; 135 161 Add(Result); 136 162 end; … … 205 231 Free; 206 232 end; 233 end; 234 235 procedure TKeyBindings.LoadToStrings(Strings: TStrings); 236 var 237 I: Integer; 238 Text: string; 239 begin 240 Strings.Clear; 241 for I := 0 to Count - 1 do begin 242 Text:= ''; 243 if Items[I].ShortCut <> 0 then 244 Text:= Text + ShortCutToText(Items[I].ShortCut); 245 if Items[I].ShortCut2 <> 0 then begin 246 if Text <> '' then Text := Text + ', '; 247 Text:= Text + ShortCutToText(Items[I].ShortCut2); 248 end; 249 if Text <> '' then Text := Items[I].FullName + ' (' + Text + ')' 250 else Text := Items[I].FullName; 251 Strings.Add(Text); 252 end; 253 end; 254 255 procedure TKeyBindings.Assign(Source: TKeyBindings); 256 var 257 I: Integer; 258 begin 259 while Count < Source.Count do 260 Add(TKeyBinding.Create); 261 while Count > Source.Count do 262 Delete(Count - 1); 263 for I := 0 to Count - 1 do 264 Items[I].Assign(Source.Items[I]); 265 end; 266 267 procedure TKeyBindings.ResetToDefault; 268 var 269 I: Integer; 270 begin 271 for I := 0 to Count - 1 do 272 Items[I].SetDefault; 207 273 end; 208 274
Note:
See TracChangeset
for help on using the changeset viewer.