Ignore:
Timestamp:
Aug 6, 2012, 2:35:22 PM (12 years ago)
Author:
chronos
Message:
  • Added: Registration of new file templates for modules.
  • Added: Program stores last opened file list in registry.
Location:
trunk/StudioModules/LDModuleProject
Files:
6 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/StudioModules/LDModuleProject/LDModuleProject.lpk

    r11 r15  
    3131      </Item3>
    3232    </Files>
     33    <i18n>
     34      <EnableI18N Value="True"/>
     35      <OutDir Value="Languages"/>
     36      <EnableI18NForLFM Value="True"/>
     37    </i18n>
    3338    <Type Value="RunAndDesignTime"/>
    34     <RequiredPkgs Count="2">
     39    <RequiredPkgs Count="3">
    3540      <Item1>
    36         <PackageName Value="LDStudioCommon"/>
     41        <PackageName Value="Common"/>
    3742      </Item1>
    3843      <Item2>
     44        <PackageName Value="LDStudioCommon"/>
     45      </Item2>
     46      <Item3>
    3947        <PackageName Value="FCL"/>
    40       </Item2>
     48      </Item3>
    4149    </RequiredPkgs>
    4250    <UsageOptions>
  • trunk/StudioModules/LDModuleProject/ULDModuleProject.lfm

    r12 r15  
    11object DataModuleProject: TDataModuleProject
     2  OnCreate = DataModuleCreate
    23  OnDestroy = DataModuleDestroy
    34  OldCreateOrder = False
    45  Height = 328
    5   HorizontalOffset = 255
    6   VerticalOffset = 75
     6  HorizontalOffset = 390
     7  VerticalOffset = 142
    78  Width = 409
    89  object ActionList1: TActionList
     
    1920    object AOpenRecent: TAction
    2021      Caption = 'Open recent'
     22      OnExecute = AOpenRecentExecute
    2123    end
    2224    object ASave: TAction
     
    4648      Action = AOpen
    4749    end
    48     object MenuItem3: TMenuItem
     50    object MenuItemOpenRecent: TMenuItem
    4951      Action = AOpenRecent
    5052    end
     
    7375    top = 120
    7476  end
     77  object LastOpenedList1: TLastOpenedList
     78    MaxCount = 10
     79    OnChange = LastOpenedList1Change
     80    left = 125
     81    top = 64
     82  end
    7583end
  • trunk/StudioModules/LDModuleProject/ULDModuleProject.pas

    r14 r15  
    77uses
    88  Classes, SysUtils, FileUtil, ActnList, Menus, Dialogs, UModularSystem,
    9   UProject;
     9  ULastOpenedList, UProject, URegistry, USource;
    1010
    1111type
     
    2222    ANew: TAction;
    2323    ActionList1: TActionList;
     24    LastOpenedList1: TLastOpenedList;
    2425    MenuItem1: TMenuItem;
    2526    MenuItem2: TMenuItem;
    26     MenuItem3: TMenuItem;
     27    MenuItemOpenRecent: TMenuItem;
    2728    MenuItem4: TMenuItem;
    2829    MenuItem5: TMenuItem;
     
    3637    procedure ANewExecute(Sender: TObject);
    3738    procedure AOpenExecute(Sender: TObject);
     39    procedure AOpenRecentExecute(Sender: TObject);
    3840    procedure AProjectManagerExecute(Sender: TObject);
    3941    procedure ASaveAsExecute(Sender: TObject);
    4042    procedure ASaveExecute(Sender: TObject);
     43    procedure DataModuleCreate(Sender: TObject);
    4144    procedure DataModuleDestroy(Sender: TObject);
     45    procedure LastOpenedList1Change(Sender: TObject);
    4246  private
    4347    { private declarations }
     
    4549    Project: TProject;
    4650    procedure UpdateInterface;
     51    procedure LoadFromRegistry(Context: TRegistryContext);
     52    procedure SaveToRegistry(Context: TRegistryContext);
    4753  end;
    4854
     
    5157  TLDModuleProject = class(TModule)
    5258  private
     59    ProjectFileType: TSourceType;
    5360  public
    5461    constructor Create; override;
     
    93100end;
    94101
     102procedure TDataModuleProject.DataModuleCreate(Sender: TObject);
     103begin
     104
     105end;
     106
    95107procedure TDataModuleProject.DataModuleDestroy(Sender: TObject);
    96108begin
    97109  AClose.Execute;
     110end;
     111
     112procedure TDataModuleProject.LastOpenedList1Change(Sender: TObject);
     113begin
     114  LastOpenedList1.LoadToMenuItem(MenuItemOpenRecent, AOpenRecentExecute);
    98115end;
    99116
     
    103120  ASaveAs.Enabled := Assigned(Project);
    104121  AClose.Enabled := Assigned(Project);
     122end;
     123
     124procedure TDataModuleProject.LoadFromRegistry(Context: TRegistryContext);
     125begin
     126  LastOpenedList1.LoadFromRegistry(Context.RootKey, Context.Key + '\RecentFile');
     127end;
     128
     129procedure TDataModuleProject.SaveToRegistry(Context: TRegistryContext);
     130begin
     131  LastOpenedList1.SaveToRegistry(Context.RootKey, Context.Key + '\RecentFile');
    105132end;
    106133
     
    122149procedure TDataModuleProject.AOpenExecute(Sender: TObject);
    123150begin
    124   OpenDialog1.FileName := Project.FileName;
     151  if Assigned(Project) then
     152    OpenDialog1.FileName := Project.FileName;
    125153  if OpenDialog1.Execute then begin
    126154    Project.FileName := OpenDialog1.FileName;
     
    128156    UpdateInterface;
    129157  end;
     158end;
     159
     160procedure TDataModuleProject.AOpenRecentExecute(Sender: TObject);
     161begin
     162
    130163end;
    131164
     
    150183    DataModuleProject.PopupMenu1.Items.Caption := SProject;
    151184    RegisterMainMenuItem(DataModuleProject.PopupMenu1.Items, nil, 1);
     185    DataModuleProject.LoadFromRegistry(RegContext(GetRegistryContext.RootKey,
     186      GetRegistryContext.Key + '\Project'));
     187    DataModuleProject.UpdateInterface;
     188    ProjectFileType := TSourceType.Create;
     189    ProjectFileType.Extension := '.ldp';
     190    ProjectFileType.Title := 'LibreDevelop project';
     191    RegisterFileType(ProjectFileType);
    152192  end;
    153193  inherited;
     
    158198  inherited;
    159199  with TLDStudioAPI(API) do begin
     200    UnregisterFileType(ProjectFileType);
     201    DataModuleProject.SaveToRegistry(RegContext(GetRegistryContext.RootKey,
     202      GetRegistryContext.Key + '\Project'));
    160203    UnregisterMainMenuItem(DataModuleProject.PopupMenu1.Items);
    161204    FreeAndNil(DataModuleProject);
  • trunk/StudioModules/LDModuleProject/UProject.pas

    r11 r15  
    77uses
    88  Classes, SysUtils, Dialogs, DOM, XMLWrite, XMLRead, FileUtil,
    9   SpecializedList;
     9  SpecializedList, USource;
    1010
    1111const
     
    7171  end;
    7272
    73   TProject = class
     73  TProject = class(TSource)
    7474  private
    7575    FModified: Boolean;
Note: See TracChangeset for help on using the changeset viewer.