| 1 | unit FormMain;
|
|---|
| 2 |
|
|---|
| 3 | interface
|
|---|
| 4 |
|
|---|
| 5 | uses
|
|---|
| 6 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus,
|
|---|
| 7 | ComCtrls, StdCtrls, ExtCtrls, ActnList, Grids, Acronym, PersistentForm,
|
|---|
| 8 | RegistryEx, LastOpenedList, ListViewSort, JobProgressView, FormAbout,
|
|---|
| 9 | Registry, Generics.Collections, LazUTF8, LazFileUtils, FormEx,
|
|---|
| 10 | FormKeyShortcuts;
|
|---|
| 11 |
|
|---|
| 12 | type
|
|---|
| 13 |
|
|---|
| 14 | { TFormMain }
|
|---|
| 15 |
|
|---|
| 16 | TFormMain = class(TFormEx)
|
|---|
| 17 | AFullScreen: TAction;
|
|---|
| 18 | AShowKeyShortCuts: TAction;
|
|---|
| 19 | AFilterShowItemsWithoutFilter: TAction;
|
|---|
| 20 | ADocumentCheck: TAction;
|
|---|
| 21 | AFilterEnabledCategories: TAction;
|
|---|
| 22 | AManageAcronym: TAction;
|
|---|
| 23 | AFilterSameLetterCase: TAction;
|
|---|
| 24 | AFilterSameLength: TAction;
|
|---|
| 25 | AHide: TAction;
|
|---|
| 26 | AExport: TAction;
|
|---|
| 27 | AProcessImports: TAction;
|
|---|
| 28 | AShowImportFormats: TAction;
|
|---|
| 29 | AShowAbout: TAction;
|
|---|
| 30 | AShowImportSources: TAction;
|
|---|
| 31 | AShowAcronyms: TAction;
|
|---|
| 32 | AShowCategories: TAction;
|
|---|
| 33 | ASettings: TAction;
|
|---|
| 34 | AFileSaveAs: TAction;
|
|---|
| 35 | AFileClose: TAction;
|
|---|
| 36 | AFileSave: TAction;
|
|---|
| 37 | AFileNew: TAction;
|
|---|
| 38 | AFileOpen: TAction;
|
|---|
| 39 | AImport: TAction;
|
|---|
| 40 | AShow: TAction;
|
|---|
| 41 | AExit: TAction;
|
|---|
| 42 | ActionList1: TActionList;
|
|---|
| 43 | CheckBoxEnabledCategories: TCheckBox;
|
|---|
| 44 | CheckBoxShowItemsWithoutFilter: TCheckBox;
|
|---|
| 45 | CheckBoxExactLength: TCheckBox;
|
|---|
| 46 | CheckBoxCaseSensitive: TCheckBox;
|
|---|
| 47 | CoolBar1: TCoolBar;
|
|---|
| 48 | JobProgressView1: TJobProgressView;
|
|---|
| 49 | LastOpenedList1: TLastOpenedList;
|
|---|
| 50 | ListViewAcronyms: TListView;
|
|---|
| 51 | ListViewFilter1: TListViewFilter;
|
|---|
| 52 | ListViewSort1: TListViewSort;
|
|---|
| 53 | MainMenu1: TMainMenu;
|
|---|
| 54 | MenuItem1: TMenuItem;
|
|---|
| 55 | MenuItem19: TMenuItem;
|
|---|
| 56 | MenuItem2: TMenuItem;
|
|---|
| 57 | MenuItem26: TMenuItem;
|
|---|
| 58 | MenuItem27: TMenuItem;
|
|---|
| 59 | MenuItem28: TMenuItem;
|
|---|
| 60 | MenuItem29: TMenuItem;
|
|---|
| 61 | N1: TMenuItem;
|
|---|
| 62 | MenuItem3: TMenuItem;
|
|---|
| 63 | MenuItemShowItemsWithoutFilter: TMenuItem;
|
|---|
| 64 | MenuItemStatusBar: TMenuItem;
|
|---|
| 65 | MenuItemParam: TMenuItem;
|
|---|
| 66 | MenuItem10: TMenuItem;
|
|---|
| 67 | MenuItem11: TMenuItem;
|
|---|
| 68 | MenuItem12: TMenuItem;
|
|---|
| 69 | MenuItem13: TMenuItem;
|
|---|
| 70 | MenuItem14: TMenuItem;
|
|---|
| 71 | MenuItem15: TMenuItem;
|
|---|
| 72 | MenuItem16: TMenuItem;
|
|---|
| 73 | MenuItem17: TMenuItem;
|
|---|
| 74 | MenuItem18: TMenuItem;
|
|---|
| 75 | MenuItem20: TMenuItem;
|
|---|
| 76 | MenuItem21: TMenuItem;
|
|---|
| 77 | MenuItem22: TMenuItem;
|
|---|
| 78 | MenuItem23: TMenuItem;
|
|---|
| 79 | MenuItem24: TMenuItem;
|
|---|
| 80 | MenuItem25: TMenuItem;
|
|---|
| 81 | MenuItemToolbar: TMenuItem;
|
|---|
| 82 | MenuItem4: TMenuItem;
|
|---|
| 83 | MenuItem5: TMenuItem;
|
|---|
| 84 | MenuItem6: TMenuItem;
|
|---|
| 85 | MenuItem7: TMenuItem;
|
|---|
| 86 | MenuItemOpenRecent: TMenuItem;
|
|---|
| 87 | MenuItem8: TMenuItem;
|
|---|
| 88 | MenuItem9: TMenuItem;
|
|---|
| 89 | OpenDialog1: TOpenDialog;
|
|---|
| 90 | PanelParam: TPanel;
|
|---|
| 91 | PanelMain: TPanel;
|
|---|
| 92 | PopupMenuFilter: TPopupMenu;
|
|---|
| 93 | PopupMenuOpenRecent: TPopupMenu;
|
|---|
| 94 | SaveDialog1: TSaveDialog;
|
|---|
| 95 | StatusBar1: TStatusBar;
|
|---|
| 96 | ToolBarFile: TToolBar;
|
|---|
| 97 | ToolBarManage: TToolBar;
|
|---|
| 98 | ToolBarOther: TToolBar;
|
|---|
| 99 | ToolBarFilter: TToolBar;
|
|---|
| 100 | ToolButton1: TToolButton;
|
|---|
| 101 | ToolButton11: TToolButton;
|
|---|
| 102 | ToolButton12: TToolButton;
|
|---|
| 103 | ToolButton13: TToolButton;
|
|---|
| 104 | ToolButton16: TToolButton;
|
|---|
| 105 | ToolButton2: TToolButton;
|
|---|
| 106 | ToolButton3: TToolButton;
|
|---|
| 107 | ToolButton4: TToolButton;
|
|---|
| 108 | ToolButton5: TToolButton;
|
|---|
| 109 | ToolButton6: TToolButton;
|
|---|
| 110 | ToolButton7: TToolButton;
|
|---|
| 111 | ToolButton8: TToolButton;
|
|---|
| 112 | ToolButton9: TToolButton;
|
|---|
| 113 | procedure ADocumentCheckExecute(Sender: TObject);
|
|---|
| 114 | procedure AExitExecute(Sender: TObject);
|
|---|
| 115 | procedure AExportExecute(Sender: TObject);
|
|---|
| 116 | procedure AFileCloseExecute(Sender: TObject);
|
|---|
| 117 | procedure AFileNewExecute(Sender: TObject);
|
|---|
| 118 | procedure AFileOpenExecute(Sender: TObject);
|
|---|
| 119 | procedure AFileSaveAsExecute(Sender: TObject);
|
|---|
| 120 | procedure AFileSaveExecute(Sender: TObject);
|
|---|
| 121 | procedure AFilterEnabledCategoriesExecute(Sender: TObject);
|
|---|
| 122 | procedure AFilterSameLetterCaseExecute(Sender: TObject);
|
|---|
| 123 | procedure AFilterSameLengthExecute(Sender: TObject);
|
|---|
| 124 | procedure AFilterShowItemsWithoutFilterExecute(Sender: TObject);
|
|---|
| 125 | procedure AFullScreenExecute(Sender: TObject);
|
|---|
| 126 | procedure AHideExecute(Sender: TObject);
|
|---|
| 127 | procedure AImportExecute(Sender: TObject);
|
|---|
| 128 | procedure AManageAcronymExecute(Sender: TObject);
|
|---|
| 129 | procedure AProcessImportsExecute(Sender: TObject);
|
|---|
| 130 | procedure ASettingsExecute(Sender: TObject);
|
|---|
| 131 | procedure AShowAboutExecute(Sender: TObject);
|
|---|
| 132 | procedure AShowAcronymsExecute(Sender: TObject);
|
|---|
| 133 | procedure AShowCategoriesExecute(Sender: TObject);
|
|---|
| 134 | procedure AShowExecute(Sender: TObject);
|
|---|
| 135 | procedure AShowImportFormatsExecute(Sender: TObject);
|
|---|
| 136 | procedure AShowImportSourcesExecute(Sender: TObject);
|
|---|
| 137 | procedure EditSearchChange(Sender: TObject);
|
|---|
| 138 | procedure FormActivate(Sender: TObject);
|
|---|
| 139 | procedure FormDestroy(Sender: TObject);
|
|---|
| 140 | procedure FormHide(Sender: TObject);
|
|---|
| 141 | procedure FormResize(Sender: TObject);
|
|---|
| 142 | procedure FormShow(Sender: TObject);
|
|---|
| 143 | procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
|---|
| 144 | procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
|---|
| 145 | procedure FormCreate(Sender: TObject);
|
|---|
| 146 | procedure LastOpenedList1Change(Sender: TObject);
|
|---|
| 147 | procedure ListViewAcronymsData(Sender: TObject; Item: TListItem);
|
|---|
| 148 | procedure ListViewAcronymsResize(Sender: TObject);
|
|---|
| 149 | procedure ListViewAcronymsSelectItem(Sender: TObject; Item: TListItem;
|
|---|
| 150 | Selected: Boolean);
|
|---|
| 151 | procedure ListViewFilter1Change(Sender: TObject);
|
|---|
| 152 | procedure ListViewSort1ColumnWidthChanged(Sender: TObject);
|
|---|
| 153 | function ListViewSort1CompareItem(Item1, Item2: TObject): Integer;
|
|---|
| 154 | procedure ListViewSort1Filter(ListViewSort: TListViewSort);
|
|---|
| 155 | procedure MenuItemParamClick(Sender: TObject);
|
|---|
| 156 | procedure MenuItemStatusBarClick(Sender: TObject);
|
|---|
| 157 | procedure MenuItemToolbarClick(Sender: TObject);
|
|---|
| 158 | procedure AShowKeyShortcutsExecute(Sender: TObject);
|
|---|
| 159 | private
|
|---|
| 160 | RegistryContext: TRegistryContext;
|
|---|
| 161 | ProjectClosed: Boolean;
|
|---|
| 162 | ImportTotalItemCount: Integer;
|
|---|
| 163 | FormKeyShortcuts: TFormKeyShortcuts;
|
|---|
| 164 | procedure AcronymDbUpdate(Sender: TObject);
|
|---|
| 165 | function FilterCell(Text1, Text2: string): Boolean;
|
|---|
| 166 | procedure ProcessImportsJob(Job: TJob);
|
|---|
| 167 | procedure FilterList(List: TObjectList<TObject>);
|
|---|
| 168 | procedure OpenRecentClick(Sender: TObject);
|
|---|
| 169 | procedure SetToolbarHints;
|
|---|
| 170 | public
|
|---|
| 171 | procedure LoadConfig;
|
|---|
| 172 | procedure SaveConfig;
|
|---|
| 173 | procedure UpdateAcronymsList;
|
|---|
| 174 | procedure UpdateInterface;
|
|---|
| 175 | procedure ProjectOpen(FileName: string);
|
|---|
| 176 | end;
|
|---|
| 177 |
|
|---|
| 178 | const
|
|---|
| 179 | ProjectExt = '.adp';
|
|---|
| 180 |
|
|---|
| 181 | resourcestring
|
|---|
| 182 | SAddedCount = 'Imported %d acronyms. Added %d new.';
|
|---|
| 183 | SProcessImportSources = 'Process import sources';
|
|---|
| 184 | SAcronymsCount = 'Acronyms count: %d';
|
|---|
| 185 | SMeaningsCount = 'Meanings count: %d';
|
|---|
| 186 | SFileFilter = 'Acronym Decoder project (' + ProjectExt + ')|*' + ProjectExt + '|All files|*.*';
|
|---|
| 187 |
|
|---|
| 188 |
|
|---|
| 189 | implementation
|
|---|
| 190 |
|
|---|
| 191 | {$R *.lfm}
|
|---|
| 192 |
|
|---|
| 193 | uses
|
|---|
| 194 | FormImport, FormSettings, FormCategories, FormAcronyms, FormExport,
|
|---|
| 195 | FormImportSources, FormImportFormats, Core, FormCheck;
|
|---|
| 196 |
|
|---|
| 197 | resourcestring
|
|---|
| 198 | SModified = 'modified';
|
|---|
| 199 | SAppExit = 'Application exit';
|
|---|
| 200 | SAppExitQuery = 'Acronyms were modified. Do you want to save them to file before exit?';
|
|---|
| 201 |
|
|---|
| 202 | const
|
|---|
| 203 | DefaultFileName = 'Acronyms' + ProjectExt;
|
|---|
| 204 | RegistryRunKey = '\Software\Microsoft\Windows\CurrentVersion\Run';
|
|---|
| 205 |
|
|---|
| 206 | { TFormMain }
|
|---|
| 207 |
|
|---|
| 208 | procedure TFormMain.SetToolbarHints;
|
|---|
| 209 | var
|
|---|
| 210 | I: Integer;
|
|---|
| 211 | J: Integer;
|
|---|
| 212 | Control: TControl;
|
|---|
| 213 | begin
|
|---|
| 214 | for J := 0 to CoolBar1.ControlCount - 1 do begin
|
|---|
| 215 | Control := CoolBar1.Controls[J];
|
|---|
| 216 | if Control is TToolBar then begin
|
|---|
| 217 | for I := 0 to TToolBar(Control).ButtonCount - 1 do begin
|
|---|
| 218 | TToolBar(Control).Buttons[I].ShowHint := True;
|
|---|
| 219 | TToolBar(Control).Buttons[I].Hint := TToolBar(Control).Buttons[I].Caption;
|
|---|
| 220 | end;
|
|---|
| 221 | end;
|
|---|
| 222 | end;
|
|---|
| 223 | end;
|
|---|
| 224 |
|
|---|
| 225 | procedure TFormMain.FormCreate(Sender: TObject);
|
|---|
| 226 | begin
|
|---|
| 227 | SetToolbarHints;
|
|---|
| 228 | PanelMain.ControlStyle := PanelMain.ControlStyle + [csOpaque];
|
|---|
| 229 | PanelParam.ControlStyle := PanelParam.ControlStyle + [csOpaque];
|
|---|
| 230 | end;
|
|---|
| 231 |
|
|---|
| 232 | procedure TFormMain.EditSearchChange(Sender: TObject);
|
|---|
| 233 | begin
|
|---|
| 234 | UpdateAcronymsList;
|
|---|
| 235 | end;
|
|---|
| 236 |
|
|---|
| 237 | procedure TFormMain.FormActivate(Sender: TObject);
|
|---|
| 238 | begin
|
|---|
| 239 | ListViewFilter1.UpdateFromListView(ListViewAcronyms);
|
|---|
| 240 | end;
|
|---|
| 241 |
|
|---|
| 242 | procedure TFormMain.FormDestroy(Sender: TObject);
|
|---|
| 243 | begin
|
|---|
| 244 | if Assigned(FormKeyShortcuts) then FreeAndNil(FormKeyShortcuts);
|
|---|
| 245 | end;
|
|---|
| 246 |
|
|---|
| 247 | procedure TFormMain.FormHide(Sender: TObject);
|
|---|
| 248 | begin
|
|---|
| 249 | if Core.Core.InitializeFinished then Core.Core.PersistentForm1.Save(Self);
|
|---|
| 250 | UpdateInterface;
|
|---|
| 251 | end;
|
|---|
| 252 |
|
|---|
| 253 | procedure TFormMain.FormResize(Sender: TObject);
|
|---|
| 254 | begin
|
|---|
| 255 | CoolBar1.AutosizeBands;
|
|---|
| 256 | end;
|
|---|
| 257 |
|
|---|
| 258 | procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
|---|
| 259 | begin
|
|---|
| 260 | Core.Core.SaveConfig;
|
|---|
| 261 | end;
|
|---|
| 262 |
|
|---|
| 263 | procedure TFormMain.FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
|---|
| 264 | begin
|
|---|
| 265 | ProjectClosed := True;
|
|---|
| 266 | AFileClose.Execute;
|
|---|
| 267 | CanClose := ProjectClosed;
|
|---|
| 268 | end;
|
|---|
| 269 |
|
|---|
| 270 | procedure TFormMain.AExitExecute(Sender: TObject);
|
|---|
| 271 | begin
|
|---|
| 272 | Close;
|
|---|
| 273 | end;
|
|---|
| 274 |
|
|---|
| 275 | procedure TFormMain.ADocumentCheckExecute(Sender: TObject);
|
|---|
| 276 | var
|
|---|
| 277 | FormCheck: TFormCheck;
|
|---|
| 278 | begin
|
|---|
| 279 | FormCheck := TFormCheck.Create(Self);
|
|---|
| 280 | try
|
|---|
| 281 | FormCheck.LoadConfig(TRegistryContext.Create(Core.Core.ApplicationInfo1.RegistryRoot,
|
|---|
| 282 | Core.Core.ApplicationInfo1.RegistryKey));
|
|---|
| 283 | FormCheck.ShowModal;
|
|---|
| 284 | FormCheck.SaveConfig(TRegistryContext.Create(Core.Core.ApplicationInfo1.RegistryRoot,
|
|---|
| 285 | Core.Core.ApplicationInfo1.RegistryKey));
|
|---|
| 286 | finally
|
|---|
| 287 | FreeAndNil(FormCheck);
|
|---|
| 288 | end;
|
|---|
| 289 | end;
|
|---|
| 290 |
|
|---|
| 291 | procedure TFormMain.AExportExecute(Sender: TObject);
|
|---|
| 292 | var
|
|---|
| 293 | FormExport: TFormExport;
|
|---|
| 294 | begin
|
|---|
| 295 | FormExport := TFormExport.Create(Self);
|
|---|
| 296 | try
|
|---|
| 297 | FormExport.AcronymDb := Core.Core.AcronymDb;
|
|---|
| 298 | FormExport.ShowModal;
|
|---|
| 299 | finally
|
|---|
| 300 | FreeAndNil(FormExport);
|
|---|
| 301 | end;
|
|---|
| 302 | end;
|
|---|
| 303 |
|
|---|
| 304 | procedure TFormMain.AFileCloseExecute(Sender: TObject);
|
|---|
| 305 | var
|
|---|
| 306 | ModalResult: TModalResult;
|
|---|
| 307 | DoClose: Boolean;
|
|---|
| 308 | begin
|
|---|
| 309 | DoClose := False;
|
|---|
| 310 | if Assigned(Core.Core.AcronymDb) then begin
|
|---|
| 311 | if Core.Core.AcronymDb.Modified then begin
|
|---|
| 312 | ModalResult := MessageDlg(SAppExit, SAppExitQuery,
|
|---|
| 313 | mtConfirmation, [mbYes, mbNo, mbCancel], 0);
|
|---|
| 314 | if ModalResult = mrYes then begin
|
|---|
| 315 | AFileSave.Execute;
|
|---|
| 316 | DoClose := True;
|
|---|
| 317 | end
|
|---|
| 318 | else if ModalResult = mrNo then begin
|
|---|
| 319 | DoClose := True;
|
|---|
| 320 | end else ProjectClosed := False;
|
|---|
| 321 | end else DoClose := True;
|
|---|
| 322 | end;
|
|---|
| 323 | if DoClose then begin
|
|---|
| 324 | FreeAndNil(Core.Core.AcronymDb);
|
|---|
| 325 | UpdateAcronymsList;
|
|---|
| 326 | UpdateInterface;
|
|---|
| 327 | ProjectClosed := True;
|
|---|
| 328 | end;
|
|---|
| 329 | end;
|
|---|
| 330 |
|
|---|
| 331 | procedure TFormMain.AFileNewExecute(Sender: TObject);
|
|---|
| 332 | begin
|
|---|
| 333 | AFileClose.Execute;
|
|---|
| 334 | if not Assigned(Core.Core.AcronymDb) then begin
|
|---|
| 335 | Core.Core.AcronymDb := TAcronymDb.Create;
|
|---|
| 336 | Core.Core.AcronymDb.FileName := DefaultFileName;
|
|---|
| 337 | Core.Core.AcronymDb.Acronyms.Clear;
|
|---|
| 338 | Core.Core.AcronymDb.OnUpdate.Add(AcronymDbUpdate);
|
|---|
| 339 | UpdateAcronymsList;
|
|---|
| 340 | UpdateInterface;
|
|---|
| 341 | end;
|
|---|
| 342 | end;
|
|---|
| 343 |
|
|---|
| 344 | procedure TFormMain.AFileOpenExecute(Sender: TObject);
|
|---|
| 345 | begin
|
|---|
| 346 | OpenDialog1.DefaultExt := ProjectExt;
|
|---|
| 347 | if Assigned(Core.Core.AcronymDb) then begin
|
|---|
| 348 | OpenDialog1.InitialDir := ExtractFileDir(Core.Core.AcronymDb.FileName);
|
|---|
| 349 | OpenDialog1.Filter := SFileFilter;
|
|---|
| 350 | OpenDialog1.FileName := ExtractFileName(Core.Core.AcronymDb.FileName);
|
|---|
| 351 | end;
|
|---|
| 352 | if OpenDialog1.Execute then begin
|
|---|
| 353 | ProjectOpen(OpenDialog1.FileName);
|
|---|
| 354 | end;
|
|---|
| 355 | end;
|
|---|
| 356 |
|
|---|
| 357 | procedure TFormMain.AFileSaveAsExecute(Sender: TObject);
|
|---|
| 358 | begin
|
|---|
| 359 | SaveDialog1.DefaultExt := ProjectExt;
|
|---|
| 360 | SaveDialog1.InitialDir := ExtractFileDir(Core.Core.AcronymDb.FileName);
|
|---|
| 361 | SaveDialog1.Filter := SFileFilter;
|
|---|
| 362 | SaveDialog1.FileName := ExtractFileName(Core.Core.AcronymDb.FileName);
|
|---|
| 363 | if SaveDialog1.Execute then begin
|
|---|
| 364 | Core.Core.AcronymDb.SaveToFile(SaveDialog1.FileName);
|
|---|
| 365 | LastOpenedList1.AddItem(SaveDialog1.FileName);
|
|---|
| 366 | UpdateInterface;
|
|---|
| 367 | end;
|
|---|
| 368 | end;
|
|---|
| 369 |
|
|---|
| 370 | procedure TFormMain.AFileSaveExecute(Sender: TObject);
|
|---|
| 371 | begin
|
|---|
| 372 | if FileExists(Core.Core.AcronymDb.FileName) then begin
|
|---|
| 373 | Core.Core.AcronymDb.SaveToFile(Core.Core.AcronymDb.FileName);
|
|---|
| 374 | LastOpenedList1.AddItem(Core.Core.AcronymDb.FileName);
|
|---|
| 375 | UpdateInterface;
|
|---|
| 376 | end else AFileSaveAs.Execute;
|
|---|
| 377 | end;
|
|---|
| 378 |
|
|---|
| 379 | procedure TFormMain.AFilterEnabledCategoriesExecute(Sender: TObject);
|
|---|
| 380 | begin
|
|---|
| 381 | UpdateAcronymsList;
|
|---|
| 382 | end;
|
|---|
| 383 |
|
|---|
| 384 | procedure TFormMain.AFilterSameLetterCaseExecute(Sender: TObject);
|
|---|
| 385 | begin
|
|---|
| 386 | UpdateAcronymsList;
|
|---|
| 387 | end;
|
|---|
| 388 |
|
|---|
| 389 | procedure TFormMain.AFilterSameLengthExecute(Sender: TObject);
|
|---|
| 390 | begin
|
|---|
| 391 | UpdateAcronymsList;
|
|---|
| 392 | end;
|
|---|
| 393 |
|
|---|
| 394 | procedure TFormMain.AFilterShowItemsWithoutFilterExecute(Sender: TObject);
|
|---|
| 395 | begin
|
|---|
| 396 | UpdateAcronymsList;
|
|---|
| 397 | end;
|
|---|
| 398 |
|
|---|
| 399 | procedure TFormMain.AFullScreenExecute(Sender: TObject);
|
|---|
| 400 | begin
|
|---|
| 401 | FullScreen := not FullScreen;
|
|---|
| 402 | TFormEx.PersistentForm.Form := Self;
|
|---|
| 403 | TFormEx.PersistentForm.SetFullScreen(FullScreen);
|
|---|
| 404 | UpdateInterface;
|
|---|
| 405 | end;
|
|---|
| 406 |
|
|---|
| 407 | procedure TFormMain.AHideExecute(Sender: TObject);
|
|---|
| 408 | begin
|
|---|
| 409 | Hide;
|
|---|
| 410 | end;
|
|---|
| 411 |
|
|---|
| 412 | procedure TFormMain.AImportExecute(Sender: TObject);
|
|---|
| 413 | var
|
|---|
| 414 | FormImport: TFormImport;
|
|---|
| 415 | begin
|
|---|
| 416 | FormImport := TFormImport.Create(Self);
|
|---|
| 417 | try
|
|---|
| 418 | FormImport.AcronymDb := Core.Core.AcronymDb;
|
|---|
| 419 | FormImport.ShowModal;
|
|---|
| 420 | UpdateAcronymsList;
|
|---|
| 421 | UpdateInterface;
|
|---|
| 422 | finally
|
|---|
| 423 | FreeAndNil(FormImport);
|
|---|
| 424 | end;
|
|---|
| 425 | end;
|
|---|
| 426 |
|
|---|
| 427 | procedure TFormMain.AManageAcronymExecute(Sender: TObject);
|
|---|
| 428 | var
|
|---|
| 429 | FormAcronyms: TFormAcronyms;
|
|---|
| 430 | begin
|
|---|
| 431 | FormAcronyms := TFormAcronyms.Create(Self);
|
|---|
| 432 | try
|
|---|
| 433 | if Assigned(ListViewAcronyms.Selected) then
|
|---|
| 434 | FormAcronyms.FocusAcronym := ListViewAcronyms.Selected.Data;
|
|---|
| 435 | FormAcronyms.AcronymDb := Core.Core.AcronymDb;
|
|---|
| 436 | FormAcronyms.Acronyms := Core.Core.AcronymDb.Acronyms;
|
|---|
| 437 | FormAcronyms.ShowModal;
|
|---|
| 438 | UpdateAcronymsList;
|
|---|
| 439 | UpdateInterface;
|
|---|
| 440 | finally
|
|---|
| 441 | FreeAndNil(FormAcronyms);
|
|---|
| 442 | end;
|
|---|
| 443 | end;
|
|---|
| 444 |
|
|---|
| 445 | procedure TFormMain.AProcessImportsExecute(Sender: TObject);
|
|---|
| 446 | begin
|
|---|
| 447 | ImportTotalItemCount := 0;
|
|---|
| 448 | Core.Core.AcronymDb.AddedCount := 0;
|
|---|
| 449 | JobProgressView1.AddJob(SProcessImportSources, ProcessImportsJob);
|
|---|
| 450 | JobProgressView1.Start;
|
|---|
| 451 | ShowMessage(Format(SAddedCount, [ImportTotalItemCount, Core.Core.AcronymDb.AddedCount]));
|
|---|
| 452 | UpdateAcronymsList;
|
|---|
| 453 | UpdateInterface;
|
|---|
| 454 | end;
|
|---|
| 455 |
|
|---|
| 456 | procedure TFormMain.ProcessImportsJob(Job: TJob);
|
|---|
| 457 | var
|
|---|
| 458 | I: Integer;
|
|---|
| 459 | begin
|
|---|
| 460 | for I := 0 to Core.Core.AcronymDb.ImportSources.Count - 1 do
|
|---|
| 461 | with Core.Core.AcronymDb.ImportSources[I] do
|
|---|
| 462 | if Enabled then begin
|
|---|
| 463 | Process(Core.Core.AcronymDb);
|
|---|
| 464 | ImportTotalItemCount := ImportTotalItemCount + ItemCount;
|
|---|
| 465 | Job.Progress.Max := Core.Core.AcronymDb.ImportSources.Count;
|
|---|
| 466 | Job.Progress.Value := I;
|
|---|
| 467 | if Job.Terminate then Break;
|
|---|
| 468 | end;
|
|---|
| 469 | end;
|
|---|
| 470 |
|
|---|
| 471 | procedure TFormMain.ASettingsExecute(Sender: TObject);
|
|---|
| 472 | var
|
|---|
| 473 | FormSettings: TFormSettings;
|
|---|
| 474 | begin
|
|---|
| 475 | FormSettings := TFormSettings.Create(Self);
|
|---|
| 476 | try
|
|---|
| 477 | FormSettings.Load;
|
|---|
| 478 | if FormSettings.ShowModal = mrOk then begin
|
|---|
| 479 | FormSettings.Save;
|
|---|
| 480 | Core.Core.SaveConfig;
|
|---|
| 481 | Core.Core.ThemeManager.UseTheme(Self);
|
|---|
| 482 | end;
|
|---|
| 483 | finally
|
|---|
| 484 | FreeAndNil(FormSettings);
|
|---|
| 485 | end;
|
|---|
| 486 | end;
|
|---|
| 487 |
|
|---|
| 488 | procedure TFormMain.AShowAboutExecute(Sender: TObject);
|
|---|
| 489 | var
|
|---|
| 490 | FormAbout: TFormAbout;
|
|---|
| 491 | begin
|
|---|
| 492 | FormAbout := TFormAbout.Create(nil);
|
|---|
| 493 | try
|
|---|
| 494 | FormAbout.ApplicationInfo := Core.Core.ApplicationInfo1;
|
|---|
| 495 | FormAbout.ShowModal;
|
|---|
| 496 | finally
|
|---|
| 497 | FormAbout.Free;
|
|---|
| 498 | end;
|
|---|
| 499 | end;
|
|---|
| 500 |
|
|---|
| 501 | procedure TFormMain.AShowAcronymsExecute(Sender: TObject);
|
|---|
| 502 | var
|
|---|
| 503 | FormAcronyms: TFormAcronyms;
|
|---|
| 504 | begin
|
|---|
| 505 | FormAcronyms := TFormAcronyms.Create(Self);
|
|---|
| 506 | try
|
|---|
| 507 | FormAcronyms.AcronymDb := Core.Core.AcronymDb;
|
|---|
| 508 | FormAcronyms.Acronyms := Core.Core.AcronymDb.Acronyms;
|
|---|
| 509 | FormAcronyms.ShowModal;
|
|---|
| 510 | UpdateAcronymsList;
|
|---|
| 511 | UpdateInterface;
|
|---|
| 512 | finally
|
|---|
| 513 | FreeAndNil(FormAcronyms);
|
|---|
| 514 | end;
|
|---|
| 515 | end;
|
|---|
| 516 |
|
|---|
| 517 | procedure TFormMain.AShowCategoriesExecute(Sender: TObject);
|
|---|
| 518 | var
|
|---|
| 519 | FormCategories: TFormCategories;
|
|---|
| 520 | begin
|
|---|
| 521 | FormCategories := TFormCategories.Create(Self);
|
|---|
| 522 | try
|
|---|
| 523 | FormCategories.AcronymDb := Core.Core.AcronymDb;
|
|---|
| 524 | FormCategories.Categories := Core.Core.AcronymDb.Categories;
|
|---|
| 525 | FormCategories.ShowModal;
|
|---|
| 526 | UpdateAcronymsList;
|
|---|
| 527 | UpdateInterface;
|
|---|
| 528 | finally
|
|---|
| 529 | FreeAndNil(FormCategories);
|
|---|
| 530 | end;
|
|---|
| 531 | end;
|
|---|
| 532 |
|
|---|
| 533 | procedure TFormMain.AShowExecute(Sender: TObject);
|
|---|
| 534 | begin
|
|---|
| 535 | Show;
|
|---|
| 536 | BringToFront;
|
|---|
| 537 | end;
|
|---|
| 538 |
|
|---|
| 539 | procedure TFormMain.AShowImportFormatsExecute(Sender: TObject);
|
|---|
| 540 | var
|
|---|
| 541 | FormImportFormats: TFormImportFormats;
|
|---|
| 542 | begin
|
|---|
| 543 | FormImportFormats := TFormImportFormats.Create(Self);
|
|---|
| 544 | try
|
|---|
| 545 | FormImportFormats.AcronymDb := Core.Core.AcronymDb;
|
|---|
| 546 | FormImportFormats.ImportFormats := Core.Core.AcronymDb.ImportFormats;
|
|---|
| 547 | FormImportFormats.ShowModal;
|
|---|
| 548 | UpdateInterface;
|
|---|
| 549 | finally
|
|---|
| 550 | FreeAndNil(FormImportFormats);
|
|---|
| 551 | end;
|
|---|
| 552 | end;
|
|---|
| 553 |
|
|---|
| 554 | procedure TFormMain.AShowImportSourcesExecute(Sender: TObject);
|
|---|
| 555 | var
|
|---|
| 556 | FormImportSources: TFormImportSources;
|
|---|
| 557 | begin
|
|---|
| 558 | FormImportSources := TFormImportSources.Create(Self);
|
|---|
| 559 | try
|
|---|
| 560 | FormImportSources.ImportSources := Core.Core.AcronymDb.ImportSources;
|
|---|
| 561 | FormImportSources.AcronymDb := Core.Core.AcronymDb;
|
|---|
| 562 | FormImportSources.ShowModal;
|
|---|
| 563 | UpdateAcronymsList;
|
|---|
| 564 | UpdateInterface;
|
|---|
| 565 | finally
|
|---|
| 566 | FreeAndNil(FormImportSources);
|
|---|
| 567 | end;
|
|---|
| 568 | end;
|
|---|
| 569 |
|
|---|
| 570 | procedure TFormMain.FormShow(Sender: TObject);
|
|---|
| 571 | begin
|
|---|
| 572 | FullScreen := Core.Core.PersistentForm1.FormFullScreen;
|
|---|
| 573 | Core.Core.Initialize;
|
|---|
| 574 |
|
|---|
| 575 | if Visible then begin
|
|---|
| 576 | UpdateInterface;
|
|---|
| 577 | ListViewFilter1.StringGrid.Col := 1;
|
|---|
| 578 | ListViewFilter1.StringGrid.Col := 0;
|
|---|
| 579 | ListViewFilter1.StringGrid.Row := 0;
|
|---|
| 580 | ListViewFilter1.StringGrid.SetFocus;
|
|---|
| 581 | end;
|
|---|
| 582 | ScaleDPI.ScaleControl(CoolBar1, ScaleDPI.DesignDPI);
|
|---|
| 583 | CoolBar1.AutosizeBands;
|
|---|
| 584 | end;
|
|---|
| 585 |
|
|---|
| 586 | procedure TFormMain.LastOpenedList1Change(Sender: TObject);
|
|---|
| 587 | begin
|
|---|
| 588 | LastOpenedList1.LoadToMenuItem(MenuItemOpenRecent, OpenRecentClick);
|
|---|
| 589 | LastOpenedList1.LoadToMenuItem(PopupMenuOpenRecent.Items, OpenRecentClick);
|
|---|
| 590 | end;
|
|---|
| 591 |
|
|---|
| 592 | procedure TFormMain.ListViewAcronymsData(Sender: TObject; Item: TListItem);
|
|---|
| 593 | begin
|
|---|
| 594 | if Item.Index < ListViewSort1.List.Count then
|
|---|
| 595 | with TAcronymMeaning(ListViewSort1.List[Item.Index]) do begin
|
|---|
| 596 | Item.Caption := Acronym.Name;
|
|---|
| 597 | Item.Data := TAcronymMeaning(ListViewSort1.List[Item.Index]);
|
|---|
| 598 | Item.SubItems.Add(Name);
|
|---|
| 599 | Item.SubItems.Add(Categories.GetString);
|
|---|
| 600 | end;
|
|---|
| 601 | end;
|
|---|
| 602 |
|
|---|
| 603 | procedure TFormMain.ListViewAcronymsResize(Sender: TObject);
|
|---|
| 604 | begin
|
|---|
| 605 | ListViewFilter1.UpdateFromListView(ListViewAcronyms);
|
|---|
| 606 | end;
|
|---|
| 607 |
|
|---|
| 608 | procedure TFormMain.ListViewAcronymsSelectItem(Sender: TObject;
|
|---|
| 609 | Item: TListItem; Selected: Boolean);
|
|---|
| 610 | begin
|
|---|
| 611 | UpdateInterface;
|
|---|
| 612 | end;
|
|---|
| 613 |
|
|---|
| 614 | procedure TFormMain.ListViewFilter1Change(Sender: TObject);
|
|---|
| 615 | begin
|
|---|
| 616 | UpdateAcronymsList;
|
|---|
| 617 | end;
|
|---|
| 618 |
|
|---|
| 619 | procedure TFormMain.ListViewSort1ColumnWidthChanged(Sender: TObject);
|
|---|
| 620 | begin
|
|---|
| 621 | ListViewFilter1.UpdateFromListView(ListViewAcronyms);
|
|---|
| 622 | end;
|
|---|
| 623 |
|
|---|
| 624 | function TFormMain.ListViewSort1CompareItem(Item1, Item2: TObject): Integer;
|
|---|
| 625 | begin
|
|---|
| 626 | Result := 0;
|
|---|
| 627 | if Assigned(Item1) and Assigned(Item2) and (ListViewSort1.Order <> soNone) then begin
|
|---|
| 628 | with ListViewSort1 do
|
|---|
| 629 | case Column of
|
|---|
| 630 | 0: Result := CompareString(TAcronymMeaning(Item1).Acronym.Name, TAcronymMeaning(Item2).Acronym.Name);
|
|---|
| 631 | 1: Result := CompareString(TAcronymMeaning(Item1).Name, TAcronymMeaning(Item2).Name);
|
|---|
| 632 | 2: Result := CompareString(TAcronymMeaning(Item1).Categories.GetString, TAcronymMeaning(Item2).Categories.GetString);
|
|---|
| 633 | end;
|
|---|
| 634 | if ListViewSort1.Order = soDown then Result := -Result;
|
|---|
| 635 | end else Result := 0;
|
|---|
| 636 | end;
|
|---|
| 637 |
|
|---|
| 638 | procedure TFormMain.AShowKeyShortcutsExecute(Sender: TObject);
|
|---|
| 639 | begin
|
|---|
| 640 | if not Assigned(FormKeyShortcuts) then
|
|---|
| 641 | FormKeyShortcuts := TFormKeyShortcuts.Create(nil);
|
|---|
| 642 | with FormKeyShortcuts do begin
|
|---|
| 643 | Images := Core.Core.ImageListSmall;
|
|---|
| 644 | SourceComponents.Clear;
|
|---|
| 645 | SourceComponents.Add(Self);
|
|---|
| 646 | Show;
|
|---|
| 647 | end;
|
|---|
| 648 | end;
|
|---|
| 649 |
|
|---|
| 650 | procedure TFormMain.ListViewSort1Filter(ListViewSort: TListViewSort);
|
|---|
| 651 | begin
|
|---|
| 652 | Core.Core.AcronymDb.AssignToList(ListViewSort1.List, AFilterEnabledCategories.Checked);
|
|---|
| 653 | FilterList(ListViewSort1.List);
|
|---|
| 654 | end;
|
|---|
| 655 |
|
|---|
| 656 | procedure TFormMain.MenuItemParamClick(Sender: TObject);
|
|---|
| 657 | begin
|
|---|
| 658 | MenuItemParam.Checked := not MenuItemParam.Checked;
|
|---|
| 659 | UpdateInterface;
|
|---|
| 660 | end;
|
|---|
| 661 |
|
|---|
| 662 | procedure TFormMain.MenuItemStatusBarClick(Sender: TObject);
|
|---|
| 663 | begin
|
|---|
| 664 | MenuItemStatusBar.Checked := not MenuItemStatusBar.Checked;
|
|---|
| 665 | UpdateInterface;
|
|---|
| 666 | end;
|
|---|
| 667 |
|
|---|
| 668 | procedure TFormMain.MenuItemToolbarClick(Sender: TObject);
|
|---|
| 669 | begin
|
|---|
| 670 | MenuItemToolbar.Checked := not MenuItemToolbar.Checked;
|
|---|
| 671 | UpdateInterface;
|
|---|
| 672 | end;
|
|---|
| 673 |
|
|---|
| 674 | procedure TFormMain.AcronymDbUpdate(Sender: TObject);
|
|---|
| 675 | begin
|
|---|
| 676 | UpdateAcronymsList;
|
|---|
| 677 | end;
|
|---|
| 678 |
|
|---|
| 679 | function TFormMain.FilterCell(Text1, Text2: string): Boolean;
|
|---|
| 680 | begin
|
|---|
| 681 | if not AFilterSameLetterCase.Checked then begin
|
|---|
| 682 | Text1 := UTF8LowerCase(Text1);
|
|---|
| 683 | Text2 := UTF8LowerCase(Text2);
|
|---|
| 684 | end;
|
|---|
| 685 | if AFilterSameLength.Checked then
|
|---|
| 686 | Result := Text1 = Text2
|
|---|
| 687 | else Result := Pos(Text1, Text2) > 0;
|
|---|
| 688 | end;
|
|---|
| 689 |
|
|---|
| 690 | procedure TFormMain.ProjectOpen(FileName: string);
|
|---|
| 691 | begin
|
|---|
| 692 | AFileClose.Execute;
|
|---|
| 693 | if not Assigned(Core.Core.AcronymDb) then begin
|
|---|
| 694 | try
|
|---|
| 695 | AFileNew.Execute;
|
|---|
| 696 | Core.Core.AcronymDb.LoadFromFile(FileName);
|
|---|
| 697 | LastOpenedList1.AddItem(FileName);
|
|---|
| 698 | finally
|
|---|
| 699 | UpdateAcronymsList;
|
|---|
| 700 | UpdateInterface;
|
|---|
| 701 | end;
|
|---|
| 702 | end;
|
|---|
| 703 | end;
|
|---|
| 704 |
|
|---|
| 705 | procedure TFormMain.FilterList(List: TObjectList<TObject>);
|
|---|
| 706 | var
|
|---|
| 707 | I: Integer;
|
|---|
| 708 | FoundCount: Integer;
|
|---|
| 709 | EnteredCount: Integer;
|
|---|
| 710 | begin
|
|---|
| 711 | EnteredCount := ListViewFilter1.TextEnteredCount;
|
|---|
| 712 | for I := List.Count - 1 downto 0 do begin
|
|---|
| 713 | if List.Items[I] is TAcronymMeaning then begin
|
|---|
| 714 | with TAcronymMeaning(List.Items[I]) do begin
|
|---|
| 715 | with ListViewFilter1 do
|
|---|
| 716 | if Visible and ((EnteredCount > 0) or ((EnteredCount = 0) and
|
|---|
| 717 | (AFilterShowItemsWithoutFilter.Checked))) then begin
|
|---|
| 718 | FoundCount := 0;
|
|---|
| 719 | if TextEnteredColumn(0) and (FilterCell(StringGrid.Cells[0, 0],
|
|---|
| 720 | TAcronymMeaning(List.Items[I]).Acronym.Name)) then Inc(FoundCount);
|
|---|
| 721 | if TextEnteredColumn(1) and (FilterCell(StringGrid.Cells[1, 0],
|
|---|
| 722 | TAcronymMeaning(List.Items[I]).Name)) then Inc(FoundCount);
|
|---|
| 723 | if TextEnteredColumn(2) and (FilterCell(StringGrid.Cells[2, 0],
|
|---|
| 724 | TAcronymMeaning(List.Items[I]).Categories.GetString)) then Inc(FoundCount);
|
|---|
| 725 | if FoundCount <> EnteredCount then List.Delete(I);
|
|---|
| 726 | end else List.Delete(I);
|
|---|
| 727 | end;
|
|---|
| 728 | end else
|
|---|
| 729 | if TAcronymMeaning(List.Items[I]) is TAcronymMeaning then begin
|
|---|
| 730 | List.Delete(I);
|
|---|
| 731 | end;
|
|---|
| 732 | end;
|
|---|
| 733 | end;
|
|---|
| 734 |
|
|---|
| 735 | procedure TFormMain.OpenRecentClick(Sender: TObject);
|
|---|
| 736 | begin
|
|---|
| 737 | AFileClose.Execute;
|
|---|
| 738 | if not Assigned(Core.Core.AcronymDb) then begin
|
|---|
| 739 | AFileNew.Execute;
|
|---|
| 740 | Core.Core.AcronymDb.LoadFromFile(TMenuItem(Sender).Caption);
|
|---|
| 741 | LastOpenedList1.AddItem(TMenuItem(Sender).Caption);
|
|---|
| 742 | UpdateAcronymsList;
|
|---|
| 743 | UpdateInterface;
|
|---|
| 744 | end;
|
|---|
| 745 | end;
|
|---|
| 746 |
|
|---|
| 747 | procedure TFormMain.UpdateAcronymsList;
|
|---|
| 748 | begin
|
|---|
| 749 | if Assigned(Core.Core.AcronymDb) then begin
|
|---|
| 750 | ListViewSort1.Refresh;
|
|---|
| 751 | end else begin
|
|---|
| 752 | ListViewSort1.List.Clear;
|
|---|
| 753 | ListViewAcronyms.Items.Count := 0;
|
|---|
| 754 | ListViewAcronyms.Refresh;
|
|---|
| 755 | end;
|
|---|
| 756 | end;
|
|---|
| 757 |
|
|---|
| 758 | procedure TFormMain.UpdateInterface;
|
|---|
| 759 | var
|
|---|
| 760 | Title: string;
|
|---|
| 761 | begin
|
|---|
| 762 | AFullscreen.Checked := FullScreen;
|
|---|
| 763 | ListViewAcronyms.Enabled := Assigned(Core.Core.AcronymDb);
|
|---|
| 764 | AFileClose.Enabled := Assigned(Core.Core.AcronymDb);
|
|---|
| 765 | AFileSave.Enabled := Assigned(Core.Core.AcronymDb) and Core.Core.AcronymDb.Modified;
|
|---|
| 766 | AFileSaveAs.Enabled := Assigned(Core.Core.AcronymDb);
|
|---|
| 767 | AImport.Enabled := Assigned(Core.Core.AcronymDb);
|
|---|
| 768 | AExport.Enabled := Assigned(Core.Core.AcronymDb);
|
|---|
| 769 | AProcessImports.Enabled := Assigned(Core.Core.AcronymDb);
|
|---|
| 770 | AShowCategories.Enabled := Assigned(Core.Core.AcronymDb);
|
|---|
| 771 | AShowAcronyms.Enabled := Assigned(Core.Core.AcronymDb);
|
|---|
| 772 | AShowCategories.Enabled := Assigned(Core.Core.AcronymDb);
|
|---|
| 773 | AShowImportSources.Enabled := Assigned(Core.Core.AcronymDb);
|
|---|
| 774 | AShowImportFormats.Enabled := Assigned(Core.Core.AcronymDb);
|
|---|
| 775 | CoolBar1.Visible := MenuItemToolbar.Checked;
|
|---|
| 776 | PanelParam.Visible := MenuItemParam.Checked;
|
|---|
| 777 | AHide.Enabled := Visible;
|
|---|
| 778 | AManageAcronym.Enabled := Assigned(ListViewAcronyms.Selected);
|
|---|
| 779 | StatusBar1.Visible := MenuItemStatusBar.Checked;
|
|---|
| 780 |
|
|---|
| 781 | Title := '';
|
|---|
| 782 | if Assigned(Core.Core.AcronymDb) and (ExtractFileNameWithoutExt(ExtractFileName(Core.Core.AcronymDb.FileName)) <> '') then begin
|
|---|
| 783 | Title := ExtractFileNameWithoutExt(ExtractFileName(Core.Core.AcronymDb.FileName));
|
|---|
| 784 | if Core.Core.AcronymDb.Modified then Title := Title + ' (' + SModified + ')';
|
|---|
| 785 | end;
|
|---|
| 786 | if Title <> '' then Title := Title + ' - ';
|
|---|
| 787 | Title := Title + Core.Core.ApplicationInfo1.AppName;
|
|---|
| 788 | {$IFDEF WINDOWS}
|
|---|
| 789 | // Under Linux title would affect reg.xml path for storing registry settings
|
|---|
| 790 | Application.Title := Title;
|
|---|
| 791 | {$ENDIF}
|
|---|
| 792 | Caption := Title;
|
|---|
| 793 | if Assigned(Core.Core.AcronymDb) then begin
|
|---|
| 794 | StatusBar1.Panels[0].Text := Format(SAcronymsCount, [
|
|---|
| 795 | Core.Core.AcronymDb.Acronyms.Count]);
|
|---|
| 796 | StatusBar1.Panels[1].Text := Format(SMeaningsCount, [
|
|---|
| 797 | Core.Core.AcronymDb.GetMeaningsCount]);
|
|---|
| 798 | end else begin
|
|---|
| 799 | StatusBar1.Panels[0].Text := '';
|
|---|
| 800 | StatusBar1.Panels[1].Text := '';
|
|---|
| 801 | end;
|
|---|
| 802 | end;
|
|---|
| 803 |
|
|---|
| 804 | procedure TFormMain.LoadConfig;
|
|---|
| 805 | begin
|
|---|
| 806 | Core.Core.PersistentForm1.RegistryContext := Core.Core.ApplicationInfo1.GetRegistryContext;
|
|---|
| 807 | RegistryContext := TRegistryContext.Create(Core.Core.ApplicationInfo1.RegistryRoot,
|
|---|
| 808 | Core.Core.ApplicationInfo1.RegistryKey + '\RecentFiles');
|
|---|
| 809 | LastOpenedList1.LoadFromRegistry(RegistryContext);
|
|---|
| 810 |
|
|---|
| 811 | with TRegistryEx.Create do
|
|---|
| 812 | try
|
|---|
| 813 | RootKey := RegistryRootHKEY[Core.Core.ApplicationInfo1.RegistryRoot];
|
|---|
| 814 | OpenKey(Core.Core.ApplicationInfo1.RegistryKey, True);
|
|---|
| 815 | AFilterSameLength.Checked := ReadBoolWithDefault('SameLength', False);
|
|---|
| 816 | AFilterSameLetterCase.Checked := ReadBoolWithDefault('SameLetterCase', False);
|
|---|
| 817 | AFilterEnabledCategories.Checked := ReadBoolWithDefault('EnabledCategories', False);
|
|---|
| 818 | MenuItemToolbar.Checked := ReadBoolWithDefault('ToolBarVisible', True);
|
|---|
| 819 | MenuItemStatusBar.Checked := ReadBoolWithDefault('StatusBarVisible', True);
|
|---|
| 820 | MenuItemParam.Checked := ReadBoolWithDefault('FilterParamVisible', True);
|
|---|
| 821 | AFilterShowItemsWithoutFilter.Checked :=
|
|---|
| 822 | ReadBoolWithDefault('ShowItemsWithoutFilter', True);
|
|---|
| 823 | finally
|
|---|
| 824 | Free;
|
|---|
| 825 | end;
|
|---|
| 826 |
|
|---|
| 827 | with TRegistryEx.Create do
|
|---|
| 828 | try
|
|---|
| 829 | RootKey := HKEY_CURRENT_USER;
|
|---|
| 830 | OpenKey(RegistryRunKey, True);
|
|---|
| 831 | Core.Core.StartOnLogon := ValueExists('Acronym Decoder');
|
|---|
| 832 | finally
|
|---|
| 833 | Free;
|
|---|
| 834 | end;
|
|---|
| 835 | end;
|
|---|
| 836 |
|
|---|
| 837 | procedure TFormMain.SaveConfig;
|
|---|
| 838 | begin
|
|---|
| 839 | RegistryContext := TRegistryContext.Create(Core.Core.ApplicationInfo1.RegistryRoot,
|
|---|
| 840 | Core.Core.ApplicationInfo1.RegistryKey + '\RecentFiles');
|
|---|
| 841 | LastOpenedList1.SaveToRegistry(RegistryContext);
|
|---|
| 842 |
|
|---|
| 843 | with TRegistryEx.Create do
|
|---|
| 844 | try
|
|---|
| 845 | RootKey := RegistryRootHKEY[Core.Core.ApplicationInfo1.RegistryRoot];
|
|---|
| 846 | OpenKey(Core.Core.ApplicationInfo1.RegistryKey, True);
|
|---|
| 847 | WriteBool('SameLength', AFilterSameLength.Checked);
|
|---|
| 848 | WriteBool('SameLetterCase', AFilterSameLetterCase.Checked);
|
|---|
| 849 | WriteBool('EnabledCategories', AFilterEnabledCategories.Checked);
|
|---|
| 850 | WriteBool('ToolBarVisible', MenuItemToolbar.Checked);
|
|---|
| 851 | WriteBool('StatusBarVisible', MenuItemStatusBar.Checked);
|
|---|
| 852 | WriteBool('FilterParamVisible', MenuItemParam.Checked);
|
|---|
| 853 | WriteBool('ShowItemsWithoutFilter', AFilterShowItemsWithoutFilter.Checked);
|
|---|
| 854 | finally
|
|---|
| 855 | Free;
|
|---|
| 856 | end;
|
|---|
| 857 |
|
|---|
| 858 | with TRegistryEx.Create do
|
|---|
| 859 | try
|
|---|
| 860 | RootKey := HKEY_CURRENT_USER;
|
|---|
| 861 | OpenKey(RegistryRunKey, True);
|
|---|
| 862 | if Core.Core.StartOnLogon then begin
|
|---|
| 863 | if Core.Core.StartMinimizedToTray then WriteString('Acronym Decoder', Application.ExeName + ' ' + Application.OptionChar + 't')
|
|---|
| 864 | else WriteString('Acronym Decoder', Application.ExeName)
|
|---|
| 865 | end else DeleteValue('Acronym Decoder');
|
|---|
| 866 | finally
|
|---|
| 867 | Free;
|
|---|
| 868 | end;
|
|---|
| 869 | end;
|
|---|
| 870 |
|
|---|
| 871 | end.
|
|---|
| 872 |
|
|---|