UI Tweaks and new application hotkeys
This commit is contained in:
parent
8d73f5cc7e
commit
756d387238
@ -65,10 +65,13 @@
|
||||
Binding="{Binding LibraryScan, Mode=TwoWay}"
|
||||
Header="Include in
library scan?"/>
|
||||
|
||||
<DataGridTextColumn
|
||||
Width="2*"
|
||||
Binding="{Binding AccountId, Mode=TwoWay}"
|
||||
Header="Audible
email/login"/>
|
||||
<DataGridTemplateColumn Width="2*" Header="Audible
email/login">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBox Text="{Binding AccountId, Mode=TwoWay}" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<DataGridTemplateColumn Width="Auto" Header="Locale">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
|
||||
@ -2,17 +2,17 @@
|
||||
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"
|
||||
mc:Ignorable="d" d:DesignWidth="550" d:DesignHeight="130"
|
||||
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"
|
||||
Width="600"
|
||||
MinHeight="130" MaxHeight="130"
|
||||
MinWidth="550" MaxWidth="550"
|
||||
Width="550" Height="130"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Icon="/Assets/libation.ico">
|
||||
|
||||
<Grid RowDefinitions="Auto,Auto,Auto">
|
||||
<Grid Margin="10" RowDefinitions="Auto,Auto,Auto">
|
||||
|
||||
<StackPanel
|
||||
Grid.Row="0"
|
||||
@ -45,7 +45,6 @@
|
||||
<Button
|
||||
Grid.Row="2"
|
||||
Padding="30,0,30,0"
|
||||
Margin="10,0,10,10"
|
||||
HorizontalAlignment="Right"
|
||||
Height="25"
|
||||
Content="Save"
|
||||
|
||||
@ -25,12 +25,18 @@ namespace LibationAvalonia.Dialogs
|
||||
DataContext = _viewModel = new();
|
||||
|
||||
this.Closing += (_, _) => this.SaveSizeAndLocation(Configuration.Instance);
|
||||
this.KeyDown += TrashBinDialog_KeyDown;
|
||||
}
|
||||
|
||||
public async void EmptyTrash_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
=> await _viewModel.PermanentlyDeleteCheckedAsync();
|
||||
public async void Restore_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
=> await _viewModel.RestoreCheckedAsync();
|
||||
private void TrashBinDialog_KeyDown(object sender, Avalonia.Input.KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Avalonia.Input.Key.Escape)
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
public class TrashBinViewModel : ViewModelBase, IDisposable
|
||||
|
||||
@ -2,9 +2,11 @@
|
||||
using Avalonia.Collections;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Data;
|
||||
using Avalonia.Input;
|
||||
using LibationFileManager;
|
||||
using ReactiveUI;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LibationAvalonia.ViewModels
|
||||
@ -32,7 +34,6 @@ namespace LibationAvalonia.ViewModels
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void Configure_Filters()
|
||||
{
|
||||
FirstFilterIsDefault = QuickFilters.UseDefault;
|
||||
@ -88,7 +89,16 @@ namespace LibationAvalonia.ViewModels
|
||||
var quickFilterNativeMenu = (NativeMenuItem)NativeMenu.GetMenu(MainWindow).Items[3];
|
||||
for (int i = quickFilterNativeMenu.Menu.Items.Count - 1; i >= 3; i--)
|
||||
{
|
||||
(((NativeMenuItem)quickFilterNativeMenu.Menu.Items[i]).Command as IDisposable).Dispose();
|
||||
var command = ((NativeMenuItem)quickFilterNativeMenu.Menu.Items[i]).Command as IDisposable;
|
||||
if (command != null)
|
||||
{
|
||||
var existingBinding = MainWindow.KeyBindings.FirstOrDefault(kb => kb.Command == command);
|
||||
if (existingBinding != null)
|
||||
MainWindow.KeyBindings.Remove(existingBinding);
|
||||
|
||||
command.Dispose();
|
||||
}
|
||||
|
||||
quickFilterNativeMenu.Menu.Items.RemoveAt(i);
|
||||
QuickFilterMenuItems.RemoveAt(i);
|
||||
}
|
||||
@ -99,10 +109,25 @@ namespace LibationAvalonia.ViewModels
|
||||
{
|
||||
var command = ReactiveCommand.Create(async () => await PerformFilter(filter));
|
||||
|
||||
quickFilterNativeMenu.Menu.Items.Add(new NativeMenuItem { Header = $"{++index}: {filter}", Command = command, Gesture = new Avalonia.Input.KeyGesture(Avalonia.Input.Key.D0 + index, Avalonia.Input.KeyModifiers.Meta) });
|
||||
var menuItem = new MenuItem { Header = $"{++index}: {filter}", Command = command };
|
||||
var nativeMenuItem = new NativeMenuItem { Header = $"{index}: {filter}", Command = command };
|
||||
|
||||
QuickFilterMenuItems.Add(new MenuItem { Header = $"_{index}: {filter}", Command = command });
|
||||
if (Configuration.IsMacOs && index <= 10)
|
||||
{
|
||||
//Register hotkeys Command + 1 - 0 for quick filters
|
||||
var key = index == 10 ? Key.D0 : Key.D0 + index;
|
||||
nativeMenuItem.Gesture = new KeyGesture(key, KeyModifiers.Meta);
|
||||
}
|
||||
else if (!Configuration.IsMacOs && index <= 12)
|
||||
{
|
||||
//Register hotkeys F1 - F12 for quick filters
|
||||
menuItem.InputGesture = new KeyGesture(Key.F1 + index - 1);
|
||||
MainWindow.KeyBindings.Add(new KeyBinding { Command = command, Gesture = menuItem.InputGesture });
|
||||
}
|
||||
|
||||
QuickFilterMenuItems.Add(menuItem);
|
||||
quickFilterNativeMenu.Menu.Items.Add(nativeMenuItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ namespace LibationAvalonia.ViewModels
|
||||
{
|
||||
if (libraryBook.Book.UserDefinedItem.BookStatus is LiberatedStatus.Liberated)
|
||||
{
|
||||
Serilog.Log.Logger.Information("Begin single pdf backup of {libraryBook}", libraryBook);
|
||||
Serilog.Log.Logger.Information("Begin convert to mp3 {libraryBook}", libraryBook);
|
||||
setQueueCollapseState(false);
|
||||
ProcessQueue.AddConvertMp3(libraryBook);
|
||||
}
|
||||
|
||||
@ -24,7 +24,6 @@ namespace LibationAvalonia.ViewModels
|
||||
/// <summary> The "Liberate" menu item header text (submenu item of the "Visible Books" menu item) </summary>
|
||||
public string LiberateVisibleToolStripText_2 { get; private set; } = menufyText("Liberate: 0");
|
||||
|
||||
|
||||
private void Configure_VisibleBooks()
|
||||
{
|
||||
LibraryCommands.BookUserDefinedItemCommitted += setLiberatedVisibleMenuItemAsync;
|
||||
@ -37,6 +36,7 @@ namespace LibationAvalonia.ViewModels
|
||||
this.RaisePropertyChanged(nameof(VisibleCountText));
|
||||
this.RaisePropertyChanged(nameof(VisibleCountMenuItemText));
|
||||
}
|
||||
|
||||
private void setVisibleNotLiberatedCount(int visibleNotLiberated)
|
||||
{
|
||||
_visibleNotLiberated = visibleNotLiberated;
|
||||
@ -85,6 +85,7 @@ namespace LibationAvalonia.ViewModels
|
||||
Serilog.Log.Logger.Error(ex, "An error occurred while backing up visible library books");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task ReplaceTagsAsync()
|
||||
{
|
||||
var dialog = new TagsBatchDialog();
|
||||
|
||||
@ -24,12 +24,12 @@ namespace LibationAvalonia.ViewModels
|
||||
|
||||
Configure_NonUI();
|
||||
Configure_BackupCounts();
|
||||
Configure_Export();
|
||||
Configure_Filters();
|
||||
Configure_Import();
|
||||
Configure_Liberate();
|
||||
Configure_ProcessQueue();
|
||||
Configure_ScanAuto();
|
||||
Configure_Export();
|
||||
Configure_Settings();
|
||||
Configure_VisibleBooks();
|
||||
}
|
||||
|
||||
@ -145,12 +145,12 @@
|
||||
<Setter Property="Height" Value="NaN"/>
|
||||
</Style>
|
||||
</MenuItem.Styles>
|
||||
<MenuItem IsEnabled="{CompiledBinding LibraryStats.HasBookResults}" Command="{CompiledBinding ExportLibraryAsync}" Header="E_xport Library" />
|
||||
<MenuItem IsEnabled="{CompiledBinding LibraryStats.HasBookResults}" Command="{CompiledBinding ExportLibraryAsync}" Header="E_xport Library" InputGesture="ctrl+S" />
|
||||
</MenuItem>
|
||||
|
||||
<!-- Quick Filters Menu -->
|
||||
|
||||
<MenuItem Name="quickFiltersToolStripMenuItem" Header="Quick _Filters" ItemsSource="{CompiledBinding QuickFilterMenuItems}" KeyDown="QuickFiltersMenuItem_KeyDown">
|
||||
<MenuItem Name="quickFiltersToolStripMenuItem" Header="Quick _Filters" ItemsSource="{CompiledBinding QuickFilterMenuItems}">
|
||||
<!-- Remove height style property for menu item -->
|
||||
<MenuItem.Styles>
|
||||
<Style Selector="ItemsPresenter#PART_ItemsPresenter">
|
||||
@ -185,8 +185,8 @@
|
||||
<Setter Property="Height" Value="NaN"/>
|
||||
</Style>
|
||||
</MenuItem.Styles>
|
||||
<MenuItem Name="accountsToolStripMenuItem" Command="{CompiledBinding ShowAccountsAsync}" Header="_Accounts..." />
|
||||
<MenuItem Name="basicSettingsToolStripMenuItem" Command="{CompiledBinding ShowSettingsAsync}" Header="_Settings..." />
|
||||
<MenuItem Name="accountsToolStripMenuItem" Command="{CompiledBinding ShowAccountsAsync}" Header="_Accounts..." InputGesture="ctrl+shift+A"/>
|
||||
<MenuItem Name="basicSettingsToolStripMenuItem" Command="{CompiledBinding ShowSettingsAsync}" Header="_Settings..." InputGesture="ctrl+P" />
|
||||
<Separator />
|
||||
<MenuItem Command="{CompiledBinding ShowTrashBinAsync}" Header="Trash Bin" />
|
||||
<MenuItem Command="{CompiledBinding LaunchHangover}" Header="Launch _Hangover" />
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.ReactiveUI;
|
||||
using DataLayer;
|
||||
using LibationAvalonia.ViewModels;
|
||||
using LibationFileManager;
|
||||
using LibationUiBase.GridView;
|
||||
using ReactiveUI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -24,6 +24,15 @@ namespace LibationAvalonia.Views
|
||||
Loaded += MainWindow_Loaded;
|
||||
Closing += MainWindow_Closing;
|
||||
LibraryLoaded += MainWindow_LibraryLoaded;
|
||||
|
||||
KeyBindings.Add(new KeyBinding { Command = ReactiveCommand.Create(selectAndFocusSearchBox), Gesture = new KeyGesture(Key.F, Configuration.IsMacOs ? KeyModifiers.Meta : KeyModifiers.Control) });
|
||||
|
||||
if (!Configuration.IsMacOs)
|
||||
{
|
||||
KeyBindings.Add(new KeyBinding { Command = ReactiveCommand.Create(ViewModel.ShowSettingsAsync), Gesture = new KeyGesture(Key.P, KeyModifiers.Control) });
|
||||
KeyBindings.Add(new KeyBinding { Command = ReactiveCommand.Create(ViewModel.ShowAccountsAsync), Gesture = new KeyGesture(Key.A, KeyModifiers.Control | KeyModifiers.Shift) });
|
||||
KeyBindings.Add(new KeyBinding { Command = ReactiveCommand.Create(ViewModel.ExportLibraryAsync), Gesture = new KeyGesture(Key.S, KeyModifiers.Control) });
|
||||
}
|
||||
}
|
||||
|
||||
private async void MainWindow_Loaded(object sender, EventArgs e)
|
||||
@ -55,6 +64,12 @@ namespace LibationAvalonia.Views
|
||||
ViewModel.ProductsDisplay.BindToGrid(dbBooks);
|
||||
}
|
||||
|
||||
private void selectAndFocusSearchBox()
|
||||
{
|
||||
filterSearchTb.SelectAll();
|
||||
filterSearchTb.Focus();
|
||||
}
|
||||
|
||||
public void OnLibraryLoaded(List<LibraryBook> initialLibrary) => LibraryLoaded?.Invoke(this, initialLibrary);
|
||||
public void ProductsDisplay_LiberateClicked(object _, LibraryBook libraryBook) => ViewModel.LiberateClicked(libraryBook);
|
||||
public void ProductsDisplay_LiberateSeriesClicked(object _, ISeriesEntry series) => ViewModel.LiberateSeriesClicked(series);
|
||||
@ -71,19 +86,6 @@ namespace LibationAvalonia.Views
|
||||
}
|
||||
}
|
||||
|
||||
private void QuickFiltersMenuItem_KeyDown(object _, KeyEventArgs e)
|
||||
{
|
||||
int keyNum = (int)e.Key - 34;
|
||||
|
||||
if (keyNum <= 9 && keyNum >= 1)
|
||||
{
|
||||
ViewModel.QuickFilterMenuItems
|
||||
.OfType<MenuItem>()
|
||||
.FirstOrDefault(i => i.Header is string h && h.StartsWith($"_{keyNum}"))
|
||||
?.Command
|
||||
?.Execute(null);
|
||||
}
|
||||
}
|
||||
private void Configure_Upgrade()
|
||||
{
|
||||
setProgressVisible(false);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user