diff --git a/OpenUtau.Core/Format/MidiWriter.cs b/OpenUtau.Core/Format/MidiWriter.cs index 999a78cf7..8ea8ad2a0 100644 --- a/OpenUtau.Core/Format/MidiWriter.cs +++ b/OpenUtau.Core/Format/MidiWriter.cs @@ -43,6 +43,7 @@ public static class MidiWriter { static public UProject LoadProject(string file) { UProject project = new UProject(); Ustx.AddDefaultExpressions(project); + project.FilePath = file; // Detects lyric encoding Encoding lyricEncoding = Encoding.UTF8; var encodingDetector = new EncodingDetector(); diff --git a/OpenUtau.Core/Util/Preferences.cs b/OpenUtau.Core/Util/Preferences.cs index 7a4a0c8de..6ff770afe 100644 --- a/OpenUtau.Core/Util/Preferences.cs +++ b/OpenUtau.Core/Util/Preferences.cs @@ -38,7 +38,35 @@ public static void SetSingerSearchPaths(List paths) { Save(); } - public static void AddRecentFile(string filePath) { + public static void AddRecentFileIfEnabled(string filePath){ + //Users can choose adding .ust, .vsqx and .mid files to recent files or not + string ext = Path.GetExtension(filePath); + switch(ext){ + case ".ustx": + AddRecentFile(filePath); + break; + case ".mid": + case ".midi": + if(Preferences.Default.RememberMid){ + AddRecentFile(filePath); + } + break; + case ".ust": + if(Preferences.Default.RememberUst){ + AddRecentFile(filePath); + } + break; + case ".vsqx": + if(Preferences.Default.RememberVsqx){ + AddRecentFile(filePath); + } + break; + default: + break; + } + } + + private static void AddRecentFile(string filePath) { if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath)) { return; } @@ -120,6 +148,9 @@ public class SerializablePreferences { public int OtoEditor = 0; public string VLabelerPath = string.Empty; public bool Beta = false; + public bool RememberMid = false; + public bool RememberUst = true; + public bool RememberVsqx = true; } } } diff --git a/OpenUtau/Strings/Strings.axaml b/OpenUtau/Strings/Strings.axaml index 29beb729c..d3cbb8248 100644 --- a/OpenUtau/Strings/Strings.axaml +++ b/OpenUtau/Strings/Strings.axaml @@ -244,6 +244,7 @@ Warning: this option removes custom presets. Beta Lyrics Helper Lyrics Helper Adds Brackets + Remember these file types in "Open Recent" Resampler Logging Stores resampler output in log files. This option slows down UI and rendering. Stable diff --git a/OpenUtau/Strings/Strings.zh-CN.axaml b/OpenUtau/Strings/Strings.zh-CN.axaml index b54578829..932b13b47 100644 --- a/OpenUtau/Strings/Strings.zh-CN.axaml +++ b/OpenUtau/Strings/Strings.zh-CN.axaml @@ -244,6 +244,7 @@ Beta测试版 + 在"最近打开"中记住以下文件格式 重采样器日志 在日志文件中保存重采样器输出。这个选项会使UI和渲染性能下降。 稳定版 diff --git a/OpenUtau/ViewModels/MainWindowViewModel.cs b/OpenUtau/ViewModels/MainWindowViewModel.cs index 96e5d67e5..38e4fc48b 100644 --- a/OpenUtau/ViewModels/MainWindowViewModel.cs +++ b/OpenUtau/ViewModels/MainWindowViewModel.cs @@ -257,9 +257,9 @@ public void OnNext(UCommand cmd, bool isUndo) { ProgressText = progressBarNotification.Info; }); } else if (cmd is LoadProjectNotification loadProject) { - Core.Util.Preferences.AddRecentFile(loadProject.project.FilePath); + Core.Util.Preferences.AddRecentFileIfEnabled(loadProject.project.FilePath); } else if (cmd is SaveProjectNotification saveProject) { - Core.Util.Preferences.AddRecentFile(saveProject.Path); + Core.Util.Preferences.AddRecentFileIfEnabled(saveProject.Path); } this.RaisePropertyChanged(nameof(Title)); } diff --git a/OpenUtau/ViewModels/PreferencesViewModel.cs b/OpenUtau/ViewModels/PreferencesViewModel.cs index dbbefe3ac..b2e3dff42 100644 --- a/OpenUtau/ViewModels/PreferencesViewModel.cs +++ b/OpenUtau/ViewModels/PreferencesViewModel.cs @@ -78,6 +78,9 @@ public override string ToString() { .ToList(); [Reactive] public LyricsHelperOption? LyricsHelper { get; set; } [Reactive] public int LyricsHelperBrackets { get; set; } + [Reactive] public bool RememberMid{ get; set; } + [Reactive] public bool RememberUst{ get; set; } + [Reactive] public bool RememberVsqx{ get; set; } private List? audioOutputDevices; private AudioOutputDevice? audioOutputDevice; @@ -127,6 +130,9 @@ public PreferencesViewModel() { LyricsHelper = LyricsHelpers.FirstOrDefault(option => option.klass.Equals(ActiveLyricsHelper.Inst.GetPreferred())); LyricsHelperBrackets = Preferences.Default.LyricsHelperBrackets ? 1 : 0; OtoEditor = Preferences.Default.OtoEditor; + RememberMid = Preferences.Default.RememberMid; + RememberUst = Preferences.Default.RememberUst; + RememberVsqx = Preferences.Default.RememberVsqx; this.WhenAnyValue(vm => vm.AudioOutputDevice) .WhereNotNull() @@ -234,6 +240,21 @@ public PreferencesViewModel() { Preferences.Default.OnnxGpu = index.deviceId; Preferences.Save(); }); + this.WhenAnyValue(vm => vm.RememberMid) + .Subscribe(index => { + Preferences.Default.RememberMid = index; + Preferences.Save(); + }); + this.WhenAnyValue(vm => vm.RememberUst) + .Subscribe(index => { + Preferences.Default.RememberUst = index; + Preferences.Save(); + }); + this.WhenAnyValue(vm => vm.RememberVsqx) + .Subscribe(index => { + Preferences.Default.RememberVsqx = index; + Preferences.Save(); + }); } public void TestAudioOutputDevice() { diff --git a/OpenUtau/Views/PreferencesDialog.axaml b/OpenUtau/Views/PreferencesDialog.axaml index 375076779..4d797a183 100644 --- a/OpenUtau/Views/PreferencesDialog.axaml +++ b/OpenUtau/Views/PreferencesDialog.axaml @@ -172,6 +172,15 @@ + + + + + + + + +