Skip to content

Commit

Permalink
Merge pull request stakira#852 from lottev1991/ShowReadmeTxt
Browse files Browse the repository at this point in the history
[Singers window] Add button to show readme.txt
  • Loading branch information
stakira authored Oct 2, 2023
2 parents a5e61e3 + 6cfab88 commit 8b40dff
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions OpenUtau/Strings/Strings.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,8 @@
<system:String x:Key="singers.otoview.showall">Show All</system:String>
<system:String x:Key="singers.otoview.zoomin">Zoom In</system:String>
<system:String x:Key="singers.otoview.zoomout">Zoom Out</system:String>
<system:String x:Key="singers.readme">Open readme.txt</system:String>
<system:String x:Key="singers.readme.notfound">readme.txt not found.</system:String>
<system:String x:Key="singers.playsample">Play sample</system:String>
<system:String x:Key="singers.refresh">Refresh</system:String>
<system:String x:Key="singers.setdefaultphonemizer">Set Default Phonemizer</system:String>
Expand Down
1 change: 1 addition & 0 deletions OpenUtau/Views/SingersDialog.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
</StackPanel>
<StackPanel Grid.Row="0" Spacing="5" Margin="0,0,0,0" Height="20"
Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Bottom">
<Button Margin="0" Content="{DynamicResource singers.readme}" Click="OnOpenReadme"/>
<Button Margin="0" Content="{DynamicResource singers.playsample}" Click="OnPlaySample"/>
</StackPanel>
<StackPanel Grid.Row="0" Grid.Column="2" Spacing="10" Margin="0" Height="20"
Expand Down
23 changes: 22 additions & 1 deletion OpenUtau/Views/SingersDialog.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,27 @@ private void OpenInVLabeler(USinger singer, UOto? oto) {
}
}

void OnOpenReadme(object sender, RoutedEventArgs e) {
var viewModel = (DataContext as SingersViewModel)!;
if (viewModel.Singer != null) {
var readme = Path.Join(viewModel.Singer.Location, "readme.txt");
if (File.Exists(readme)) {
var p = new Process();
p.StartInfo = new ProcessStartInfo(readme) {
UseShellExecute = true
};
p.Start();
} else {
MessageBox.Show(
this,
ThemeManager.GetString("singers.readme.notfound"),
ThemeManager.GetString("errors.caption"),
MessageBox.MessageBoxButtons.Ok);
return;
}
}
}

public void OnPlaySample(object sender, RoutedEventArgs e) {
var viewModel = (DataContext as SingersViewModel)!;
var playBack = PlaybackManager.Inst.AudioOutput;
Expand Down Expand Up @@ -407,4 +428,4 @@ public void OnNext(UCommand cmd, bool isUndo) {

#endregion
}
}
}

0 comments on commit 8b40dff

Please sign in to comment.