diff --git a/OpenUtau.Core/Util/Preferences.cs b/OpenUtau.Core/Util/Preferences.cs
index 62543329f..4a8674871 100644
--- a/OpenUtau.Core/Util/Preferences.cs
+++ b/OpenUtau.Core/Util/Preferences.cs
@@ -113,6 +113,7 @@ public class SerializablePreferences {
public bool ShowTips = true;
public int Theme;
public bool UseTrackColor = false;
+ public bool ClearCacheOnQuit = false;
public bool PreRender = true;
public int NumRenderThreads = 2;
public string OnnxRunner = string.Empty;
diff --git a/OpenUtau/Strings/Strings.axaml b/OpenUtau/Strings/Strings.axaml
index 5b71710b1..4b0cd225d 100644
--- a/OpenUtau/Strings/Strings.axaml
+++ b/OpenUtau/Strings/Strings.axaml
@@ -277,6 +277,8 @@ Warning: this option removes custom presets.
Light
Use track color in UI
Preferences
+ Cache
+ Clear cache on quit
Note: please restart OpenUtau after changing this item.
Off
On
diff --git a/OpenUtau/ViewModels/PreferencesViewModel.cs b/OpenUtau/ViewModels/PreferencesViewModel.cs
index 0fbf254a9..65e4f360c 100644
--- a/OpenUtau/ViewModels/PreferencesViewModel.cs
+++ b/OpenUtau/ViewModels/PreferencesViewModel.cs
@@ -29,6 +29,7 @@ public AudioOutputDevice? AudioOutputDevice {
public string AdditionalSingersPath => PathManager.Inst.AdditionalSingersPath;
[Reactive] public bool InstallToAdditionalSingersPath { get; set; }
[Reactive] public bool PreRender { get; set; }
+ public string CachePath => PathManager.Inst.CachePath;
[Reactive] public int NumRenderThreads { get; set; }
public List OnnxRunnerOptions { get; set; }
[Reactive] public string OnnxRunner { get; set; }
@@ -41,6 +42,7 @@ public AudioOutputDevice? AudioOutputDevice {
[Reactive] public bool ShowGhostNotes { get; set; }
[Reactive] public int OtoEditor { get; set; }
public string VLabelerPath => Preferences.Default.VLabelerPath;
+ [Reactive] public bool ClearCacheOnQuit { get; set; }
public int LogicalCoreCount {
get => Environment.ProcessorCount;
}
@@ -133,6 +135,7 @@ public PreferencesViewModel() {
RememberMid = Preferences.Default.RememberMid;
RememberUst = Preferences.Default.RememberUst;
RememberVsqx = Preferences.Default.RememberVsqx;
+ ClearCacheOnQuit = Preferences.Default.ClearCacheOnQuit;
this.WhenAnyValue(vm => vm.AudioOutputDevice)
.WhereNotNull()
@@ -260,6 +263,11 @@ public PreferencesViewModel() {
Preferences.Default.RememberVsqx = index;
Preferences.Save();
});
+ this.WhenAnyValue(vm => vm.ClearCacheOnQuit)
+ .Subscribe(index => {
+ Preferences.Default.ClearCacheOnQuit = index;
+ Preferences.Save();
+ });
}
public void TestAudioOutputDevice() {
diff --git a/OpenUtau/Views/MainWindow.axaml.cs b/OpenUtau/Views/MainWindow.axaml.cs
index 33a78b226..8f5fc43ae 100644
--- a/OpenUtau/Views/MainWindow.axaml.cs
+++ b/OpenUtau/Views/MainWindow.axaml.cs
@@ -17,6 +17,7 @@
using OpenUtau.Core;
using OpenUtau.Core.Format;
using OpenUtau.Core.Ustx;
+using OpenUtau.Core.Util;
using ReactiveUI;
using Serilog;
using Point = Avalonia.Point;
@@ -564,7 +565,7 @@ private void LayoutSplit(double? x, double? y) {
Width = x != null ? wa.Size.Width * x.Value : wa.Size.Width;
Height = (y != null ? wa.Size.Height * y.Value : wa.Size.Height) - titleBarHeight;
if (pianoRollWindow != null) {
- pianoRollWindow.Position = new PixelPoint(x != null ? (int)Width : 0, y != null ? (int)(Height + (OS.IsMacOS() ? 25 : titleBarHeight)) : 0);
+ pianoRollWindow.Position = new PixelPoint(x != null ? (int) Width : 0, y != null ? (int) (Height + (OS.IsMacOS() ? 25 : titleBarHeight)) : 0);
pianoRollWindow.Width = x != null ? wa.Size.Width - Width : wa.Size.Width;
pianoRollWindow.Height = (y != null ? wa.Size.Height - (Height + titleBarHeight) : wa.Size.Height) - titleBarHeight;
}
@@ -575,7 +576,7 @@ void OnKeyDown(object sender, KeyEventArgs args) {
return;
}
var tracksVm = viewModel.TracksViewModel;
- if (args.KeyModifiers == KeyModifiers.None) {
+ if (args.KeyModifiers == KeyModifiers.None){
args.Handled = true;
switch (args.Key) {
case Key.Delete: viewModel.TracksViewModel.DeleteSelectedParts(); break;
@@ -696,10 +697,10 @@ async void OnDrop(object? sender, DragEventArgs args) {
} else if (ext == ".dll") {
var result = await MessageBox.Show(
this,
- ThemeManager.GetString("dialogs.installdll.message")+file,
+ ThemeManager.GetString("dialogs.installdll.message") + file,
ThemeManager.GetString("dialogs.installdll.caption"),
MessageBox.MessageBoxButtons.OkCancel);
- if(result == MessageBox.MessageBoxResult.Ok){
+ if (result == MessageBox.MessageBoxResult.Ok) {
Core.Api.PhonemizerInstaller.Install(file);
}
} else if (ext == ".exe") {
@@ -756,7 +757,7 @@ public void VScrollPointerWheelChanged(object sender, PointerWheelEventArgs args
public void TimelinePointerWheelChanged(object sender, PointerWheelEventArgs args) {
var control = (Control)sender;
- var position = args.GetCurrentPoint((Visual)sender).Position;
+ var position = args.GetCurrentPoint((Visual) sender).Position;
var size = control.Bounds.Size;
position = position.WithX(position.X / size.Width).WithY(position.Y / size.Height);
viewModel.TracksViewModel.OnXZoomed(position, 0.1 * args.Delta.Y);
@@ -857,7 +858,7 @@ public void PartsCanvasPointerPressed(object sender, PointerPressedEventArgs arg
}
public void PartsCanvasPointerMoved(object sender, PointerEventArgs args) {
- var control = (Control)sender;
+ var control = (Control) sender;
var point = args.GetCurrentPoint(control);
if (partEditState != null) {
partEditState.Update(point.Pointer, point.Position);
@@ -886,7 +887,7 @@ public void PartsCanvasPointerReleased(object sender, PointerReleasedEventArgs a
if (partEditState.MouseButton != args.InitialPressMouseButton) {
return;
}
- var control = (Control)sender;
+ var control = (Control) sender;
var point = args.GetCurrentPoint(control);
partEditState.Update(point.Pointer, point.Position);
partEditState.End(point.Pointer, point.Position);
@@ -994,6 +995,11 @@ async void ReplaceAudio(UPart part) {
public async void WindowClosing(object? sender, WindowClosingEventArgs e) {
if (forceClose || DocManager.Inst.ChangesSaved) {
+ if (Preferences.Default.ClearCacheOnQuit) {
+ Log.Information("Clearing cache...");
+ PathManager.Inst.ClearCache();
+ Log.Information("Cache cleared.");
+ }
return;
}
e.Cancel = true;
@@ -1028,4 +1034,4 @@ public void OnNext(UCommand cmd, bool isUndo) {
}
}
}
-}
+}
\ No newline at end of file
diff --git a/OpenUtau/Views/PreferencesDialog.axaml b/OpenUtau/Views/PreferencesDialog.axaml
index 7a543b9fb..6e27b9374 100644
--- a/OpenUtau/Views/PreferencesDialog.axaml
+++ b/OpenUtau/Views/PreferencesDialog.axaml
@@ -90,6 +90,12 @@
+
+
+
+
+
+