Changeset 10 for trunk/UFormMain.pas
- Timestamp:
- Apr 22, 2016, 9:59:52 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UFormMain.pas
r9 r10 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus, 9 9 ComCtrls, StdCtrls, ExtCtrls, ActnList, UAcronym, UPersistentForm, Contnrs, 10 URegistry, ULastOpenedList, Registry;10 URegistry, ULastOpenedList, UCoolTranslator, Registry; 11 11 12 12 type … … 19 19 AAcronymRemove: TAction; 20 20 AAcronymRemoveAll: TAction; 21 ASettings: TAction; 21 22 AFileSaveAs: TAction; 22 23 AFileClose: TAction; … … 28 29 AExit: TAction; 29 30 ActionList1: TActionList; 31 CoolTranslator1: TCoolTranslator; 30 32 EditSearch: TEdit; 31 33 LastOpenedList1: TLastOpenedList; … … 41 43 MenuItem16: TMenuItem; 42 44 MenuItem17: TMenuItem; 45 MenuItem18: TMenuItem; 46 MenuItem19: TMenuItem; 43 47 MenuItemOpenRecent: TMenuItem; 44 48 MenuItem2: TMenuItem; … … 67 71 procedure AFileSaveExecute(Sender: TObject); 68 72 procedure AImportExecute(Sender: TObject); 73 procedure ASettingsExecute(Sender: TObject); 69 74 procedure AShowExecute(Sender: TObject); 70 75 procedure EditSearchChange(Sender: TObject); … … 101 106 102 107 uses 103 UFormImport, UFormAcronym; 108 UFormImport, UFormAcronym, UFormSettings; 109 110 resourcestring 111 SModified = 'modified'; 112 SAppExit = 'Application exit'; 113 SAppExitQuery = 'Acronyms were modified. Do you want to save them to file before exit?'; 114 SRemoveAllAcronyms = 'Remove all acronyms'; 115 SRemoveAllAcronymsQuery = 'Do you want to remove all acronyms?'; 116 SRemoveAcronym = 'Remove acronym'; 117 SRemoveAcronymQuery = 'Do you want to remove selected acronym?'; 104 118 105 119 const … … 133 147 begin 134 148 if Assigned(AcronymDb) and AcronymDb.Modified then begin 135 ModalResult := MessageDlg('Application exit', 136 'Acronyms were modified. Do you want to save them to file before exit?', 149 ModalResult := MessageDlg(SAppExit, SAppExitQuery, 137 150 mtConfirmation, [mbYes, mbNo, mbCancel], 0); 138 151 if ModalResult = mrYes then begin … … 237 250 procedure TFormMain.AAcronymRemoveAllExecute(Sender: TObject); 238 251 begin 239 if MessageDlg( 'Remove all acronyms', 'Do you want to remove all acronyms?',252 if MessageDlg(SRemoveAllAcronyms, SRemoveAllAcronymsQuery, 240 253 TMsgDlgType.mtConfirmation, [mbCancel, mbOk], 0) = mrOk then begin 241 254 AcronymDb.Acronyms.Clear; … … 249 262 begin 250 263 if Assigned(ListViewAcronyms.Selected) then begin 251 if MessageDlg( 'Remove acronym', 'Do you want to remove selected acronym?',264 if MessageDlg(SRemoveAcronym, SRemoveAcronymQuery, 252 265 TMsgDlgType.mtConfirmation, [mbCancel, mbOk], 0) = mrOk then begin 253 266 AcronymDb.RemoveAcronym(TAcronymMeaning(ListViewAcronyms.Selected.Data).Acronym.Name, … … 285 298 end; 286 299 300 procedure TFormMain.ASettingsExecute(Sender: TObject); 301 begin 302 FormSettings.ShowModal; 303 end; 304 287 305 procedure TFormMain.AShowExecute(Sender: TObject); 288 306 begin … … 387 405 Title := Application.Title; 388 406 if Assigned(AcronymDb) then Title := Title + ' - ' + ExtractFileName(AcronymDb.FileName); 389 if Assigned(AcronymDb) and AcronymDb.Modified then Title := Title + ' ( modified)';407 if Assigned(AcronymDb) and AcronymDb.Modified then Title := Title + ' (' + SModified + ')'; 390 408 Caption := Title; 391 409 end; … … 396 414 PersistentForm1.RegistryContext := RegistryContext; 397 415 LastOpenedList1.LoadFromRegistry(RegistryContext); 416 417 with TRegistryEx.Create do 418 try 419 RootKey := HKEY_CURRENT_USER; 420 OpenKey(DefaultRegKey, True); 421 if ValueExists('LanguageCode') then 422 CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode(ReadStringWithDefault('LanguageCode', '')) 423 else CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode(''); 424 finally 425 Free; 426 end; 398 427 end; 399 428 … … 401 430 begin 402 431 LastOpenedList1.SaveToRegistry(RegistryContext); 432 433 with TRegistryEx.Create do 434 try 435 RootKey := HKEY_CURRENT_USER; 436 OpenKey(DefaultRegKey, True); 437 if Assigned(CoolTranslator1.Language) and (CoolTranslator1.Language.Code <> '') then 438 WriteString('LanguageCode', CoolTranslator1.Language.Code) 439 else DeleteValue('LanguageCode'); 440 finally 441 Free; 442 end; 403 443 end; 404 444
Note:
See TracChangeset
for help on using the changeset viewer.