fix(start): discarding unsaved settings lets go of the page's edits only, a failed key save starts nothing

- the page shows the settings as held again, not read from the file as Restore does, so what
  other pages set and not yet saved (the depot's filters, the window maximized) stays
- the start goes on only once nothing is left to be saved, the keys' file included
This commit is contained in:
maj00r
2026-11-16 01:20:36 +01:00
parent 5b43e29f9e
commit 829a3e7a3d
2 changed files with 16 additions and 6 deletions

View File

@@ -619,11 +619,12 @@ public partial class MainWindow : Window
if (save is null) if (save is null)
return; return;
if (save == false) if (save == false)
SettingsView.DiscardChanges(); SettingsView.DiscardEdits();
else else
{ {
SettingsView.Save(); SettingsView.Save();
if (AppServices.Current.SettingsStore.LastSaveFailed) // eu07.ini or the keys' file not written: still there to be saved
if (SettingsView.HasUnsavedChanges)
{ {
await MessageBox.Show(this, App.Loc["SettingsNotSaved"], App.Loc["UnsavedChanges"], await MessageBox.Show(this, App.Loc["SettingsNotSaved"], App.Loc["UnsavedChanges"],
MessageBoxButtons.Ok); MessageBoxButtons.Ok);

View File

@@ -1151,10 +1151,7 @@ public partial class Settings : UserControl, ISettingsCapture
ThumbnailSizeChanged?.Invoke(); ThumbnailSizeChanged?.Invoke();
} }
private void ResetButton_OnClick(object? sender, RoutedEventArgs e) => DiscardChanges(); private void ResetButton_OnClick(object? sender, RoutedEventArgs e)
/// <summary>The edits not saved let go, the page and the keys as the files have them: "Przywróć".</summary>
public void DiscardChanges()
{ {
AppServices.Current.SettingsStore.Load(); AppServices.Current.SettingsStore.Load();
ApplyToUi(); ApplyToUi();
@@ -1164,6 +1161,18 @@ public partial class Settings : UserControl, ISettingsCapture
UpdateSaveState(); UpdateSaveState();
} }
/// <summary>
/// The page's own edits let go, and the keys': the page shows the settings as held. Not read again from the file
/// as "Restore" does - what other pages set and not yet saved (a filter of the depot, the window maximized) stays.
/// </summary>
public void DiscardEdits()
{
ApplyToUi();
_keyBindings.Reload();
_dirty = false;
UpdateSaveState();
}
/// <summary>The list as <see cref="ResolutionChoices"/> has it for the monitors there are now, with the size selected.</summary> /// <summary>The list as <see cref="ResolutionChoices"/> has it for the monitors there are now, with the size selected.</summary>
private void SelectResolution(int width, int height) private void SelectResolution(int width, int height)
{ {