Skip to content

Commit

Permalink
Changed the queue window to better reflect when a song gets skipped
Browse files Browse the repository at this point in the history
Album Cover now gets deleted when Songify is on pause
Fixed minimize to try on startup not working properly
  • Loading branch information
Inzaniity committed May 18, 2024
1 parent 62ef802 commit 393ab91
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
13 changes: 11 additions & 2 deletions Songify Slim/Util/General/GlobalObjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static class GlobalObjects
public static string AllowedPlaylistName;
internal static string AllowedPlaylistUrl;
public static PrivateProfile SpotifyProfile;
public static bool ForceUpdate;
public static bool ForceUpdate;
private static readonly TaskQueue updateQueueWindowTasks = new();
public static string RootDirectory => string.IsNullOrEmpty(Settings.Settings.Directory)
? Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location)
Expand Down Expand Up @@ -176,14 +176,22 @@ public static async Task UpdateQueueWindow()
{
// Determine if we have a matching request object that hasn't been used for replacement yet
RequestObject reqObj = ReqList.FirstOrDefault(o => o.Trackid == fullTrack.Id && !replacementTracker.ContainsKey(o.Trackid) && fullTrack.Id != CurrentSong.SongId);
RequestObject skipObj = SkipList.FirstOrDefault(o => o.Trackid == fullTrack.Id);
if (reqObj != null)
{
// If we found a request object, and it hasn't been used for replacement, add it and mark as used
(window as WindowQueue)?.dgv_Queue.Items.Add(reqObj);
replacementTracker[reqObj.Trackid] = true; // Mark this track ID as having been replaced
}
else if (skipObj != null)
{
skipObj.Requester = "Skipping...";
// If we found a request object, and it hasn't been used for replacement, add it and mark as used
(window as WindowQueue)?.dgv_Queue.Items.Add(skipObj);
replacementTracker[skipObj.Trackid] = true; // Mark this track ID as having been replaced
}
else
{
// Otherwise, just add the song information from the queue as a new request object
Expand All @@ -200,6 +208,7 @@ public static async Task UpdateQueueWindow()
Albumcover = null
});
}
}
(window as WindowQueue)?.dgv_Queue.Items.Refresh();
}
Expand Down
3 changes: 2 additions & 1 deletion Songify Slim/Util/Songify/SongFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -600,14 +600,15 @@ private static Task WriteSongInfo(TrackInfo songInfo)

if (!songInfo.IsPlaying)
{
if (Settings.Settings.DownloadCover) IOManager.DownloadCover(null, coverPath);

if (!Settings.Settings.CustomPauseTextEnabled)
return Task.CompletedTask;
// read the text file
if (!File.Exists(songPath)) File.Create(songPath).Close();
IOManager.WriteOutput(songPath, Settings.Settings.CustomPauseText);

if (Settings.Settings.SplitOutput) IOManager.WriteSplitOutput(Settings.Settings.CustomPauseText, title, "");

//IOManager.DownloadCover(null, coverPath);

Application.Current.Dispatcher.Invoke(() =>
Expand Down
3 changes: 3 additions & 0 deletions Songify Slim/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,9 @@ private async void MetroWindowLoaded(object sender, RoutedEventArgs e)

private void InitialSetup()
{
if (Settings.Systray)
MinimizeToSysTray();

GrdDisclaimer.Visibility = Settings.DonationReminder ? Visibility.Collapsed : Visibility.Visible;

if (!Directory.Exists(Settings.Directory) && MessageBox.Show($"The directory \"{Settings.Directory}\" doesn't exist.\nThe output directory has been set to \"{Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location)}\".", "Directory doesn't exist", MessageBoxButton.OK, MessageBoxImage.Error) == MessageBoxResult.OK)
Expand Down
17 changes: 17 additions & 0 deletions Songify Slim/Views/Window_Queue.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,23 @@
<DataGridTextColumn Visibility="Visible" x:Name="ColLength" Width="*" Header="{x:Static properties:Resources.s_Length}" Binding="{Binding Path=Length}" />
<DataGridTextColumn Visibility="Visible" x:Name="ColRequester" Width="*" Header="{x:Static properties:Resources.s_Requester}" Binding="{Binding Path=Requester}" />
</DataGrid.Columns>
<DataGrid.RowStyle>
<Style BasedOn="{StaticResource {x:Type DataGridRow}}" TargetType="DataGridRow">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="LightGray"></Setter>
</Trigger>

<DataTrigger Binding="{Binding Requester}" Value="Skipping...">
<Setter Property="Background" Value="IndianRed" />
</DataTrigger>
<DataTrigger Binding="{Binding Requester}" Value="Spotify">
<Setter Property="Background" Value="Transparent" />
</DataTrigger>
</Style.Triggers>
<Setter Property="Background" Value="SeaGreen"></Setter>
</Style>
</DataGrid.RowStyle>
</DataGrid>

</Grid>
Expand Down
4 changes: 2 additions & 2 deletions Songify Slim/Views/Window_Queue.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ private async void DgvItemDelete_Click(object sender, RoutedEventArgs e)
await Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
GlobalObjects.ReqList.Remove(req);
GlobalObjects.SkipList.Add(req);
}));
dgv_Queue.Items.Refresh();

GlobalObjects.QueueUpdateQueueWindow();
}

private void ColVisChecked(object sender, RoutedEventArgs e)
Expand Down

0 comments on commit 393ab91

Please sign in to comment.