Changeset 6 for trunk/UCore.pas


Ignore:
Timestamp:
May 6, 2015, 11:19:49 AM (10 years ago)
Author:
chronos
Message:
  • Added: Now opened projects are remembered between application restarts.
  • Added: Show basic list of files in selected project.
  • Added: Packages Common and TemplateGenerics.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UCore.pas

    r5 r6  
    66
    77uses
    8   Classes, SysUtils, FileUtil, ActnList, Controls, UVCS, UProject, Forms,
    9   Dialogs;
     8  Classes, SysUtils, XMLConf, FileUtil, ActnList, Controls, UVCS, UProject,
     9  ULastOpenedList, Forms, Dialogs;
    1010
    1111type
     
    2828    AViewFavorites: TAction;
    2929    ImageList1: TImageList;
     30    LastOpenedList1: TLastOpenedList;
    3031    OpenDialog1: TOpenDialog;
     32    XMLConfig1: TXMLConfig;
    3133    procedure ACommandCheckoutExecute(Sender: TObject);
    3234    procedure ACommandCleanupExecute(Sender: TObject);
     
    3840    procedure DataModuleCreate(Sender: TObject);
    3941    procedure DataModuleDestroy(Sender: TObject);
     42    procedure LastOpenedList1Change(Sender: TObject);
    4043  private
    4144    procedure UpdateInterface;
    4245  public
    4346    Project: TProject;
     47    procedure LoadConfig;
     48    procedure SaveConfig;
     49    procedure Init;
     50    procedure Done;
     51    procedure ProjectOpen(Directory: string);
    4452  end;
    4553
     
    5260
    5361uses
    54   UFormMain;
     62  UFormMain, UFormBrowse;
    5563
    5664{ TCore }
     
    7179end;
    7280
     81procedure TCore.LastOpenedList1Change(Sender: TObject);
     82begin
     83  LastOpenedList1.LoadToMenuItem(FormMain.MenuItemOpenRecent, FormMain.OpenRecentExecute);
     84end;
     85
    7386procedure TCore.UpdateInterface;
    7487begin
    7588  AProjectClose.Enabled := Assigned(Project);
    7689  FormMain.UpdateInterface;
     90end;
     91
     92procedure TCore.LoadConfig;
     93begin
     94  LastOpenedList1.LoadFromXMLConfig(XMLConfig1, 'LastOpenedProjects');
     95end;
     96
     97procedure TCore.SaveConfig;
     98begin
     99  LastOpenedList1.SaveToXMLConfig(XMLConfig1, 'LastOpenedProjects');
     100end;
     101
     102procedure TCore.Init;
     103begin
     104  LoadConfig;
     105  if (LastOpenedList1.Items.Count > 0) and DirectoryExistsUTF8(LastOpenedList1.Items[0]) then
     106    ProjectOpen(LastOpenedList1.Items[0]);
     107end;
     108
     109procedure TCore.Done;
     110begin
     111  SaveConfig;
     112end;
     113
     114procedure TCore.ProjectOpen(Directory: string);
     115begin
     116  AProjectClose.Execute;
     117  Project := TProject.Create;
     118  Project.VCSType := vtSubversion;
     119  Project.Directory := Directory;
     120  UpdateInterface;
     121  FormBrowse.Directory := Project.Directory;
     122  FormBrowse.ReloadList;
     123  LastOpenedList1.AddItem(Project.Directory);
    77124end;
    78125
     
    85132    else OldDir := '';
    86133  if SelectDirectory('Open project', OldDir, Dir) then begin
    87     AProjectClose.Execute;
    88     Project := TProject.Create;
    89     Project.Directory := Dir;
    90     UpdateInterface;
     134    ProjectOpen(Dir);
    91135  end;
    92136end;
Note: See TracChangeset for help on using the changeset viewer.