{******************************************************************************* MainUnit: main.pas contains functions of profile managment *******************************************************************************} {******************************************************************************* LazUpdater runs SVN Update/Checkout, Make and Strip for FPC and Lazarus. Copyright (C) 2010 Ingo Steiniger This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, see . *******************************************************************************} {******************************************************************************* Button Profile "Save As" *******************************************************************************} procedure TForm_Main.Btn_ProfSaveAsClick(Sender: TObject); begin Form_NewProf.Edit_Name.Text:=CoBo_Prof.Items.Strings[CoBo_Prof.ItemIndex]; Form_NewProf.Edit_Name.SelectAll; if Form_NewProf.ShowModal=mrOK then begin SaveProfile(Form_NewProf.Edit_Name.Text); CoBo_Prof.ItemIndex:=CoBo_Prof.Items.Add(Form_NewProf.Edit_Name.Text); end; end; {******************************************************************************* Button Profile "delete" *******************************************************************************} procedure TForm_Main.Btn_ProfDelClick(Sender: TObject); var OldIdx:Integer; begin if CoBo_Prof.ItemIndex>0 then begin if MessageDlg(rsDeleteCurren, mtWarning, [mbYes, mbNo], 0)= mrYes then begin OldIdx:=CoBo_Prof.ItemIndex; myINI:=TINIFile.Create(LUConfigFile); myINI.EraseSection(CoBo_Prof.Items.Strings[CoBo_Prof.ItemIndex]); myINI.Free; CoBo_Prof.Items.Delete(CoBo_Prof.ItemIndex); if OldIdx = CoBo_Prof.Items.Count then begin CoBo_Prof.ItemIndex:=OldIdx-1; end else begin CoBo_Prof.ItemIndex:=OldIdx; end; end; end else begin MessageDlg(rsDefaultProfi, mtError, [mbOK], 0); end; end; {******************************************************************************* switch profile *******************************************************************************} procedure TForm_Main.CoBo_ProfChange(Sender: TObject); begin SaveProfile(CurrentProfileName); LoadProfile(CoBo_Prof.Text); InitOver; end; {******************************************************************************* Save Profile *******************************************************************************} procedure TForm_Main.SaveProfile(Profilename:String); begin if Profilename='default' then begin Profilename:=''; end else begin Profilename:=Profilename+'_'; end; myINI:=TINIFile.Create(LUConfigFile); //-FPC myINI.WriteString(Profilename+'Fpc', 'FpcDir', Edit_FpcUpdDir.Text); myINI.WriteString(Profilename+'Fpc', 'FpcURL', Edit_FpcURL.Text); myINI.WriteString(Profilename+'Fpc', 'FpcUpd', Edit_FpcSvnOpt.Text); myINI.WriteString(Profilename+'Fpc', 'FpcOpt', Edit_FpcMakeOpt.Text); myINI.WriteString(Profilename+'Fpc', 'FpcInst', Edit_FpcInstDir.Text); myINI.WriteString(Profilename+'Fpc', 'FpcInstOpt', Edit_FpcInstOpt.Text); myINI.WriteBool(Profilename+'Fpc', 'FpcDoMake', ChBo_FpcDoMake.Checked); myINI.WriteBool(Profilename+'Fpc', 'FpcFMake', ChBo_FpcFMake.Checked); myINI.WriteBool(Profilename+'Fpc', 'FpcDoInst', ChBo_FpcDoInst.Checked); myINI.WriteBool(Profilename+'Fpc', 'FpcDoUpd', ChBo_FpcDoUpd.Checked); //-Lazarus myINI.WriteString(Profilename+'Lazarus', 'LazDir', Edit_LazUpdDir.Text); myINI.WriteString(Profilename+'Lazarus', 'LazURL', Edit_LazURL.Text); myINI.WriteString(Profilename+'Lazarus', 'LazUpd', Edit_LazUpdOpt.Text); myINI.WriteString(Profilename+'Lazarus', 'LazOpt', Edit_LazMakeOpt.Text); myINI.WriteString(Profilename+'Lazarus', 'LazBuildOpt', Edit_LazBuildOpt.Text); myINI.WriteBool(Profilename+'Lazarus', 'LazDoMake', ChBo_LazDoMake.Checked); myINI.WriteBool(Profilename+'Lazarus', 'LazDoStrip', ChBo_LazDoStrip.Checked); myINI.WriteBool(Profilename+'Lazarus', 'LazFMake', ChBo_LazFMake.Checked); myINI.WriteBool(Profilename+'Lazarus', 'LazFMake2', ChBo_LazFMake2.Checked); myINI.WriteBool(Profilename+'Lazarus', 'LazDoUpd', ChBo_LazDoUpd.Checked); myINI.WriteBool(Profilename+'Lazarus', 'LazUseLazBuild', ChBo_lazbuild.Checked); //-Common myINI.WriteString(Profilename+'Common', 'BinSVN', Edit_BinSVN.Text); myINI.WriteString(Profilename+'Common', 'BinMake', Edit_BinMake.Text); myINI.WriteString(Profilename+'Common', 'BinFPC', Edit_BinFPC.Text); myINI.WriteString(Profilename+'Common', 'BinLazBuild', Edit_BinLazBuild.Text); myINI.Free; end; {******************************************************************************* Load Profile *******************************************************************************} procedure TForm_Main.LoadProfile(Profilename:String); begin CurrentProfileName:=CoBo_Prof.Text; doWarn:=False; if Profilename='default' then begin Profilename:=''; end else begin Profilename:=Profilename+'_'; end; myINI:=TINIFile.Create(LUConfigFile); //-FPC Edit_FpcUpdDir.Text:=myINI.ReadString(Profilename+'Fpc', 'FpcDir', ''); Edit_FpcURL.Text:=myINI.ReadString(Profilename+'Fpc', 'FpcURL', ''); Edit_FpcSvnOpt.Text:=myINI.ReadString(Profilename+'Fpc', 'FpcUpd', ''); Edit_FpcMakeOpt.Text:=myINI.ReadString(Profilename+'Fpc', 'FpcOpt', ''); Edit_FpcInstOpt.Text:=myINI.ReadString(Profilename+'Fpc', 'FpcInstOpt', ''); Edit_FpcInstDir.Text:=myINI.ReadString(Profilename+'Fpc', 'FpcInst', ''); LUFpcInstDir:=Edit_FpcInstDir.Text; ChBo_FpcDoMake.Checked:=myINI.ReadBool(Profilename+'Fpc', 'FpcDoMake', False); ChBo_FpcFMake.Checked:=myINI.ReadBool(Profilename+'Fpc', 'FpcFMake', False); ChBo_FpcDoInst.Checked:=myINI.ReadBool(Profilename+'Fpc', 'FpcDoInst', False); ChBo_FpcDoUpd.Checked:=myINI.ReadBool(Profilename+'Fpc', 'FpcDoUpd', True); //-Lazarus Edit_LazUpdDir.Text:=myINI.ReadString(Profilename+'Lazarus', 'LazDir', ''); Edit_LazURL.Text:=myINI.ReadString(Profilename+'Lazarus', 'LazURL', ''); Edit_LazUpdOpt.Text:=myINI.ReadString(Profilename+'Lazarus', 'LazUpd', ''); Edit_LazMakeOpt.Text:=myINI.ReadString(Profilename+'Lazarus', 'LazOpt', ''); Edit_LazBuildOpt.Text:=myINI.ReadString(Profilename+'Lazarus', 'LazBuildOpt', ''); ChBo_LazDoMake.Checked:=myINI.ReadBool(Profilename+'Lazarus', 'LazDoMake', False); ChBo_LazDoStrip.Checked:=myINI.ReadBool(Profilename+'Lazarus', 'LazDoStrip', False); ChBo_LazFMake.Checked:=myINI.ReadBool(Profilename+'Lazarus', 'LazFMake', False); ChBo_LazFMake2.Checked:=myINI.ReadBool(Profilename+'Lazarus', 'LazFMake2', False); ChBo_LazDoUpd.Checked:=myINI.ReadBool(Profilename+'Lazarus', 'LazDoUpd', True); ChBo_LazBuild.Checked:=myINI.ReadBool(Profilename+'Lazarus', 'LazUseLazBuild', False); //-Common Edit_BinSVN.Text:=myINI.ReadString(Profilename+'Common', 'BinSVN', ''); Edit_BinMake.Text:=myINI.ReadString(Profilename+'Common', 'BinMake', ''); Edit_BinFPC.Text:=myINI.ReadString(Profilename+'Common', 'BinFPC', ''); Edit_BinLazBuild.Text:=myINI.ReadString(Profilename+'Common', 'BinLazBuild', ''); myINI.Free; //use this defaults if fields are empty if Edit_FpcURL.Text='' then begin Edit_FpcURL.Text:='http://svn.freepascal.org/svn/fpc/trunk'; end; if Edit_LazURL.Text='' then begin Edit_LazURL.Text:='http://svn.freepascal.org/svn/lazarus/trunk'; end; setBinaries; //enable warning of alpha feature doWarn:=True; end;