|
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. |
0 commit comments