tvplanit: Fix usage of relative paths in mormot full demo. Rename project to "demo" (instead of "mormotdemo" to find the translation file).

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5174 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-09-17 18:34:47 +00:00
parent 243ad144b1
commit 16d6ee43b7
3 changed files with 50 additions and 37 deletions

View File

@ -125,12 +125,15 @@ type
FActiveView: Integer; FActiveView: Integer;
FVisibleDays: Integer; FVisibleDays: Integer;
FResID: Integer; FResID: Integer;
FLanguageDir: String;
procedure CreateResourceGroup; procedure CreateResourceGroup;
function GetlanguageDir: String;
procedure PopulateLanguages; procedure PopulateLanguages;
procedure PositionControls; procedure PositionControls;
procedure SetActiveView(AValue: Integer); procedure SetActiveView(AValue: Integer);
procedure SetLanguage(ALang: String); overload; procedure SetLanguage(ALang: String); overload;
procedure SetLanguage(AIndex: Integer); overload; procedure SetLanguage(AIndex: Integer); overload;
procedure SetLanguageDir(const AValue: String);
procedure ShowAllEvents; procedure ShowAllEvents;
procedure ShowContacts; procedure ShowContacts;
procedure ShowEventsPerDay; procedure ShowEventsPerDay;
@ -144,6 +147,7 @@ type
procedure WriteIni; procedure WriteIni;
public public
{ public declarations } { public declarations }
property LanguageDir: String read GetLanguageDir write SetLanguageDir;
end; end;
var var
@ -503,6 +507,17 @@ begin
Caption := Application.Title; Caption := Application.Title;
end; end;
function TMainForm.GetLanguageDir: String;
begin
if FLanguageDir = '' then
Result := ExpandFileName(AppendPathDelim(Application.Location) + LANGUAGE_DIR)
else
if FilenameIsAbsolute(FLanguageDir) then
Result := FLanguageDir
else
Result := ExpandFileName(AppendPathDelim(Application.Location) + FLanguageDir);
end;
procedure TMainForm.MnuAboutClick(Sender: TObject); procedure TMainForm.MnuAboutClick(Sender: TObject);
var var
F: TfrmAbout; F: TfrmAbout;
@ -641,7 +656,7 @@ begin
L := TStringList.Create; L := TStringList.Create;
po := TStringList.Create; po := TStringList.Create;
try try
langdir := ExpandFileName(AppendPathDelim(Application.Location) + LANGUAGE_DIR); langdir := AppendPathDelim(GetLanguageDir);
FindAllFiles(L, langdir, '*.po'); FindAllFiles(L, langdir, '*.po');
po.Sorted := true; po.Sorted := true;
po.Duplicates := dupIgnore; po.Duplicates := dupIgnore;
@ -882,7 +897,7 @@ var
translator: TUpdateTranslator; translator: TUpdateTranslator;
nf: TVpNavFolder; nf: TVpNavFolder;
begin begin
langdir := ExpandFileName(AppendPathDelim(Application.Location) + LANGUAGE_DIR); langdir := AppendPathDelim(GetLanguageDir);
// Select new language // Select new language
if ALang = 'en' then if ALang = 'en' then
@ -1000,6 +1015,12 @@ begin
Invalidate; Invalidate;
end; end;
procedure TMainForm.SetLanguageDir(const AValue: String);
begin
FLanguageDir := AValue;
PopulateLanguages;
end;
procedure TMainForm.ShowAllEvents; procedure TMainForm.ShowAllEvents;
begin begin
Notebook.PageIndex := 0; Notebook.PageIndex := 0;

View File

