Skip to content

Commit c673fc9

Browse files
committed
Merge branch 'feature/polishing-for-v4.16' into develop
2 parents 41092b0 + f38953b commit c673fc9

File tree

8 files changed

+86
-36
lines changed

8 files changed

+86
-36
lines changed

Docs/ReadMe.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ code snippets.
132132
No files are written outside the folder where you copied the files and the
133133
registry is not modified.
134134

135+
** WARNING: When updating an existing portable installation with a new version
136+
of CodeSnip it is important that you do not change or delete the AppData and
137+
UserData folders. If you do this you risk loosing your settings and/or database.
138+
135139

136140
Uninstallation
137141
================================================================================

Src/FmAboutDlg.pas

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ implementation
196196
UMessageBox,
197197
UResourceUtils,
198198
UStrUtils,
199-
UThemesEx;
199+
UThemesEx,
200+
UVersionInfo;
200201

201202
{$R *.dfm}
202203

@@ -424,49 +425,58 @@ procedure TAboutDlg.InitHTMLFrames;
424425
var
425426
IsDBAvalable: Boolean;
426427
IsMetaDataAvailable: Boolean;
427-
IsLicenseInfomAvailable: Boolean;
428+
IsLicenseInfoAvailable: Boolean;
429+
430+
function DBVersion: string;
431+
var
432+
Ver: TVersionNumber;
433+
begin
434+
Ver := fMetaData.GetVersion;
435+
if Ver.V1 = 1 then
436+
Result := '1'
437+
else
438+
Result := Ver;
439+
end;
440+
428441
begin
429442
// Resolve conditionally displayed block placeholders
430443
IsDBAvalable := Database.Snippets.Count(False) > 0;
431444
IsMetaDataAvailable := fMetaData.IsSupportedVersion
432445
and not fMetaData.IsCorrupt;
433-
IsLicenseInfomAvailable := IsMetaDataAvailable
446+
IsLicenseInfoAvailable := IsMetaDataAvailable
434447
and (fMetaData.GetLicenseInfo.Name <> '')
435448
and (fMetaData.GetCopyrightInfo.Date <> '')
436449
and (fMetaData.GetCopyrightInfo.Holder <> '');
437450
Tplt.ResolvePlaceholderHTML(
438-
'DBAvailable',
439-
TCSS.BlockDisplayProp(IsDBAvalable)
451+
'DBAvailable', TCSS.BlockDisplayProp(IsDBAvalable)
452+
);
453+
Tplt.ResolvePlaceholderHTML(
454+
'DBNotAvailable', TCSS.BlockDisplayProp(not IsDBAvalable)
440455
);
441456
Tplt.ResolvePlaceholderHTML(
442-
'DBNotAvailable',
443-
TCSS.BlockDisplayProp(not IsDBAvalable)
457+
'MetaDataAvailable', TCSS.BlockDisplayProp(IsMetaDataAvailable)
444458
);
445459
Tplt.ResolvePlaceholderHTML(
446-
'MetaDataAvailable',
447-
TCSS.BlockDisplayProp(IsMetaDataAvailable)
460+
'MetaDataNotAvailable', TCSS.BlockDisplayProp(not IsMetaDataAvailable)
448461
);
449462
Tplt.ResolvePlaceholderHTML(
450-
'MetaDataNotAvailable',
451-
TCSS.BlockDisplayProp(not IsMetaDataAvailable)
463+
'LicenseInfoAvailable', TCSS.BlockDisplayProp(IsLicenseInfoAvailable)
452464
);
453465
Tplt.ResolvePlaceholderHTML(
454-
'LicenseInfoAvailable',
455-
TCSS.BlockDisplayProp(IsLicenseInfomAvailable)
466+
'LicenseInfoAvailableInline',
467+
TCSS.InlineDisplayProp(IsLicenseInfoAvailable)
456468
);
457469
Tplt.ResolvePlaceholderHTML(
458470
'LicenseInfoNotAvailable',
459-
TCSS.BlockDisplayProp(not IsLicenseInfomAvailable)
471+
TCSS.BlockDisplayProp(not IsLicenseInfoAvailable)
460472
);
461473

