Skip to content

Commit 4ec90ae

Browse files
committed
Add new all-compilers settings unit to project
New static TCompilerSettings class in new Compiler.USettings unit provided to read/write settings to config file that apply to all compilers. Added only a single PermitStartupDetection class property that specifies whether CodeSnip should detect un-registered Delphi compiler installations on start-up. Added a new ssCompilers ("Compilers") section to USettings unit for use by the new TCompilerSettings class.
1 parent d156dca commit 4ec90ae

File tree

4 files changed

+69
-4
lines changed

4 files changed

+69
-4
lines changed

Src/CodeSnip.dpr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,8 @@ uses
371371
UXMLDocHelper in 'UXMLDocHelper.pas',
372372
UXMLDocumentEx in 'UXMLDocumentEx.pas',
373373
FmDeleteUserDBDlg in 'FmDeleteUserDBDlg.pas' {DeleteUserDBDlg},
374-
Compilers.UAutoDetect in 'Compilers.UAutoDetect.pas';
374+
Compilers.UAutoDetect in 'Compilers.UAutoDetect.pas',
375+
Compilers.USettings in 'Compilers.USettings.pas';
375376

376377
// Include resources
377378
{$Resource ExternalObj.tlb} // Type library file

Src/CodeSnip.dproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,7 @@
576576
<Form>DeleteUserDBDlg</Form>
577577
</DCCReference>
578578
<DCCReference Include="Compilers.UAutoDetect.pas"/>
579+
<DCCReference Include="Compilers.USettings.pas"/>
579580
<None Include="CodeSnip.todo"/>
580581
<BuildConfiguration Include="Base">
581582
<Key>Base</Key>

Src/Compilers.USettings.pas

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
* This Source Code Form is subject to the terms of the Mozilla Public License,
3+
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
4+
* obtain one at https://mozilla.org/MPL/2.0/
5+
*
6+
* Copyright (C) 2022, Peter Johnson (gravatar.com/delphidabbler).
7+
*
8+
* Class that reads and writes settings that apply to all compilers.
9+
}
10+
11+
12+
unit Compilers.USettings;
13+
14+
interface
15+
16+
uses
17+
UBaseObjects,
18+
USettings;
19+
20+
type
21+
/// <summary>Manages settings that apply to all compilers.</summary>
22+
TCompilerSettings = class(TNoConstructObject)
23+
strict private
24+
const
25+
AllCompilersConfigSection = ssCompilers;
26+
PermitStartupDetectionKey = 'PermitStartupDetection';
27+
class function ReadStorage: ISettingsSection;
28+
class function GetPermitStartupDetection: Boolean; static;
29+
class procedure SetPermitStartupDetection(const Value: Boolean); static;
30+
public
31+
class property PermitStartupDetection: Boolean
32+
read GetPermitStartupDetection write SetPermitStartupDetection
33+
default True;
34+
end;
35+
36+
implementation
37+
38+
{ TCompilerSettings }
39+
40+
class function TCompilerSettings.GetPermitStartupDetection: Boolean;
41+
begin
42+
Result := ReadStorage.GetBoolean(PermitStartupDetectionKey, True);
43+
end;
44+
45+
class function TCompilerSettings.ReadStorage: ISettingsSection;
46+
begin
47+
Result := Settings.ReadSection(AllCompilersConfigSection);
48+
end;
49+
50+
class procedure TCompilerSettings.SetPermitStartupDetection(
51+
const Value: Boolean);
52+
var
53+
Stg: ISettingsSection;
54+
begin
55+
Stg := ReadStorage;
56+
Stg.SetBoolean(PermitStartupDetectionKey, Value);
57+
Stg.Save;
58+
end;
59+
60+
end.
61+

Src/USettings.pas

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,12 @@ interface
164164
/// <para>-ssWindowState - info about the size and state of various
165165
/// windows</para>
166166
/// <para>-ssDatabase - database customisation info</para>
167-
/// <para>-ssUpdateChecks - info about update checks</para>
167+
/// <para>-ssCompilers - info about all compilers</para>
168168
/// </summary>
169169
TSettingsSectionId = (
170170
ssFindText, ssFindCompiler, ssFindXRefs, ssCompilerInfo,
171171
ssPreferences, ssUnits, ssDuplicateSnippet,
172-
ssFavourites, ssWindowState, ssDatabase
172+
ssFavourites, ssWindowState, ssDatabase, ssCompilers
173173
);
174174

175175
type
@@ -540,7 +540,8 @@ function TIniSettings.SectionName(const Id: TSettingsSectionId;
540540
'DuplicateSnippet', // ssDuplicateSnippet
541541
'Favourites', // ssFavourites
542542
'WindowState', // ssWindowState
543-
'Database' // ssDatabase
543+
'Database', // ssDatabase
544+
'Compilers' // ssCompilers
544545
);
545546
begin
546547
Result := cSectionNames[Id];
@@ -751,3 +752,4 @@ procedure TIniSettingsSection.SetStrings(const CountName, ItemFmt: string;
751752

752753
end.
753754

755+

0 commit comments

Comments
 (0)