Add a 'Copy' button to the fax UI (#22027)

* Add a 'Copy' button to the fax UI

* Add ValidatePrototypeId attribute

Co-authored-by: Kara <lunarautomaton6@gmail.com>

---------

Co-authored-by: Kara <lunarautomaton6@gmail.com>
This commit is contained in:
Arimah Greene
2023-12-25 02:08:15 +01:00
committed by GitHub
parent 28310a131c
commit b20fcf5141
6 changed files with 76 additions and 4 deletions

View File

@@ -22,6 +22,7 @@ public sealed class FaxBoundUi : BoundUserInterface
_window.OpenCentered();
_window.OnClose += Close;
_window.CopyButtonPressed += OnCopyButtonPressed;
_window.SendButtonPressed += OnSendButtonPressed;
_window.RefreshButtonPressed += OnRefreshButtonPressed;
_window.PeerSelected += OnPeerSelected;
@@ -32,6 +33,11 @@ public sealed class FaxBoundUi : BoundUserInterface
SendMessage(new FaxSendMessage());
}
private void OnCopyButtonPressed()
{
SendMessage(new FaxCopyMessage());
}
private void OnRefreshButtonPressed()
{
SendMessage(new FaxRefreshMessage());

View File

@@ -20,6 +20,10 @@
</BoxContainer>
<Control HorizontalExpand="True" MinHeight="20" />
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<Button Name="CopyButton"
Text="{Loc 'fax-machine-ui-copy-button'}"
HorizontalExpand="False"
Disabled="True" />
<Button Name="SendButton"
Text="{Loc 'fax-machine-ui-send-button'}"
HorizontalExpand="True"

View File

@@ -9,6 +9,7 @@ namespace Content.Client.Fax.UI;
[GenerateTypedNameReferences]
public sealed partial class FaxWindow : DefaultWindow
{
public event Action? CopyButtonPressed;
public event Action? SendButtonPressed;
public event Action? RefreshButtonPressed;
public event Action<string>? PeerSelected;
@@ -17,6 +18,7 @@ public sealed partial class FaxWindow : DefaultWindow
{
RobustXamlLoader.Load(this);
CopyButton.OnPressed += _ => CopyButtonPressed?.Invoke();
SendButton.OnPressed += _ => SendButtonPressed?.Invoke();
RefreshButton.OnPressed += _ => RefreshButtonPressed?.Invoke();
PeerSelector.OnItemSelected += args =>
@@ -25,6 +27,7 @@ public sealed partial class FaxWindow : DefaultWindow
public void UpdateState(FaxUiState state)
{
CopyButton.Disabled = !state.CanCopy;
SendButton.Disabled = !state.CanSend;
FromLabel.Text = state.DeviceName;