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/Forms/FormMain.pas

    r148 r149  
    1 unit UFormMain;
     1unit FormMain;
    22
    33interface
     
    55uses
    66  Classes, SysUtils, LazFileUtils, Forms, Controls, Graphics, Dialogs, Menus,
    7   ComCtrls;
     7  ComCtrls, FormContacts;
    88
    99type
     
    6565    procedure SetToolbarHints;
    6666    procedure UpdateFormTitle;
     67    procedure DataFileChangeExecute(Sender: TObject);
     68    procedure LastOpenedFileChangeExecute(Sender: TObject);
     69    procedure LoadConfig;
     70    procedure SaveConfig;
    6771  public
     72    FormContacts: TFormContacts;
    6873    procedure UpdateInterface;
    6974  end;
    7075
    71 var
    72   FormMain: TFormMain;
    73 
    7476
    7577implementation
     
    7880
    7981uses
    80   UCore, UFormContacts, VCard, UVCardFile, RegistryEx;
     82  Core, VCard, VCardFile, RegistryEx;
    8183
    8284resourcestring
     
    8890begin
    8991  FormContacts.Close;
    90   Core.PersistentForm1.Save(Self);
     92  Core.Core.PersistentForm1.Save(Self);
     93  Application.Terminate;
    9194end;
    9295
    9396procedure TFormMain.FormCloseQuery(Sender: TObject; var CanClose: boolean);
    9497begin
    95   Core.AFileClose.Execute;
    96   CanClose := Core.FileClosed;
     98  Core.Core.AFileClose.Execute;
     99  CanClose := Core.Core.FileClosed;
    97100end;
    98101
    99102procedure TFormMain.FormCreate(Sender: TObject);
    100103begin
     104  Core.Core.Translator.TranslateComponentRecursive(Self);
     105  Core.Core.ThemeManager1.UseTheme(Self);
     106
    101107  FormContacts := TFormContacts.Create(nil);
     108  Core.Core.OnDataFileChange := DataFileChangeExecute;
     109  Core.Core.OnLastOpenedListChange := LastOpenedFileChangeExecute;
    102110end;
    103111
     
    117125  try
    118126    SetToolbarHints;
    119     Core.Initialize;
    120     Core.ThemeManager1.UseTheme(Self);
    121     Core.PersistentForm1.Load(Self);
    122     Core.ScaleDPI1.ScaleControl(CoolBar1, Core.ScaleDPI1.DesignDPI);
     127    Core.Core.Initialize;
     128    Core.Core.ThemeManager1.UseTheme(Self);
     129    Core.Core.PersistentForm1.Load(Self);
     130    Core.Core.ScaleDPI1.ScaleControl(CoolBar1, Core.Core.ScaleDPI1.DesignDPI);
    123131    CoolBar1.AutosizeBands;
    124132
    125     FormContacts.Context := TRegistryContext.Create(Core.ApplicationInfo1.RegistryRoot,
    126       Core.ApplicationInfo1.RegistryKey + '\ContactsColumns');
    127     FormContacts.Contacts := TVCardFile(Core.DataFile).VCard.Contacts;
     133    FormContacts.Context := TRegistryContext.Create(Core.Core.ApplicationInfo1.RegistryRoot,
     134      Core.Core.ApplicationInfo1.RegistryKey + '\ContactsColumns');
     135    FormContacts.Contacts := TVCardFile(Core.Core.DataFile).VCard.Contacts;
    128136    FormContacts.ManualDock(Self, nil, alClient);
    129137    FormContacts.Align := alClient;
     
    166174begin
    167175  Title := '';
    168   if Assigned(Core.DataFile) and
    169   (ExtractFileNameWithoutExt(ExtractFileName(Core.DataFile.FileName)) <> '') then
    170     Title := Title + ExtractFileNameWithoutExt(ExtractFileName(Core.DataFile.FileName));
    171   if Assigned(Core.DataFile) and Core.DataFile.Modified then
     176  if Assigned(Core.Core.DataFile) and
     177  (ExtractFileNameWithoutExt(ExtractFileName(Core.Core.DataFile.FileName)) <> '') then
     178    Title := Title + ExtractFileNameWithoutExt(ExtractFileName(Core.Core.DataFile.FileName));
     179  if Assigned(Core.Core.DataFile) and Core.Core.DataFile.Modified then
    172180    Title := Title + ' (' + SModified + ')';
    173181  if Title <> '' then Title := Title + ' - ';
    174   Title := Title + Core.ApplicationInfo1.AppName;
     182  Title := Title + Core.Core.ApplicationInfo1.AppName;
    175183  //Application.Title := Title;
    176184  Caption := Title;
    177185end;
    178186
     187procedure TFormMain.DataFileChangeExecute(Sender: TObject);
     188begin
     189  if Assigned(FormContacts) then begin
     190    if Assigned(Core.Core.DataFile) then
     191      FormContacts.Contacts := TVCardFile(Core.Core.DataFile).VCard.Contacts
     192      else FormContacts.Contacts := nil;
     193  end;
     194
     195  FormContacts.ReloadList;
     196  FormContacts.UpdateInterface;
     197  UpdateInterface;
     198end;
     199
     200procedure TFormMain.LastOpenedFileChangeExecute(Sender: TObject);
     201begin
     202  Core.Core.LastOpenedList1.LoadToMenuItem(MenuItemFileOpenRecent, Core.Core.AFileOpenRecentExecute);
     203  Core.Core.LastOpenedList1.LoadToMenuItem(PopupMenuOpenRecent.Items, Core.Core.AFileOpenRecentExecute);
     204end;
     205
     206procedure TFormMain.LoadConfig;
     207begin
     208  with TRegistryEx.Create do
     209  try
     210    CurrentContext := Core.Core.ApplicationInfo1.GetRegistryContext;
     211    MenuItemToolbar.Checked := ReadBoolWithDefault('ToolBarVisible', True);
     212  finally
     213    Free;
     214  end;
     215end;
     216
     217procedure TFormMain.SaveConfig;
     218begin
     219  with TRegistryEx.Create do
     220  try
     221    CurrentContext := Core.Core.ApplicationInfo1.GetRegistryContext;
     222    WriteBool('ToolBarVisible', MenuItemToolbar.Checked);
     223  finally
     224    Free;
     225  end;
     226end;
     227
    179228procedure TFormMain.UpdateInterface;
    180229begin
Note: See TracChangeset for help on using the changeset viewer.