Skip to content

Commit

Permalink
Move record options to record view
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoCoderMatrix86 committed Jul 3, 2024
1 parent 1dc6832 commit 37fe200
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 34 deletions.
12 changes: 12 additions & 0 deletions AudioCuesheetEditor/AudioCuesheetEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
<Content Remove="Resources\Localization\OptionsDialog\en.json" />
<Content Remove="Resources\Localization\RecordControl\de.json" />
<Content Remove="Resources\Localization\RecordControl\en.json" />
<Content Remove="Resources\Localization\RecordOptions\de.json" />
<Content Remove="Resources\Localization\RecordOptions\en.json" />
<Content Remove="Resources\Localization\TracksTable\de.json" />
<Content Remove="Resources\Localization\TracksTable\en.json" />
<Content Remove="Resources\Localization\CultureSelector\de.json" />
Expand Down Expand Up @@ -82,6 +84,8 @@
<EmbeddedResource Include="Resources\Localization\OptionsDialog\en.json" />
<EmbeddedResource Include="Resources\Localization\RecordControl\de.json" />
<EmbeddedResource Include="Resources\Localization\RecordControl\en.json" />
<EmbeddedResource Include="Resources\Localization\RecordOptions\de.json" />
<EmbeddedResource Include="Resources\Localization\RecordOptions\en.json" />
<EmbeddedResource Include="Resources\Localization\TracksTable\de.json" />
<EmbeddedResource Include="Resources\Localization\TracksTable\en.json" />
<EmbeddedResource Include="Resources\Localization\CultureSelector\de.json" />
Expand Down Expand Up @@ -124,5 +128,13 @@
<ItemGroup>
<ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" />
</ItemGroup>

<ItemGroup>
<UpToDateCheckInput Remove="Shared\RecordOptions.razor" />
</ItemGroup>

<ItemGroup>
<_ContentIncludedByDefault Remove="Shared\RecordOptions.razor" />
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions AudioCuesheetEditor/Pages/RecordControl.razor
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ along with Foobar. If not, see

@code {
//TODO: Allow the user to edit the default RecordCountdownTimer
//TODO: Allow the user to stop the record countdown
Timer updateGUITimer = new Timer(300);
Timer? startRecordTimer;
DateTime recordTimerStarted;
Expand Down
9 changes: 9 additions & 0 deletions AudioCuesheetEditor/Pages/ViewModeRecord.razor
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ along with Foobar. If not, see

<Column>
<Accordion>
<Collapse Visible="recordOptionsVisible">
<CollapseHeader>
<Button Clicked="(() => recordOptionsVisible = !recordOptionsVisible)"><Heading Size="HeadingSize.Is3">@_localizer["Record options"]</Heading></Button>
</CollapseHeader>
<CollapseBody>
<RecordOptions />
</CollapseBody>
</Collapse>
<Collapse Visible="recordControlVisible">
<CollapseHeader>
<Button Clicked="(() => recordControlVisible = !recordControlVisible)"><Heading Size="HeadingSize.Is3">@_localizer["Recordcontrol"]</Heading></Button>
Expand Down Expand Up @@ -148,6 +156,7 @@ along with Foobar. If not, see
Boolean recordControlVisible = true;
Boolean enterNewTrackVisible = true;
Boolean cuesheetTracksVisible = true;
Boolean recordOptionsVisible = false;

IEnumerable<MusicBrainzArtist>? autocompleteArtists;
IEnumerable<MusicBrainzTrack>? autocompleteTitles;
Expand Down
11 changes: 11 additions & 0 deletions AudioCuesheetEditor/Resources/Localization/RecordOptions/de.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"culture": "de",
"translations": {
"Filename for recorded audio": "Dateiname für aufgenommenes Audio",
"Record countdown timer in seconds": "Aufnahmecountdown in Sekunden",
"Record time sensitivity": "Genauigkeit der Aufnahmezeiten",
"TimeSensitivityMode.Full": "Alles (inkl. Millisekunden)",
"TimeSensitivityMode.Seconds": "Nur Sekunden",
"TimeSensitivityMode.Minutes": "Nur Minuten"
}
}
10 changes: 10 additions & 0 deletions AudioCuesheetEditor/Resources/Localization/RecordOptions/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"culture": "en",
"translations": {
"Filename for recorded audio": "Filename for recorded audio",
"Record time sensitivity": "Recordtime sensitivity",
"TimeSensitivityMode.Full": "Everything (incl. milliseconds)",
"TimeSensitivityMode.Seconds": "Only seconds",
"TimeSensitivityMode.Minutes": "Only minutes"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"Error": "Fehler",
"Here all validation messages will be displayed. For details switch to full edit mode.": "Hier werden alle Validierungsnachrichten angezeigt. Für Details wechseln Sie bitte in den Bearbeitungsmodus \"Komplette Bearbeitung\".",
"Start record timer": "Aufnahmecountdown starten",
"Record will start in {0} seconds!": "Aufnahme wird in {0} Sekunden starten!"
"Record will start in {0} seconds!": "Aufnahme wird in {0} Sekunden starten!",
"Record options": "Aufnahmeoptionen"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"Error": "Error",
"Here all validation messages will be displayed. For details switch to full edit mode.": "All validation messages will be displayed here. For details please switch to \"Full edit mode\".",
"Start record timer": "Start record countdown timer",
"Record will start in {0} seconds!": "Record will start in {0} seconds!"
"Record will start in {0} seconds!": "Record will start in {0} seconds!",
"Record options": "Record options"
}
}
32 changes: 0 additions & 32 deletions AudioCuesheetEditor/Shared/OptionsDialog.razor
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ along with Foobar. If not, see
<Tabs @bind-SelectedTab="@selectedOptionsTab">
<Items>
<Tab Name="common">@_localizer["Common settings"]</Tab>
<Tab Name="recording">@_localizer["Record settings"]</Tab>
</Items>
</Tabs>
</CardHeader>
Expand Down Expand Up @@ -135,37 +134,6 @@ along with Foobar. If not, see
</Field>
</Validation>
</TabPanel>
<TabPanel Name="recording" Padding="Padding.Is3.OnY">
<Validation AsyncValidator="(args, token) => ValidatorUtility<ApplicationOptions>.Validate(args, applicationOptions, x => x.RecordedAudiofilename, _validationMessageLocalizer, token)">
<Field Horizontal="true">
<FieldLabel ColumnSize="ColumnSize.Is5.OnWidescreen.Is12.OnDesktop">@_localizer["Filename for recorded audio"]</FieldLabel>
<FieldBody ColumnSize="ColumnSize.Is7.OnWidescreen.Is12.OnDesktop">
<TextEdit @bind-Text="applicationOptions.RecordedAudiofilename" Immediate="false">
<Feedback>
<ValidationError Tooltip />
</Feedback>
</TextEdit>
</FieldBody>
</Field>
</Validation>
<Field Horizontal="true">
<FieldLabel ColumnSize="ColumnSize.Is5.OnWidescreen.Is12.OnDesktop">@_localizer["Record countdown timer in seconds"]</FieldLabel>
<FieldBody ColumnSize="ColumnSize.Is7.OnWidescreen.Is12.OnDesktop">
<NumericEdit TValue="uint" @bind-Value="applicationOptions.RecordCountdownTimer" Min="1" />
</FieldBody>
</Field>
<Field Horizontal="true">
<FieldLabel ColumnSize="ColumnSize.Is5.OnWidescreen.Is12.OnDesktop">@_localizer["Record time sensitivity"]</FieldLabel>
<FieldBody ColumnSize="ColumnSize.Is7.OnWidescreen.Is12.OnDesktop">
<Select TValue="String" @bind-SelectedValue="@applicationOptions.RecordTimeSensitivityname">
@foreach (var name in Enum.GetNames(typeof(TimeSensitivityMode)))
{
<SelectItem Value="@name">@_localizer["TimeSensitivityMode." + name]</SelectItem>
}
</Select>
</FieldBody>
</Field>
</TabPanel>
</TabsContent>
</CardBody>
</Card>
Expand Down
89 changes: 89 additions & 0 deletions AudioCuesheetEditor/Shared/RecordOptions.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<!--
This file is part of AudioCuesheetEditor.
AudioCuesheetEditor is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
AudioCuesheetEditor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see
<http: //www.gnu.org/licenses />.
-->
@implements IDisposable

