Changeset 86 for trunk/Forms


Ignore:
Timestamp:
Aug 8, 2016, 1:41:25 PM (8 years ago)
Author:
chronos
Message:
  • Modified: Non-visual code moved from FormMain to Core data module.
Location:
trunk/Forms
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormAcronyms.pas

    r85 r86  
    6363
    6464uses
    65   UFormMain, UFormAcronym;
     65  UCore, UFormMain, UFormAcronym;
    6666
    6767resourcestring
     
    126126  if FormAcronym.ShowModal = mrOk then begin
    127127    FormAcronym.Save(TempEntry);
    128     Meaning := FormMain.AcronymDb.AddAcronym(TempEntry.Name, TempEntry.Meaning);
     128    Meaning := Core.AcronymDb.AddAcronym(TempEntry.Name, TempEntry.Meaning);
    129129    Meaning.Description := TempEntry.Description;
    130130    Meaning.Categories.AssignFromStrings(TempEntry.Categories);
     
    161161      not FormMain.CompareStrings(TempEntry.Categories, TempCategories) then begin
    162162        // TODO: Update item inplace if possible
    163         FormMain.AcronymDb.RemoveMeaning(TAcronymMeaning(ListViewAcronyms.Selected.Data));
    164         Meaning := FormMain.AcronymDb.AddAcronym(TempEntry.Name, TempEntry.Meaning);
     163        Core.AcronymDb.RemoveMeaning(TAcronymMeaning(ListViewAcronyms.Selected.Data));
     164        Meaning := Core.AcronymDb.AddAcronym(TempEntry.Name, TempEntry.Meaning);
    165165        Meaning.Description := TempEntry.Description;
    166166        Meaning.Categories.AssignFromStrings(TempEntry.Categories);
     
    186186        if ListViewAcronyms.Items[I].Selected then begin
    187187          ListViewAcronyms.Items[I].Selected := False;
    188           FormMain.AcronymDb.RemoveMeaning(TAcronymMeaning(ListViewAcronyms.Items[I].Data));
     188          Core.AcronymDb.RemoveMeaning(TAcronymMeaning(ListViewAcronyms.Items[I].Data));
    189189        end;
    190190      UpdateAcronymsList;
     
    231231procedure TFormAcronyms.ListViewSort1Filter(ListViewSort: TListViewSort);
    232232begin
    233   FormMain.AcronymDb.Acronyms.Sort(AcronymComparer);
    234   FormMain.AcronymDb.AssignToList(ListViewSort1.List);
     233  Core.AcronymDb.Acronyms.Sort(AcronymComparer);
     234  Core.AcronymDb.AssignToList(ListViewSort1.List);
    235235  MeaningCount := ListViewSort1.List.Count;
    236236  FilterList(ListViewSort1.List);
     
    276276procedure TFormAcronyms.UpdateInterface;
    277277begin
    278   ARemove.Enabled := Assigned(FormMain.AcronymDb) and Assigned(ListViewAcronyms.Selected);
    279   AModify.Enabled := Assigned(FormMain.AcronymDb) and Assigned(ListViewAcronyms.Selected);
    280   AAdd.Enabled := Assigned(FormMain.AcronymDb);
     278  ARemove.Enabled := Assigned(Core.AcronymDb) and Assigned(ListViewAcronyms.Selected);
     279  AModify.Enabled := Assigned(Core.AcronymDb) and Assigned(ListViewAcronyms.Selected);
     280  AAdd.Enabled := Assigned(Core.AcronymDb);
    281281  ASelectAll.Enabled := True;
    282282end;
  • trunk/Forms/UFormCategories.pas

    r85 r86  
    5353
    5454uses
    55   UFormMain;
     55  UCore;
    5656
    5757resourcestring
     
    7575  S := InputBox(SCategory, SCategoryQuery, '');
    7676  if S <> '' then begin
    77     if not Assigned(FormMain.AcronymDb.Categories.SearchByName(S)) then begin;
    78       TAcronymCategory(FormMain.AcronymDb.Categories[FormMain.AcronymDb.Categories.Add(TAcronymCategory.Create)]).Name := S;
    79       FormMain.AcronymDb.Modified := True;
     77    if not Assigned(Core.AcronymDb.Categories.SearchByName(S)) then begin;
     78      TAcronymCategory(Core.AcronymDb.Categories[Core.AcronymDb.Categories.Add(TAcronymCategory.Create)]).Name := S;
     79      Core.AcronymDb.Modified := True;
    8080      UpdateList;
    8181    end else ShowMessage(Format(SCategoryAlreadyExists, [S]));
     
    9090    S := InputBox(SCategory, SCategoryQuery, ListViewCategories.Selected.Caption);
    9191    if S <> ListViewCategories.Selected.Caption then begin
    92       if not Assigned(FormMain.AcronymDb.Categories.SearchByName(S)) then begin;
     92      if not Assigned(Core.AcronymDb.Categories.SearchByName(S)) then begin;
    9393        TAcronymCategory(ListViewCategories.Selected.Data).Name := S;
    94         FormMain.AcronymDb.Modified := True;
     94        Core.AcronymDb.Modified := True;
    9595        UpdateList;
    9696      end else ShowMessage(Format(SCategoryAlreadyExists, [S]));
     
    124124procedure TFormCategories.ListViewCategoriesData(Sender: TObject; Item: TListItem);
    125125begin
    126   if Item.Index < FormMain.AcronymDb.Categories.Count then
    127   with TAcronymCategory(FormMain.AcronymDb.Categories[Item.Index]) do begin
     126  if Item.Index < Core.AcronymDb.Categories.Count then
     127  with TAcronymCategory(Core.AcronymDb.Categories[Item.Index]) do begin
    128128    Item.Caption := Name;
    129     Item.Data := FormMain.AcronymDb.Categories[Item.Index];
     129    Item.Data := Core.AcronymDb.Categories[Item.Index];
    130130    Item.SubItems.Add(IntToStr(AcronymMeanings.Count));
    131131  end;
     
    151151procedure TFormCategories.UpdateList;
    152152begin
    153   ListViewCategories.Items.Count := FormMain.AcronymDb.Categories.Count;
     153  ListViewCategories.Items.Count := Core.AcronymDb.Categories.Count;
    154154  ListViewCategories.Refresh;
    155155  UpdateInterface;
  • trunk/Forms/UFormCategorySelect.pas

    r33 r86  
    3939
    4040uses
    41   UFormMain;
     41  UCore;
    4242
    4343{ TFormCategorySelect }
     
    6262  I: Integer;
    6363begin
    64   with FormMain.AcronymDb do begin
     64  with Core.AcronymDb do begin
    6565    ListBox1.Sorted := False;
    6666    while ListBox1.Items.Count < Categories.Count do
  • trunk/Forms/UFormImport.pas

    r23 r86  
    3737
    3838uses
    39   UFormMain;
     39  UCore;
    4040
    4141resourcestring
     
    7979      AcronymMeaning := Trim(Copy(Line, 2, Length(Line)));
    8080      if (AcronymName <> '') and (AcronymMeaning <> '') then begin
    81         Acronym := FormMain.AcronymDb.Acronyms.SearchByName(AcronymName);
     81        Acronym := Core.AcronymDb.Acronyms.SearchByName(AcronymName);
    8282        if not Assigned(Acronym) then begin
    8383          Acronym := TAcronym.Create;
    8484          Acronym.Name := AcronymName;
    85           FormMain.AcronymDb.Acronyms.Add(Acronym);
     85          Core.AcronymDb.Acronyms.Add(Acronym);
    8686        end;
    8787        Meaning := Acronym.Meanings.SearchByName(AcronymMeaning);
     
    9696    end;
    9797  end;
    98   if AddedCount > 0 then FormMain.AcronymDb.Modified := True;
     98  if AddedCount > 0 then Core.AcronymDb.Modified := True;
    9999  ShowMessage(Format(SImportedNewAcronyms, [AddedCount]));
    100100end;
     
    125125      else AcronymDescription := '';
    126126    if (AcronymName <> '') and (AcronymDescription <> '') then begin
    127       Acronym := FormMain.AcronymDb.Acronyms.SearchByName(AcronymName);
     127      Acronym := Core.AcronymDb.Acronyms.SearchByName(AcronymName);
    128128      if not Assigned(Acronym) then begin
    129129        Acronym := TAcronym.Create;
    130130        Acronym.Name := AcronymName;
    131         FormMain.AcronymDb.Acronyms.Add(Acronym);
     131        Core.AcronymDb.Acronyms.Add(Acronym);
    132132      end;
    133133      Meaning := Acronym.Meanings.SearchByName(AcronymDescription);
     
    143143  end;
    144144  Columns.Free;
    145   if AddedCount > 0 then FormMain.AcronymDb.Modified := True;
     145  if AddedCount > 0 then Core.AcronymDb.Modified := True;
    146146  ShowMessage(Format(SImportedNewAcronyms, [AddedCount]));
    147147end;
  • trunk/Forms/UFormImportFormats.pas

    r85 r86  
    5353
    5454uses
    55   UFormMain, UFormImportFormat;
     55  UCore, UFormImportFormat;
    5656
    5757resourcestring
     
    118118      ImportFormats.Add(NewImportFormat);
    119119      NewImportFormat := nil;
    120       FormMain.AcronymDb.Modified := True;
     120      Core.AcronymDb.Modified := True;
    121121      UpdateList;
    122122    end else ShowMessage(Format(SImportFormatAlreadyExists, [NewImportFormat.Name]));
     
    138138        if not Assigned(ImportFormats.SearchByName(NewImportFormat.Name)) then begin;
    139139          TImportFormat(ListView1.Selected.Data).Assign(NewImportFormat);
    140           FormMain.AcronymDb.Modified := True;
     140          Core.AcronymDb.Modified := True;
    141141          UpdateList;
    142142        end else ShowMessage(Format(SImportFormatAlreadyExists, [NewImportFormat.Name]));
    143143      end else begin
    144144        TImportFormat(ListView1.Selected.Data).Assign(NewImportFormat);
    145         FormMain.AcronymDb.Modified := True;
     145        Core.AcronymDb.Modified := True;
    146146        UpdateList;
    147147      end;
  • trunk/Forms/UFormImportSource.pas

    r84 r86  
    6161
    6262uses
    63   UFormMain, UFormImportFormat, UFormCategorySelect;
     63  UCore, UFormImportFormat, UFormCategorySelect;
    6464
    6565{ TFormImportSource }
     
    7676      FormImportFormat.Save(NewImportFormat);
    7777      TImportFormat(ComboBox1.Items.Objects[ComboBox1.ItemIndex]).Assign(NewImportFormat);
    78       FormMain.AcronymDb.Modified := True;
     78      Core.AcronymDb.Modified := True;
    7979      ComboBox1.Items.Strings[ComboBox1.ItemIndex] := NewImportFormat.Name;
    8080    end;
     
    130130  EditName.Text := ImportSource.Name;
    131131  EditURL.Text := ImportSource.URL;
    132   while ComboBox1.Items.Count > FormMain.AcronymDb.ImportFormats.Count do
     132  while ComboBox1.Items.Count > Core.AcronymDb.ImportFormats.Count do
    133133    ComboBox1.Items.Delete(ComboBox1.Items.Count - 1);
    134   while ComboBox1.Items.Count < FormMain.AcronymDb.ImportFormats.Count do
     134  while ComboBox1.Items.Count < Core.AcronymDb.ImportFormats.Count do
    135135    ComboBox1.Items.Add('');
    136   for I := 0 to FormMain.AcronymDb.ImportFormats.Count - 1 do begin
    137     ComboBox1.Items[I] := TImportFormat(FormMain.AcronymDb.ImportFormats[I]).Name;
    138     ComboBox1.Items.Objects[I] := FormMain.AcronymDb.ImportFormats[I];
     136  for I := 0 to Core.AcronymDb.ImportFormats.Count - 1 do begin
     137    ComboBox1.Items[I] := TImportFormat(Core.AcronymDb.ImportFormats[I]).Name;
     138    ComboBox1.Items.Objects[I] := Core.AcronymDb.ImportFormats[I];
    139139  end;
    140140  ComboBox1.ItemIndex := ComboBox1.Items.IndexOfObject(ImportSource.Format);
  • trunk/Forms/UFormImportSources.pas

    r85 r86  
    7575
    7676uses
    77   UFormMain, UFormImportSource;
     77  UCore, UFormMain, UFormImportSource;
    7878
    7979resourcestring
     
    193193      ImportSources.Add(NewImportSource);
    194194      NewImportSource := nil;
    195       FormMain.AcronymDb.Modified := True;
     195      Core.AcronymDb.Modified := True;
    196196      UpdateList;
    197197    end else ShowMessage(Format(SImportSourceAlreadyExists, [NewImportSource.Name]));
     
    233233        if not Assigned(ImportSources.SearchByName(NewImportSource.Name)) then begin;
    234234          TImportSource(ListView1.Selected.Data).Assign(NewImportSource);
    235           FormMain.AcronymDb.Modified := True;
     235          Core.AcronymDb.Modified := True;
    236236          UpdateList;
    237237        end else ShowMessage(Format(SImportSourceAlreadyExists, [NewImportSource.Name]));
    238238      end else begin
    239239        TImportSource(ListView1.Selected.Data).Assign(NewImportSource);
    240         FormMain.AcronymDb.Modified := True;
     240        Core.AcronymDb.Modified := True;
    241241        UpdateList;
    242242      end;
     
    249249begin
    250250  if Assigned(ListView1.Selected) then begin
    251     FormMain.AcronymDb.AddedCount := 0;
     251    Core.AcronymDb.AddedCount := 0;
    252252    JobProgressView1.AddJob(SProcessSelectedSource, ProcessImportJob);
    253253    JobProgressView1.Start;
    254     ShowMessage(Format(SAddedCount, [TImportSource(ListView1.Selected.Data).ItemCount, FormMain.AcronymDb.AddedCount]));
     254    ShowMessage(Format(SAddedCount, [TImportSource(ListView1.Selected.Data).ItemCount,
     255      Core.AcronymDb.AddedCount]));
    255256  end;
    256257end;
  • trunk/Forms/UFormMain.pas

    r83 r86  
    120120    procedure TrayIcon1Click(Sender: TObject);
    121121  private
    122     InitializeStarted: Boolean;
    123     InitializeFinished: Boolean;
    124     FAlwaysOnTop: Boolean;
    125122    RegistryContext: TRegistryContext;
    126123    ProjectClosed: Boolean;
    127124    ImportTotalItemCount: Integer;
    128     function FindFirstNonOption: string;
    129     procedure ProjectOpen(FileName: string);
    130     procedure Initialize;
    131125    procedure ProcessImportsJob(Job: TJob);
    132     procedure SetAlwaysOnTop(AValue: Boolean);
    133126    procedure FilterList(List: TListObject);
    134127    procedure OpenRecentClick(Sender: TObject);
     128  public
     129    procedure LoadConfig;
     130    procedure SaveConfig;
    135131    procedure UpdateAcronymsList;
    136132    procedure UpdateInterface;
    137     procedure LoadConfig;
    138     procedure SaveConfig;
    139   public
    140     AcronymDb: TAcronymDb;
    141     StartOnLogon: Boolean;
    142     StartMinimizedToTray: Boolean;
     133    procedure ProjectOpen(FileName: string);
    143134    function CompareStrings(Strings1, Strings2: TStrings): Boolean;
    144     property AlwaysOnTop: Boolean read FAlwaysOnTop write SetAlwaysOnTop;
    145135  end;
    146136
     
    159149uses
    160150  UFormImport, UFormSettings, UFormCategories, UFormAcronyms,
    161   UFormImportSources, UFormAbout, UFormImportFormats;
     151  UFormImportSources, UFormAbout, UFormImportFormats, UCore;
    162152
    163153resourcestring
     
    171161  DefaultRegKey = '\Software\Chronosoft\Acronym Decoder';
    172162  RegistryRunKey = '\Software\Microsoft\Windows\CurrentVersion\Run';
    173   ExampleFile = 'Example acronyms.adp';
    174163
    175164{ TFormMain }
     
    179168  I: Integer;
    180169begin
    181   AcronymDb := TAcronymDb.Create;
    182   InitializeStarted := False;
    183   InitializeFinished := False;
    184170  for I := 0 to ToolBar1.ButtonCount - 1 do
    185171    ToolBar1.Buttons[I].Hint := ToolBar1.Buttons[I].Caption;
     
    193179procedure TFormMain.FormHide(Sender: TObject);
    194180begin
    195   if InitializeFinished then PersistentForm1.Save(Self);
     181  if Core.InitializeFinished then PersistentForm1.Save(Self);
    196182end;
    197183
     
    199185begin
    200186  PersistentForm1.Save(Self);
    201   SaveConfig;
     187  Core.SaveConfig;
    202188end;
    203189
     
    219205begin
    220206  DoClose := False;
    221   if Assigned(AcronymDb) then begin
    222     if AcronymDb.Modified then begin
     207  if Assigned(Core.AcronymDb) then begin
     208    if Core.AcronymDb.Modified then begin
    223209       ModalResult := MessageDlg(SAppExit, SAppExitQuery,
    224210       mtConfirmation, [mbYes, mbNo, mbCancel], 0);
     
    233219  end;
    234220  if DoClose then begin
    235     FreeAndNil(AcronymDb);
     221    FreeAndNil(Core.AcronymDb);
    236222    UpdateAcronymsList;
    237223    UpdateInterface;
     
    244230  AFileClose.Execute;
    245231  if ProjectClosed  then begin
    246     AcronymDb := TAcronymDb.Create;
    247     AcronymDb.FileName := DefaultFileName;
    248     AcronymDb.Acronyms.Clear;
     232    Core.AcronymDb := TAcronymDb.Create;
     233    Core.AcronymDb.FileName := DefaultFileName;
     234    Core.AcronymDb.Acronyms.Clear;
    249235    UpdateAcronymsList;
    250236    UpdateInterface;
     
    255241begin
    256242  OpenDialog1.DefaultExt := ProjectExt;
    257   if Assigned(AcronymDb) then
    258     OpenDialog1.FileName := AcronymDb.FileName;
     243  if Assigned(Core.AcronymDb) then
     244    OpenDialog1.FileName := Core.AcronymDb.FileName;
    259245  if OpenDialog1.Execute then begin
    260246    ProjectOpen(OpenDialog1.FileName);
     
    265251begin
    266252  SaveDialog1.DefaultExt := ProjectExt;
    267   SaveDialog1.FileName := AcronymDb.FileName;
     253  SaveDialog1.FileName := Core.AcronymDb.FileName;
    268254  if SaveDialog1.Execute then begin
    269     AcronymDb.SaveToFile(SaveDialog1.FileName);
     255    Core.AcronymDb.SaveToFile(SaveDialog1.FileName);
    270256    LastOpenedList1.AddItem(SaveDialog1.FileName);
    271257    UpdateInterface;
     
    275261procedure TFormMain.AFileSaveExecute(Sender: TObject);
    276262begin
    277   if FileExists(AcronymDb.FileName) then begin
    278     AcronymDb.SaveToFile(AcronymDb.FileName);
    279     LastOpenedList1.AddItem(AcronymDb.FileName);
     263  if FileExists(Core.AcronymDb.FileName) then begin
     264    Core.AcronymDb.SaveToFile(Core.AcronymDb.FileName);
     265    LastOpenedList1.AddItem(Core.AcronymDb.FileName);
    280266    UpdateInterface;
    281267  end else AFileSaveAs.Execute;
     
    292278begin
    293279  ImportTotalItemCount := 0;
    294   AcronymDb.AddedCount := 0;
     280  Core.AcronymDb.AddedCount := 0;
    295281  JobProgressView1.AddJob(SProcessImportSources, ProcessImportsJob);
    296282  JobProgressView1.Start;
    297   ShowMessage(Format(SAddedCount, [ImportTotalItemCount, AcronymDb.AddedCount]));
     283  ShowMessage(Format(SAddedCount, [ImportTotalItemCount, Core.AcronymDb.AddedCount]));
    298284  UpdateAcronymsList;
    299285  UpdateInterface;
     
    304290  I: Integer;
    305291begin
    306   for I := 0 to AcronymDb.ImportSources.Count - 1 do
    307   with TImportSource(AcronymDb.ImportSources[I]) do
     292  for I := 0 to Core.AcronymDb.ImportSources.Count - 1 do
     293  with TImportSource(Core.AcronymDb.ImportSources[I]) do
    308294  if Enabled then begin
    309295    Process;
    310296    ImportTotalItemCount := ImportTotalItemCount + ItemCount;
    311     Job.Progress.Max := AcronymDb.ImportSources.Count;
     297    Job.Progress.Max := Core.AcronymDb.ImportSources.Count;
    312298    Job.Progress.Value := I;
    313299    if Job.Terminate then Break;
     
    320306  if FormSettings.ShowModal = mrOk then begin
    321307    FormSettings.Save;
    322     SaveConfig;
     308    Core.SaveConfig;
    323309  end;
    324310end;
     
    338324procedure TFormMain.AShowCategoriesExecute(Sender: TObject);
    339325begin
    340   FormCategories.Categories := AcronymDb.Categories;
     326  FormCategories.Categories := Core.AcronymDb.Categories;
    341327  FormCategories.ShowModal;
    342328  UpdateAcronymsList;
     
    352338procedure TFormMain.AShowImportFormatsExecute(Sender: TObject);
    353339begin
    354   FormImportFormats.ImportFormats := AcronymDb.ImportFormats;
     340  FormImportFormats.ImportFormats := Core.AcronymDb.ImportFormats;
    355341  FormImportFormats.ShowModal;
    356342  UpdateInterface;
     
    359345procedure TFormMain.AShowImportSourcesExecute(Sender: TObject);
    360346begin
    361   FormImportSources.ImportSources := AcronymDb.ImportSources;
     347  FormImportSources.ImportSources := Core.AcronymDb.ImportSources;
    362348  FormImportSources.ShowModal;
    363349  UpdateAcronymsList;
     
    377363procedure TFormMain.FormDestroy(Sender: TObject);
    378364begin
    379   FreeAndNil(AcronymDb);
    380365end;
    381366
    382367procedure TFormMain.FormShow(Sender: TObject);
    383368begin
    384   Initialize;
     369  Core.Initialize;
    385370
    386371  if Visible then begin
     
    442427procedure TFormMain.ListViewSort1Filter(ListViewSort: TListViewSort);
    443428begin
    444   AcronymDb.AssignToList(ListViewSort1.List);
     429  Core.AcronymDb.AssignToList(ListViewSort1.List);
    445430  FilterList(ListViewSort1.List);
    446431end;
     
    456441  if not Visible then AShow.Execute
    457442    else Hide;
    458 end;
    459 
    460 function TFormMain.FindFirstNonOption: string;
    461 var
    462   S: string;
    463   I: Integer;
    464 begin
    465   Result := '';
    466   for I := 1 to Application.ParamCount do begin
    467     S := Application.Params[I];
    468     if S[1] = Application.OptionChar then Continue;
    469     Result := S;
    470     Break;
    471   end;
    472443end;
    473444
     
    478449    try
    479450      AFileNew.Execute;
    480       AcronymDb.LoadFromFile(FileName);
     451      Core.AcronymDb.LoadFromFile(FileName);
    481452      LastOpenedList1.AddItem(FileName);
    482453    finally
     
    484455      UpdateInterface;
    485456    end;
    486   end;
    487 end;
    488 
    489 procedure TFormMain.Initialize;
    490 var
    491   FileNameOption: string;
    492 begin
    493   if not InitializeStarted then begin
    494     InitializeStarted := True;
    495     LoadConfig;
    496 
    497     {$IFDEF 0}
    498     if Application.HasOption('h', 'help') then begin
    499       WriteLn('AcronymDecoder <project file>');
    500       WriteLn('  -t    --tray   Start minimized in system tray');
    501       WriteLn('  -h    --help  Show this help');
    502       Application.Terminate;
    503       Exit;
    504     end;
    505     {$ENDIF}
    506 
    507     if Application.HasOption('t', 'tray') then begin
    508       Visible := False;
    509     end;
    510 
    511     FileNameOption := FindFirstNonOption;
    512     if FileNameOption <> '' then begin
    513       // Open file specified as command line parameter
    514       AcronymDB.LoadFromFile(FileNameOption);
    515       LastOpenedList1.AddItem(OpenDialog1.FileName);
    516     end else
    517     if (LastOpenedList1.Items.Count > 0) and FileExists(LastOpenedList1.Items[0]) then begin
    518       // Open last opened file
    519       AcronymDB.LoadFromFile(LastOpenedList1.Items[0])
    520     end else begin
    521       // Open default database with examples if no item is in recent openned history
    522       FileNameOption := ExtractFileDir(Application.ExeName) + DirectorySeparator + ExampleFile;
    523       {$IFDEF Linux}
    524       // If installed in Linux system then use installation directory for po files
    525       if Application.ExeName = '/usr/bin/' + ExtractFileNameOnly(Application.ExeName) then
    526         FileNameOption := '/usr/share/' + ExtractFileNameOnly(Application.ExeName) + '/Examples/' + ExampleFile;
    527       {$ENDIF}
    528       ProjectOpen(FileNameOption);
    529     end;
    530     UpdateAcronymsList;
    531     ListViewFilter1.UpdateFromListView(ListViewAcronyms);
    532     InitializeFinished := True;
    533457  end;
    534458end;
     
    545469      Exit;
    546470    end;
    547 end;
    548 
    549 procedure TFormMain.SetAlwaysOnTop(AValue: Boolean);
    550 begin
    551   if FAlwaysOnTop = AValue then Exit;
    552   FAlwaysOnTop := AValue;
    553   if FAlwaysOnTop then FormStyle := fsSystemStayOnTop
    554     else FormStyle := fsNormal;
    555471end;
    556472
     
    598514  if ProjectClosed then begin
    599515    AFileNew.Execute;
    600     AcronymDb.LoadFromFile(TMenuItem(Sender).Caption);
     516    Core.AcronymDb.LoadFromFile(TMenuItem(Sender).Caption);
    601517    LastOpenedList1.AddItem(TMenuItem(Sender).Caption);
    602518    UpdateAcronymsList;
     
    607523procedure TFormMain.UpdateAcronymsList;
    608524begin
    609   if Assigned(AcronymDb) then begin
     525  if Assigned(Core.AcronymDb) then begin
    610526    ListViewSort1.Refresh;
    611527  end else begin
     
    620536  Title: string;
    621537begin
    622   ListViewAcronyms.Enabled := Assigned(AcronymDb);
    623   AFileClose.Enabled := Assigned(AcronymDb);
    624   AFileSave.Enabled := Assigned(AcronymDb) and AcronymDb.Modified;
    625   AFileSaveAs.Enabled := Assigned(AcronymDb);
    626   AManualImport.Enabled := Assigned(AcronymDb);
    627   AProcessImports.Enabled := Assigned(AcronymDb);
    628   AShowCategories.Enabled := Assigned(AcronymDb);
    629   AShowAcronyms.Enabled := Assigned(AcronymDb);
    630   AShowCategories.Enabled := Assigned(AcronymDb);
    631   AShowImportSources.Enabled := Assigned(AcronymDb);
    632   AShowImportFormats.Enabled := Assigned(AcronymDb);
     538  ListViewAcronyms.Enabled := Assigned(Core.AcronymDb);
     539  AFileClose.Enabled := Assigned(Core.AcronymDb);
     540  AFileSave.Enabled := Assigned(Core.AcronymDb) and Core.AcronymDb.Modified;
     541  AFileSaveAs.Enabled := Assigned(Core.AcronymDb);
     542  AManualImport.Enabled := Assigned(Core.AcronymDb);
     543  AProcessImports.Enabled := Assigned(Core.AcronymDb);
     544  AShowCategories.Enabled := Assigned(Core.AcronymDb);
     545  AShowAcronyms.Enabled := Assigned(Core.AcronymDb);
     546  AShowCategories.Enabled := Assigned(Core.AcronymDb);
     547  AShowImportSources.Enabled := Assigned(Core.AcronymDb);
     548  AShowImportFormats.Enabled := Assigned(Core.AcronymDb);
    633549  ToolBar1.Visible := MenuItemToolbar.Checked;
    634550
    635551  Title := Application.Title;
    636   if Assigned(AcronymDb) and (ExtractFileName(AcronymDb.FileName) <> '') then
    637     if Assigned(AcronymDb) then Title := Title + ' - ' + ExtractFileName(AcronymDb.FileName);
    638   if Assigned(AcronymDb) and AcronymDb.Modified then Title := Title + ' (' + SModified + ')';
     552  if Assigned(Core.AcronymDb) and (ExtractFileName(Core.AcronymDb.FileName) <> '') then
     553    if Assigned(Core.AcronymDb) then Title := Title + ' - ' + ExtractFileName(Core.AcronymDb.FileName);
     554  if Assigned(Core.AcronymDb) and Core.AcronymDb.Modified then Title := Title + ' (' + SModified + ')';
    639555  Caption := Title;
    640556end;
     
    660576      CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode(ReadStringWithDefault('LanguageCode', ''))
    661577      else CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode('');
    662     AlwaysOnTop := ReadBoolWithDefault('AlwaysOnTop', False);
    663     StartMinimizedToTray := ReadBoolWithDefault('StartMinimizedToTray', False);
     578    Core.AlwaysOnTop := ReadBoolWithDefault('AlwaysOnTop', False);
     579    Core.StartMinimizedToTray := ReadBoolWithDefault('StartMinimizedToTray', False);
    664580    CheckBoxExactMath.Checked := ReadBoolWithDefault('ExactMatch', False);
    665581    MenuItemToolbar.Checked := ReadBoolWithDefault('ToolBarVisible', True);
     
    672588    RootKey := HKEY_CURRENT_USER;
    673589    OpenKey(RegistryRunKey, True);
    674     StartOnLogon := ValueExists('Acronym Decoder');
     590    Core.StartOnLogon := ValueExists('Acronym Decoder');
    675591  finally
    676592    Free;
     
    690606      WriteString('LanguageCode', CoolTranslator1.Language.Code)
    691607      else DeleteValue('LanguageCode');
    692     WriteBool('AlwaysOnTop', AlwaysOnTop);
    693     WriteBool('StartMinimizedToTray', StartMinimizedToTray);
     608    WriteBool('AlwaysOnTop', Core.AlwaysOnTop);
     609    WriteBool('StartMinimizedToTray', Core.StartMinimizedToTray);
    694610    WriteBool('ExactMatch', CheckBoxExactMath.Checked);
    695611    WriteBool('ToolBarVisible', MenuItemToolbar.Checked);
     
    702618    RootKey := HKEY_CURRENT_USER;
    703619    OpenKey(RegistryRunKey, True);
    704     if StartOnLogon then begin
    705       if StartMinimizedToTray then WriteString('Acronym Decoder', Application.ExeName + ' ' + Application.OptionChar + 't')
     620    if Core.StartOnLogon then begin
     621      if Core.StartMinimizedToTray then WriteString('Acronym Decoder', Application.ExeName + ' ' + Application.OptionChar + 't')
    706622        else WriteString('Acronym Decoder', Application.ExeName)
    707623    end else DeleteValue('Acronym Decoder');
  • trunk/Forms/UFormSettings.pas

    r75 r86  
    4040
    4141uses
    42   UFormMain;
     42  UFormMain, UCore;
    4343
    4444{ TFormSettings }
     
    6464procedure TFormSettings.Load;
    6565begin
    66   CheckBoxAlwaysOnTop.Checked := FormMain.AlwaysOnTop;
    67   CheckBoxStartOnLogon.Checked := FormMain.StartOnLogon;
    68   CheckBoxStartMinimizedToTray.Checked := FormMain.StartMinimizedToTray;
     66  CheckBoxAlwaysOnTop.Checked := Core.AlwaysOnTop;
     67  CheckBoxStartOnLogon.Checked := Core.StartOnLogon;
     68  CheckBoxStartMinimizedToTray.Checked := Core.StartMinimizedToTray;
    6969  UpdateInterface;
    7070end;
     
    7272procedure TFormSettings.Save;
    7373begin
    74   FormMain.AlwaysOnTop := CheckBoxAlwaysOnTop.Checked;
    75   FormMain.StartOnLogon := CheckBoxStartOnLogon.Checked;
    76   FormMain.StartMinimizedToTray := CheckBoxStartMinimizedToTray.Checked;
     74  Core.AlwaysOnTop := CheckBoxAlwaysOnTop.Checked;
     75  Core.StartOnLogon := CheckBoxStartOnLogon.Checked;
     76  Core.StartMinimizedToTray := CheckBoxStartMinimizedToTray.Checked;
    7777end;
    7878
Note: See TracChangeset for help on using the changeset viewer.