mirror of
https://github.com/Royce551/FRESHMusicPlayer.git
synced 2025-01-22 19:02:19 -05:00
various changes, maintenance options
This commit is contained in:
parent
4a78df7ed9
commit
ef509caad1
10 changed files with 113 additions and 19 deletions
|
@ -13,7 +13,6 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Models\" />
|
<Folder Include="Models\" />
|
||||||
<AvaloniaResource Include="Assets\**" />
|
<AvaloniaResource Include="Assets\**" />
|
||||||
<Folder Include="NewFolder\" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="Assets\icon.ico" />
|
<None Remove="Assets\icon.ico" />
|
||||||
|
|
|
@ -34,7 +34,7 @@ namespace FRESHMusicPlayer.ViewModels
|
||||||
public Player Player { get; private set; }
|
public Player Player { get; private set; }
|
||||||
public Timer ProgressTimer { get; private set; } = new(100);
|
public Timer ProgressTimer { get; private set; } = new(100);
|
||||||
public Library Library { get; private set; }
|
public Library Library { get; private set; }
|
||||||
public ConfigurationFile Config { get; private set; }
|
public ConfigurationFile Config { get; set; }
|
||||||
public Track CurrentTrack { get; private set; }
|
public Track CurrentTrack { get; private set; }
|
||||||
public IntegrationHandler Integrations { get; private set; } = new();
|
public IntegrationHandler Integrations { get; private set; } = new();
|
||||||
public NotificationHandler Notifications { get; private set; } = new();
|
public NotificationHandler Notifications { get; private set; } = new();
|
||||||
|
@ -755,7 +755,7 @@ namespace FRESHMusicPlayer.ViewModels
|
||||||
#region NavBar
|
#region NavBar
|
||||||
public void OpenSettingsCommand()
|
public void OpenSettingsCommand()
|
||||||
{
|
{
|
||||||
new Views.Settings().SetThings(Config).Show(Window);
|
new Views.Settings().SetThings(Config, Library).Show(Window);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OpenQueueManagementCommand()
|
public void OpenQueueManagementCommand()
|
||||||
|
|
|
@ -22,5 +22,33 @@ namespace FRESHMusicPlayer.ViewModels
|
||||||
get => content;
|
get => content;
|
||||||
set => this.RaiseAndSetIfChanged(ref content, value);
|
set => this.RaiseAndSetIfChanged(ref content, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool hasOK = true;
|
||||||
|
public bool HasOK
|
||||||
|
{
|
||||||
|
get => hasOK;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref hasOK, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool hasYes = false;
|
||||||
|
public bool HasYes
|
||||||
|
{
|
||||||
|
get => hasYes;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref hasYes, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool hasNo = false;
|
||||||
|
public bool HasNo
|
||||||
|
{
|
||||||
|
get => hasNo;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref hasNo, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool hasCancel = false;
|
||||||
|
public bool HasCancel
|
||||||
|
{
|
||||||
|
get => hasCancel;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref hasCancel, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,12 +15,14 @@ using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using FRESHMusicPlayer.Handlers;
|
using FRESHMusicPlayer.Handlers;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
using FRESHMusicPlayer.Views;
|
||||||
|
|
||||||
namespace FRESHMusicPlayer.ViewModels
|
namespace FRESHMusicPlayer.ViewModels
|
||||||
{
|
{
|
||||||
public class SettingsViewModel : ViewModelBase
|
public class SettingsViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
public ConfigurationFile Config;
|
public ConfigurationFile Config;
|
||||||
|
public Library Library;
|
||||||
|
|
||||||
public bool IsRunningOnLinux { get => RuntimeInformation.IsOSPlatform(OSPlatform.Linux); }
|
public bool IsRunningOnLinux { get => RuntimeInformation.IsOSPlatform(OSPlatform.Linux); }
|
||||||
public bool IsRunningOnMac { get => RuntimeInformation.IsOSPlatform(OSPlatform.OSX); }
|
public bool IsRunningOnMac { get => RuntimeInformation.IsOSPlatform(OSPlatform.OSX); }
|
||||||
|
@ -149,6 +151,7 @@ namespace FRESHMusicPlayer.ViewModels
|
||||||
this.RaisePropertyChanged(nameof(IntegrateMPRIS));
|
this.RaisePropertyChanged(nameof(IntegrateMPRIS));
|
||||||
this.RaisePropertyChanged(nameof(MPRISShowCoverArt));
|
this.RaisePropertyChanged(nameof(MPRISShowCoverArt));
|
||||||
this.RaisePropertyChanged(nameof(CheckForUpdates));
|
this.RaisePropertyChanged(nameof(CheckForUpdates));
|
||||||
|
this.RaisePropertyChanged(nameof(IsRestartNeeded));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReportIssueCommand() => InterfaceUtils.OpenURL(@"https://github.com/Royce551/FRESHMusicPlayer/issues/new");
|
public void ReportIssueCommand() => InterfaceUtils.OpenURL(@"https://github.com/Royce551/FRESHMusicPlayer/issues/new");
|
||||||
|
@ -179,6 +182,30 @@ namespace FRESHMusicPlayer.ViewModels
|
||||||
this.RaisePropertyChanged(nameof(AutoImportText));
|
this.RaisePropertyChanged(nameof(AutoImportText));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ResetSettingsCommand()
|
||||||
|
{
|
||||||
|
var mainWindow = GetMainWindow().DataContext as MainWindowViewModel; // little messy, maybe figure out how to make this cleaner
|
||||||
|
mainWindow.Config = new ConfigurationFile();
|
||||||
|
Program.Config = mainWindow.Config;
|
||||||
|
Config = mainWindow.Config;
|
||||||
|
StartThings();
|
||||||
|
}
|
||||||
|
public async void CleanLibraryCommand()
|
||||||
|
{
|
||||||
|
await Task.Run(() =>
|
||||||
|
{
|
||||||
|
var tracks = Library.Read().Select(x => x.Path).Distinct();
|
||||||
|
Library.Nuke(false);
|
||||||
|
Library.Import(tracks.ToArray());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
public async void NukeLibraryCommand()
|
||||||
|
{
|
||||||
|
var messageBox = new MessageBox().SetStuff(MainWindowViewModel.ProjectName, "You are about to irreversibly clear your library.", true, false, false, true);
|
||||||
|
await messageBox.ShowDialog(Window);
|
||||||
|
if (messageBox.OK) Library.Nuke();
|
||||||
|
}
|
||||||
|
|
||||||
private void CheckRestartNeeded()
|
private void CheckRestartNeeded()
|
||||||
{
|
{
|
||||||
if (workingConfig.Language == Config.Language && workingConfig.IntegrateDiscordRPC == Config.IntegrateDiscordRPC && workingConfig.IntegrateMPRIS == Config.IntegrateMPRIS) IsRestartNeeded = false;
|
if (workingConfig.Language == Config.Language && workingConfig.IntegrateDiscordRPC == Config.IntegrateDiscordRPC && workingConfig.IntegrateMPRIS == Config.IntegrateMPRIS) IsRestartNeeded = false;
|
||||||
|
|
|
@ -166,13 +166,13 @@
|
||||||
<ColumnDefinition Width="1*" />
|
<ColumnDefinition Width="1*" />
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Image Source="{Binding CoverArt}" Grid.Column="0" Margin="10,-10,5,0" MaxWidth="64" MaxHeight="64" VerticalAlignment="Center" ToolTip.ShowDelay="10" PointerPressed="OpenTrackInfo" ContextMenu="{DynamicResource OverflowMenu}">
|
<Image Source="{Binding CoverArt}" Grid.Column="0" Margin="10,-10,10,0" MaxWidth="64" MaxHeight="64" VerticalAlignment="Center" ToolTip.ShowDelay="10" PointerPressed="OpenTrackInfo" ContextMenu="{DynamicResource OverflowMenu}">
|
||||||
<ToolTip.Tip>
|
<ToolTip.Tip>
|
||||||
<Image Source="{Binding CoverArt}" Width="450" Height="450"/>
|
<Image Source="{Binding CoverArt}" Width="450" Height="450"/>
|
||||||
</ToolTip.Tip>
|
</ToolTip.Tip>
|
||||||
</Image>
|
</Image>
|
||||||
<!--Middle Section-->
|
<!--Middle Section-->
|
||||||
<Grid Grid.Column="1" Margin="5,8,0,0" >
|
<Grid Grid.Column="1" Margin="0,8,0,0" >
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
|
|
|
@ -30,10 +30,9 @@ namespace FRESHMusicPlayer.Views
|
||||||
#endif
|
#endif
|
||||||
DoStuff();
|
DoStuff();
|
||||||
RootPanel = this.FindControl<Panel>("RootPanel");
|
RootPanel = this.FindControl<Panel>("RootPanel");
|
||||||
DragDrop.SetAllowDrop(RootPanel, true);
|
SetValue(DragDrop.AllowDropProperty, true);
|
||||||
RootPanel.AddHandler(DragDrop.DragEnterEvent, OnDragEnter);
|
AddHandler(DragDrop.DragEnterEvent, (s, e) => OnDragEnter(s, e));
|
||||||
RootPanel.AddHandler(DragDrop.DragOverEvent, OnDragEnter);
|
AddHandler(DragDrop.DropEvent, (s, e) => OnDragDrop(s, e));
|
||||||
RootPanel.AddHandler(DragDrop.DropEvent, OnDragDrop);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:vm="using:FRESHMusicPlayer.ViewModels"
|
xmlns:vm="using:FRESHMusicPlayer.ViewModels"
|
||||||
mc:Ignorable="d" SizeToContent="Height" Width="450"
|
mc:Ignorable="d" SizeToContent="Height" Width="450"
|
||||||
x:Class="FRESHMusicPlayer.Views.MessageBox" WindowStartupLocation="CenterOwner"
|
x:Class="FRESHMusicPlayer.Views.MessageBox" WindowStartupLocation="CenterOwner" ShowInTaskbar="False" CanResize="False"
|
||||||
Icon="/Assets/icon.ico" Title="{Binding Title}">
|
Icon="/Assets/icon.ico" Title="{Binding Title}">
|
||||||
|
|
||||||
<Window.DataContext>
|
<Window.DataContext>
|
||||||
|
@ -14,7 +14,10 @@
|
||||||
<StackPanel Margin="10">
|
<StackPanel Margin="10">
|
||||||
<TextBlock Text="{Binding Content}" TextWrapping="Wrap"/>
|
<TextBlock Text="{Binding Content}" TextWrapping="Wrap"/>
|
||||||
<StackPanel Margin="5" Orientation="Horizontal" HorizontalAlignment="Right">
|
<StackPanel Margin="5" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||||
<Button Content="OK" Click="OnButtonClick"/>
|
<Button Content="OK" Click="OnButtonClick" IsVisible="{Binding HasOK}"/>
|
||||||
|
<Button Content="Yes" Click="OnYesButtonClick" IsVisible="{Binding HasYes}"/>
|
||||||
|
<Button Content="No" Click="OnNoButtonClick" IsVisible="{Binding HasNo}"/>
|
||||||
|
<Button Content="Cancel" Click="OnCancelButtonClick" IsVisible="{Binding HasCancel}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Window>
|
</Window>
|
||||||
|
|
|
@ -3,11 +3,19 @@ using Avalonia.Controls;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
using FRESHMusicPlayer.ViewModels;
|
using FRESHMusicPlayer.ViewModels;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace FRESHMusicPlayer.Views
|
namespace FRESHMusicPlayer.Views
|
||||||
{
|
{
|
||||||
public class MessageBox : Window
|
public class MessageBox : Window
|
||||||
{
|
{
|
||||||
|
private MessageBoxViewModel ViewModel => DataContext as MessageBoxViewModel;
|
||||||
|
|
||||||
|
public bool OK { get; private set; } = false;
|
||||||
|
public bool Yes { get; private set; } = false;
|
||||||
|
public bool No { get; private set; } = false;
|
||||||
|
public bool Cancel { get; private set; } = false;
|
||||||
|
|
||||||
public MessageBox()
|
public MessageBox()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
@ -17,11 +25,19 @@ namespace FRESHMusicPlayer.Views
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessageBox SetStuff(string title, string content)
|
public MessageBox SetStuff(string title,
|
||||||
|
string content,
|
||||||
|
bool hasOK = true,
|
||||||
|
bool hasYes = false,
|
||||||
|
bool hasNo = false,
|
||||||
|
bool hasCancel = false)
|
||||||
{
|
{
|
||||||
var context = DataContext as MessageBoxViewModel;
|
ViewModel.Title = title;
|
||||||
context.Title = title;
|
ViewModel.Content = content;
|
||||||
context.Content = content;
|
ViewModel.HasOK = hasOK;
|
||||||
|
ViewModel.HasYes = hasYes;
|
||||||
|
ViewModel.HasNo = hasNo;
|
||||||
|
ViewModel.HasCancel = hasCancel;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +48,22 @@ namespace FRESHMusicPlayer.Views
|
||||||
|
|
||||||
private void OnButtonClick(object sender, RoutedEventArgs e)
|
private void OnButtonClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
OK = true;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
private void OnYesButtonClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Yes = true;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
private void OnNoButtonClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
No = true;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
private void OnCancelButtonClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Cancel = true;
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,11 +52,15 @@
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="{x:Static resx:Resources.Settings_Appearance}">
|
<!--<TabItem Header="{x:Static resx:Resources.Settings_Appearance}">
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>-->
|
||||||
<TabItem Header="{x:Static resx:Resources.Settings_Maintenance}">
|
<TabItem Header="{x:Static resx:Resources.Settings_Maintenance}">
|
||||||
|
<StackPanel>
|
||||||
|
<Button Content="Reset settings to default" Command="{Binding ResetSettingsCommand}" Margin="0,10,0,0"/>
|
||||||
|
<Button Content="Clean and update library" Command="{Binding CleanLibraryCommand}"/>
|
||||||
|
<Button Content="Nuke library" Foreground="{StaticResource Green}" Command="{Binding NukeLibraryCommand}"/>
|
||||||
|
</StackPanel>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="{x:Static resx:Resources.Menu_About}">
|
<TabItem Header="{x:Static resx:Resources.Menu_About}">
|
||||||
<StackPanel Margin="10" HorizontalAlignment="Stretch">
|
<StackPanel Margin="10" HorizontalAlignment="Stretch">
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
|
using FRESHMusicPlayer.Handlers;
|
||||||
using FRESHMusicPlayer.Handlers.Configuration;
|
using FRESHMusicPlayer.Handlers.Configuration;
|
||||||
using FRESHMusicPlayer.ViewModels;
|
using FRESHMusicPlayer.ViewModels;
|
||||||
|
|
||||||
|
@ -16,10 +17,11 @@ namespace FRESHMusicPlayer.Views
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public Settings SetThings(ConfigurationFile config)
|
public Settings SetThings(ConfigurationFile config, Library library)
|
||||||
{
|
{
|
||||||
var viewModel = DataContext as SettingsViewModel;
|
var viewModel = DataContext as SettingsViewModel;
|
||||||
viewModel.Config = config;
|
viewModel.Config = config;
|
||||||
|
viewModel.Library = library;
|
||||||
viewModel.StartThings();
|
viewModel.StartThings();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue