Files
Libation/Source/LibationAvalonia/ViewModels/MainVM.Settings.cs
T
Cursor Agentandrmcrackan 4df08d383a Show when the trash is not empty
Removal is a soft delete and nothing on screen said so. GetLibrary() filters
!IsDeleted, so a trashed book leaves the grid, the search index and every status
count at once, with no indication it still exists. In #1925 a purchased book sat
in the trash for a week while the reporter and I looked everywhere else for it.

Add a status bar segment reading '29 in trash' that opens the trash bin when
clicked, and put the same count on the Settings > Trash Bin menu item. Both hide
themselves when the trash is empty, which is the normal case and says nothing
worth screen space.

The count is a separate query rather than part of LibraryStats: GetCounts also
runs against the visible subset on every filter change, where a database round
trip would be wasted work. GetLibraryBookCountsByTrashFlag already existed and
counts rows without loading entities. Refreshed on LibrarySizeChanged, which
both removal and restore already fire, and after the trash bin dialog closes.

Wording lives in LibationUiBase.TrashBinUi so Avalonia and WinForms agree.

Co-authored-by: rmcrackan <rmcrackan@gmail.com>
2026-08-18 18:19:37 +00:00

62 lines
2.0 KiB
C#

using Avalonia.Controls;
using LibationFileManager;
using LibationUiBase.Forms;
using ReactiveUI;
using System;
using System.Reactive;
using System.Threading.Tasks;
namespace LibationAvalonia.ViewModels;
partial class MainVM
{
public string FindBetterQualityBooksTip => Configuration.GetHelpText("FindBetterQualityBooks");
public bool MenuBarVisible { get => field; set => this.RaiseAndSetIfChanged(ref field, value); } = !Configuration.IsMacOs;
public ReactiveCommand<Unit, Unit> LaunchHangover { get; private set; } = null!;
private void Configure_Settings()
{
LaunchHangover = ReactiveCommand.CreateFromTask(LaunchHangoverAsync);
if (App.Current is Avalonia.Application app &&
NativeMenu.GetMenu(app)?.Items[0] is NativeMenuItem aboutMenu)
aboutMenu.Command = ReactiveCommand.Create(ShowAboutAsync);
}
public Task ShowAboutAsync() => new LibationAvalonia.Dialogs.AboutDialog().ShowDialog(MainWindow);
public Task ShowAccountsAsync() => new LibationAvalonia.Dialogs.AccountsDialog().ShowDialog(MainWindow);
public Task ShowSettingsAsync() => new LibationAvalonia.Dialogs.SettingsDialog().ShowDialog(MainWindow);
public async Task ShowTrashBinAsync()
{
await new LibationAvalonia.Dialogs.TrashBinDialog().ShowDialog(MainWindow);
//Restoring or permanently deleting inside the dialog changes the count behind it.
await RefreshBooksInTrashAsync();
}
public Task ShowFindBetterQualityBooksAsync() => new LibationAvalonia.Dialogs.FindBetterQualityBooksDialog().ShowDialog(MainWindow);
private async Task LaunchHangoverAsync()
{
try
{
HangoverLauncher.Launch();
}
catch (Exception ex)
{
Serilog.Log.Logger.Error(ex, "Failed to launch Hangover");
await MessageBox.Show(
MainWindow,
HangoverLauncher.GetLaunchFailureMessage(ex),
"Launch Hangover",
MessageBoxButtons.OK,
MessageBoxIcon.Warning);
}
}
public async Task StartWalkthroughAsync()
{
MenuBarVisible = true;
await new Walkthrough(MainWindow).RunAsync();
MenuBarVisible = !Configuration.IsMacOs;
}
}