Changeset 21


Ignore:
Timestamp:
Feb 12, 2012, 8:05:28 PM (13 years ago)
Author:
chronos
Message:
  • Added: Storing last opened project list in registry.
  • Added: Opiton to reopen last opened project.
Location:
trunk
Files:
3 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Languages/LazFuckIDE.cs.po

    r20 r21  
    152152#: tmainform.ashrinksource.caption
    153153msgid "Shrink source"
    154 msgstr ""
     154msgstr "Srazit kód"
    155155
    156156#: tmainform.aviewcompiled.caption
     
    198198msgstr "Program"
    199199
     200#: tmainform.menuitemopenrecent.caption
     201msgid "Open recent"
     202msgstr ""
     203
    200204#: tmainform.menuitemtarget.caption
    201205msgctxt "tmainform.menuitemtarget.caption"
     
    220224msgstr "Volby"
    221225
     226#: toptionsform.checkbox1.caption
     227msgid "Reopend last opened project"
     228msgstr ""
     229
    222230#: toptionsform.label1.caption
    223231msgid "Memory size:"
  • trunk/Languages/LazFuckIDE.po

    r20 r21  
    189189msgstr ""
    190190
     191#: tmainform.menuitemopenrecent.caption
     192msgid "Open recent"
     193msgstr ""
     194
    191195#: tmainform.menuitemtarget.caption
    192196msgctxt "TMAINFORM.MENUITEMTARGET.CAPTION"
     
    211215msgstr ""
    212216
     217#: toptionsform.checkbox1.caption
     218msgid "Reopend last opened project"
     219msgstr ""
     220
    213221#: toptionsform.label1.caption
    214222msgid "Memory size:"
  • trunk/LazFuckIDE.lpi

    r19 r21  
    8585      </Item5>
    8686    </RequiredPackages>
    87     <Units Count="10">
     87    <Units Count="12">
    8888      <Unit0>
    8989        <Filename Value="LazFuckIDE.lpr"/>
     
    144144        <UnitName Value="UCompilerPHP"/>
    145145      </Unit9>
     146      <Unit10>
     147        <Filename Value="Common\ULastOpenedList.pas"/>
     148        <IsPartOfProject Value="True"/>
     149        <UnitName Value="ULastOpenedList"/>
     150      </Unit10>
     151      <Unit11>
     152        <Filename Value="Common\URegistry.pas"/>
     153        <IsPartOfProject Value="True"/>
     154        <UnitName Value="URegistry"/>
     155      </Unit11>
    146156    </Units>
    147157  </ProjectOptions>
     
    154164    <SearchPaths>
    155165      <IncludeFiles Value="$(ProjOutDir)"/>
    156       <OtherUnitFiles Value="Compiler"/>
     166      <OtherUnitFiles Value="Compiler;Common"/>
    157167      <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
    158168    </SearchPaths>
  • trunk/LazFuckIDE.lpr

    r19 r21  
    1010  Interfaces, // this includes the LCL widgetset
    1111  Forms, UMainForm, UBrainFuck, UInterpreterForm, UApplicationInfo,
    12   UCompiledForm, UOptionsForm, CoolTranslator, Common, TemplateGenerics,
    13   UCompiler, UCompilerDelphi, UCompilerPHP
     12  UCompiledForm, UOptionsForm, ULastOpenedList, URegistry, CoolTranslator,
     13  Common, TemplateGenerics, UCompiler, UCompilerDelphi, UCompilerPHP
    1414  { you can add units after this };
    1515
  • trunk/UMainForm.lfm

    r20 r21  
    208208          0000000000000000000000000000000000000000000000000000
    209209        }
     210      end
     211      object MenuItemOpenRecent: TMenuItem
     212        Caption = 'Open recent'
    210213      end
    211214      object MenuItem3: TMenuItem
  • trunk/UMainForm.lrt

    r20 r21  
    22TMAINFORM.TOOLBUTTON5.CAPTION=ToolButton5
    33TMAINFORM.MENUITEM1.CAPTION=Project
     4TMAINFORM.MENUITEMOPENRECENT.CAPTION=Open recent
    45TMAINFORM.MENUITEM5.CAPTION=-
    56TMAINFORM.MENUITEM9.CAPTION=Program
  • trunk/UMainForm.pas

    r20 r21  
    88  Classes, SysUtils, FileUtil, SynEdit, Forms, Controls, Graphics, Dialogs,
    99  Menus, ActnList, StdCtrls, ComCtrls, UBrainFuck, UCoolTranslator, StrUtils,
    10   SpecializedList, UCompiler;
     10  SpecializedList, UCompiler, Registry, URegistry, ULastOpenedList;
     11
     12const
     13  RegistryRoot = HKEY_CURRENT_USER;
    1114
    1215type
     
    6265    MenuItem26: TMenuItem;
    6366    MenuItem27: TMenuItem;
     67    MenuItemOpenRecent: TMenuItem;
    6468    MenuItemTarget: TMenuItem;
    6569    MenuItem3: TMenuItem;
     
    116120      Shift: TShiftState; X, Y: Integer);
    117121  private
     122    procedure AProjectOpenRecentExecute(Sender: TObject);
    118123    procedure BrainFuckInterpreterChangeState(Sender: TObject);
    119124    procedure MenuItemTargetClick(Sender: TObject);
     125    procedure ProjectOpen(FileName: string);
    120126  public
    121127    Modified: Boolean;
     
    126132    BreakPoints: TListInteger;
    127133    Compilers: TListObject; // TListObject<TCompiler>
     134    LastOpenedList: TLastOpenedList;
     135    OpenProjectOnStart: Boolean;
     136    procedure LoadFromRegistry(Root: HKEY; Key: string);
     137    procedure SaveToRegistry(Root: HKEY; Key: string);
    128138    procedure UpdateInterface;
    129139    procedure UpdateStatusBar;
     
    146156procedure TMainForm.FormShow(Sender: TObject);
    147157begin
    148   AProjectNew.Execute;
     158  if OpenProjectOnStart and (LastOpenedList.Count > 0) then
     159    ProjectOpen(LastOpenedList[0])
     160    else AProjectNew.Execute;
    149161end;
    150162
     
    190202    for I := 0 to Parent.Count - 1 do
    191203      if Parent.Items[I].MenuIndex <> MenuIndex then Parent.Items[I].Checked := False
     204  end;
     205end;
     206
     207procedure TMainForm.ProjectOpen(FileName: string);
     208begin
     209  MemoSource.Lines.LoadFromFile(UTF8Decode(FileName));
     210  LastOpenedList.AddItem(FileName);
     211  ProjectFileName := FileName;
     212  UpdateInterface;
     213  Modified := False;
     214end;
     215
     216procedure TMainForm.LoadFromRegistry(Root: HKEY; Key: string);
     217begin
     218  with TRegistryEx.Create do
     219  try
     220    RootKey := Root;
     221    OpenKey(Key, True);
     222    OpenProjectOnStart := ReadBoolWithDefault('OpenProjectOnStart', True);
     223  finally
     224    Free;
     225  end;
     226  LastOpenedList.LoadFromRegistry(Root, Key);
     227end;
     228
     229procedure TMainForm.SaveToRegistry(Root: HKEY; Key: string);
     230begin
     231  LastOpenedList.SaveToRegistry(Root, Key);
     232  with TRegistryEx.Create do
     233  try
     234    RootKey := Root;
     235    OpenKey(Key, True);
     236    WriteBool('OpenProjectOnStart', OpenProjectOnStart);
     237  finally
     238    Free;
    192239  end;
    193240end;
     
    242289  Compilers.Add(TBrainFuckCompilerPHP.Create);
    243290  UpdateTergetList;
     291  LastOpenedList := TLastOpenedList.Create;
     292  LastOpenedList.MenuItem := MenuItemOpenRecent;
     293  LastOpenedList.ClickAction := AProjectOpenRecentExecute;
     294  LoadFromRegistry(RegistryRoot, ApplicationInfo.RegistryKey);
    244295end;
    245296
    246297procedure TMainForm.FormDestroy(Sender: TObject);
    247298begin
     299  SaveToRegistry(RegistryRoot, ApplicationInfo.RegistryKey);
     300  LastOpenedList.Free;
    248301  Compilers.Free;
    249302  BrainFuckCompiler.Free;
     
    377430end;
    378431
     432procedure TMainForm.AProjectOpenRecentExecute(Sender: TObject);
     433begin
     434  ProjectOpen(LastOpenedList[TMenuItem(Sender).MenuIndex]);
     435end;
     436
    379437procedure TMainForm.AProjectOpenExecute(Sender: TObject);
    380438begin
    381439  OpenDialog1.FileName := ProjectFileName;
    382440  if OpenDialog1.Execute then begin
    383     MemoSource.Lines.LoadFromFile(UTF8Decode(OpenDialog1.FileName));
    384     ProjectFileName := OpenDialog1.FileName;
    385     UpdateInterface;
    386     Modified := False;
     441    ProjectOpen(OpenDialog1.FileName);
    387442  end;
    388443end;
  • trunk/UOptionsForm.lfm

    r15 r21  
    7979    TabOrder = 4
    8080  end
     81  object CheckBox1: TCheckBox
     82    Left = 8
     83    Height = 19
     84    Top = 120
     85    Width = 205
     86    Caption = 'Reopend last opened project'
     87    TabOrder = 5
     88  end
    8189end
  • trunk/UOptionsForm.lrt

    r15 r21  
    55TOPTIONSFORM.LABEL2.CAPTION=Cell size:
    66TOPTIONSFORM.LABEL3.CAPTION=Interface language:
     7TOPTIONSFORM.CHECKBOX1.CAPTION=Reopend last opened project
  • trunk/UOptionsForm.pas

    r15 r21  
    1616    ButtonOk: TButton;
    1717    ButtonCancel: TButton;
     18    CheckBox1: TCheckBox;
    1819    ComboBoxLanguage: TComboBox;
    1920    Label1: TLabel;
     
    4849  ComboBoxLanguage.ItemIndex := MainForm.CoolTranslator1.Languages.IndexOf(MainForm.CoolTranslator1.Language);
    4950  if ComboBoxLanguage.ItemIndex = -1 then ComboBoxLanguage.ItemIndex := 0;
     51  CheckBox1.Checked := MainForm.OpenProjectOnStart;
    5052end;
    5153
     
    5456  if ComboBoxLanguage.ItemIndex <> -1 then
    5557    MainForm.CoolTranslator1.Language := TLanguage(ComboBoxLanguage.Items.Objects[ComboBoxLanguage.ItemIndex]);
     58  MainForm.OpenProjectOnStart := CheckBox1.Checked;
    5659end;
    5760
Note: See TracChangeset for help on using the changeset viewer.