@ -12,7 +12,7 @@
</General> </General>
<i18n> <i18n>
<EnableI18N Value="True"/> <EnableI18N Value="True"/>
<OutDir Value="..\..\languages"/> <OutDir Value="..\..\..\languages"/>
</i18n> </i18n>
<VersionInfo> <VersionInfo>
<StringTable ProductVersion=""/> <StringTable ProductVersion=""/>
@ -39,66 +39,50 @@
<PackageName Value="LCL"/> <PackageName Value="LCL"/>
</Item3> </Item3>
</RequiredPackages> </RequiredPackages>
<Units Count="10"> <Units Count="7">
<Unit0> <Unit0>
<Filename Value="mormotdemo.lpr"/> <Filename Value="demo.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
</Unit0> </Unit0>
<Unit1> <Unit1>
<Filename Value="demomain.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="MainForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="demoMain"/>
</Unit1>
<Unit2>
<Filename Value="sound.pas"/>
<IsPartOfProject Value="True"/>
</Unit2>
<Unit3>
<Filename Value="ExVpRptSetup.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="frmReportSetup"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit3>
<Unit4>
<Filename Value="mormotdatamodule.pas"/> <Filename Value="mormotdatamodule.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<ComponentName Value="DemoDM"/> <ComponentName Value="DemoDM"/>
<HasResources Value="True"/> <HasResources Value="True"/>
<ResourceBaseClass Value="DataModule"/> <ResourceBaseClass Value="DataModule"/>
</Unit4> </Unit1>
<Unit5> <Unit2>
<Filename Value="..\..\fulldemo\demomain.lfm"/> <Filename Value="..\..\fulldemo\demomain.lfm"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
</Unit5> </Unit2>
<Unit6> <Unit3>
<Filename Value="..\..\fulldemo\demomain.pas"/> <Filename Value="..\..\fulldemo\demomain.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<ComponentName Value="MainForm"/>
<HasResources Value="True"/> <HasResources Value="True"/>
</Unit6> <ResourceBaseClass Value="Form"/>
<Unit7> <UnitName Value="demoMain"/>
</Unit3>
<Unit4>
<Filename Value="..\..\fulldemo\ExVpRptSetup.lfm"/> <Filename Value="..\..\fulldemo\ExVpRptSetup.lfm"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
</Unit7> </Unit4>
<Unit8> <Unit5>
<Filename Value="..\..\fulldemo\ExVpRptSetup.pas"/> <Filename Value="..\..\fulldemo\ExVpRptSetup.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<HasResources Value="True"/> <HasResources Value="True"/>
</Unit8> </Unit5>
<Unit9> <Unit6>
<Filename Value="..\..\fulldemo\sound.pas"/> <Filename Value="..\..\fulldemo\sound.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
</Unit9> </Unit6>
</Units> </Units>
</ProjectOptions> </ProjectOptions>
<CompilerOptions> <CompilerOptions>
<Version Value="11"/> <Version Value="11"/>
<PathDelim Value="\"/> <PathDelim Value="\"/>
<Target> <Target>
<Filename Value="mormotdemo"/> <Filename Value="demo"/>
</Target> </Target>
<SearchPaths> <SearchPaths>
<IncludeFiles Value="$(ProjOutDir);..\mORMotSourceHere;..\..\..\source"/> <IncludeFiles Value="$(ProjOutDir);..\mORMotSourceHere;..\..\..\source"/>

View File

@ -1,4 +1,4 @@
program mormotdemo; program demo;
{ IMPORTANT NOTE: { IMPORTANT NOTE:
If compilation aborts with an error that libkernel32a, libgcc.a and libmsvcrt.a If compilation aborts with an error that libkernel32a, libgcc.a and libmsvcrt.a
@ -30,6 +30,14 @@ begin
Application.Initialize; Application.Initialize;
Application.CreateForm(TDemoDM, DemoDM); Application.CreateForm(TDemoDM, DemoDM);
Application.CreateForm(TMainForm, MainForm); Application.CreateForm(TMainForm, MainForm);
// Fix the location of the localization and language files - their relative
// path is different here from those in the other "fulldemo".
MainForm.VpControlLink1.LocalizationFile := '../../../source/vplocalize.xml';
MainForm.LanguageDir := '../../../languages';
// ... and expand the form caption
MainForm.Caption := 'TurboPower VisualPlanIt & mORMot Demo';
Application.Run; Application.Run;
end. end.