add: air alarm scrubber select all gases button (#39296)

* add select all gases button

* now make it work

* localize

* refactor

* remove redundant Orientation

Co-authored-by: Perry Fraser <perryprog@users.noreply.github.com>

* remove useless HorizontalExpand

Co-authored-by: Perry Fraser <perryprog@users.noreply.github.com>

* add nice newline

Co-authored-by: Perry Fraser <perryprog@users.noreply.github.com>

* deduplicate Enum.GetValues<Gas> usage

---------

Co-authored-by: Perry Fraser <perryprog@users.noreply.github.com>
This commit is contained in:
qwerltaz
2025-08-05 02:34:10 +02:00
committed by GitHub
parent 1d07b77707
commit 2c933c8de7
3 changed files with 25 additions and 2 deletions

View File

@@ -29,7 +29,13 @@
<Collapsible Margin="2 2 2 2">
<CollapsibleHeading Title="Gas filters" />
<CollapsibleBody Margin="20 0 0 0">
<GridContainer HorizontalExpand="True" Name="CGasContainer" Columns="3" />
<BoxContainer Orientation="Vertical">
<BoxContainer Margin="2">
<Button Name="CSelectAll" Text="{Loc 'air-alarm-ui-scrubber-select-all-gases-label'}" />
<Button Name="CDeselectAll" Text="{Loc 'air-alarm-ui-scrubber-deselect-all-gases-label'}" />
</BoxContainer>
<GridContainer Name="CGasContainer" Columns="3" />
</BoxContainer>
</CollapsibleBody>
</Collapsible>
</BoxContainer>

View File

@@ -22,6 +22,8 @@ public sealed partial class ScrubberControl : BoxContainer
private FloatSpinBox _volumeRate => CVolumeRate;
private CheckBox _wideNet => CWideNet;
private Button _copySettings => CCopySettings;
private Button _selectAll => CSelectAll;
private Button _deselectAll => CDeselectAll;
private GridContainer _gases => CGasContainer;
private Dictionary<Gas, Button> _gasControls = new();
@@ -78,7 +80,20 @@ public sealed partial class ScrubberControl : BoxContainer
ScrubberDataCopied?.Invoke(_data);
};
foreach (var value in Enum.GetValues<Gas>())
var allGases = Enum.GetValues<Gas>();
_selectAll.OnPressed += _ =>
{
_data.FilterGases = new HashSet<Gas>(allGases);
ScrubberDataChanged?.Invoke(_address, _data);
};
_deselectAll.OnPressed += _ =>
{
_data.FilterGases = [];
ScrubberDataChanged?.Invoke(_address, _data);
};
foreach (var value in allGases)
{
var gasButton = new Button
{

View File

@@ -69,6 +69,8 @@ air-alarm-ui-vent-internal-bound-label = Internal bound
air-alarm-ui-scrubber-pump-direction-label = Direction
air-alarm-ui-scrubber-volume-rate-label = Rate (L)
air-alarm-ui-scrubber-wide-net-label = WideNet
air-alarm-ui-scrubber-select-all-gases-label = Select all
air-alarm-ui-scrubber-deselect-all-gases-label = Deselect all
### Thresholds