* #396 New feature : match download status to files
* UI: Visible Books \> Set 'Downloaded' status automatically. Visible books. Prompts before saving changes * CLI: Full library. No prompt
This commit is contained in:
parent
a54516b4f5
commit
c4cebbebe7
23 changed files with 1071 additions and 604 deletions
|
|
@ -50,7 +50,7 @@ namespace LibationAvalonia.Dialogs
|
|||
|
||||
protected override void SaveAndClose()
|
||||
{
|
||||
LibraryBook.Book.UpdateBook(NewTags, bookStatus: BookLiberatedStatus, pdfStatus: PdfLiberatedStatus);
|
||||
LibraryBook.Book.UpdateUserDefinedItem(NewTags, bookStatus: BookLiberatedStatus, pdfStatus: PdfLiberatedStatus);
|
||||
base.SaveAndClose();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="120"
|
||||
xmlns:controls="clr-namespace:LibationAvalonia.Controls"
|
||||
x:Class="LibationAvalonia.Dialogs.LiberatedStatusBatchAutoDialog"
|
||||
Title="Liberated status: Whether the book has been downloaded"
|
||||
MinHeight="100" MaxHeight="165"
|
||||
MinWidth="600" MaxWidth="800"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Icon="/Assets/libation.ico">
|
||||
|
||||
<Grid RowDefinitions="Auto,Auto,Auto">
|
||||
|
||||
<StackPanel
|
||||
Grid.Row="0"
|
||||
Orientation="Horizontal">
|
||||
|
||||
<CheckBox
|
||||
Margin="0,0,0,10"
|
||||
IsChecked="{Binding SetDownloaded, Mode=TwoWay}">
|
||||
|
||||
<TextBlock
|
||||
TextWrapping="Wrap"
|
||||
Text="If the audio file can be found, set download status to 'Downloaded'" />
|
||||
</CheckBox>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel
|
||||
Grid.Row="1"
|
||||
Orientation="Horizontal">
|
||||
|
||||
<CheckBox
|
||||
Margin="0,0,0,10"
|
||||
IsChecked="{Binding SetNotDownloaded, Mode=TwoWay}">
|
||||
|
||||
<TextBlock
|
||||
TextWrapping="Wrap"
|
||||
Text="If the audio file cannot be found, set download status to 'Not Downloaded'" />
|
||||
</CheckBox>
|
||||
</StackPanel>
|
||||
|
||||
<Button
|
||||
Grid.Row="2"
|
||||
Padding="30,0,30,0"
|
||||
Margin="10,0,10,10"
|
||||
HorizontalAlignment="Right"
|
||||
Height="25"
|
||||
Content="Save"
|
||||
Click="SaveButton_Clicked"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace LibationAvalonia.Dialogs
|
||||
{
|
||||
public partial class LiberatedStatusBatchAutoDialog : DialogWindow
|
||||
{
|
||||
public bool SetDownloaded { get; set; }
|
||||
public bool SetNotDownloaded { get; set; }
|
||||
|
||||
public LiberatedStatusBatchAutoDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = this;
|
||||
}
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
public void SaveButton_Clicked(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
=> SaveAndClose();
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="120"
|
||||
xmlns:controls="clr-namespace:LibationAvalonia.Controls"
|
||||
x:Class="LibationAvalonia.Dialogs.LiberatedStatusBatchDialog"
|
||||
x:Class="LibationAvalonia.Dialogs.LiberatedStatusBatchManualDialog"
|
||||
Title="Liberated status: Whether the book has been downloaded"
|
||||
MinWidth="400" MinHeight="120"
|
||||
MaxWidth="400" MaxHeight="120"
|
||||
|
|
@ -5,7 +5,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace LibationAvalonia.Dialogs
|
||||
{
|
||||
public partial class LiberatedStatusBatchDialog : DialogWindow
|
||||
public partial class LiberatedStatusBatchManualDialog : DialogWindow
|
||||
{
|
||||
private class liberatedComboBoxItem
|
||||
{
|
||||
|
|
@ -34,7 +34,7 @@ namespace LibationAvalonia.Dialogs
|
|||
new liberatedComboBoxItem { Status = LiberatedStatus.NotLiberated, Text = "Not Downloaded" },
|
||||
};
|
||||
|
||||
public LiberatedStatusBatchDialog()
|
||||
public LiberatedStatusBatchManualDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
SelectedItem = BookStatuses[0] as liberatedComboBoxItem;
|
||||
|
|
@ -92,6 +92,12 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Dialogs\LiberatedStatusBatchAutoDialog.axaml.cs">
|
||||
<DependentUpon>LiberatedStatusBatchAutoDialog.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Dialogs\LiberatedStatusBatchManualDialog.axaml.cs">
|
||||
<DependentUpon>LiberatedStatusBatchManualDialog.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Views\ProcessBookControl.axaml.cs">
|
||||
<DependentUpon>ProcessBookControl.axaml</DependentUpon>
|
||||
</Compile>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
using ApplicationServices;
|
||||
using Avalonia.Threading;
|
||||
using DataLayer;
|
||||
using Dinah.Core;
|
||||
using LibationFileManager;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -57,14 +59,12 @@ namespace LibationAvalonia.Views
|
|||
if (confirmationResult != DialogResult.Yes)
|
||||
return;
|
||||
|
||||
foreach (var libraryBook in visibleLibraryBooks)
|
||||
libraryBook.Book.UserDefinedItem.Tags = dialog.NewTags;
|
||||
LibraryCommands.UpdateUserDefinedItem(visibleLibraryBooks.Select(lb => lb.Book));
|
||||
}
|
||||
visibleLibraryBooks.UpdateTags(dialog.NewTags);
|
||||
}
|
||||
|
||||
public async void setDownloadedToolStripMenuItem_Click(object sender, Avalonia.Interactivity.RoutedEventArgs args)
|
||||
public async void setDownloadedManualToolStripMenuItem_Click(object sender, Avalonia.Interactivity.RoutedEventArgs args)
|
||||
{
|
||||
var dialog = new Dialogs.LiberatedStatusBatchDialog();
|
||||
var dialog = new Dialogs.LiberatedStatusBatchManualDialog();
|
||||
var result = await dialog.ShowDialog<DialogResult>(this);
|
||||
if (result != DialogResult.OK)
|
||||
return;
|
||||
|
|
@ -81,12 +81,36 @@ namespace LibationAvalonia.Views
|
|||
if (confirmationResult != DialogResult.Yes)
|
||||
return;
|
||||
|
||||
foreach (var libraryBook in visibleLibraryBooks)
|
||||
libraryBook.Book.UserDefinedItem.BookStatus = dialog.BookLiberatedStatus;
|
||||
LibraryCommands.UpdateUserDefinedItem(visibleLibraryBooks.Select(lb => lb.Book));
|
||||
}
|
||||
visibleLibraryBooks.UpdateBookStatus(dialog.BookLiberatedStatus);
|
||||
}
|
||||
|
||||
public async void removeToolStripMenuItem_Click(object sender, Avalonia.Interactivity.RoutedEventArgs args)
|
||||
public async void setDownloadedAutoToolStripMenuItem_Click(object sender, Avalonia.Interactivity.RoutedEventArgs args)
|
||||
{
|
||||
var dialog = new Dialogs.LiberatedStatusBatchAutoDialog();
|
||||
var result = await dialog.ShowDialog<DialogResult>(this);
|
||||
if (result != DialogResult.OK)
|
||||
return;
|
||||
|
||||
var bulkSetStatus = new BulkSetDownloadStatus(_viewModel.ProductsDisplay.GetVisibleBookEntries(), dialog.SetDownloaded, dialog.SetNotDownloaded);
|
||||
var count = await Task.Run(() => bulkSetStatus.Discover());
|
||||
|
||||
if (count == 0)
|
||||
return;
|
||||
|
||||
var confirmationResult = await MessageBox.Show(
|
||||
bulkSetStatus.AggregateMessage,
|
||||
"Replace downloaded status?",
|
||||
MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Question,
|
||||
MessageBoxDefaultButton.Button1);
|
||||
|
||||
if (confirmationResult != DialogResult.Yes)
|
||||
return;
|
||||
|
||||
bulkSetStatus.Execute();
|
||||
}
|
||||
|
||||
public async void removeToolStripMenuItem_Click(object sender, Avalonia.Interactivity.RoutedEventArgs args)
|
||||
{
|
||||
var visibleLibraryBooks = _viewModel.ProductsDisplay.GetVisibleBookEntries();
|
||||
|
||||
|
|
|
|||
|
|
@ -110,7 +110,8 @@
|
|||
</MenuItem.Styles>
|
||||
<MenuItem Click="liberateVisible" Header="{Binding LiberateVisibleToolStripText_2}" IsEnabled="{Binding AnyVisibleNotLiberated}" />
|
||||
<MenuItem Click="replaceTagsToolStripMenuItem_Click" Header="Replace _Tags..." />
|
||||
<MenuItem Click="setDownloadedToolStripMenuItem_Click" Header="Set '_Downloaded' status..." />
|
||||
<MenuItem Click="setDownloadedManualToolStripMenuItem_Click" Header="Set '_Downloaded' status manually..." />
|
||||
<MenuItem Click="setDownloadedAutoToolStripMenuItem_Click" Header="Set '_Downloaded' status automatically..." />
|
||||
<MenuItem Click="removeToolStripMenuItem_Click" Header="_Remove from library..." />
|
||||
</MenuItem>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue