Changeset 13 for trunk/UCore.pas
- Timestamp:
- May 30, 2015, 1:02:36 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UCore.pas
r10 r13 19 19 ACommandCommit: TAction; 20 20 ACommandStatus: TAction; 21 AProjectGroupSaveAs: TAction; 22 AProjectGroupSave: TAction; 23 AProjectGroupClose: TAction; 24 AProjectGroupOpen: TAction; 25 AProjectGroupNew: TAction; 26 AViewTest: TAction; 21 27 AProjectCheckout: TAction; 22 28 AProjectClose: TAction; … … 28 34 AViewFavorites: TAction; 29 35 ImageList1: TImageList; 30 LastOpenedList 1: TLastOpenedList;36 LastOpenedListProject: TLastOpenedList; 31 37 LastOpenedListNewDir: TLastOpenedList; 38 LastOpenedListProjectGroup: TLastOpenedList; 32 39 LastOpenedListRepoURL: TLastOpenedList; 33 40 OpenDialog1: TOpenDialog; 41 SaveDialog1: TSaveDialog; 34 42 XMLConfig1: TXMLConfig; 35 43 procedure ACommandCheckoutExecute(Sender: TObject); … … 39 47 procedure AProjectCheckoutExecute(Sender: TObject); 40 48 procedure AProjectCloseExecute(Sender: TObject); 49 procedure AProjectGroupCloseExecute(Sender: TObject); 50 procedure AProjectGroupNewExecute(Sender: TObject); 51 procedure AProjectGroupOpenExecute(Sender: TObject); 52 procedure AProjectGroupSaveAsExecute(Sender: TObject); 53 procedure AProjectGroupSaveExecute(Sender: TObject); 41 54 procedure AProjectOpenExecute(Sender: TObject); 42 55 procedure AQuitExecute(Sender: TObject); 43 56 procedure ASettingsExecute(Sender: TObject); 57 procedure AViewTestExecute(Sender: TObject); 44 58 procedure DataModuleCreate(Sender: TObject); 45 59 procedure DataModuleDestroy(Sender: TObject); 46 procedure LastOpenedList1Change(Sender: TObject); 60 procedure LastOpenedListProjectChange(Sender: TObject); 61 procedure LastOpenedListProjectGroupChange(Sender: TObject); 47 62 private 48 63 procedure UpdateInterface; … … 53 68 Backends: TObjectList; // TList<TBackend> 54 69 Project: TProject; 70 ProjectGroup: TProjectGroup; 71 UserName: string; 72 Email: string; 55 73 procedure LoadConfig; 56 74 procedure SaveConfig; … … 58 76 procedure Done; 59 77 procedure ProjectOpen(Directory: string); 78 procedure ProjectGroupOpen(FileName: string); 60 79 end; 61 80 … … 69 88 uses 70 89 UFormMain, UFormBrowse, UFormSettings, UFormCommit, UFormCheckout, 71 USubversion, UBazaar, UCVS ;90 USubversion, UBazaar, UCVS, UGit, UFormTest, UFormProjectGroup; 72 91 73 92 { TCore } … … 80 99 procedure TCore.ASettingsExecute(Sender: TObject); 81 100 begin 82 FormSettings.ShowModal; 101 FormSettings.Load(XMLConfig1); 102 if FormSettings.ShowModal = mrOk then begin 103 FormSettings.Save(XMLConfig1); 104 end; 105 end; 106 107 procedure TCore.AViewTestExecute(Sender: TObject); 108 begin 109 FormTest.Show; 83 110 end; 84 111 … … 95 122 end; 96 123 97 procedure TCore.LastOpenedList1Change(Sender: TObject); 98 begin 99 LastOpenedList1.LoadToMenuItem(FormMain.MenuItemOpenRecent, FormMain.OpenRecentExecute); 124 procedure TCore.LastOpenedListProjectChange(Sender: TObject); 125 begin 126 LastOpenedListProject.LoadToMenuItem(FormMain.MenuItemOpenRecent, FormMain.OpenRecentExecute); 127 end; 128 129 procedure TCore.LastOpenedListProjectGroupChange(Sender: TObject); 130 begin 131 LastOpenedListProjectGroup.LoadToMenuItem(FormMain.MenuItemRecentProjectGroup, FormMain.ProjectGroupOpenRecentExecute); 100 132 end; 101 133 … … 103 135 begin 104 136 AProjectClose.Enabled := Assigned(Project); 137 AProjectGroupClose.Enabled := Assigned(ProjectGroup); 138 AProjectGroupSave.Enabled := Assigned(ProjectGroup); 139 AProjectGroupSaveAs.Enabled := Assigned(ProjectGroup); 105 140 FormMain.UpdateInterface; 106 141 end; … … 111 146 RegisterBackend(TBackendBazaar.Create); 112 147 RegisterBackend(TBackendCVS.Create); 148 RegisterBackend(TBackendGit.Create); 113 149 end; 114 150 … … 130 166 procedure TCore.LoadConfig; 131 167 begin 132 LastOpenedList 1.LoadFromXMLConfig(XMLConfig1, 'LastOpenedProjects');168 LastOpenedListProject.LoadFromXMLConfig(XMLConfig1, 'LastOpenedProjects'); 133 169 LastOpenedListRepoURL.LoadFromXMLConfig(XMLConfig1, 'LastOpenedRepoURL'); 134 170 LastOpenedListNewDir.LoadFromXMLConfig(XMLConfig1, 'LastOpenedNewDir'); 171 LastOpenedListProjectGroup.LoadFromXMLConfig(XMLConfig1, 'LastOpenedListProjectGroup'); 172 UserName := XMLConfig1.GetValue('UserName', ''); 173 Email := XMLConfig1.GetValue('Email', ''); 135 174 end; 136 175 137 176 procedure TCore.SaveConfig; 138 177 begin 139 LastOpenedList 1.SaveToXMLConfig(XMLConfig1, 'LastOpenedProjects');178 LastOpenedListProject.SaveToXMLConfig(XMLConfig1, 'LastOpenedProjects'); 140 179 LastOpenedListRepoURL.SaveToXMLConfig(XMLConfig1, 'LastOpenedRepoURL'); 141 180 LastOpenedListNewDir.SaveToXMLConfig(XMLConfig1, 'LastOpenedNewDir'); 181 LastOpenedListProjectGroup.SaveToXMLConfig(XMLConfig1, 'LastOpenedListProjectGroup'); 182 XMLConfig1.SetValue('UserName', UserName); 183 XMLConfig1.SetValue('Email', Email); 142 184 end; 143 185 … … 146 188 RegisterBackends; 147 189 LoadConfig; 148 if (LastOpenedList 1.Items.Count > 0) and DirectoryExistsUTF8(LastOpenedList1.Items[0]) then149 ProjectOpen(LastOpenedList 1.Items[0]);190 if (LastOpenedListProject.Items.Count > 0) and DirectoryExistsUTF8(LastOpenedListProject.Items[0]) then 191 ProjectOpen(LastOpenedListProject.Items[0]); 150 192 end; 151 193 … … 160 202 Project := TProject.Create; 161 203 Project.Backend := DetectBackend(Directory); 204 Project.WorkingCopy.UserName := Core.UserName; 205 Project.WorkingCopy.Email := Core.Email; 162 206 if Assigned(Project.Backend) then begin 163 207 Project.Directory := Directory; … … 165 209 FormBrowse.Directory := Project.Directory; 166 210 FormBrowse.ReloadList; 167 LastOpenedList 1.AddItem(Project.Directory);211 LastOpenedListProject.AddItem(Project.Directory); 168 212 end else ShowMessage('Directory not recognized as working copy of any of supported VCS systems'); 213 end; 214 215 procedure TCore.ProjectGroupOpen(FileName: string); 216 begin 217 AProjectGroupClose.Execute; 218 ProjectGroup := TProjectGroup.Create; 219 ProjectGroup.FileName := FileName; 220 UpdateInterface; 221 FormProjectGroup.ReloadTree; 222 LastOpenedListProjectGroup.AddItem(FileName); 169 223 end; 170 224 … … 187 241 FormBrowse.ReloadList; 188 242 UpdateInterface; 243 end; 244 245 procedure TCore.AProjectGroupCloseExecute(Sender: TObject); 246 begin 247 FreeAndNil(ProjectGroup); 248 UpdateInterface; 249 FormProjectGroup.ReloadTree; 250 end; 251 252 procedure TCore.AProjectGroupNewExecute(Sender: TObject); 253 begin 254 AProjectClose.Execute; 255 ProjectGroup := TProjectGroup.Create; 256 ProjectGroup.FileName := 'New project group.vcgrp'; 257 UpdateInterface; 258 FormProjectGroup.ReloadTree; 259 end; 260 261 procedure TCore.AProjectGroupOpenExecute(Sender: TObject); 262 begin 263 if LastOpenedListProjectGroup.Items.Count > 0 then 264 OpenDialog1.FileName := LastOpenedListProjectGroup.Items[0]; 265 if OpenDialog1.Execute then begin 266 AProjectClose.Execute; 267 ProjectGroupOpen(OpenDialog1.FileName); 268 end; 269 end; 270 271 procedure TCore.AProjectGroupSaveAsExecute(Sender: TObject); 272 begin 273 SaveDialog1.FileName := ProjectGroup.FileName; 274 if SaveDialog1.Execute then begin 275 ProjectGroup.SaveToFile(SaveDialog1.FileName); 276 UpdateInterface; 277 end; 278 end; 279 280 procedure TCore.AProjectGroupSaveExecute(Sender: TObject); 281 begin 282 if FileExistsUTF8(ProjectGroup.FileName) then ProjectGroup.SaveToFile(ProjectGroup.FileName) 283 else AProjectGroupSaveAs.Execute; 189 284 end; 190 285
Note:
See TracChangeset
for help on using the changeset viewer.