Changeset 4 for trunk/UCore.pas


Ignore:
Timestamp:
Sep 1, 2014, 7:10:03 PM (10 years ago)
Author:
chronos
Message:
  • Added: Concept of project and open project as directory.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UCore.pas

    r1 r4  
    11unit UCore;
    22
    3 {$mode objfpc}{$H+}
     3{$mode delphi}{$H+}
    44
    55interface
    66
    77uses
    8   Classes, SysUtils, FileUtil;
     8  Classes, SysUtils, FileUtil, ActnList, Controls, UVCS, UProject, Forms,
     9  Dialogs;
    910
    1011type
     12
     13  { TCore }
     14
    1115  TCore = class(TDataModule)
     16    AAbout: TAction;
     17    AProjectClose: TAction;
     18    ActionList1: TActionList;
     19    AHelp: TAction;
     20    AProjectOpen: TAction;
     21    AQuit: TAction;
     22    ASettings: TAction;
     23    AViewFavorites: TAction;
     24    ImageList1: TImageList;
     25    OpenDialog1: TOpenDialog;
     26    procedure AProjectCloseExecute(Sender: TObject);
     27    procedure AProjectOpenExecute(Sender: TObject);
     28    procedure AQuitExecute(Sender: TObject);
     29    procedure DataModuleCreate(Sender: TObject);
     30    procedure DataModuleDestroy(Sender: TObject);
    1231  private
    13     { private declarations }
     32    procedure UpdateInterface;
    1433  public
    15     { public declarations }
     34    Project: TProject;
    1635  end;
    1736
     
    2342{$R *.lfm}
    2443
     44uses
     45  UFormMain;
     46
     47{ TCore }
     48
     49procedure TCore.AQuitExecute(Sender: TObject);
     50begin
     51  Application.Terminate;
     52end;
     53
     54procedure TCore.DataModuleCreate(Sender: TObject);
     55begin
     56  UpdateInterface;
     57end;
     58
     59procedure TCore.DataModuleDestroy(Sender: TObject);
     60begin
     61  Project.Free;
     62end;
     63
     64procedure TCore.UpdateInterface;
     65begin
     66  AProjectClose.Enabled := Assigned(Project);
     67  FormMain.UpdateInterface;
     68end;
     69
     70procedure TCore.AProjectOpenExecute(Sender: TObject);
     71var
     72  Dir: string;
     73  OldDir: string;
     74begin
     75  if Assigned(Project) then OldDir := Project.Directory
     76    else OldDir := '';
     77  if SelectDirectory('Open project', OldDir, Dir) then begin
     78    AProjectClose.Execute;
     79    Project := TProject.Create;
     80    Project.Directory := Dir;
     81    UpdateInterface;
     82  end;
     83end;
     84
     85procedure TCore.AProjectCloseExecute(Sender: TObject);
     86begin
     87  FreeAndNil(Project);
     88  UpdateInterface;
     89end;
     90
    2591end.
    2692
Note: See TracChangeset for help on using the changeset viewer.