0.1.11.0: Cleaned up code formatting etc.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5409 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
gbamber
2016-12-04 18:31:18 +00:00
parent 1e944a1c58
commit 5cc6f902d0
8 changed files with 146 additions and 140 deletions

View File

@ -24,7 +24,7 @@
<UseVersionInfo Value="True"/> <UseVersionInfo Value="True"/>
<AutoIncrementBuild Value="True"/> <AutoIncrementBuild Value="True"/>
<MinorVersionNr Value="1"/> <MinorVersionNr Value="1"/>
<RevisionNr Value="10"/> <RevisionNr Value="11"/>
<StringTable Comments="Buld configured for Win Linux and Darwin" FileDescription="An editor for OnlinePackageManager update JSON files" InternalName="jsoneditor" LegalCopyright="(c)2016 usernames lainz and minesadorada @ forum.lazarus.freepascal.org" LegalTrademarks="GPL code" OriginalFilename="jsoneditor" ProductName="Lazarus and Freepascal" ProductVersion="1.x and 3.x"/> <StringTable Comments="Buld configured for Win Linux and Darwin" FileDescription="An editor for OnlinePackageManager update JSON files" InternalName="jsoneditor" LegalCopyright="(c)2016 usernames lainz and minesadorada @ forum.lazarus.freepascal.org" LegalTrademarks="GPL code" OriginalFilename="jsoneditor" ProductName="Lazarus and Freepascal" ProductVersion="1.x and 3.x"/>
</VersionInfo> </VersionInfo>
<BuildModes Count="5"> <BuildModes Count="5">

View File