462-
// Rsolve content placeholders
474+
// Resolve content placeholders
463475
Tplt.ResolvePlaceholderText(
464-
'CopyrightYear',
465-
fMetaData.GetCopyrightInfo.Date
476+
'CopyrightYear', fMetaData.GetCopyrightInfo.Date
466477
);
467478
Tplt.ResolvePlaceholderText(
468-
'CopyrightHolders',
469-
fMetaData.GetCopyrightInfo.Holder
479+
'CopyrightHolders', fMetaData.GetCopyrightInfo.Holder
470480
);
471481
Tplt.ResolvePlaceholderHTML(
472482
'DBLicense',
@@ -489,6 +499,7 @@ procedure TAboutDlg.InitHTMLFrames;
489499
Tplt.ResolvePlaceholderHTML(
490500
'TesterList', ContribListHTML(fMetaData.GetTesters)
491501
);
502+
Tplt.ResolvePlaceholderText('Version', DBVersion);
492503
end
493504
);
494505
end;

Src/Help/HTML/snippet_class.htm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ <h1>
5858
</ul>
5959
<p>
6060
<strong class="warning">Warning:</strong> It is an error to use this
61-
snippet kind for records or classes that have no methods (for example pure
62-
abstract classes) &ndash; use a <a
61+
snippet kind for records or classes that have no method implementations (for example pure abstract classes) &ndash; use a <a
6362
href="snippet_type.htm"
6463
>simple type definition</a> snippet instead.
6564
</p>

Src/Res/HTML/dlg-about-database-tplt.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
<a
4747
class="external-link"
4848
href="https://github.com/delphidabbler/code-snippets"
49-
>Code Snippets Database</a> is a resource containing numerous fragments of useful Object Pascal code.
49+
>Code Snippets Database</a> is a resource containing numerous fragments of useful Object Pascal code.<span style="<%LicenseInfoAvailableInline%>"> You are using version <%Version%>.</span>
5050
</p>
5151

5252
<div style="<%DBAvailable%>">

Src/Res/HTML/dlg-dbupdate-intro-tplt.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
First go to <a
3636
class="external-link"
3737
href="<%CSDBReleaseURL%>"
38-
><%CSDBReleaseURL%></a> and find the latest release of the database built for <em>CodeSnip</em> v4.16 and later. Look for a zip file whose name has the form <code>csdb416-v2.x.x.zip</code> where <code>2.x.x</code> is the database version number.
38+
><%CSDBReleaseURL%></a> and find the latest version 2 release of the database. Look for a zip file whose name has the form <code>csdb-v2.x.x-data.zip</code> where <code>2.x.x</code> is the database version number.
3939
</p>
4040

4141
<p>

Src/Res/HTML/welcome-tplt.html

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,12 @@ <h1>
6464

6565
<div id="main-db" class="box">
6666
<div class="caption">
67-
Code Snippets database
67+
DelphiDabbler Code Snippets database
6868
</div>
6969
<div style="<%HaveMainDB%>">
7070
<div class="content">
71-
There are <em><%MainDBCount%></em> snippets in the Code Snippets
72-
database.
73-
</div>
74-
<div class="content">
75-
<a
76-
href="#"
77-
class="command-link"
78-
onclick="updateDbase();return false;"
79-
>Check for updates</a>
71+
There are <em><%MainDBCount%></em> snippets in the DelphiDabbler
72+
Code Snippets database.
8073
</div>
8174
</div>
8275
<div style="<%NoMainDB%>">
@@ -86,13 +79,17 @@ <h1>
8679
class="external-link"
8780
>DelphiDabbler Code Snippets Database</a> has not been
8881
installed.</em>
82+
<a
83+
href="help:TaskUpdateCSDB"
84+
class="help-link"
85+
>Learn more</a>
8986
</div>
9087
<div class="content">
9188
<a
9289
href="#"
9390
class="command-link"
9491
onclick="updateDbase();return false;"
95-
>Download it now</a>
92+
>Install it now</a>
9693
</div>
9794
</div>
9895

@@ -204,5 +201,5 @@ <h1>
204201
</div>
205202

206203
</body>
207-
204+
208205
</html>

