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

View File

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

View File

@ -1,4 +1,4 @@
program mormotdemo;
program demo;
{ IMPORTANT NOTE:
If compilation aborts with an error that libkernel32a, libgcc.a and libmsvcrt.a
@ -30,6 +30,14 @@ begin
Application.Initialize;
Application.CreateForm(TDemoDM, DemoDM);
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;
end.