mirror of
https://github.com/Royce551/FRESHMusicPlayer.git
synced 2025-01-22 02:41:48 -05:00
Bug fixes, reimplement tab persistence
This commit is contained in:
parent
a248e443d7
commit
cb8625711b
10 changed files with 41 additions and 14 deletions
|
@ -22,6 +22,7 @@ namespace FRESHMusicPlayer.Controls.BlurryImage
|
|||
|
||||
public override void Render(DrawingContext context)
|
||||
{
|
||||
if (Source is null) return;
|
||||
var source = Source;
|
||||
var mem = new MemoryStream();
|
||||
Source.Save(mem);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using FRESHMusicPlayer.ViewModels;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace FRESHMusicPlayer.Handlers.Configuration
|
||||
{
|
||||
|
@ -51,7 +52,7 @@ namespace FRESHMusicPlayer.Handlers.Configuration
|
|||
/// <summary>
|
||||
/// The last tab FMP was on before closing
|
||||
/// </summary>
|
||||
public int CurrentTab { get; set; } = 0;
|
||||
public Tab CurrentTab { get; set; } = Tab.Import;
|
||||
/// <summary>
|
||||
/// Directories to scan for tracks to import from on startup
|
||||
/// </summary>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using ATL;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Media.Imaging;
|
||||
using FRESHMusicPlayer.Handlers.Lyrics;
|
||||
using ReactiveUI;
|
||||
|
@ -48,6 +49,8 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
|
||||
public void Update()
|
||||
{
|
||||
if (!MainWindow.Player.FileLoaded) return;
|
||||
|
||||
var track = new Track(MainWindow.Player.FilePath);
|
||||
|
||||
CoverArt = track.EmbeddedPictures.Count <= 0 ? null : new Bitmap(new MemoryStream(track.EmbeddedPictures[0].PictureData));
|
||||
|
@ -56,16 +59,22 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
{
|
||||
TimedLyrics = new LRCTimedLyricsProvider(MainWindow.Player.FilePath);
|
||||
Text = string.Empty;
|
||||
TextMinus2 = TextMinus1 = TextPlus1 = TextPlus2 = string.Empty;
|
||||
FontWeight = FontWeight.Bold;
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(track.Lyrics.UnsynchronizedLyrics)) // Embedded untimed lyrics
|
||||
{
|
||||
Text = track.Lyrics.UnsynchronizedLyrics;
|
||||
TimedLyrics = null;
|
||||
TextMinus2 = TextMinus1 = TextPlus1 = TextPlus2 = string.Empty;
|
||||
FontWeight = FontWeight.Regular;
|
||||
}
|
||||
else // No lyrics
|
||||
{
|
||||
Text = Properties.Resources.Lyrics_NoLyrics;
|
||||
TimedLyrics = null;
|
||||
TextMinus2 = TextMinus1 = TextPlus1 = TextPlus2 = string.Empty;
|
||||
FontWeight = FontWeight.Regular;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,6 +109,13 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
set => this.RaiseAndSetIfChanged(ref textPlus2, value);
|
||||
}
|
||||
|
||||
private FontWeight fontWeight = FontWeight.Regular;
|
||||
public FontWeight FontWeight
|
||||
{
|
||||
get => fontWeight;
|
||||
set => this.RaiseAndSetIfChanged(ref fontWeight, value);
|
||||
}
|
||||
|
||||
private Bitmap coverArt;
|
||||
public Bitmap CoverArt
|
||||
{
|
||||
|
|
|
@ -492,12 +492,13 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
Player.CurrentTime.Add(TimeSpan.FromSeconds(Program.Config.FilePosition));
|
||||
}
|
||||
}
|
||||
//await Dispatcher.UIThread.InvokeAsync(() => SelectedTab = Program.Config.CurrentTab, DispatcherPriority.ApplicationIdle);
|
||||
|
||||
SelectedTab = Program.Config.CurrentTab;
|
||||
// this delays the tab switch until avalonia is ready
|
||||
|
||||
|
||||
HandleIntegrations();
|
||||
|
||||
//(GetMainWindow() as MainWindow).RootPanel.Opacity = 1; // this triggers the startup fade
|
||||
await Dispatcher.UIThread.InvokeAsync(() => (GetMainWindow() as MainWindow).RootPanel.Opacity = 1, DispatcherPriority.ApplicationIdle); // this triggers the startup fade
|
||||
await PerformAutoImport();
|
||||
}
|
||||
|
||||
|
@ -545,7 +546,7 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
Library?.Database.Dispose();
|
||||
Integrations.Dispose();
|
||||
Program.Config.Volume = Volume;
|
||||
//Program.Config.CurrentTab = SelectedTab;
|
||||
Program.Config.CurrentTab = SelectedTab;
|
||||
if (Player.FileLoaded)
|
||||
{
|
||||
Program.Config.FilePath = Player.FilePath;
|
||||
|
|
|
@ -92,6 +92,8 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
|
||||
public void Update()
|
||||
{
|
||||
if (!Player.FileLoaded) return;
|
||||
|
||||
var track = new Track(Player.FilePath);
|
||||
|
||||
CoverArt = track.EmbeddedPictures.Count <= 0 ? null : new Bitmap(new MemoryStream(track.EmbeddedPictures[0].PictureData));
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
<StackPanel VerticalAlignment="Center">
|
||||
<TextBlock Text="{Binding TextMinus2}" HorizontalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center" Foreground="{DynamicResource SecondaryTextColor}"/>
|
||||
<TextBlock Text="{Binding TextMinus1}" HorizontalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center" Foreground="{DynamicResource SecondaryTextColor}"/>
|
||||
<TextBlock Text="{Binding Text}" HorizontalAlignment="Center" VerticalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center" FontWeight="Bold"/>
|
||||
<TextBlock Text="{Binding Text}" HorizontalAlignment="Center" VerticalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center" FontWeight="{Binding FontWeight}"/>
|
||||
<TextBlock Text="{Binding TextPlus1}" HorizontalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center" Foreground="{DynamicResource SecondaryTextColor}"/>
|
||||
<TextBlock Text="{Binding TextPlus2}" HorizontalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center" Foreground="{DynamicResource SecondaryTextColor}"/>
|
||||
</StackPanel>
|
||||
|
|
|
@ -136,7 +136,7 @@
|
|||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Slider x:Name="VolumeSlider" Grid.Column="0" Maximum="1" Value="{Binding Volume}">
|
||||
<Slider x:Name="VolumeSlider" Grid.Column="0" Maximum="1" Width="104" HorizontalAlignment="Right" Value="{Binding Volume}">
|
||||
<Slider.Transitions>
|
||||
<Transitions>
|
||||
<DoubleTransition Property="Opacity" Duration="0:0:0.25"/>
|
||||
|
|
|
@ -128,7 +128,7 @@ namespace FRESHMusicPlayer.Views
|
|||
|
||||
private async void OnKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Source is not TextBox && e.Source is not ListBoxItem)
|
||||
if ((e.Source is not TextBox && e.Source is not ListBoxItem) || e.KeyModifiers.HasFlag(KeyModifiers.Control))
|
||||
switch (e.Key)
|
||||
{
|
||||
case Key.Q:
|
||||
|
|
|
@ -4,11 +4,17 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:vm="using:FRESHMusicPlayer.ViewModels"
|
||||
xmlns:resx ="clr-namespace:FRESHMusicPlayer.Properties"
|
||||
xmlns:svg="clr-namespace:Avalonia.Svg.Skia;assembly=Avalonia.Svg.Skia"
|
||||
mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="450"
|
||||
x:Class="FRESHMusicPlayer.Views.Search">
|
||||
<UserControl.DataContext>
|
||||
<vm:SearchViewModel/>
|
||||
</UserControl.DataContext>
|
||||
<UserControl.Resources>
|
||||
<svg:SvgImage x:Key="Play" Source="/Assets/play.svg"/>
|
||||
<svg:SvgImage x:Key="Enqueue" Source="/Assets/enqueue.svg"/>
|
||||
<svg:SvgImage x:Key="Delete" Source="/Assets/delete.svg"/>
|
||||
</UserControl.Resources>
|
||||
|
||||
<DockPanel>
|
||||
<TextBox x:Name="SearchBox" DockPanel.Dock="Top" Margin="10,5" Watermark="Type here to search!" Text="{Binding Search}" KeyDown="OnKeyDown"/>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:resx ="clr-namespace:FRESHMusicPlayer.Properties"
|
||||
mc:Ignorable="d"
|
||||
d:DesignWidth="600" d:DesignHeight="400"
|
||||
d:DesignWidth="350" d:DesignHeight="900"
|
||||
x:Class="FRESHMusicPlayer.Views.Settings">
|
||||
|
||||
<UserControl.DataContext>
|
||||
|
@ -28,20 +28,20 @@
|
|||
<CheckBox Content="{x:Static resx:Resources.Settings_PlaytimeLogging}" IsChecked="{Binding PlaytimeLogging}"/>
|
||||
<CheckBox Content="{x:Static resx:Resources.Settings_ShowTimeInWindow}" IsChecked="{Binding ShowTimeInWindow}"/>
|
||||
|
||||
<TextBlock FontWeight="Bold" FontSize="18" Text="{x:Static resx:Resources.Settings_AutoImport}"/>
|
||||
<TextBlock FontWeight="Bold" FontSize="16" Text="{x:Static resx:Resources.Settings_AutoImport}"/>
|
||||
|
||||
<TextBlock Text="{Binding AutoImportText}"/>
|
||||
<Button Content="{x:Static resx:Resources.Settings_AddFolder}" Command="{Binding AddFolderCommand}"/>
|
||||
<Button Content="{x:Static resx:Resources.Settings_ClearAll}" Command="{Binding ClearAllCommand}"/>
|
||||
|
||||
<TextBlock FontWeight="Bold" FontSize="18" Text="{x:Static resx:Resources.Settings_Integrations}"/>
|
||||
<TextBlock FontWeight="Bold" FontSize="16" Text="{x:Static resx:Resources.Settings_Integrations}"/>
|
||||
|
||||
<CheckBox Content="{x:Static resx:Resources.Settings_IntegrateDiscordRPC}" IsChecked="{Binding IntegrateDiscordRPC}"/>
|
||||
<CheckBox Content="MPRIS" IsVisible="{Binding IsRunningOnLinux}" IsChecked="{Binding IntegrateMPRIS}"/>
|
||||
<CheckBox Content="{x:Static resx:Resources.Settings_MPRISShowCoverArt}" Margin="20,0,0,0" IsChecked="{Binding MPRISShowCoverArt}" IsVisible="{Binding IsRunningOnLinux}"/>
|
||||
<TextBlock Text="{x:Static resx:Resources.Settings_MPRISShowCoverArt_Info}" Margin="20,0,0,0" TextWrapping="Wrap" Foreground="{DynamicResource ThemeControlLowBrush}" IsVisible="{Binding IsRunningOnLinux}"/>
|
||||
|
||||
<TextBlock FontWeight="Bold" FontSize="18" Text="{x:Static resx:Resources.Settings_Updates}" IsVisible="{Binding IsRunningOnMac}"/>
|
||||
<TextBlock FontWeight="Bold" FontSize="16" Text="{x:Static resx:Resources.Settings_Updates}" IsVisible="{Binding IsRunningOnMac}"/>
|
||||
|
||||
<CheckBox Content="{x:Static resx:Resources.Settings_CheckForUpdates}" IsChecked="{Binding CheckForUpdates}" IsVisible="{Binding IsRunningOnMac}"/>
|
||||
|
||||
|
@ -52,7 +52,7 @@
|
|||
<Button Content="{x:Static resx:Resources.Settings_CleanLibrary}" Command="{Binding CleanLibraryCommand}"/>
|
||||
<Button Content="{x:Static resx:Resources.Settings_NukeLibrary}" Foreground="{DynamicResource Green}" Command="{Binding NukeLibraryCommand}"/>
|
||||
<TextBlock HorizontalAlignment="Center" FontSize="18" FontWeight="Bold" Text="{x:Static resx:Resources.Menu_About}"/>
|
||||
<Image Source="/Assets/fmplogofull.png" Stretch="UniformToFill" Width="300" HorizontalAlignment="Left" Margin="0,0,0,20"/>
|
||||
<Image Source="/Assets/fmplogofull.png" Stretch="UniformToFill" Width="200" HorizontalAlignment="Left" Margin="0,0,0,20"/>
|
||||
<TextBlock Text="{Binding Version}"/>
|
||||
<TextBlock Text="{x:Static resx:Resources.Settings_Credits}"/>
|
||||
<TextBlock Text="{x:Static resx:Resources.Settings_License}" Margin="0,0,0,20"/>
|
||||
|
|
Loading…
Reference in a new issue