mirror of
https://github.com/Royce551/FRESHMusicPlayer.git
synced 2025-01-22 10:51:52 -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>
|
||||
<Folder Include="Models\" />
|
||||
<AvaloniaResource Include="Assets\**" />
|
||||
<Folder Include="NewFolder\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="Assets\icon.ico" />
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
public Player Player { get; private set; }
|
||||
public Timer ProgressTimer { get; private set; } = new(100);
|
||||
public Library Library { get; private set; }
|
||||
public ConfigurationFile Config { get; private set; }
|
||||
public ConfigurationFile Config { get; set; }
|
||||
public Track CurrentTrack { get; private set; }
|
||||
public IntegrationHandler Integrations { get; private set; } = new();
|
||||
public NotificationHandler Notifications { get; private set; } = new();
|
||||
|
@ -755,7 +755,7 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
#region NavBar
|
||||
public void OpenSettingsCommand()
|
||||
{
|
||||
new Views.Settings().SetThings(Config).Show(Window);
|
||||
new Views.Settings().SetThings(Config, Library).Show(Window);
|
||||
}
|
||||
|
||||
public void OpenQueueManagementCommand()
|
||||
|
|
|
@ -22,5 +22,33 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
get => content;
|
||||
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 FRESHMusicPlayer.Handlers;
|
||||
using Avalonia.Controls;
|
||||
using FRESHMusicPlayer.Views;
|
||||
|
||||
namespace FRESHMusicPlayer.ViewModels
|
||||
{
|
||||
public class SettingsViewModel : ViewModelBase
|
||||
{
|
||||
public ConfigurationFile Config;
|
||||
public Library Library;
|
||||
|
||||
public bool IsRunningOnLinux { get => RuntimeInformation.IsOSPlatform(OSPlatform.Linux); }
|
||||
public bool IsRunningOnMac { get => RuntimeInformation.IsOSPlatform(OSPlatform.OSX); }
|
||||
|
@ -149,6 +151,7 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
this.RaisePropertyChanged(nameof(IntegrateMPRIS));
|
||||
this.RaisePropertyChanged(nameof(MPRISShowCoverArt));
|
||||
this.RaisePropertyChanged(nameof(CheckForUpdates));
|
||||
this.RaisePropertyChanged(nameof(IsRestartNeeded));
|
||||
}
|
||||
|
||||
public void ReportIssueCommand() => InterfaceUtils.OpenURL(@"https://github.com/Royce551/FRESHMusicPlayer/issues/new");
|
||||
|
@ -179,6 +182,30 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
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()
|
||||
{
|
||||
if (workingConfig.Language == Config.Language && workingConfig.IntegrateDiscordRPC == Config.IntegrateDiscordRPC && workingConfig.IntegrateMPRIS == Config.IntegrateMPRIS) IsRestartNeeded = false;
|
||||
|
|
|
@ -166,13 +166,13 @@
|
|||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</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>
|
||||
<Image Source="{Binding CoverArt}" Width="450" Height="450"/>
|
||||
</ToolTip.Tip>
|
||||
</Image>
|
||||
<!--Middle Section-->
|
||||
<Grid Grid.Column="1" Margin="5,8,0,0" >
|
||||
<Grid Grid.Column="1" Margin="0,8,0,0" >
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
|
|
|
@ -30,10 +30,9 @@ namespace FRESHMusicPlayer.Views
|
|||
#endif
|
||||
DoStuff();
|
||||
RootPanel = this.FindControl<Panel>("RootPanel");
|
||||
DragDrop.SetAllowDrop(RootPanel, true);
|
||||
RootPanel.AddHandler(DragDrop.DragEnterEvent, OnDragEnter);
|
||||
RootPanel.AddHandler(DragDrop.DragOverEvent, OnDragEnter);
|
||||
RootPanel.AddHandler(DragDrop.DropEvent, OnDragDrop);
|
||||
SetValue(DragDrop.AllowDropProperty, true);
|
||||
AddHandler(DragDrop.DragEnterEvent, (s, e) => OnDragEnter(s, e));
|
||||
AddHandler(DragDrop.DropEvent, (s, e) => OnDragDrop(s, e));
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:vm="using:FRESHMusicPlayer.ViewModels"
|
||||
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}">
|
||||
|
||||
<Window.DataContext>
|
||||
|
@ -14,7 +14,10 @@
|
|||
<StackPanel Margin="10">
|
||||
<TextBlock Text="{Binding Content}" TextWrapping="Wrap"/>
|
||||
<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>
|
||||
</Window>
|
||||
|
|
|
@ -3,11 +3,19 @@ using Avalonia.Controls;
|
|||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using FRESHMusicPlayer.ViewModels;
|
||||
using System;
|
||||
|
||||
namespace FRESHMusicPlayer.Views
|
||||
{
|
||||
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()
|
||||
{
|
||||
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;
|
||||
context.Title = title;
|
||||
context.Content = content;
|
||||
ViewModel.Title = title;
|
||||
ViewModel.Content = content;
|
||||
ViewModel.HasOK = hasOK;
|
||||
ViewModel.HasYes = hasYes;
|
||||
ViewModel.HasNo = hasNo;
|
||||
ViewModel.HasCancel = hasCancel;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -32,6 +48,22 @@ namespace FRESHMusicPlayer.Views
|
|||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,11 +52,15 @@
|
|||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</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}">
|
||||
|
||||
<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 Header="{x:Static resx:Resources.Menu_About}">
|
||||
<StackPanel Margin="10" HorizontalAlignment="Stretch">
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using FRESHMusicPlayer.Handlers;
|
||||
using FRESHMusicPlayer.Handlers.Configuration;
|
||||
using FRESHMusicPlayer.ViewModels;
|
||||
|
||||
|
@ -16,10 +17,11 @@ namespace FRESHMusicPlayer.Views
|
|||
#endif
|
||||
}
|
||||
|
||||
public Settings SetThings(ConfigurationFile config)
|
||||
public Settings SetThings(ConfigurationFile config, Library library)
|
||||
{
|
||||
var viewModel = DataContext as SettingsViewModel;
|
||||
viewModel.Config = config;
|
||||
viewModel.Library = library;
|
||||
viewModel.StartThings();
|
||||
return this;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue