Changeset 149 for trunk/Forms/FormMain.pas
- Timestamp:
- Jun 5, 2023, 8:45:38 PM (18 months ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/FormMain.pas
r148 r149 1 unit UFormMain;1 unit FormMain; 2 2 3 3 interface … … 5 5 uses 6 6 Classes, SysUtils, LazFileUtils, Forms, Controls, Graphics, Dialogs, Menus, 7 ComCtrls ;7 ComCtrls, FormContacts; 8 8 9 9 type … … 65 65 procedure SetToolbarHints; 66 66 procedure UpdateFormTitle; 67 procedure DataFileChangeExecute(Sender: TObject); 68 procedure LastOpenedFileChangeExecute(Sender: TObject); 69 procedure LoadConfig; 70 procedure SaveConfig; 67 71 public 72 FormContacts: TFormContacts; 68 73 procedure UpdateInterface; 69 74 end; 70 75 71 var72 FormMain: TFormMain;73 74 76 75 77 implementation … … 78 80 79 81 uses 80 UCore, UFormContacts, VCard, UVCardFile, RegistryEx;82 Core, VCard, VCardFile, RegistryEx; 81 83 82 84 resourcestring … … 88 90 begin 89 91 FormContacts.Close; 90 Core.PersistentForm1.Save(Self); 92 Core.Core.PersistentForm1.Save(Self); 93 Application.Terminate; 91 94 end; 92 95 93 96 procedure TFormMain.FormCloseQuery(Sender: TObject; var CanClose: boolean); 94 97 begin 95 Core. AFileClose.Execute;96 CanClose := Core. FileClosed;98 Core.Core.AFileClose.Execute; 99 CanClose := Core.Core.FileClosed; 97 100 end; 98 101 99 102 procedure TFormMain.FormCreate(Sender: TObject); 100 103 begin 104 Core.Core.Translator.TranslateComponentRecursive(Self); 105 Core.Core.ThemeManager1.UseTheme(Self); 106 101 107 FormContacts := TFormContacts.Create(nil); 108 Core.Core.OnDataFileChange := DataFileChangeExecute; 109 Core.Core.OnLastOpenedListChange := LastOpenedFileChangeExecute; 102 110 end; 103 111 … … 117 125 try 118 126 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); 123 131 CoolBar1.AutosizeBands; 124 132 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; 128 136 FormContacts.ManualDock(Self, nil, alClient); 129 137 FormContacts.Align := alClient; … … 166 174 begin 167 175 Title := ''; 168 if Assigned(Core. DataFile) and169 (ExtractFileNameWithoutExt(ExtractFileName(Core. DataFile.FileName)) <> '') then170 Title := Title + ExtractFileNameWithoutExt(ExtractFileName(Core. DataFile.FileName));171 if Assigned(Core. DataFile) andCore.DataFile.Modified then176 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 172 180 Title := Title + ' (' + SModified + ')'; 173 181 if Title <> '' then Title := Title + ' - '; 174 Title := Title + Core. ApplicationInfo1.AppName;182 Title := Title + Core.Core.ApplicationInfo1.AppName; 175 183 //Application.Title := Title; 176 184 Caption := Title; 177 185 end; 178 186 187 procedure TFormMain.DataFileChangeExecute(Sender: TObject); 188 begin 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; 198 end; 199 200 procedure TFormMain.LastOpenedFileChangeExecute(Sender: TObject); 201 begin 202 Core.Core.LastOpenedList1.LoadToMenuItem(MenuItemFileOpenRecent, Core.Core.AFileOpenRecentExecute); 203 Core.Core.LastOpenedList1.LoadToMenuItem(PopupMenuOpenRecent.Items, Core.Core.AFileOpenRecentExecute); 204 end; 205 206 procedure TFormMain.LoadConfig; 207 begin 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; 215 end; 216 217 procedure TFormMain.SaveConfig; 218 begin 219 with TRegistryEx.Create do 220 try 221 CurrentContext := Core.Core.ApplicationInfo1.GetRegistryContext; 222 WriteBool('ToolBarVisible', MenuItemToolbar.Checked); 223 finally 224 Free; 225 end; 226 end; 227 179 228 procedure TFormMain.UpdateInterface; 180 229 begin
Note:
See TracChangeset
for help on using the changeset viewer.