IDE: force users to select at least one buidlmode in BuildManyModes. Issue #40826.

This commit is contained in:
Bart 2024-03-09 18:48:19 +01:00
parent 286a0c704a
commit 006429d521
3 changed files with 24 additions and 18 deletions

View File

@ -344,6 +344,7 @@ begin
BMList := TBuildModesCheckList.Create(lisCompileFollowingModes);
ModeList := TList.Create;
try
BMList.DisAllowNoneSelected := True; //force user to select at least 1 buildmode
if BMList.ShowModal <> mrOK then Exit;
BMList.SaveManyModesSelection; // Remember the selection for next time.
ActiveMode := Project1.ActiveBuildMode;
@ -366,12 +367,6 @@ begin
DebugLn('BuildManyModes: Active Mode');
LastMode := (ModeList.Count=0);
if not BuildOneMode(LastMode) then Exit;
end
else if ModeList.Count=0 then
begin
IDEMessageDialog(lisExit, lisPleaseSelectAtLeastOneBuildMode,
mtInformation, [mbOK]);
Exit;
end;
// Build rest of the modes.
DebugLn('BuildManyModes: Rest of the Modes');

View File

@ -7,13 +7,13 @@ object GenericCheckListForm: TGenericCheckListForm
Caption = 'GenericCheckListForm'
ClientHeight = 277
ClientWidth = 343
OnShow = FormShow
Position = poScreenCenter
LCLVersion = '1.9.0.0'
LCLVersion = '3.99.0.0'
OnShow = FormShow
object ButtonPanel1: TButtonPanel
Left = 6
Height = 30
Top = 241
Height = 26
Top = 245
Width = 331
OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True
@ -36,18 +36,18 @@ object GenericCheckListForm: TGenericCheckListForm
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 6
Height = 200
Top = 31
Height = 218
Top = 13
Width = 331
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 6
ItemHeight = 0
OnItemClick = CheckListBox1ItemClick
TabOrder = 1
OnItemClick = CheckListBox1ItemClick
end
object InfoLabel: TLabel
Left = 6
Height = 19
Height = 1
Top = 6
Width = 331
Align = alTop

View File

@ -22,8 +22,11 @@ type
procedure FormShow(Sender: TObject);
private
fActionBtn: TBitBtn;
fDisallowNoneSelected: Boolean;
procedure UpdateButtons;
public
property DisallowNoneSelected: Boolean read fDisallowNoneSelected write fDisallowNoneSelected;
constructor Create(TheOwner: TComponent); override;
constructor CreateWithActionButton(aCaption: TCaption; aResourceGlyphName: string = '');
end;
@ -36,7 +39,7 @@ implementation
constructor TGenericCheckListForm.CreateWithActionButton(aCaption: TCaption;
aResourceGlyphName: string);
begin
inherited Create(nil);
Create(nil);
fActionBtn := TBitBtn.Create(ButtonPanel1);
fActionBtn.Caption := aCaption;
fActionBtn.ModalResult := mrYes; // ActionButton will return mrYes.
@ -63,17 +66,25 @@ procedure TGenericCheckListForm.UpdateButtons;
var
i: Integer;
begin
if Assigned(fActionBtn) then
if Assigned(fActionBtn) or DisallowNoneSelected then
begin
for i := 0 to CheckListBox1.Count-1 do
if CheckListBox1.Checked[i] then
begin
fActionBtn.Enabled := True;
if Assigned(fActionBtn) then fActionBtn.Enabled := True;
ButtonPanel1.OKButton.Enabled := True;
Exit;
end;
fActionBtn.Enabled := False;
if Assigned(fActionBtn) then fActionBtn.Enabled := False;
if DisallowNoneSelected then ButtonPanel1.OKButton.Enabled := False;
end;
end;
constructor TGenericCheckListForm.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
fDisallowNoneSelected := False;
end;
end.