Skip to content

Commit 8b13b3d

Browse files
committed
Download form improvements - dont show non-default branch by default
default branch is currently simba2000 and is controlled from Simba-Build-Archive README in a hidden html comment
1 parent 2da4285 commit 8b13b3d

File tree

2 files changed

+45
-7
lines changed

2 files changed

+45
-7
lines changed

Source/ide/simba.form_downloadsimba.lfm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ object SimbaDownloadSimbaForm: TSimbaDownloadSimbaForm
66
Caption = 'Download Simba'
77
ClientHeight = 470
88
ClientWidth = 846
9-
OnCreate = FormCreate
10-
OnShow = FormShow
119
Position = poMainFormCenter
1210
ShowInTaskBar = stAlways
13-
LCLVersion = '3.8.0.0'
11+
LCLVersion = '4.0.0.4'
12+
OnCreate = FormCreate
13+
OnShow = FormShow
1414
object Notebook1: TNotebook
1515
Left = 0
1616
Height = 470

Source/ide/simba.form_downloadsimba.pas

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ interface
1919
simba.settings,
2020
simba.httpclient,
2121
simba.component_treeview,
22-
simba.component_buttonpanel;
22+
simba.component_buttonpanel,
23+
simba.component_button;
2324

2425
type
2526
TDownloaderFormNode = class(TTreeNode)
2627
public
2728
Commit: String;
29+
Branch: String;
2830
DownloadURL: String;
2931
end;
3032

@@ -71,6 +73,7 @@ TSimbaDownloadSimbaForm = class(TForm)
7173
procedure Label6MouseEnter(Sender: TObject);
7274
procedure Label6MouseLeave(Sender: TObject);
7375
private
76+
FDefaultBranch: String;
7477
FData: array of record
7578
Date: String;
7679
Branch: String;
@@ -83,6 +86,7 @@ TSimbaDownloadSimbaForm = class(TForm)
8386

8487
procedure DoGetNodeColor(Node: TTreeNode; var TheColor: TColor);
8588
procedure DoTreeDoubleClick(Sender: TObject);
89+
procedure DoCheckClick(Sender: TObject);
8690

8791
procedure DoPopulate;
8892
procedure DoPopulated(Sender: TObject);
@@ -198,10 +202,20 @@ procedure TSimbaDownloadSimbaForm.FormCreate(Sender: TObject);
198202
ButtonPanel: TSimbaButtonPanel;
199203
Control: TControl;
200204
begin
201-
Color := SimbaTheme.ColorBackground;
205+
Color := SimbaTheme.ColorFrame;
206+
Font.Color := SimbaTheme.ColorFont;
202207
Width := Scale96ToScreen(750);
203208
Height := Scale96ToScreen(450);
204209

210+
with TSimbaLabeledCheckButton.Create(Self) do
211+
begin
212+
Parent := Self;
213+
Align := alTop;
214+
Caption := 'Show all branches';
215+
BorderSpacing.Around := 5;
216+
CheckButton.OnClick := @DoCheckClick;
217+
end;
218+
205219
FTreeView := TSimbaTreeView.Create(Self, TDownloaderFormNode);
206220
FTreeView.Parent := Mainpage;
207221
FTreeView.Align := alClient;
@@ -269,6 +283,23 @@ procedure TSimbaDownloadSimbaForm.DoTreeDoubleClick(Sender: TObject);
269283
TDownloader.Create(Node, FStatusLabel);
270284
end;
271285

286+
procedure TSimbaDownloadSimbaForm.DoCheckClick(Sender: TObject);
287+
288+
procedure HideOrShowOtherBranches(Node: TTreeNode);
289+
begin
290+
if TSimbaCheckButton(Sender).Down then
291+
Node.Visible := True
292+
else
293+
Node.Visible := TDownloaderFormNode(Node).Branch = FDefaultBranch;
294+
end;
295+
296+
begin
297+
if (FDefaultBranch = '') then
298+
Exit;
299+
300+
FTreeView.ForEachTopLevel(@HideOrShowOtherBranches);
301+
end;
302+
272303
procedure TSimbaDownloadSimbaForm.DoPopulate;
273304
var
274305
Count: Integer = 0;
@@ -297,6 +328,8 @@ procedure TSimbaDownloadSimbaForm.DoPopulate;
297328

298329
if (Length(Lines) > 0) then
299330
begin
331+
FDefaultBranch := Lines[0].Between('<!--', '-->');
332+
300333
SetLength(FData, Length(Lines));
301334
for I := 6 to High(Lines) do
302335
begin
@@ -320,7 +353,7 @@ procedure TSimbaDownloadSimbaForm.DoPopulated(Sender: TObject);
320353
var
321354
I: Integer;
322355
Download: String;
323-
Node: TTreeNode;
356+
Node: TDownloaderFormNode;
324357
begin
325358
if (Length(FData) = 0) then
326359
begin
@@ -332,9 +365,14 @@ procedure TSimbaDownloadSimbaForm.DoPopulated(Sender: TObject);
332365
FTreeView.Clear();
333366
for I := 0 to High(FData) do
334367
begin
335-
Node := FTreeView.AddNode(FData[I].Date + ' | ' + FData[I].Branch + ' | ' + FData[I].Commit);
368+
Node := TDownloaderFormNode(FTreeView.AddNode(FData[I].Date + ' | ' + FData[I].Branch + ' | ' + FData[I].Commit));
369+
Node.Commit := FData[I].Commit;
370+
Node.Branch := FData[I].Branch;
336371
for Download in FData[i].Downloads do
337372
AddDownloadNode(Node, Download, FData[I].Commit);
373+
374+
// by default other branches are not visible
375+
Node.Visible := (FDefaultBranch = '') or (Node.Branch = FDefaultBranch);
338376
end;
339377
FTreeView.EndUpdate();
340378
if (FTreeView.Items.Count > 0) then

0 commit comments

Comments
 (0)