source: tags/1.3.1/Forms/UFormMain.pas

Last change on this file was 112, checked in by chronos, 8 years ago
  • Fixed: Put back accidently removed actions to tray icon popup menu.
File size: 20.4 KB
Line 
1unit UFormMain;
2
3{$mode delphi}{$H+}
4
5interface
6
7uses
8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus,
9 ComCtrls, StdCtrls, ExtCtrls, ActnList, Grids, UAcronym, UPersistentForm,
10 URegistry, ULastOpenedList, UListViewSort, UJobProgressView, UCoolTranslator,
11 Registry, SpecializedList, LazUTF8, LazFileUtils;
12
13type
14
15 { TFormMain }
16
17 TFormMain = class(TForm)
18 AHide: TAction;
19 AExport: TAction;
20 AProcessImports: TAction;
21 AShowImportFormats: TAction;
22 AShowAbout: TAction;
23 AShowImportSources: TAction;
24 AShowAcronyms: TAction;
25 AShowCategories: TAction;
26 ASettings: TAction;
27 AFileSaveAs: TAction;
28 AFileClose: TAction;
29 AFileSave: TAction;
30 AFileNew: TAction;
31 AFileOpen: TAction;
32 AImport: TAction;
33 AShow: TAction;
34 AExit: TAction;
35 ActionList1: TActionList;
36 CheckBoxExactMath: TCheckBox;
37 LastOpenedList1: TLastOpenedList;
38 ListViewAcronyms: TListView;
39 ListViewFilter1: TListViewFilter;
40 ListViewSort1: TListViewSort;
41 MainMenu1: TMainMenu;
42 MenuItem10: TMenuItem;
43 MenuItem11: TMenuItem;
44 MenuItem12: TMenuItem;
45 MenuItem13: TMenuItem;
46 MenuItem14: TMenuItem;
47 MenuItem15: TMenuItem;
48 MenuItem16: TMenuItem;
49 MenuItem17: TMenuItem;
50 MenuItem18: TMenuItem;
51 MenuItem20: TMenuItem;
52 MenuItem21: TMenuItem;
53 MenuItem22: TMenuItem;
54 MenuItem23: TMenuItem;
55 MenuItem24: TMenuItem;
56 MenuItem25: TMenuItem;
57 MenuItemToolbar: TMenuItem;
58 MenuItem4: TMenuItem;
59 MenuItem5: TMenuItem;
60 MenuItem6: TMenuItem;
61 MenuItem7: TMenuItem;
62 MenuItemOpenRecent: TMenuItem;
63 MenuItem8: TMenuItem;
64 MenuItem9: TMenuItem;
65 OpenDialog1: TOpenDialog;
66 Panel1: TPanel;
67 PopupMenuOpenRecent: TPopupMenu;
68 SaveDialog1: TSaveDialog;
69 ToolBar1: TToolBar;
70 ToolButton1: TToolButton;
71 ToolButton10: TToolButton;
72 ToolButton11: TToolButton;
73 ToolButton12: TToolButton;
74 ToolButton2: TToolButton;
75 ToolButton3: TToolButton;
76 ToolButton4: TToolButton;
77 ToolButton5: TToolButton;
78 ToolButton6: TToolButton;
79 ToolButton7: TToolButton;
80 ToolButton8: TToolButton;
81 ToolButton9: TToolButton;
82 procedure AExitExecute(Sender: TObject);
83 procedure AExportExecute(Sender: TObject);
84 procedure AFileCloseExecute(Sender: TObject);
85 procedure AFileNewExecute(Sender: TObject);
86 procedure AFileOpenExecute(Sender: TObject);
87 procedure AFileSaveAsExecute(Sender: TObject);
88 procedure AFileSaveExecute(Sender: TObject);
89 procedure AHideExecute(Sender: TObject);
90 procedure AImportExecute(Sender: TObject);
91 procedure AProcessImportsExecute(Sender: TObject);
92 procedure ASettingsExecute(Sender: TObject);
93 procedure AShowAboutExecute(Sender: TObject);
94 procedure AShowAcronymsExecute(Sender: TObject);
95 procedure AShowCategoriesExecute(Sender: TObject);
96 procedure AShowExecute(Sender: TObject);
97 procedure AShowImportFormatsExecute(Sender: TObject);
98 procedure AShowImportSourcesExecute(Sender: TObject);
99 procedure CheckBoxExactMathChange(Sender: TObject);
100 procedure EditSearchChange(Sender: TObject);
101 procedure FormHide(Sender: TObject);
102 procedure FormShow(Sender: TObject);
103 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
104 procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
105 procedure FormCreate(Sender: TObject);
106 procedure FormDestroy(Sender: TObject);
107 procedure LastOpenedList1Change(Sender: TObject);
108 procedure ListViewAcronymsData(Sender: TObject; Item: TListItem);
109 procedure ListViewAcronymsResize(Sender: TObject);
110 procedure ListViewAcronymsSelectItem(Sender: TObject; Item: TListItem;
111 Selected: Boolean);
112 procedure ListViewFilter1Change(Sender: TObject);
113 procedure ListViewSort1ColumnWidthChanged(Sender: TObject);
114 function ListViewSort1CompareItem(Item1, Item2: TObject): Integer;
115 procedure ListViewSort1Filter(ListViewSort: TListViewSort);
116 procedure MenuItemToolbarClick(Sender: TObject);
117 private
118 RegistryContext: TRegistryContext;
119 ProjectClosed: Boolean;
120 ImportTotalItemCount: Integer;
121 procedure ProcessImportsJob(Job: TJob);
122 procedure FilterList(List: TListObject);
123 procedure OpenRecentClick(Sender: TObject);
124 public
125 procedure LoadConfig;
126 procedure SaveConfig;
127 procedure UpdateAcronymsList;
128 procedure UpdateInterface;
129 procedure ProjectOpen(FileName: string);
130 function CompareStrings(Strings1, Strings2: TStrings): Boolean;
131 end;
132
133var
134 FormMain: TFormMain;
135
136resourcestring
137 SAddedCount = 'Imported %d acronyms. Added %d new.';
138 SProcessImportSources = 'Process import sources';
139
140
141implementation
142
143{$R *.lfm}
144
145uses
146 UFormImport, UFormSettings, UFormCategories, UFormAcronyms, UFormExport,
147 UFormImportSources, UFormAbout, UFormImportFormats, UCore;
148
149resourcestring
150 SModified = 'modified';
151 SAppExit = 'Application exit';
152 SAppExitQuery = 'Acronyms were modified. Do you want to save them to file before exit?';
153
154const
155 ProjectExt = '.adp';
156 DefaultFileName = 'Acronyms' + ProjectExt;
157 RegistryRunKey = '\Software\Microsoft\Windows\CurrentVersion\Run';
158
159{ TFormMain }
160
161procedure TFormMain.FormCreate(Sender: TObject);
162var
163 I: Integer;
164begin
165 for I := 0 to ToolBar1.ButtonCount - 1 do
166 ToolBar1.Buttons[I].Hint := ToolBar1.Buttons[I].Caption;
167end;
168
169procedure TFormMain.EditSearchChange(Sender: TObject);
170begin
171 UpdateAcronymsList;
172end;
173
174procedure TFormMain.FormHide(Sender: TObject);
175begin
176 if Core.InitializeFinished then Core.PersistentForm1.Save(Self);
177 UpdateInterface;
178end;
179
180procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
181begin
182 Core.PersistentForm1.Save(Self);
183 Core.SaveConfig;
184end;
185
186procedure TFormMain.FormCloseQuery(Sender: TObject; var CanClose: boolean);
187begin
188 ProjectClosed := True;
189 AFileClose.Execute;
190 CanClose := ProjectClosed;
191end;
192
193procedure TFormMain.AExitExecute(Sender: TObject);
194begin
195 Close;
196end;
197
198procedure TFormMain.AExportExecute(Sender: TObject);
199begin
200 FormExport := TFormExport.Create(Self);
201 try
202 FormExport.ShowModal;
203 finally
204 FreeAndNil(FormExport);
205 end;
206end;
207
208procedure TFormMain.AFileCloseExecute(Sender: TObject);
209var
210 ModalResult: TModalResult;
211 DoClose: Boolean;
212begin
213 DoClose := False;
214 if Assigned(Core.AcronymDb) then begin
215 if Core.AcronymDb.Modified then begin
216 ModalResult := MessageDlg(SAppExit, SAppExitQuery,
217 mtConfirmation, [mbYes, mbNo, mbCancel], 0);
218 if ModalResult = mrYes then begin
219 AFileSave.Execute;
220 DoClose := True;
221 end
222 else if ModalResult = mrNo then begin
223 DoClose := True;
224 end else ProjectClosed := False;
225 end else DoClose := True;
226 end;
227 if DoClose then begin
228 FreeAndNil(Core.AcronymDb);
229 UpdateAcronymsList;
230 UpdateInterface;
231 ProjectClosed := True;
232 end;
233end;
234
235procedure TFormMain.AFileNewExecute(Sender: TObject);
236begin
237 AFileClose.Execute;
238 if ProjectClosed then begin
239 Core.AcronymDb := TAcronymDb.Create;
240 Core.AcronymDb.FileName := DefaultFileName;
241 Core.AcronymDb.Acronyms.Clear;
242 UpdateAcronymsList;
243 UpdateInterface;
244 end;
245end;
246
247procedure TFormMain.AFileOpenExecute(Sender: TObject);
248begin
249 OpenDialog1.DefaultExt := ProjectExt;
250 if Assigned(Core.AcronymDb) then
251 OpenDialog1.FileName := Core.AcronymDb.FileName;
252 if OpenDialog1.Execute then begin
253 ProjectOpen(OpenDialog1.FileName);
254 end;
255end;
256
257procedure TFormMain.AFileSaveAsExecute(Sender: TObject);
258begin
259 SaveDialog1.DefaultExt := ProjectExt;
260 SaveDialog1.FileName := Core.AcronymDb.FileName;
261 if SaveDialog1.Execute then begin
262 Core.AcronymDb.SaveToFile(SaveDialog1.FileName);
263 LastOpenedList1.AddItem(SaveDialog1.FileName);
264 UpdateInterface;
265 end;
266end;
267
268procedure TFormMain.AFileSaveExecute(Sender: TObject);
269begin
270 if FileExists(Core.AcronymDb.FileName) then begin
271 Core.AcronymDb.SaveToFile(Core.AcronymDb.FileName);
272 LastOpenedList1.AddItem(Core.AcronymDb.FileName);
273 UpdateInterface;
274 end else AFileSaveAs.Execute;
275end;
276
277procedure TFormMain.AHideExecute(Sender: TObject);
278begin
279 Hide;
280end;
281
282procedure TFormMain.AImportExecute(Sender: TObject);
283begin
284 FormImport := TFormImport.Create(Self);
285 try
286 FormImport.ShowModal;
287 UpdateAcronymsList;
288 UpdateInterface;
289 finally
290 FreeAndNil(FormImport);
291 end;
292end;
293
294procedure TFormMain.AProcessImportsExecute(Sender: TObject);
295begin
296 ImportTotalItemCount := 0;
297 Core.AcronymDb.AddedCount := 0;
298 Core.JobProgressView1.AddJob(SProcessImportSources, ProcessImportsJob);
299 Core.JobProgressView1.Start;
300 ShowMessage(Format(SAddedCount, [ImportTotalItemCount, Core.AcronymDb.AddedCount]));
301 UpdateAcronymsList;
302 UpdateInterface;
303end;
304
305procedure TFormMain.ProcessImportsJob(Job: TJob);
306var
307 I: Integer;
308begin
309 for I := 0 to Core.AcronymDb.ImportSources.Count - 1 do
310 with TImportSource(Core.AcronymDb.ImportSources[I]) do
311 if Enabled then begin
312 Process;
313 ImportTotalItemCount := ImportTotalItemCount + ItemCount;
314 Job.Progress.Max := Core.AcronymDb.ImportSources.Count;
315 Job.Progress.Value := I;
316 if Job.Terminate then Break;
317 end;
318end;
319
320procedure TFormMain.ASettingsExecute(Sender: TObject);
321begin
322 FormSettings := TFormSettings.Create(Self);
323 try
324 FormSettings.Load;
325 if FormSettings.ShowModal = mrOk then begin
326 FormSettings.Save;
327 Core.SaveConfig;
328 end;
329 finally
330 FreeAndNil(FormSettings);
331 end;
332end;
333
334procedure TFormMain.AShowAboutExecute(Sender: TObject);
335begin
336 FormAbout := TFormAbout.Create(Self);
337 try
338 FormAbout.ShowModal;
339 finally
340 FreeAndNil(FormAbout);
341 end;
342end;
343
344procedure TFormMain.AShowAcronymsExecute(Sender: TObject);
345begin
346 FormAcronyms := TFormAcronyms.Create(Self);
347 try
348 FormAcronyms.ShowModal;
349 UpdateAcronymsList;
350 UpdateInterface;
351 finally
352 FreeAndNil(FormAcronyms);
353 end;
354end;
355
356procedure TFormMain.AShowCategoriesExecute(Sender: TObject);
357begin
358 FormCategories := TFormCategories.Create(Self);
359 try
360 FormCategories.Categories := Core.AcronymDb.Categories;
361 FormCategories.ShowModal;
362 UpdateAcronymsList;
363 UpdateInterface;
364 finally
365 FreeAndNil(FormCategories);
366 end;
367end;
368
369procedure TFormMain.AShowExecute(Sender: TObject);
370begin
371 Show;
372 BringToFront;
373end;
374
375procedure TFormMain.AShowImportFormatsExecute(Sender: TObject);
376begin
377 FormImportFormats := TFormImportFormats.Create(Self);
378 try
379 FormImportFormats.ImportFormats := Core.AcronymDb.ImportFormats;
380 FormImportFormats.ShowModal;
381 UpdateInterface;
382 finally
383 FreeAndNil(FormImportFormats);
384 end;
385end;
386
387procedure TFormMain.AShowImportSourcesExecute(Sender: TObject);
388begin
389 FormImportSources := TFormImportSources.Create(Self);
390 try
391 FormImportSources.ImportSources := Core.AcronymDb.ImportSources;
392 FormImportSources.ShowModal;
393 UpdateAcronymsList;
394 UpdateInterface;
395 finally
396 FreeAndNil(FormImportSources);
397 end;
398end;
399
400procedure TFormMain.CheckBoxExactMathChange(Sender: TObject);
401begin
402 UpdateAcronymsList;
403end;
404
405procedure TFormMain.FormDestroy(Sender: TObject);
406begin
407end;
408
409procedure TFormMain.FormShow(Sender: TObject);
410begin
411 Core.Initialize;
412
413 if Visible then begin
414 Core.PersistentForm1.Load(Self);
415 UpdateInterface;
416 ListViewFilter1.StringGrid.Col := 1;
417 ListViewFilter1.StringGrid.Col := 0;
418 ListViewFilter1.StringGrid.Row := 0;
419 ListViewFilter1.StringGrid.SetFocus;
420 end;
421end;
422
423procedure TFormMain.LastOpenedList1Change(Sender: TObject);
424begin
425 LastOpenedList1.LoadToMenuItem(MenuItemOpenRecent, OpenRecentClick);
426 LastOpenedList1.LoadToMenuItem(PopupMenuOpenRecent.Items, OpenRecentClick);
427end;
428
429procedure TFormMain.ListViewAcronymsData(Sender: TObject; Item: TListItem);
430begin
431 if Item.Index < ListViewSort1.List.Count then
432 with TAcronymMeaning(ListViewSort1.List[Item.Index]) do begin
433 Item.Caption := Acronym.Name;
434 Item.Data := TAcronymMeaning(ListViewSort1.List[Item.Index]);
435 Item.SubItems.Add(Name);
436 Item.SubItems.Add(Categories.GetString);
437 end;
438end;
439
440procedure TFormMain.ListViewAcronymsResize(Sender: TObject);
441begin
442 ListViewFilter1.UpdateFromListView(ListViewAcronyms);
443end;
444
445procedure TFormMain.ListViewAcronymsSelectItem(Sender: TObject;
446 Item: TListItem; Selected: Boolean);
447begin
448 UpdateInterface;
449end;
450
451procedure TFormMain.ListViewFilter1Change(Sender: TObject);
452begin
453 UpdateAcronymsList;
454end;
455
456procedure TFormMain.ListViewSort1ColumnWidthChanged(Sender: TObject);
457begin
458 ListViewFilter1.UpdateFromListView(ListViewAcronyms);
459end;
460
461function TFormMain.ListViewSort1CompareItem(Item1, Item2: TObject): Integer;
462begin
463 Result := 0;
464 if Assigned(Item1) and Assigned(Item2) and (ListViewSort1.Order <> soNone) then begin
465 with ListViewSort1 do
466 case Column of
467 0: Result := CompareString(TAcronymMeaning(Item1).Acronym.Name, TAcronymMeaning(Item2).Acronym.Name);
468 1: Result := CompareString(TAcronymMeaning(Item1).Name, TAcronymMeaning(Item2).Name);
469 2: Result := CompareString(TAcronymMeaning(Item1).Categories.GetString, TAcronymMeaning(Item2).Categories.GetString);
470 end;
471 if ListViewSort1.Order = soDown then Result := -Result;
472 end else Result := 0;
473end;
474
475procedure TFormMain.ListViewSort1Filter(ListViewSort: TListViewSort);
476begin
477 Core.AcronymDb.AssignToList(ListViewSort1.List);
478 FilterList(ListViewSort1.List);
479end;
480
481procedure TFormMain.MenuItemToolbarClick(Sender: TObject);
482begin
483 MenuItemToolbar.Checked := not MenuItemToolbar.Checked;
484 UpdateInterface;
485end;
486
487procedure TFormMain.ProjectOpen(FileName: string);
488begin
489 AFileClose.Execute;
490 if ProjectClosed then begin
491 try
492 AFileNew.Execute;
493 Core.AcronymDb.LoadFromFile(FileName);
494 LastOpenedList1.AddItem(FileName);
495 finally
496 UpdateAcronymsList;
497 UpdateInterface;
498 end;
499 end;
500end;
501
502function TFormMain.CompareStrings(Strings1, Strings2: TStrings): Boolean;
503var
504 I: Integer;
505begin
506 Result := Strings1.Count = Strings2.Count;
507 if not Result then Exit;
508 for I := 0 to Strings1.Count - 1 do
509 if (Strings1[I] <> Strings2[I]) or (Strings1.Objects[I] <> Strings2.Objects[I]) then begin
510 Result := False;
511 Exit;
512 end;
513end;
514
515procedure TFormMain.FilterList(List: TListObject);
516var
517 I: Integer;
518 FoundCount: Integer;
519 EnteredCount: Integer;
520begin
521 EnteredCount := ListViewFilter1.TextEnteredCount;
522 for I := List.Count - 1 downto 0 do begin
523 if List.Items[I] is TAcronymMeaning then begin
524 with TAcronymMeaning(List.Items[I]) do begin
525 with ListViewFilter1 do
526 if Visible and (EnteredCount > 0) then begin
527 FoundCount := 0;
528 if CheckBoxExactMath.Checked then begin
529 if TextEnteredColumn(0) and (StringGrid.Cells[0, 0] =
530 TAcronymMeaning(List.Items[I]).Acronym.Name) then Inc(FoundCount);
531 if TextEnteredColumn(1) and (StringGrid.Cells[1, 0] =
532 TAcronymMeaning(List.Items[I]).Name) then Inc(FoundCount);
533 if TextEnteredColumn(2) and (StringGrid.Cells[2, 0] =
534 TAcronymMeaning(List.Items[I]).Categories.GetString) then Inc(FoundCount);
535 end else begin
536 if Pos(UTF8LowerCase(StringGrid.Cells[0, 0]),
537 UTF8LowerCase(TAcronymMeaning(List.Items[I]).Acronym.Name)) > 0 then Inc(FoundCount);
538 if Pos(UTF8LowerCase(StringGrid.Cells[1, 0]),
539 UTF8LowerCase(TAcronymMeaning(List.Items[I]).Name)) > 0 then Inc(FoundCount);
540 if Pos(UTF8LowerCase(StringGrid.Cells[2, 0]),
541 UTF8LowerCase(TAcronymMeaning(List.Items[I]).Categories.GetString)) > 0 then Inc(FoundCount);
542 end;
543 if FoundCount <> EnteredCount then List.Delete(I);
544 end else List.Delete(I);
545 end;
546 end else
547 if TAcronymMeaning(List.Items[I]) is TAcronymMeaning then begin
548 List.Delete(I);
549 end;
550 end;
551end;
552
553procedure TFormMain.OpenRecentClick(Sender: TObject);
554begin
555 AFileClose.Execute;
556 if ProjectClosed then begin
557 AFileNew.Execute;
558 Core.AcronymDb.LoadFromFile(TMenuItem(Sender).Caption);
559 LastOpenedList1.AddItem(TMenuItem(Sender).Caption);
560 UpdateAcronymsList;
561 UpdateInterface;
562 end;
563end;
564
565procedure TFormMain.UpdateAcronymsList;
566begin
567 if Assigned(Core.AcronymDb) then begin
568 ListViewSort1.Refresh;
569 end else begin
570 ListViewSort1.List.Clear;
571 ListViewAcronyms.Items.Count := 0;
572 ListViewAcronyms.Refresh;
573 end;
574end;
575
576procedure TFormMain.UpdateInterface;
577var
578 Title: string;
579begin
580 ListViewAcronyms.Enabled := Assigned(Core.AcronymDb);
581 AFileClose.Enabled := Assigned(Core.AcronymDb);
582 AFileSave.Enabled := Assigned(Core.AcronymDb) and Core.AcronymDb.Modified;
583 AFileSaveAs.Enabled := Assigned(Core.AcronymDb);
584 AImport.Enabled := Assigned(Core.AcronymDb);
585 AExport.Enabled := Assigned(Core.AcronymDb);
586 AProcessImports.Enabled := Assigned(Core.AcronymDb);
587 AShowCategories.Enabled := Assigned(Core.AcronymDb);
588 AShowAcronyms.Enabled := Assigned(Core.AcronymDb);
589 AShowCategories.Enabled := Assigned(Core.AcronymDb);
590 AShowImportSources.Enabled := Assigned(Core.AcronymDb);
591 AShowImportFormats.Enabled := Assigned(Core.AcronymDb);
592 ToolBar1.Visible := MenuItemToolbar.Checked;
593 AHide.Enabled := FormMain.Visible;
594
595 Title := Application.Title;
596 if Assigned(Core.AcronymDb) and (ExtractFileName(Core.AcronymDb.FileName) <> '') then
597 if Assigned(Core.AcronymDb) then Title := Title + ' - ' + ExtractFileName(Core.AcronymDb.FileName);
598 if Assigned(Core.AcronymDb) and Core.AcronymDb.Modified then Title := Title + ' (' + SModified + ')';
599 Caption := Title;
600end;
601
602procedure TFormMain.LoadConfig;
603begin
604 RegistryContext := RegContext(HKEY_CURRENT_USER, DefaultRegKey);
605 Core.PersistentForm1.RegistryContext := RegistryContext;
606 RegistryContext := RegContext(HKEY_CURRENT_USER, DefaultRegKey + '\RecentFiles');
607 LastOpenedList1.LoadFromRegistry(RegistryContext);
608
609 {$IFDEF Linux}
610 // If installed in Linux system then use installation directory for po files
611 if Application.ExeName = '/usr/bin/' + ExtractFileNameOnly(Application.ExeName) then
612 Core.CoolTranslator1.POFilesFolder := '/usr/share/' + ExtractFileNameOnly(Application.ExeName) + '/languages';
613 {$ENDIF}
614
615 with TRegistryEx.Create do
616 try
617 RootKey := HKEY_CURRENT_USER;
618 OpenKey(DefaultRegKey, True);
619 if ValueExists('LanguageCode') then
620 Core.CoolTranslator1.Language := Core.CoolTranslator1.Languages.SearchByCode(ReadStringWithDefault('LanguageCode', ''))
621 else Core.CoolTranslator1.Language := Core.CoolTranslator1.Languages.SearchByCode('');
622 Core.AlwaysOnTop := ReadBoolWithDefault('AlwaysOnTop', False);
623 Core.StartMinimizedToTray := ReadBoolWithDefault('StartMinimizedToTray', False);
624 CheckBoxExactMath.Checked := ReadBoolWithDefault('ExactMatch', False);
625 MenuItemToolbar.Checked := ReadBoolWithDefault('ToolBarVisible', True);
626 finally
627 Free;
628 end;
629
630 with TRegistryEx.Create do
631 try
632 RootKey := HKEY_CURRENT_USER;
633 OpenKey(RegistryRunKey, True);
634 Core.StartOnLogon := ValueExists('Acronym Decoder');
635 finally
636 Free;
637 end;
638end;
639
640procedure TFormMain.SaveConfig;
641begin
642 RegistryContext := RegContext(HKEY_CURRENT_USER, DefaultRegKey + '\RecentFiles');
643 LastOpenedList1.SaveToRegistry(RegistryContext);
644
645 with TRegistryEx.Create do
646 try
647 RootKey := HKEY_CURRENT_USER;
648 OpenKey(DefaultRegKey, True);
649 if Assigned(Core.CoolTranslator1.Language) and (Core.CoolTranslator1.Language.Code <> '') then
650 WriteString('LanguageCode', Core.CoolTranslator1.Language.Code)
651 else DeleteValue('LanguageCode');
652 WriteBool('AlwaysOnTop', Core.AlwaysOnTop);
653 WriteBool('StartMinimizedToTray', Core.StartMinimizedToTray);
654 WriteBool('ExactMatch', CheckBoxExactMath.Checked);
655 WriteBool('ToolBarVisible', MenuItemToolbar.Checked);
656 finally
657 Free;
658 end;
659
660 with TRegistryEx.Create do
661 try
662 RootKey := HKEY_CURRENT_USER;
663 OpenKey(RegistryRunKey, True);
664 if Core.StartOnLogon then begin
665 if Core.StartMinimizedToTray then WriteString('Acronym Decoder', Application.ExeName + ' ' + Application.OptionChar + 't')
666 else WriteString('Acronym Decoder', Application.ExeName)
667 end else DeleteValue('Acronym Decoder');
668 finally
669 Free;
670 end;
671end;
672
673end.
674
Note: See TracBrowser for help on using the repository browser.