@ -10,7 +10,7 @@
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<EditorIndex Value="3"/> <EditorIndex Value="3"/>
<CursorPos Y="30"/> <CursorPos Y="30"/>
<UsageCount Value="56"/> <UsageCount Value="57"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit0> </Unit0>
<Unit1> <Unit1>
@ -21,11 +21,11 @@
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/> <IsVisibleTab Value="True"/>
<TopLine Value="13"/> <TopLine Value="13"/>
<CursorPos X="62" Y="28"/> <CursorPos X="44" Y="30"/>
<UsageCount Value="56"/> <UsageCount Value="57"/>
<Bookmarks Count="2"> <Bookmarks Count="2">
<Item0 Y="468" ID="1"/> <Item0 Y="457" ID="1"/>
<Item1 X="8" Y="737"/> <Item1 Y="727"/>
</Bookmarks> </Bookmarks>
<Loaded Value="True"/> <Loaded Value="True"/>
<LoadedDesigner Value="True"/> <LoadedDesigner Value="True"/>
@ -33,7 +33,7 @@
<Unit2> <Unit2>
<Filename Value="ugenericcollection.pas"/> <Filename Value="ugenericcollection.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UsageCount Value="56"/> <UsageCount Value="57"/>
</Unit2> </Unit2>
<Unit3> <Unit3>
<Filename Value="D:\Lazarusprojects\golfml\egacalculator\source\umainform.pas"/> <Filename Value="D:\Lazarusprojects\golfml\egacalculator\source\umainform.pas"/>
@ -103,7 +103,7 @@
<EditorIndex Value="2"/> <EditorIndex Value="2"/>
<TopLine Value="10428"/> <TopLine Value="10428"/>
<CursorPos X="29" Y="10452"/> <CursorPos X="29" Y="10452"/>
<UsageCount Value="11"/> <UsageCount Value="12"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit11> </Unit11>
<Unit12> <Unit12>
@ -111,130 +111,130 @@
<EditorIndex Value="1"/> <EditorIndex Value="1"/>
<TopLine Value="517"/> <TopLine Value="517"/>
<CursorPos X="3" Y="478"/> <CursorPos X="3" Y="478"/>
<UsageCount Value="11"/> <UsageCount Value="12"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit12> </Unit12>
</Units> </Units>
<JumpHistory Count="30" HistoryIndex="29"> <JumpHistory Count="30" HistoryIndex="29">
<Position1> <Position1>
<Filename Value="C:\NewPascalDarwin\lazarus\lcl\grids.pas"/> <Filename Value="C:\NewPascalDarwin\lazarus\lcl\grids.pas"/>
<Caret Line="1395" Column="21" TopLine="1371"/> <Caret Line="745" Column="27" TopLine="709"/>
</Position1> </Position1>
<Position2> <Position2>
<Filename Value="C:\NewPascalDarwin\lazarus\lcl\grids.pas"/> <Filename Value="C:\NewPascalDarwin\lazarus\lcl\grids.pas"/>
<Caret Line="745" Column="27" TopLine="709"/> <Caret Line="114" Column="3" TopLine="76"/>
</Position2> </Position2>
<Position3> <Position3>
<Filename Value="C:\NewPascalDarwin\lazarus\lcl\grids.pas"/> <Filename Value="umain.pas"/>
<Caret Line="114" Column="3" TopLine="76"/> <Caret Line="155" TopLine="134"/>
</Position3> </Position3>
<Position4> <Position4>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="155" TopLine="134"/> <Caret Line="308" Column="3" TopLine="306"/>
</Position4> </Position4>
<Position5> <Position5>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="308" Column="3" TopLine="306"/> <Caret Line="796" Column="19" TopLine="766"/>
</Position5> </Position5>
<Position6> <Position6>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="796" Column="19" TopLine="766"/> <Caret Line="46" Column="40" TopLine="31"/>
</Position6> </Position6>
<Position7> <Position7>
<Filename Value="umain.pas"/>
<Caret Line="46" Column="40" TopLine="31"/>
</Position7>
<Position8>
<Filename Value="C:\NewPascalDarwin\fpc\rtl\objpas\classes\classesh.inc"/> <Filename Value="C:\NewPascalDarwin\fpc\rtl\objpas\classes\classesh.inc"/>
<Caret Line="498" Column="37" TopLine="465"/> <Caret Line="498" Column="37" TopLine="465"/>
</Position7>
<Position8>
<Filename Value="umain.pas"/>
<Caret Line="450" Column="47" TopLine="426"/>
</Position8> </Position8>
<Position9> <Position9>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="450" Column="47" TopLine="426"/> <Caret Line="298" Column="27" TopLine="285"/>
</Position9> </Position9>
<Position10> <Position10>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="298" Column="27" TopLine="285"/> <Caret Line="313" Column="46" TopLine="290"/>
</Position10> </Position10>
<Position11> <Position11>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="313" Column="46" TopLine="290"/> <Caret Line="316" Column="65" TopLine="293"/>
</Position11> </Position11>
<Position12> <Position12>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="316" Column="65" TopLine="293"/> <Caret Line="313" Column="46" TopLine="289"/>
</Position12> </Position12>
<Position13> <Position13>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="313" Column="46" TopLine="289"/> <Caret Line="320" TopLine="296"/>
</Position13> </Position13>
<Position14> <Position14>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="320" TopLine="296"/> <Caret Line="310" Column="29" TopLine="295"/>
</Position14> </Position14>
<Position15> <Position15>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="310" Column="29" TopLine="295"/> <Caret Line="672" Column="56" TopLine="635"/>
</Position15> </Position15>
<Position16> <Position16>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="672" Column="56" TopLine="635"/> <Caret Line="810" Column="41" TopLine="787"/>
</Position16> </Position16>
<Position17> <Position17>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="810" Column="41" TopLine="787"/> <Caret Line="812" Column="36" TopLine="786"/>
</Position17> </Position17>
<Position18> <Position18>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="812" Column="36" TopLine="786"/> <Caret Line="813" Column="5" TopLine="790"/>
</Position18> </Position18>
<Position19> <Position19>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="813" Column="5" TopLine="790"/> <Caret Line="811" TopLine="787"/>
</Position19> </Position19>
<Position20> <Position20>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="811" TopLine="787"/> <Caret Line="814" Column="5" TopLine="787"/>
</Position20> </Position20>
<Position21> <Position21>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="814" Column="5" TopLine="787"/> <Caret Line="812" Column="24" TopLine="784"/>
</Position21> </Position21>
<Position22> <Position22>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="812" Column="24" TopLine="784"/> <Caret Line="811" Column="11" TopLine="788"/>
</Position22> </Position22>
<Position23> <Position23>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="811" Column="11" TopLine="788"/> <Caret Line="813" Column="6" TopLine="789"/>
</Position23> </Position23>
<Position24> <Position24>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="813" Column="6" TopLine="789"/> <Caret Line="489" TopLine="481"/>
</Position24> </Position24>
<Position25> <Position25>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="489" TopLine="481"/> <Caret Line="819" TopLine="789"/>
</Position25> </Position25>
<Position26> <Position26>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="819" TopLine="789"/> <Caret Line="813" TopLine="789"/>
</Position26> </Position26>
<Position27> <Position27>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="813" TopLine="789"/> <Caret Line="79" Column="26" TopLine="50"/>
</Position27> </Position27>
<Position28> <Position28>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="79" Column="26" TopLine="50"/> <Caret Line="812" TopLine="795"/>
</Position28> </Position28>
<Position29> <Position29>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="812" TopLine="795"/> <Caret Line="735" Column="33" TopLine="720"/>
</Position29> </Position29>
<Position30> <Position30>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="735" Column="33" TopLine="720"/> <Caret Line="683" TopLine="646"/>
</Position30> </Position30>
</JumpHistory> </JumpHistory>
</ProjectSession> </ProjectSession>

