Skip to content

Commit 67ffcfe

Browse files
committed
Listening to the settings update event
1 parent 63aede6 commit 67ffcfe

File tree

3 files changed

+110
-23
lines changed

3 files changed

+110
-23
lines changed

source/views/frame/Frame.BuildButtons.fmx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ object BuildButtonsFrame: TBuildButtonsFrame
2222
Images = ImageContainer.images
2323
ImageIndex = 12
2424
Margins.Left = 5.000000000000000000
25+
PopupMenu = pmDeployDropDown
2526
Position.X = 40.000000000000000000
2627
Size.Width = 30.000000000000000000
2728
Size.Height = 30.000000000000000000
2829
Size.PlatformDefault = False
29-
StyleLookup = 'actiontoolbutton'
30+
StyleLookup = 'actiontoolbuttondropdown'
3031
end
3132
object sbRunCurrentProject: TSpeedButton
3233
Action = MenuActionsContainer.actRunCurrentProjectAsync
@@ -41,4 +42,13 @@ object BuildButtonsFrame: TBuildButtonsFrame
4142
Size.PlatformDefault = False
4243
StyleLookup = 'actiontoolbutton'
4344
end
45+
object pmDeployDropDown: TPopupMenu
46+
Left = 32
47+
Top = 16
48+
object miSmartDeploy: TMenuItem
49+
AutoCheck = True
50+
Text = 'Smart Deploy'
51+
OnClick = miSmartDeployClick
52+
end
53+
end
4454
end
Lines changed: 66 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,66 @@
1-
unit Frame.BuildButtons;
2-
3-
interface
4-
5-
uses
6-
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
7-
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
8-
FMX.Controls.Presentation;
9-
10-
type
11-
TBuildButtonsFrame = class(TFrame)
12-
sbBuildCurrentProject: TSpeedButton;
13-
spDeployCurrentProject: TSpeedButton;
14-
sbRunCurrentProject: TSpeedButton;
15-
end;
16-
17-
implementation
18-
19-
{$R *.fmx}
20-
21-
end.
1+
unit Frame.BuildButtons;
2+
interface
3+
uses
4+
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
5+
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
6+
FMX.Controls.Presentation, Builder.Messagery, Builder.SpeedButton, FMX.Menus;
7+
8+
type
9+
TBuildButtonsFrame = class(TFrame)
10+
sbBuildCurrentProject: TSpeedButton;
11+
spDeployCurrentProject: TSpeedButton;
12+
sbRunCurrentProject: TSpeedButton;
13+
pmDeployDropDown: TPopupMenu;
14+
miSmartDeploy: TMenuItem;
15+
procedure miSmartDeployClick(Sender: TObject);
16+
private
17+
FUpdateSettings: IDisconnectable;
18+
public
19+
constructor Create(AOwner: TComponent); override;
20+
destructor Destroy(); override;
21+
end;
22+
23+
implementation
24+
25+
uses
26+
Container.Menu.Actions;
27+
28+
{$R *.fmx}
29+
30+
{ TBuildButtonsFrame }
31+
32+
constructor TBuildButtonsFrame.Create(AOwner: TComponent);
33+
begin
34+
inherited;
35+
FUpdateSettings := TMessagery.SubscribeToEvent<TUpdateSettingsEvent>(
36+
procedure(const AEventNotification: TUpdateSettingsEvent)
37+
begin
38+
var LSmartDeploy := AEventNotification.Body.SmartDeploy;
39+
TThread.Queue(TThread.Current,
40+
procedure()
41+
begin
42+
miSmartDeploy.IsChecked := LSmartDeploy;
43+
if LSmartDeploy then begin
44+
spDeployCurrentProject.Action := MenuActionsContainer.actSmartDeployCurrentProjectAsync;
45+
sbRunCurrentProject.Action := MenuActionsContainer.actSmartRunCurrentProjectAsync;
46+
end else begin
47+
spDeployCurrentProject.Action := MenuActionsContainer.actDeployCurrentProjectAsync;
48+
sbRunCurrentProject.Action := MenuActionsContainer.actRunCurrentProjectAsync;
49+
end;
50+
end);
51+
end);
52+
end;
53+
54+
destructor TBuildButtonsFrame.Destroy;
55+
begin
56+
FUpdateSettings.Disconnect();
57+
inherited;
58+
end;
59+
60+
procedure TBuildButtonsFrame.miSmartDeployClick(Sender: TObject);
61+
begin
62+
TMessagery.BroadcastEventAsync(
63+
TUpdateSettingsEvent.Create(TMenuItem(Sender).IsChecked));
64+
end;
65+
66+
end.

source/views/frame/Frame.DebugButtons.pas

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ interface
55
uses
66
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
77
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
8-
FMX.Controls.Presentation;
8+
FMX.Controls.Presentation, Builder.Messagery;
99

1010
type
1111
TDebugButtonsFrame = class(TFrame)
@@ -16,6 +16,11 @@ TDebugButtonsFrame = class(TFrame)
1616
btnStop: TSpeedButton;
1717
btnPause: TSpeedButton;
1818
sbContinue: TSpeedButton;
19+
private
20+
FUpdateSettings: IDisconnectable;
21+
public
22+
constructor Create(AOwner: TComponent); override;
23+
destructor Destroy(); override;
1924
end;
2025

2126
implementation
@@ -26,4 +31,31 @@ implementation
2631

2732
{$R *.fmx}
2833

34+
{ TDebugButtonsFrame }
35+
36+
constructor TDebugButtonsFrame.Create(AOwner: TComponent);
37+
begin
38+
inherited;
39+
FUpdateSettings := TMessagery.SubscribeToEvent<TUpdateSettingsEvent>(
40+
procedure(const AEventNotification: TUpdateSettingsEvent)
41+
begin
42+
var LSmartDeploy := AEventNotification.Body.SmartDeploy;
43+
TThread.Queue(TThread.Current,
44+
procedure()
45+
begin
46+
if LSmartDeploy then begin
47+
sbDebugCurrentProject.Action := MenuActionsContainer.actSmartDebugCurrentProjectAsync;
48+
end else begin
49+
sbDebugCurrentProject.Action := MenuActionsContainer.actDebugCurrentProjectAsync;
50+
end;
51+
end);
52+
end);
53+
end;
54+
55+
destructor TDebugButtonsFrame.Destroy;
56+
begin
57+
FUpdateSettings.Disconnect();
58+
inherited;
59+
end;
60+
2961
end.

0 commit comments

Comments
 (0)