1 | unit UFormMain;
|
---|
2 |
|
---|
3 | {$mode delphi}{$H+}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus,
|
---|
9 | ComCtrls, StdCtrls, ExtCtrls, ActnList, UAcronym, UPersistentForm,
|
---|
10 | URegistry, ULastOpenedList, UListViewSort, UCoolTranslator, Registry,
|
---|
11 | SpecializedList, LazUTF8;
|
---|
12 |
|
---|
13 | type
|
---|
14 |
|
---|
15 | { TFormMain }
|
---|
16 |
|
---|
17 | TFormMain = class(TForm)
|
---|
18 | AProcessImports: TAction;
|
---|
19 | AShowImportFormats: TAction;
|
---|
20 | AShowAbout: TAction;
|
---|
21 | AShowImportSources: TAction;
|
---|
22 | AShowAcronyms: TAction;
|
---|
23 | AShowCategories: TAction;
|
---|
24 | ASettings: TAction;
|
---|
25 | AFileSaveAs: TAction;
|
---|
26 | AFileClose: TAction;
|
---|
27 | AFileSave: TAction;
|
---|
28 | AFileNew: TAction;
|
---|
29 | AFileOpen: TAction;
|
---|
30 | AImport: TAction;
|
---|
31 | AShow: TAction;
|
---|
32 | AExit: TAction;
|
---|
33 | ActionList1: TActionList;
|
---|
34 | CheckBoxExactMath: TCheckBox;
|
---|
35 | CoolTranslator1: TCoolTranslator;
|
---|
36 | ImageList1: TImageList;
|
---|
37 | LastOpenedList1: TLastOpenedList;
|
---|
38 | ListViewAcronyms: TListView;
|
---|
39 | ListViewFilter1: TListViewFilter;
|
---|
40 | ListViewSort1: TListViewSort;
|
---|
41 | MainMenu1: TMainMenu;
|
---|
42 | MenuItem1: TMenuItem;
|
---|
43 | MenuItem10: TMenuItem;
|
---|
44 | MenuItem11: TMenuItem;
|
---|
45 | MenuItem12: TMenuItem;
|
---|
46 | MenuItem13: TMenuItem;
|
---|
47 | MenuItem14: TMenuItem;
|
---|
48 | MenuItem15: TMenuItem;
|
---|
49 | MenuItem16: TMenuItem;
|
---|
50 | MenuItem17: TMenuItem;
|
---|
51 | MenuItem18: TMenuItem;
|
---|
52 | MenuItem19: TMenuItem;
|
---|
53 | MenuItem20: TMenuItem;
|
---|
54 | MenuItem21: TMenuItem;
|
---|
55 | MenuItem22: TMenuItem;
|
---|
56 | MenuItem23: TMenuItem;
|
---|
57 | MenuItem4: TMenuItem;
|
---|
58 | MenuItem5: TMenuItem;
|
---|
59 | MenuItem6: TMenuItem;
|
---|
60 | MenuItem7: TMenuItem;
|
---|
61 | MenuItemOpenRecent: TMenuItem;
|
---|
62 | MenuItem2: TMenuItem;
|
---|
63 | MenuItem3: TMenuItem;
|
---|
64 | MenuItem8: TMenuItem;
|
---|
65 | MenuItem9: TMenuItem;
|
---|
66 | OpenDialog1: TOpenDialog;
|
---|
67 | PersistentForm1: TPersistentForm;
|
---|
68 | PopupMenuTryIcon: TPopupMenu;
|
---|
69 | SaveDialog1: TSaveDialog;
|
---|
70 | TrayIcon1: TTrayIcon;
|
---|
71 | procedure AExitExecute(Sender: TObject);
|
---|
72 | procedure AFileCloseExecute(Sender: TObject);
|
---|
73 | procedure AFileNewExecute(Sender: TObject);
|
---|
74 | procedure AFileOpenExecute(Sender: TObject);
|
---|
75 | procedure AFileSaveAsExecute(Sender: TObject);
|
---|
76 | procedure AFileSaveExecute(Sender: TObject);
|
---|
77 | procedure AImportExecute(Sender: TObject);
|
---|
78 | procedure AProcessImportsExecute(Sender: TObject);
|
---|
79 | procedure ASettingsExecute(Sender: TObject);
|
---|
80 | procedure AShowAboutExecute(Sender: TObject);
|
---|
81 | procedure AShowAcronymsExecute(Sender: TObject);
|
---|
82 | procedure AShowCategoriesExecute(Sender: TObject);
|
---|
83 | procedure AShowExecute(Sender: TObject);
|
---|
84 | procedure AShowImportFormatsExecute(Sender: TObject);
|
---|
85 | procedure AShowImportSourcesExecute(Sender: TObject);
|
---|
86 | procedure CheckBoxExactMathChange(Sender: TObject);
|
---|
87 | procedure EditSearchChange(Sender: TObject);
|
---|
88 | procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
---|
89 | procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
---|
90 | procedure FormCreate(Sender: TObject);
|
---|
91 | procedure FormDestroy(Sender: TObject);
|
---|
92 | procedure FormShow(Sender: TObject);
|
---|
93 | procedure LastOpenedList1Change(Sender: TObject);
|
---|
94 | procedure ListViewAcronymsData(Sender: TObject; Item: TListItem);
|
---|
95 | procedure ListViewAcronymsSelectItem(Sender: TObject; Item: TListItem;
|
---|
96 | Selected: Boolean);
|
---|
97 | procedure ListViewFilter1Change(Sender: TObject);
|
---|
98 | function ListViewSort1CompareItem(Item1, Item2: TObject): Integer;
|
---|
99 | procedure ListViewSort1Filter(ListViewSort: TListViewSort);
|
---|
100 | procedure TrayIcon1Click(Sender: TObject);
|
---|
101 | private
|
---|
102 | FAlwaysOnTop: Boolean;
|
---|
103 | RegistryContext: TRegistryContext;
|
---|
104 | ProjectClosed: Boolean;
|
---|
105 | procedure SetAlwaysOnTop(AValue: Boolean);
|
---|
106 | procedure FilterList(List: TListObject);
|
---|
107 | procedure OpenRecentClick(Sender: TObject);
|
---|
108 | procedure UpdateAcronymsList;
|
---|
109 | procedure UpdateInterface;
|
---|
110 | procedure LoadConfig;
|
---|
111 | procedure SaveConfig;
|
---|
112 | public
|
---|
113 | AcronymDb: TAcronymDb;
|
---|
114 | function CompareStrings(Strings1, Strings2: TStrings): Boolean;
|
---|
115 | property AlwaysOnTop: Boolean read FAlwaysOnTop write SetAlwaysOnTop;
|
---|
116 | end;
|
---|
117 |
|
---|
118 | var
|
---|
119 | FormMain: TFormMain;
|
---|
120 |
|
---|
121 | implementation
|
---|
122 |
|
---|
123 | {$R *.lfm}
|
---|
124 |
|
---|
125 | uses
|
---|
126 | UFormImport, UFormSettings, UFormCategories, UFormAcronyms,
|
---|
127 | UFormImportSources, UFormAbout, UFormImportFormats;
|
---|
128 |
|
---|
129 | resourcestring
|
---|
130 | SModified = 'modified';
|
---|
131 | SAppExit = 'Application exit';
|
---|
132 | SAppExitQuery = 'Acronyms were modified. Do you want to save them to file before exit?';
|
---|
133 |
|
---|
134 | const
|
---|
135 | ProjectExt = '.adp';
|
---|
136 | DefaultFileName = 'Acronyms' + ProjectExt;
|
---|
137 | DefaultRegKey = '\Software\Acronym Decoder';
|
---|
138 |
|
---|
139 | { TFormMain }
|
---|
140 |
|
---|
141 | procedure TFormMain.FormCreate(Sender: TObject);
|
---|
142 | begin
|
---|
143 | AcronymDb := TAcronymDb.Create;
|
---|
144 | end;
|
---|
145 |
|
---|
146 | procedure TFormMain.EditSearchChange(Sender: TObject);
|
---|
147 | begin
|
---|
148 | UpdateAcronymsList;
|
---|
149 | end;
|
---|
150 |
|
---|
151 | procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
---|
152 | begin
|
---|
153 | PersistentForm1.Save(Self);
|
---|
154 | SaveConfig;
|
---|
155 | end;
|
---|
156 |
|
---|
157 | procedure TFormMain.FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
---|
158 | begin
|
---|
159 | AFileClose.Execute;
|
---|
160 | CanClose := ProjectClosed;
|
---|
161 | end;
|
---|
162 |
|
---|
163 | procedure TFormMain.AExitExecute(Sender: TObject);
|
---|
164 | begin
|
---|
165 | Close;
|
---|
166 | end;
|
---|
167 |
|
---|
168 | procedure TFormMain.AFileCloseExecute(Sender: TObject);
|
---|
169 | var
|
---|
170 | ModalResult: TModalResult;
|
---|
171 | DoClose: Boolean;
|
---|
172 | begin
|
---|
173 | DoClose := False;
|
---|
174 | if Assigned(AcronymDb) then begin
|
---|
175 | if AcronymDb.Modified then begin
|
---|
176 | ModalResult := MessageDlg(SAppExit, SAppExitQuery,
|
---|
177 | mtConfirmation, [mbYes, mbNo, mbCancel], 0);
|
---|
178 | if ModalResult = mrYes then begin
|
---|
179 | AFileSave.Execute;
|
---|
180 | DoClose := True;
|
---|
181 | end
|
---|
182 | else if ModalResult = mrNo then begin
|
---|
183 | DoClose := True;
|
---|
184 | end else ProjectClosed := False;
|
---|
185 | end else DoClose := True;
|
---|
186 | end;
|
---|
187 | if DoClose then begin
|
---|
188 | FreeAndNil(AcronymDb);
|
---|
189 | UpdateAcronymsList;
|
---|
190 | UpdateInterface;
|
---|
191 | ProjectClosed := True;
|
---|
192 | end;
|
---|
193 | end;
|
---|
194 |
|
---|
195 | procedure TFormMain.AFileNewExecute(Sender: TObject);
|
---|
196 | begin
|
---|
197 | AFileClose.Execute;
|
---|
198 | if ProjectClosed then begin
|
---|
199 | AcronymDb := TAcronymDb.Create;
|
---|
200 | AcronymDb.FileName := DefaultFileName;
|
---|
201 | AcronymDb.Acronyms.Clear;
|
---|
202 | UpdateAcronymsList;
|
---|
203 | UpdateInterface;
|
---|
204 | end;
|
---|
205 | end;
|
---|
206 |
|
---|
207 | procedure TFormMain.AFileOpenExecute(Sender: TObject);
|
---|
208 | begin
|
---|
209 | OpenDialog1.DefaultExt := ProjectExt;
|
---|
210 | if Assigned(AcronymDb) then
|
---|
211 | OpenDialog1.FileName := AcronymDb.FileName;
|
---|
212 | if OpenDialog1.Execute then begin
|
---|
213 | AFileClose.Execute;
|
---|
214 | if ProjectClosed then begin
|
---|
215 | AFileNew.Execute;
|
---|
216 | AcronymDb.LoadFromFile(OpenDialog1.FileName);
|
---|
217 | LastOpenedList1.AddItem(OpenDialog1.FileName);
|
---|
218 | UpdateAcronymsList;
|
---|
219 | UpdateInterface;
|
---|
220 | end;
|
---|
221 | end;
|
---|
222 | end;
|
---|
223 |
|
---|
224 | procedure TFormMain.AFileSaveAsExecute(Sender: TObject);
|
---|
225 | begin
|
---|
226 | SaveDialog1.DefaultExt := ProjectExt;
|
---|
227 | SaveDialog1.FileName := AcronymDb.FileName;
|
---|
228 | if SaveDialog1.Execute then begin
|
---|
229 | AcronymDb.SaveToFile(SaveDialog1.FileName);
|
---|
230 | LastOpenedList1.AddItem(SaveDialog1.FileName);
|
---|
231 | UpdateInterface;
|
---|
232 | end;
|
---|
233 | end;
|
---|
234 |
|
---|
235 | procedure TFormMain.AFileSaveExecute(Sender: TObject);
|
---|
236 | begin
|
---|
237 | if FileExists(AcronymDb.FileName) then begin
|
---|
238 | AcronymDb.SaveToFile(AcronymDb.FileName);
|
---|
239 | LastOpenedList1.AddItem(AcronymDb.FileName);
|
---|
240 | UpdateInterface;
|
---|
241 | end else AFileSaveAs.Execute;
|
---|
242 | end;
|
---|
243 |
|
---|
244 | procedure TFormMain.AImportExecute(Sender: TObject);
|
---|
245 | begin
|
---|
246 | FormImport.ShowModal;
|
---|
247 | UpdateAcronymsList;
|
---|
248 | UpdateInterface;
|
---|
249 | end;
|
---|
250 |
|
---|
251 | procedure TFormMain.AProcessImportsExecute(Sender: TObject);
|
---|
252 | var
|
---|
253 | I: Integer;
|
---|
254 | begin
|
---|
255 | for I := 0 to AcronymDb.ImportSources.Count - 1 do
|
---|
256 | TImportSource(AcronymDb.ImportSources[I]).Process;
|
---|
257 | UpdateAcronymsList;
|
---|
258 | UpdateInterface;
|
---|
259 | end;
|
---|
260 |
|
---|
261 | procedure TFormMain.ASettingsExecute(Sender: TObject);
|
---|
262 | begin
|
---|
263 | FormSettings.Load;
|
---|
264 | if FormSettings.ShowModal = mrOk then
|
---|
265 | FormSettings.Save;
|
---|
266 | end;
|
---|
267 |
|
---|
268 | procedure TFormMain.AShowAboutExecute(Sender: TObject);
|
---|
269 | begin
|
---|
270 | FormAbout.ShowModal;
|
---|
271 | end;
|
---|
272 |
|
---|
273 | procedure TFormMain.AShowAcronymsExecute(Sender: TObject);
|
---|
274 | begin
|
---|
275 | FormAcronyms.ShowModal;
|
---|
276 | end;
|
---|
277 |
|
---|
278 | procedure TFormMain.AShowCategoriesExecute(Sender: TObject);
|
---|
279 | begin
|
---|
280 | FormCategories.Categories := AcronymDb.Categories;
|
---|
281 | FormCategories.ShowModal;
|
---|
282 | UpdateAcronymsList;
|
---|
283 | UpdateInterface;
|
---|
284 | end;
|
---|
285 |
|
---|
286 | procedure TFormMain.AShowExecute(Sender: TObject);
|
---|
287 | begin
|
---|
288 | Show;
|
---|
289 | end;
|
---|
290 |
|
---|
291 | procedure TFormMain.AShowImportFormatsExecute(Sender: TObject);
|
---|
292 | begin
|
---|
293 | FormImportFormats.ImportFormats := AcronymDb.ImportFormats;
|
---|
294 | FormImportFormats.ShowModal;
|
---|
295 | UpdateInterface;
|
---|
296 | end;
|
---|
297 |
|
---|
298 | procedure TFormMain.AShowImportSourcesExecute(Sender: TObject);
|
---|
299 | begin
|
---|
300 | FormImportSources.ImportSources := AcronymDb.ImportSources;
|
---|
301 | FormImportSources.ShowModal;
|
---|
302 | UpdateInterface;
|
---|
303 | end;
|
---|
304 |
|
---|
305 | procedure TFormMain.CheckBoxExactMathChange(Sender: TObject);
|
---|
306 | begin
|
---|
307 | UpdateAcronymsList;
|
---|
308 | end;
|
---|
309 |
|
---|
310 | procedure TFormMain.FormDestroy(Sender: TObject);
|
---|
311 | begin
|
---|
312 | FreeAndNil(AcronymDb);
|
---|
313 | end;
|
---|
314 |
|
---|
315 | procedure TFormMain.FormShow(Sender: TObject);
|
---|
316 | begin
|
---|
317 | LoadConfig;
|
---|
318 | PersistentForm1.Load(Self);
|
---|
319 |
|
---|
320 | if (LastOpenedList1.Items.Count > 0) and FileExists(LastOpenedList1.Items[0]) then
|
---|
321 | AcronymDB.LoadFromFile(LastOpenedList1.Items[0]);
|
---|
322 | UpdateAcronymsList;
|
---|
323 | ListViewFilter1.UpdateFromListView(ListViewAcronyms);
|
---|
324 | UpdateInterface;
|
---|
325 | end;
|
---|
326 |
|
---|
327 | procedure TFormMain.LastOpenedList1Change(Sender: TObject);
|
---|
328 | begin
|
---|
329 | LastOpenedList1.LoadToMenuItem(MenuItemOpenRecent, OpenRecentClick);
|
---|
330 | end;
|
---|
331 |
|
---|
332 | procedure TFormMain.ListViewAcronymsData(Sender: TObject; Item: TListItem);
|
---|
333 | begin
|
---|
334 | if Item.Index < ListViewSort1.List.Count then
|
---|
335 | with TAcronymMeaning(ListViewSort1.List[Item.Index]) do begin
|
---|
336 | Item.Caption := Acronym.Name;
|
---|
337 | Item.SubItems.Add(Name);
|
---|
338 | Item.Data := TAcronymMeaning(ListViewSort1.List[Item.Index]);
|
---|
339 | Item.SubItems.Add(Categories.GetString);
|
---|
340 | end;
|
---|
341 | end;
|
---|
342 |
|
---|
343 | procedure TFormMain.ListViewAcronymsSelectItem(Sender: TObject;
|
---|
344 | Item: TListItem; Selected: Boolean);
|
---|
345 | begin
|
---|
346 | UpdateInterface;
|
---|
347 | end;
|
---|
348 |
|
---|
349 | procedure TFormMain.ListViewFilter1Change(Sender: TObject);
|
---|
350 | begin
|
---|
351 | UpdateAcronymsList;
|
---|
352 | end;
|
---|
353 |
|
---|
354 | function TFormMain.ListViewSort1CompareItem(Item1, Item2: TObject): Integer;
|
---|
355 | begin
|
---|
356 | Result := 0;
|
---|
357 | if Assigned(Item1) and Assigned(Item2) and (ListViewSort1.Order <> soNone) then begin
|
---|
358 | with ListViewSort1 do
|
---|
359 | case Column of
|
---|
360 | 0: Result := CompareString(TAcronymMeaning(Item1).Acronym.Name, TAcronymMeaning(Item2).Acronym.Name);
|
---|
361 | 1: Result := CompareString(TAcronymMeaning(Item1).Description, TAcronymMeaning(Item2).Description);
|
---|
362 | 2: Result := CompareString(TAcronymMeaning(Item1).Categories.GetString, TAcronymMeaning(Item2).Categories.GetString);
|
---|
363 | end;
|
---|
364 | if ListViewSort1.Order = soDown then Result := -Result;
|
---|
365 | end else Result := 0;
|
---|
366 | end;
|
---|
367 |
|
---|
368 | procedure TFormMain.ListViewSort1Filter(ListViewSort: TListViewSort);
|
---|
369 | begin
|
---|
370 | AcronymDb.Acronyms.Sort(AcronymComparer);
|
---|
371 | AcronymDb.AssignToList(ListViewSort1.List);
|
---|
372 | FilterList(ListViewSort1.List);
|
---|
373 | end;
|
---|
374 |
|
---|
375 | procedure TFormMain.TrayIcon1Click(Sender: TObject);
|
---|
376 | begin
|
---|
377 | Visible := not Visible;
|
---|
378 | end;
|
---|
379 |
|
---|
380 | function TFormMain.CompareStrings(Strings1, Strings2: TStrings): Boolean;
|
---|
381 | var
|
---|
382 | I: Integer;
|
---|
383 | begin
|
---|
384 | Result := Strings1.Count = Strings2.Count;
|
---|
385 | if not Result then Exit;
|
---|
386 | for I := 0 to Strings1.Count - 1 do
|
---|
387 | if (Strings1[I] <> Strings2[I]) or (Strings1.Objects[I] <> Strings2.Objects[I]) then begin
|
---|
388 | Result := False;
|
---|
389 | Exit;
|
---|
390 | end;
|
---|
391 | end;
|
---|
392 |
|
---|
393 | procedure TFormMain.SetAlwaysOnTop(AValue: Boolean);
|
---|
394 | begin
|
---|
395 | if FAlwaysOnTop = AValue then Exit;
|
---|
396 | FAlwaysOnTop := AValue;
|
---|
397 | if FAlwaysOnTop then FormStyle := fsSystemStayOnTop
|
---|
398 | else FormStyle := fsNormal;
|
---|
399 | end;
|
---|
400 |
|
---|
401 | procedure TFormMain.FilterList(List: TListObject);
|
---|
402 | var
|
---|
403 | I: Integer;
|
---|
404 | FoundCount: Integer;
|
---|
405 | EnteredCount: Integer;
|
---|
406 | begin
|
---|
407 | EnteredCount := ListViewFilter1.TextEnteredCount;
|
---|
408 | for I := List.Count - 1 downto 0 do begin
|
---|
409 | if List.Items[I] is TAcronymMeaning then begin
|
---|
410 | with TAcronymMeaning(List.Items[I]) do begin
|
---|
411 | with ListViewFilter1 do
|
---|
412 | if Visible and (EnteredCount > 0) then begin
|
---|
413 | FoundCount := 0;
|
---|
414 | if CheckBoxExactMath.Checked then begin
|
---|
415 | if TextEnteredColumn(0) and (StringGrid.Cells[0, 0] =
|
---|
416 | TAcronymMeaning(List.Items[I]).Acronym.Name) then Inc(FoundCount);
|
---|
417 | if TextEnteredColumn(1) and (StringGrid.Cells[1, 0] =
|
---|
418 | TAcronymMeaning(List.Items[I]).Name) then Inc(FoundCount);
|
---|
419 | if TextEnteredColumn(2) and (StringGrid.Cells[2, 0] =
|
---|
420 | TAcronymMeaning(List.Items[I]).Categories.GetString) then Inc(FoundCount);
|
---|
421 | end else begin
|
---|
422 | if Pos(UTF8LowerCase(StringGrid.Cells[0, 0]),
|
---|
423 | UTF8LowerCase(TAcronymMeaning(List.Items[I]).Acronym.Name)) > 0 then Inc(FoundCount);
|
---|
424 | if Pos(UTF8LowerCase(StringGrid.Cells[1, 0]),
|
---|
425 | UTF8LowerCase(TAcronymMeaning(List.Items[I]).Name)) > 0 then Inc(FoundCount);
|
---|
426 | if Pos(UTF8LowerCase(StringGrid.Cells[2, 0]),
|
---|
427 | UTF8LowerCase(TAcronymMeaning(List.Items[I]).Categories.GetString)) > 0 then Inc(FoundCount);
|
---|
428 | end;
|
---|
429 | if FoundCount <> EnteredCount then List.Delete(I);
|
---|
430 | end else List.Delete(I);
|
---|
431 | end;
|
---|
432 | end else
|
---|
433 | if TAcronymMeaning(List.Items[I]) is TAcronymMeaning then begin
|
---|
434 | List.Delete(I);
|
---|
435 | end;
|
---|
436 | end;
|
---|
437 | end;
|
---|
438 |
|
---|
439 | procedure TFormMain.OpenRecentClick(Sender: TObject);
|
---|
440 | begin
|
---|
441 | AFileClose.Execute;
|
---|
442 | if ProjectClosed then begin
|
---|
443 | AFileNew.Execute;
|
---|
444 | AcronymDb.LoadFromFile(TMenuItem(Sender).Caption);
|
---|
445 | LastOpenedList1.AddItem(TMenuItem(Sender).Caption);
|
---|
446 | UpdateAcronymsList;
|
---|
447 | UpdateInterface;
|
---|
448 | end;
|
---|
449 | end;
|
---|
450 |
|
---|
451 | procedure TFormMain.UpdateAcronymsList;
|
---|
452 | begin
|
---|
453 | if Assigned(AcronymDb) then begin
|
---|
454 | ListViewSort1.Refresh;
|
---|
455 | end else ListViewSort1.List.Clear;
|
---|
456 | end;
|
---|
457 |
|
---|
458 | procedure TFormMain.UpdateInterface;
|
---|
459 | var
|
---|
460 | Title: string;
|
---|
461 | begin
|
---|
462 | ListViewAcronyms.Enabled := Assigned(AcronymDb);
|
---|
463 | AFileClose.Enabled := Assigned(AcronymDb);
|
---|
464 | AFileSave.Enabled := Assigned(AcronymDb) and AcronymDb.Modified;
|
---|
465 | AFileSaveAs.Enabled := Assigned(AcronymDb);
|
---|
466 | AImport.Enabled := Assigned(AcronymDb);
|
---|
467 | AShowCategories.Enabled := Assigned(AcronymDb);
|
---|
468 | AShowAcronyms.Enabled := Assigned(AcronymDb);
|
---|
469 | AShowImportSources.Enabled := Assigned(AcronymDb);
|
---|
470 |
|
---|
471 | Title := Application.Title;
|
---|
472 | if Assigned(AcronymDb) then Title := Title + ' - ' + ExtractFileName(AcronymDb.FileName);
|
---|
473 | if Assigned(AcronymDb) and AcronymDb.Modified then Title := Title + ' (' + SModified + ')';
|
---|
474 | Caption := Title;
|
---|
475 | end;
|
---|
476 |
|
---|
477 | procedure TFormMain.LoadConfig;
|
---|
478 | begin
|
---|
479 | RegistryContext := RegContext(HKEY_CURRENT_USER, DefaultRegKey);
|
---|
480 | PersistentForm1.RegistryContext := RegistryContext;
|
---|
481 | LastOpenedList1.LoadFromRegistry(RegistryContext);
|
---|
482 |
|
---|
483 | with TRegistryEx.Create do
|
---|
484 | try
|
---|
485 | RootKey := HKEY_CURRENT_USER;
|
---|
486 | OpenKey(DefaultRegKey, True);
|
---|
487 | if ValueExists('LanguageCode') then
|
---|
488 | CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode(ReadStringWithDefault('LanguageCode', ''))
|
---|
489 | else CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode('');
|
---|
490 | AlwaysOnTop := ReadBoolWithDefault('AlwaysOnTop', False);
|
---|
491 | CheckBoxExactMath.Checked := ReadBoolWithDefault('ExactMatch', False);
|
---|
492 | finally
|
---|
493 | Free;
|
---|
494 | end;
|
---|
495 | end;
|
---|
496 |
|
---|
497 | procedure TFormMain.SaveConfig;
|
---|
498 | begin
|
---|
499 | LastOpenedList1.SaveToRegistry(RegistryContext);
|
---|
500 |
|
---|
501 | with TRegistryEx.Create do
|
---|
502 | try
|
---|
503 | RootKey := HKEY_CURRENT_USER;
|
---|
504 | OpenKey(DefaultRegKey, True);
|
---|
505 | if Assigned(CoolTranslator1.Language) and (CoolTranslator1.Language.Code <> '') then
|
---|
506 | WriteString('LanguageCode', CoolTranslator1.Language.Code)
|
---|
507 | else DeleteValue('LanguageCode');
|
---|
508 | WriteBool('AlwaysOnTop', AlwaysOnTop);
|
---|
509 | WriteBool('ExactMatch', CheckBoxExactMath.Checked);
|
---|
510 | finally
|
---|
511 | Free;
|
---|
512 | end;
|
---|
513 | end;
|
---|
514 |
|
---|
515 | end.
|
---|
516 |
|
---|