Src/UCSSUtils.pas

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,13 @@ TCSS = record
403403
/// <returns>string. Required CSS property.</returns>
404404
class function BlockDisplayProp(const Show: Boolean): string; static;
405405

406+
/// <summary>Creates a CSS "display" property that causes its element to be
407+
/// either hidden or displayed as "inline".</summary>
408+
/// <param name="Show">Boolean [in] Flag indicating if block is to be
409+
/// displayed (True) or hidden (False).</param>
410+
/// <returns>string. Required CSS property.</returns>
411+
class function InlineDisplayProp(const Show: Boolean): string; static;
412+
406413
/// <summary>Creates a CSS "overflow", "overflow-x" or overflow-y"
407414
/// property.</summary>
408415
/// <param name="Value">TCSSOverflowValue [in] Required overflow handling.
@@ -586,6 +593,14 @@ class function TCSS.HideBorderProp(const Side: TCSSSide): string;
586593
Result := BorderProp(Side, 0, cbsNone, clNone);
587594
end;
588595

596+
class function TCSS.InlineDisplayProp(const Show: Boolean): string;
597+
const
598+
// Map of flag onto required display style
599+
BlockDisplayStyles: array[Boolean] of TCSSDisplayStyle = (cdsNone, cdsInline);
600+
begin
601+
Result := DisplayProp(BlockDisplayStyles[Show]);
602+
end;
603+
589604
class function TCSS.LengthList(const List: array of Integer;
590605
const LU: TCSSLengthUnit): string;
591606
var

Src/UVersionInfo.pas

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ interface
3030
Record representing the four fields of a version number.
3131
}
3232
TVersionNumber = record
33+
strict private
34+
/// <summary>Converts version number to a string.</summary>
35+
function ToString: string;
3336
public
3437
V1: Word; // Major version number
3538
V2: Word; // Minor version number
@@ -107,6 +110,12 @@ TVersionNumber = record
107110
@return Converted version number.
108111
@except EConvertError. raised if string in wrong format.
109112
}
113+
class operator Implicit(Ver: TVersionNumber): string;
114+
{Operator overload that performs implicit conversion of a version number
115+
to a string in dotted quad format.
116+
@param Ver [in] Version number to be converted.
117+
@return Dotted quad string.
118+
}
110119
class operator Explicit(Ver: TVersionNumber): TPJVersionNumber;
111120
{Operator overload that performs an explicit conversion of a
112121
TVersionNumber to a TPJVersionNumber (from PJVersionInfo unit).
@@ -269,7 +278,7 @@ class function TVersionInfo.SpecialBuildStr: string;
269278
@return Dotted quad string.
270279
}
271280
begin
272-
Result := Format('%d.%d.%d.%d', [Ver.V1, Ver.V2, Ver.V3, Ver.V4]);
281+
Result := Ver.ToString;
273282
end;
274283

275284
class operator TVersionNumber.GreaterThan(Ver1, Ver2: TVersionNumber): Boolean;
@@ -327,6 +336,16 @@ function TVersionNumber.IsNull: Boolean;
327336
Result.V4 := Ver.V4;
328337
end;
329338

339+
class operator TVersionNumber.Implicit(Ver: TVersionNumber): string;
340+
{Operator overload that performs implicit conversion of a version number to a
341+
string in dotted quad format.
342+
@param Ver [in] Version number to be converted.
343+
@return Dotted quad string.
344+
}
345+
begin
346+
Result := Ver.ToString;
347+
end;
348+
330349
class operator TVersionNumber.LessThan(Ver1, Ver2: TVersionNumber): Boolean;
331350
{Operator overload that compares two version numbers to check if first is
332351
less than second.
@@ -371,6 +390,11 @@ class function TVersionNumber.Nul: TVersionNumber;
371390
Result.V4 := 0;
372391
end;
373392

393+
function TVersionNumber.ToString: string;
394+
begin
395+
Result := Format('%d.%d.%d.%d', [V1, V2, V3, V4]);
396+
end;
397+
374398
class function TVersionNumber.TryStrToVersionNumber(const S: string;
375399
out V: TVersionNumber): Boolean;
376400
var

0 commit comments

Comments
 (0)