Changeset 149 for trunk/Core.pas


Ignore:
Timestamp:
Jun 5, 2023, 8:45:38 PM (18 months ago)
Author:
chronos
Message:
  • Modified: Remove U prefix from unit names.
File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Core.pas

    r148 r149  
    1 unit UCore;
     1unit Core;
    22
    33interface
     
    6969    procedure TranslatorTranslate(Sender: TObject);
    7070  private
     71    FOnDataFileChange: TNotifyEvent;
     72    FOnLastOpenedListChange: TNotifyEvent;
    7173    InitializeStarted: Boolean;
    7274    InitializeFinished: Boolean;
     
    7678    ProfilePhotoFileName: string;
    7779    RecentFileRegistryContext: TRegistryContext;
     80    FormMain: TForm;
    7881    procedure FileModified(Sender: TObject);
    7982    function FindFirstNonOption: string;
     
    8386    procedure DoError(Text: string; Line: Integer);
    8487    procedure AddItemToLastOpenedList(FileName: string);
     88    procedure DoDataFileChange;
    8589  public
    8690    DefaultDataFileClass: TDataFileClass;
     
    104108    procedure Initialize;
    105109    procedure UpdateInterface;
     110    property OnDataFileChange: TNotifyEvent read FOnDataFileChange
     111      write FOnDataFileChange;
     112    property OnLastOpenedListChange: TNotifyEvent read FOnLastOpenedListChange
     113      write FOnLastOpenedListChange;
    106114  end;
    107115
     
    115123
    116124uses
    117   UFormMain, UFormSettings, UFormContacts, UFormFindDuplicity, TestCase,
    118   UFormGenerate, UFormError, UFormFind, UFormTest, UFormSource, UFormCompare,
    119   UTestCases, UVCardFile;
     125  FormMain, FormSettings, FormFindDuplicity, TestCase,
     126  FormGenerate, FormError, FormFind, FormTest, FormSource, FormCompare,
     127  TestCases, VCardFile;
    120128
    121129resourcestring
     
    133141procedure TCore.AExitExecute(Sender: TObject);
    134142begin
    135   FormMain.Close;
     143  Application.Terminate;
    136144end;
    137145
     
    257265    Contacts := TVCardFile(DataFile).VCard.Contacts;
    258266    ShowModal;
    259     FormContacts.ReloadList;
    260     FormMain.UpdateInterface;
     267    DoDataFileChange;
    261268  finally
    262269    Free;
     
    270277    Contacts := TVCardFile(DataFile).VCard.Contacts;
    271278    ShowModal;
    272     FormContacts.ReloadList;
    273     FormMain.UpdateInterface;
     279    DoDataFileChange;
    274280  finally
    275281    Free;
     
    283289    Contacts := TVCardFile(DataFile).VCard.Contacts;
    284290    if ShowModal = mrOk then begin
    285       FormContacts.ReloadList;
    286       FormContacts.UpdateInterface;
    287291      DataFile.Modified := True;
    288       FormMain.UpdateInterface;
     292      DoDataFileChange;
    289293    end;
    290294  finally
     
    317321    if ShowModal = mrOK then begin
    318322      SaveData;
    319       ThemeManager1.UseTheme(FormMain);
    320       ThemeManager1.UseTheme(FormContacts);
     323      //ThemeManager1.UseTheme(FormMain);
     324      //ThemeManager1.UseTheme(FormContacts);
    321325    end;
    322326  finally
     
    435439  RecentFileRegistryContext := TRegistryContext.Create(ApplicationInfo1.RegistryRoot,
    436440    ApplicationInfo1.RegistryKey + '\RecentFiles');
     441
     442  FormMain := TFormMain.Create(nil);
     443  FormMain.Show;
    437444end;
    438445
     
    443450  if Assigned(ProfileImage) then
    444451    FreeAndNil(ProfileImage);
     452  FreeAndNil(FormMain);
    445453end;
    446454
    447455procedure TCore.LastOpenedList1Change(Sender: TObject);
    448456begin
    449   LastOpenedList1.LoadToMenuItem(FormMain.MenuItemFileOpenRecent, AFileOpenRecentExecute);
    450   LastOpenedList1.LoadToMenuItem(FormMain.PopupMenuOpenRecent.Items, AFileOpenRecentExecute);
     457  if Assigned(FOnLastOpenedListChange) then
     458    FOnLastOpenedListChange(Self);
    451459end;
    452460
     
    462470
    463471procedure TCore.FileOpen(FileName: string);
     472var
     473  FormError: TFormError;
    464474begin
    465475  if FileExists(FileName) then begin
     
    519529begin
    520530  UpdateInterface;
    521   FormMain.UpdateInterface;
    522   if Assigned(FormContacts) then begin
    523     if Assigned(DataFile) then
    524       FormContacts.Contacts := TVCardFile(DataFile).VCard.Contacts
    525       else FormContacts.Contacts := nil;
    526     FormContacts.ReloadList;
    527     FormContacts.UpdateInterface;
    528   end;
     531  DoDataFileChange;
    529532end;
    530533
     
    543546      ThemeManager1.Theme := ThemeManager1.Themes.FindByName(ReadStringWithDefault('Theme', 'System'))
    544547      else ThemeManager1.Theme := ThemeManager1.Themes.FindByName('System');
    545     FormMain.MenuItemToolbar.Checked := ReadBoolWithDefault('ToolBarVisible', True);
    546548    ReopenLastFileOnStart := ReadBoolWithDefault('ReopenLastFileOnStart', True);
    547549    LastContactTabIndex := ReadIntegerWithDefault('LastContactTabIndex', 0);
     
    571573      WriteString('Theme', ThemeManager1.Theme.Name)
    572574      else DeleteValue('Theme');
    573     WriteBool('ToolBarVisible', FormMain.MenuItemToolbar.Checked);
    574575    WriteBool('ReopenLastFileOnStart', ReopenLastFileOnStart);
    575576    WriteInteger('LastContactTabIndex', LastContactTabIndex);
     
    600601    SaveToRegistry(RecentFileRegistryContext);
    601602  end;
     603end;
     604
     605procedure TCore.DoDataFileChange;
     606begin
     607  if Assigned(FOnDataFileChange) then
     608    FOnDataFileChange(Self);
    602609end;
    603610
Note: See TracChangeset for help on using the changeset viewer.