View File

@ -303,6 +303,10 @@ msgstr "The .lpk entry #%d is is absent"
msgid "- There are no .lpk files in the list yet" msgid "- There are no .lpk files in the list yet"
msgstr "- There are no .lpk files in the list yet" msgstr "- There are no .lpk files in the list yet"
#: umain.rsthereareoneo
msgid "- There are one or more .lpk entries with the same name.%s- Every .lpk entry must have a unique name."
msgstr ""
#: umain.rsthisoptionsh #: umain.rsthisoptionsh
msgid "This option should only be used for crucial updates or bug-fixed packages. Are you OK with that?" msgid "This option should only be used for crucial updates or bug-fixed packages. Are you OK with that?"
msgstr "" msgstr ""

View File

@ -122,6 +122,10 @@ msgstr "Archivos del Paquete"
msgid "Load..." msgid "Load..."
msgstr "Cargar..." msgstr "Cargar..."
#: tfrmmain.mnu_filenew.caption
msgid "New"
msgstr ""
#: tfrmmain.mnu_filesave.caption #: tfrmmain.mnu_filesave.caption
msgid "Save" msgid "Save"
msgstr "Guardar" msgstr "Guardar"
@ -291,6 +295,10 @@ msgstr "La entrada .lpk #%d está ausente"
msgid "- There are no .lpk files in the list yet" msgid "- There are no .lpk files in the list yet"
msgstr "- No hay ningún archivo .lpk en la lista todavía" msgstr "- No hay ningún archivo .lpk en la lista todavía"
#: umain.rsthereareoneo
msgid "- There are one or more .lpk entries with the same name.%s- Every .lpk entry must have a unique name."
msgstr ""
#: umain.rsthisoptionsh #: umain.rsthisoptionsh
msgid "This option should only be used for crucial updates or bug-fixed packages. Are you OK with that?" msgid "This option should only be used for crucial updates or bug-fixed packages. Are you OK with that?"
msgstr "Esta opción debe ser usada solamente para actualizaciones cruciales o paquetes con arreglos de bugs. ¿Estás de acuerdo con esto?" msgstr "Esta opción debe ser usada solamente para actualizaciones cruciales o paquetes con arreglos de bugs. ¿Estás de acuerdo con esto?"
@ -330,3 +338,4 @@ msgstr "¿Quieres copiar %s a la carpeta %s?"
#: umain.rsyoumayneedto #: umain.rsyoumayneedto
msgid "(You may need to restart the app to see the change)" msgid "(You may need to restart the app to see the change)"
msgstr "(Quizás necesites reiniciar la aplicación para ver los cambios)" msgstr "(Quizás necesites reiniciar la aplicación para ver los cambios)"