@inject ITextLocalizer<RecordOptions> _localizer
@inject LocalStorageOptionsProvider _localStorageOptionsProvider
@inject ITextLocalizerService _localizationService
@inject ITextLocalizer<ValidationMessage> _validationMessageLocalizer

<Validations>
<Validation AsyncValidator="(args, token) => ValidatorUtility<ApplicationOptions>.Validate(args, applicationOptions, x => x.RecordedAudiofilename, _validationMessageLocalizer, token)">
<Field Horizontal="true">
<FieldLabel ColumnSize="ColumnSize.Is5.OnWidescreen.Is12.OnDesktop">@_localizer["Filename for recorded audio"]</FieldLabel>
<FieldBody ColumnSize="ColumnSize.Is7.OnWidescreen.Is12.OnDesktop">
@if (applicationOptions != null)
{
<TextEdit @bind-Text="applicationOptions.RecordedAudiofilename" Immediate="false">
<Feedback>
<ValidationError Tooltip />
</Feedback>
</TextEdit>
}
</FieldBody>
</Field>
</Validation>
<Field Horizontal="true">
<FieldLabel ColumnSize="ColumnSize.Is5.OnWidescreen.Is12.OnDesktop">@_localizer["Record time sensitivity"]</FieldLabel>
<FieldBody ColumnSize="ColumnSize.Is7.OnWidescreen.Is12.OnDesktop">
@if (applicationOptions != null)
{
<Select TValue="String" @bind-SelectedValue="@applicationOptions.RecordTimeSensitivityname">
@foreach (var name in Enum.GetNames(typeof(TimeSensitivityMode)))
{
<SelectItem Value="@name">@_localizer["TimeSensitivityMode." + name]</SelectItem>
}
</Select>
}
</FieldBody>
</Field>
</Validations>

@code {
//TODO: Save each property when changed
//TODO: Save, reset, reload, etc. like import options
ApplicationOptions? applicationOptions;

public void Dispose()
{
_localizationService.LocalizationChanged -= LocalizationService_LocalizationChanged;
_localStorageOptionsProvider.OptionSaved -= LocalStorageOptionsProvider_OptionsSaved;
}

protected override async Task OnInitializedAsync()
{
_localizationService.LocalizationChanged += LocalizationService_LocalizationChanged;
_localStorageOptionsProvider.OptionSaved += LocalStorageOptionsProvider_OptionsSaved;

applicationOptions = await _localStorageOptionsProvider.GetOptions<ApplicationOptions>();
await base.OnInitializedAsync();
}

void LocalizationService_LocalizationChanged(object? sender, EventArgs args)
{
StateHasChanged();
}

void LocalStorageOptionsProvider_OptionsSaved(object? sender, IOptions options)
{
if (options is ApplicationOptions applicationOption)
{
applicationOptions = applicationOption;
}
}
}

0 comments on commit 37fe200

Please sign in to comment.