View File

@ -260,6 +260,10 @@ msgstr ""
msgid "- There are no .lpk files in the list yet" msgid "- There are no .lpk files in the list yet"
msgstr "" msgstr ""
#: umain.rsthereareoneo
msgid "- There are one or more .lpk entries with the same name.%s- Every .lpk entry must have a unique name."
msgstr ""
#: umain.rsthisoptionsh #: umain.rsthisoptionsh
msgid "This option should only be used for crucial updates or bug-fixed packages. Are you OK with that?" msgid "This option should only be used for crucial updates or bug-fixed packages. Are you OK with that?"
msgstr "" msgstr ""

View File

@ -42,7 +42,6 @@ object frmMain: TfrmMain
Width = 90 Width = 90
Caption = 'Force Update' Caption = 'Force Update'
Color = clWindow Color = clWindow
OnChange = cbForceUpdateChange
OnMouseUp = cbForceUpdateMouseUp OnMouseUp = cbForceUpdateMouseUp
ParentColor = False ParentColor = False
TabOrder = 1 TabOrder = 1
@ -96,7 +95,6 @@ object frmMain: TfrmMain
RowCount = 1 RowCount = 1
TabOrder = 3 TabOrder = 3
TitleStyle = tsNative TitleStyle = tsNative
OnCellProcess = stringPackageFilesCellProcess
ColWidths = ( ColWidths = (
150 150
150 150
@ -131,7 +129,6 @@ object frmMain: TfrmMain
Caption = '&Close' Caption = '&Close'
Kind = bkClose Kind = bkClose
ModalResult = 11 ModalResult = 11
OnClick = cmd_CloseClick
TabOrder = 6 TabOrder = 6
end end
object cmd_save: TBitBtn object cmd_save: TBitBtn

View File

@ -25,8 +25,9 @@ unit umain;
..to 0.1.6.0 Refactored and updated (minesadorada) ..to 0.1.6.0 Refactored and updated (minesadorada)
0.1.7.0: Bugfix (lainz) 0.1.7.0: Bugfix (lainz)
0.1.8.0: Config file change (minesadorada) 0.1.8.0: Config file change (minesadorada)
0.1.9.0: Error check for duplicate lpk entries (minesadorada)
0.1.10.0: Exception handling for Load + Save (minesadorada) 0.1.10.0: Exception handling for Load + Save (minesadorada)
Error check for duplicate lpk entries (minesadorada) 0.1.11.0: Cleaned up code formatting etc.
} }
{$mode objfpc}{$H+} {$mode objfpc}{$H+}
@ -78,12 +79,13 @@ type
public public
constructor Create; constructor Create;
destructor Destroy; override; destructor Destroy; override;
function LoadFromFile(AFileName: string):Boolean; function LoadFromFile(AFileName: string): boolean;
function SaveToFile(AFileName: string): boolean; function SaveToFile(AFileName: string): boolean;
published published
property Package: TPackageData read FPackage write FPackage; property Package: TPackageData read FPackage write FPackage;
property PackageFiles: TPackageFilesList read FPackageFiles write FPackageFiles; property PackageFiles: TPackageFilesList read FPackageFiles write FPackageFiles;
end; end;
{ TfrmMain } { TfrmMain }
TfrmMain = class(TForm) TfrmMain = class(TForm)
@ -119,10 +121,8 @@ type
stringPackageFiles: TStringGrid; stringPackageFiles: TStringGrid;
procedure btnAddClick(Sender: TObject); procedure btnAddClick(Sender: TObject);
procedure btnRemoveClick(Sender: TObject); procedure btnRemoveClick(Sender: TObject);
procedure cbForceUpdateChange(Sender: TObject);
procedure cbForceUpdateMouseUp(Sender: TObject; Button: TMouseButton; procedure cbForceUpdateMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: integer); Shift: TShiftState; X, Y: integer);
procedure cmd_CloseClick(Sender: TObject);
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean); procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
@ -138,12 +138,10 @@ type
procedure SaveAsItemClick(Sender: TObject); procedure SaveAsItemClick(Sender: TObject);
procedure sb_editNameClick(Sender: TObject); procedure sb_editNameClick(Sender: TObject);
procedure spd_CheckURLClick(Sender: TObject); procedure spd_CheckURLClick(Sender: TObject);
procedure stringPackageFilesCellProcess(Sender: TObject; aCol,
aRow: Integer; processType: TCellProcessType; var aValue: string);
private private
{ private declarations } { private declarations }
JSONPackage: TPackage; JSONPackage: TPackage;
bForceSaveAs, bShowPopupHints, bDisableWarnings, bDirty,bIsVirgin: boolean; bForceSaveAs, bShowPopupHints, bDisableWarnings, bDirty, bIsVirgin: boolean;
sJSONFilePath: string; sJSONFilePath: string;
sUpdateDirectory, sZipDirectory: string; sUpdateDirectory, sZipDirectory: string;
CFG: TIniFile; CFG: TIniFile;
@ -153,7 +151,7 @@ type
procedure CtrlHidePopup(Sender: TObject); procedure CtrlHidePopup(Sender: TObject);
procedure CtrlSetUpPopupHandlers; procedure CtrlSetUpPopupHandlers;
procedure CtrlMakeDirty(Sender: TObject); procedure CtrlMakeDirty(Sender: TObject);
function IsADuplicateLPK:Boolean; function FoundADuplicateLPK: boolean;
public public
{ public declarations } { public declarations }
end; end;
@ -203,6 +201,8 @@ resourcestring
rsLanguageChan = 'Language changed to "%s".'; rsLanguageChan = 'Language changed to "%s".';
rsSorryThisLan = 'Sorry, this language is unavailable at this time.'; rsSorryThisLan = 'Sorry, this language is unavailable at this time.';
rsYouMayNeedTo = '(You may need to restart the app to see the change)'; rsYouMayNeedTo = '(You may need to restart the app to see the change)';
rsThereAreOneO = '- There are one or more .lpk entries with the same name.%s'
+ '- Every .lpk entry must have a unique name.';
{ TPackageData } { TPackageData }
@ -235,14 +235,16 @@ begin
exit; exit;
MyPopup.Text := ''; MyPopup.Text := '';
MyPopup.Title := ''; MyPopup.Title := '';
If (Sender.InheritsFrom(TControl) = FALSE) then exit; if (Sender.InheritsFrom(TControl) = False) then
exit;
myPopup.Text := TControl(Sender).Hint; myPopup.Text := TControl(Sender).Hint;
if (MyPopup.Text <> '') then if (MyPopup.Text <> '') then
begin begin
mypopup.Title := rsHelpAndInfor; mypopup.Title := rsHelpAndInfor;
mypopup.Text := mypopup.Text; mypopup.Text := mypopup.Text;
if bIsVirgin then mypopup.Text:=mypopup.Text + LineEnding + rsTurnHintsOff; if bIsVirgin then
mypopup.Text := mypopup.Text + LineEnding + rsTurnHintsOff;
mypopup.showatpos(Mouse.CursorPos.X, Mouse.CursorPos.Y); mypopup.showatpos(Mouse.CursorPos.X, Mouse.CursorPos.Y);
end; end;
end; end;
@ -256,7 +258,8 @@ begin
begin begin
for iCount := 0 to Pred(ControlCount) do for iCount := 0 to Pred(ControlCount) do
begin begin
If (Controls[iCount].InheritsFrom(TControl) = FALSE) then continue; if (Controls[iCount].InheritsFrom(TControl) = False) then
continue;
if (Controls[iCount] is TEdit) then if (Controls[iCount] is TEdit) then
begin begin
TEdit(Controls[iCount]).OnMouseEnter := @CtrlShowPopup; TEdit(Controls[iCount]).OnMouseEnter := @CtrlShowPopup;
@ -304,21 +307,21 @@ begin
end; end;
function TfrmMain.IsADuplicateLPK:Boolean; function TfrmMain.FoundADuplicateLPK: boolean;
Var var
TempStringList:TStrings; TempStringList: TStrings;
iCount:Integer; iCount: integer;
begin begin
Result:=FALSE; Result := False;
TempStringList:=TstringList.Create; TempStringList := TStringList.Create;
TRY try
For iCount:=0 to Pred(stringPackageFiles.RowCount) do for iCount := 0 to Pred(stringPackageFiles.RowCount) do
begin begin
If TempStringlist.IndexOf(stringPackageFiles.Cells[0,iCount]) = -1 then if TempStringlist.IndexOf(stringPackageFiles.Cells[0, iCount]) = -1 then
TempStringList.Add(stringPackageFiles.Cells[0,iCount]) TempStringList.Add(stringPackageFiles.Cells[0, iCount])
else else
Result:=TRUE; Result := True;
end; end;
finally finally
TempStringList.Free; TempStringList.Free;
end; end;
@ -335,11 +338,6 @@ begin
stringPackageFiles.RowCount := stringPackageFiles.RowCount - 1; stringPackageFiles.RowCount := stringPackageFiles.RowCount - 1;
end; end;
procedure TfrmMain.cbForceUpdateChange(Sender: TObject);
begin
end;
procedure TfrmMain.cbForceUpdateMouseUp(Sender: TObject; Button: TMouseButton; procedure TfrmMain.cbForceUpdateMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: integer); Shift: TShiftState; X, Y: integer);
var var
@ -355,11 +353,6 @@ begin
end; end;
end; end;
procedure TfrmMain.cmd_CloseClick(Sender: TObject);
begin
end;
procedure TfrmMain.FormClose(Sender: TObject; var CloseAction: TCloseAction); procedure TfrmMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin begin
CFG.WriteBool('Options', 'Virgin', False); CFG.WriteBool('Options', 'Virgin', False);
@ -369,7 +362,7 @@ end;
procedure TfrmMain.FormCloseQuery(Sender: TObject; var CanClose: boolean); procedure TfrmMain.FormCloseQuery(Sender: TObject; var CanClose: boolean);
begin begin
CanClose := True; CanClose := True;
if bDisableWarnings = TRUE then if bDisableWarnings = True then
exit; exit;
if bDirty = True then if bDirty = True then
begin begin
@ -380,20 +373,20 @@ end;
procedure TfrmMain.FormCreate(Sender: TObject); procedure TfrmMain.FormCreate(Sender: TObject);
var var
sLang,INIFilePath: string; sLang, INIFilePath: string;
procedure CreateUniqueINI(aCount:Integer); procedure CreateUniqueINI(aCount: integer);
// Recursively loop until correct INI found, or new one created // Recursively loop until correct INI found, or new one created
begin begin
INIFilePath:=GetAppConfigFile(False) + IntToStr(aCount); INIFilePath := GetAppConfigFile(False) + IntToStr(aCount);
CFG := TIniFile.Create(INIFilePath); CFG := TIniFile.Create(INIFilePath);
If CFG.ReadString('Options','AppPath',ProgramDirectory) <> ProgramDirectory then if CFG.ReadString('Options', 'AppPath', ProgramDirectory) <> ProgramDirectory then
Begin begin
CFG.Free; // Ditch the old one CFG.Free; // Ditch the old one
inc(aCount); Inc(aCount);
CreateUniqueINI(aCount); // Make a new one CreateUniqueINI(aCount); // Make a new one
end;
end; end;
end;
begin begin
Self.AutoAdjustLayout(lapAutoAdjustForDPI, Self.DesignTimeDPI, Self.AutoAdjustLayout(lapAutoAdjustForDPI, Self.DesignTimeDPI,
@ -422,10 +415,10 @@ begin
// If program location is different, create a new CFG file // If program location is different, create a new CFG file
// Because each component's location might be different // Because each component's location might be different
CreateUniqueINI(0); CreateUniqueINI(0);
CFG.WriteString('Options','AppPath',ProgramDirectory); CFG.WriteString('Options', 'AppPath', ProgramDirectory);
// Pop-up hints (show on first run, then not again unless the user chooses) // Pop-up hints (show on first run, then not again unless the user chooses)
bIsVirgin:=CFG.ReadBool('Options', 'Virgin', True); bIsVirgin := CFG.ReadBool('Options', 'Virgin', True);
bShowPopupHints := bIsVirgin; bShowPopupHints := bIsVirgin;
mnu_helpShowHints.Checked := bShowPopupHints; mnu_helpShowHints.Checked := bShowPopupHints;
// Override here if the user has re-enabled them // Override here if the user has re-enabled them
@ -463,25 +456,25 @@ begin
sJSONFilePath := FileOpen1.Dialog.Filename; sJSONFilePath := FileOpen1.Dialog.Filename;
CFG.WriteString('Options', 'LastLoadedJSONPath', ExtractFileDir(sJSONFilePath)); CFG.WriteString('Options', 'LastLoadedJSONPath', ExtractFileDir(sJSONFilePath));
JSONPackage := TPackage.Create; JSONPackage := TPackage.Create;
TRY try
if JSONPackage.LoadFromFile(FileOpen1.Dialog.FileName) then if JSONPackage.LoadFromFile(FileOpen1.Dialog.FileName) then
begin
editName.Text := JSONPackage.Package.Name;
editDownloadURL.Text := JSONPackage.Package.DownloadURL;
cbForceUpdate.Checked := JSONPackage.Package.ForceUpdate;
stringPackageFiles.RowCount := JSONPackage.PackageFiles.Count + 1;
for i := 0 to JSONPackage.PackageFiles.Count - 1 do
begin begin
stringPackageFiles.Cells[0, i + 1] := JSONPackage.PackageFiles.Items[i].Name; editName.Text := JSONPackage.Package.Name;
stringPackageFiles.Cells[1, i + 1] := JSONPackage.PackageFiles.Items[i].Version; editDownloadURL.Text := JSONPackage.Package.DownloadURL;
end; cbForceUpdate.Checked := JSONPackage.Package.ForceUpdate;
end
else stringPackageFiles.RowCount := JSONPackage.PackageFiles.Count + 1;
ShowMessageFmt('There was a problem loading "%s" - is it corrupted or in the wrong format?', for i := 0 to JSONPackage.PackageFiles.Count - 1 do
[ExtractFilename(FileOpen1.Dialog.FileName)]); begin
stringPackageFiles.Cells[0, i + 1] := JSONPackage.PackageFiles.Items[i].Name;
stringPackageFiles.Cells[1, i + 1] := JSONPackage.PackageFiles.Items[i].Version;
end;
end
else
ShowMessageFmt('There was a problem loading "%s" - is it corrupted or in the wrong format?',
[ExtractFilename(FileOpen1.Dialog.FileName)]);
finally finally
JSONPackage.Free; JSONPackage.Free;
end; end;
end; end;
end; end;
@ -490,10 +483,10 @@ procedure TfrmMain.mnu_fileNewClick(Sender: TObject);
begin begin
editname.Text := rsMypackagenam; editname.Text := rsMypackagenam;
editDownloadURL.Text := rsHttpWwwUpdat; editDownloadURL.Text := rsHttpWwwUpdat;
cbForceUpdate.Checked:=False; cbForceUpdate.Checked := False;
stringPackageFiles.RowCount:=1; stringPackageFiles.RowCount := 1;
sJSONFilePath:=''; sJSONFilePath := '';
sZipDirectory:=''; sZipDirectory := '';
end; end;
procedure TfrmMain.mnu_fileSaveClick(Sender: TObject); procedure TfrmMain.mnu_fileSaveClick(Sender: TObject);
@ -675,11 +668,12 @@ begin
Result := True; Result := True;
end; end;
end; end;
If IsADuplicateLPK then
// Check for duplicate .lpk entries
if FoundADuplicateLPK then
begin begin
stringPackageFiles.Color := clYellow; stringPackageFiles.Color := clYellow;
slErrorList.Add('- There are one or more .lpk entries with the same name.' slErrorList.Add(Format(rsThereAreOneO, [LineEnding]));
+ LineEnding + '- Every .lpk entry must have a unique name.');
Result := True; Result := True;
end; end;
end; end;
@ -702,7 +696,7 @@ begin
if bForceSaveAs or (sJSONFilePath = '') then if bForceSaveAs or (sJSONFilePath = '') then
begin begin
FileSaveAs1.Dialog.InitialDir := sUpdateDirectory; FileSaveAs1.Dialog.InitialDir := sUpdateDirectory;
FileSaveAs1.Dialog.FileName:='update_' + ExtractFilenameOnly(editName.text); FileSaveAs1.Dialog.FileName := 'update_' + ExtractFilenameOnly(editName.Text);
if FileSaveAs1.Dialog.Execute then if FileSaveAs1.Dialog.Execute then
sJSONFilePath := FileSaveAs1.Dialog.FileName sJSONFilePath := FileSaveAs1.Dialog.FileName
else else
@ -723,7 +717,7 @@ begin
Version := stringPackageFiles.Cells[1, i]; Version := stringPackageFiles.Cells[1, i];
end; end;
end; end;
if FileExistsUTF8(sJSONFilePath) AND (bDisableWarnings=FALSE) then if FileExistsUTF8(sJSONFilePath) and (bDisableWarnings = False) then
begin begin
if MessageDlg(rsOverwrite + ' ' + sJSONFilePath + '?', mtConfirmation, if MessageDlg(rsOverwrite + ' ' + sJSONFilePath + '?', mtConfirmation,
[mbYes, mbNo], 0, mbYes) = mrYes then [mbYes, mbNo], 0, mbYes) = mrYes then
@ -781,11 +775,6 @@ begin
end; end;
end; end;
procedure TfrmMain.stringPackageFilesCellProcess(Sender: TObject; aCol,
aRow: Integer; processType: TCellProcessType; var aValue: string);
begin
end;
{ TPackage } { TPackage }
constructor TPackage.Create; constructor TPackage.Create;
@ -805,22 +794,24 @@ begin
inherited Destroy; inherited Destroy;
end; end;
Function TPackage.LoadFromFile(AFileName: string):Boolean; function TPackage.LoadFromFile(AFileName: string): boolean;
var var
DeStreamer: TJSONDeStreamer; DeStreamer: TJSONDeStreamer;
s: TStringList; s: TStringList;
begin begin
Result:=TRUE; Result := True;
s := TStringList.Create; s := TStringList.Create;
TRY try
s.LoadFromFile(AFileName); s.LoadFromFile(AFileName);
DeStreamer := TJSONDeStreamer.Create(nil); DeStreamer := TJSONDeStreamer.Create(nil);
TRY try
DeStreamer.JSONToObject(s.Text, Self); DeStreamer.JSONToObject(s.Text, Self);
EXCEPT except
On E:Exception do Result:=FALSE; // Eat the exception
end; On E: Exception do
Finally Result := False;
end;
finally
DeStreamer.Free; DeStreamer.Free;
s.Free; s.Free;
end; end;
@ -831,7 +822,7 @@ var
Streamer: TJSONStreamer; Streamer: TJSONStreamer;
s: TStringList; s: TStringList;
begin begin
Result := False; Result := True;
s := TStringList.Create; s := TStringList.Create;
try try
Streamer := TJSONStreamer.Create(nil); Streamer := TJSONStreamer.Create(nil);
@ -839,9 +830,10 @@ begin
s.AddText(Streamer.ObjectToJSONString(Self)); s.AddText(Streamer.ObjectToJSONString(Self));
try try
s.SaveToFile(AFileName); s.SaveToFile(AFileName);
Result := True;
except except
// Eat the exception
On E: Exception do
Result := False;
end; end;
finally finally
Streamer.Free; Streamer.Free;