Skip to content

Commit

Permalink
Merge pull request #377 from NickvisionApps/more
Browse files Browse the repository at this point in the history
Features and Fixes Part 2
  • Loading branch information
nlogozzo authored Oct 22, 2023
2 parents ab03745 + 1dbb464 commit a3bfd37
Show file tree
Hide file tree
Showing 27 changed files with 5,073 additions and 4,847 deletions.
34 changes: 24 additions & 10 deletions NickvisionTagger.GNOME/Blueprints/window.blp
Original file line number Diff line number Diff line change
Expand Up @@ -583,16 +583,30 @@ Adw.ApplicationWindow _root {
activatable-widget: _publishingDateButton;

[suffix]
Gtk.MenuButton _publishingDateButton {
valign: center;
direction: none;
popover: Gtk.Popover {
Gtk.Calendar _publishingDateCalendar {
name: "calendarPublishingDate";
}
};
Gtk.Box {
orientation: horizontal;
spacing: 6;

Gtk.MenuButton _publishingDateButton {
valign: center;
direction: none;
popover: Gtk.Popover {
Gtk.Calendar _publishingDateCalendar {
name: "calendarPublishingDate";
}
};

styles ["calendar-button"]
}

styles ["calendar-button"]

Gtk.Button _clearPublishingDateButton {
valign: center;
tooltip-text: _("Clear Publishing Date");
icon-name: "user-trash-symbolic";

styles ["flat"]
}
}
}
}
Expand All @@ -604,7 +618,7 @@ Adw.ApplicationWindow _root {

header-suffix: Gtk.Button _addNewPropertyButton {
valign: center;
tooltip-text: "Add New Property";
tooltip-text: _("Add New Property");
action-name: "win.addCustomProperty";

Adw.ButtonContent {
Expand Down
15 changes: 14 additions & 1 deletion NickvisionTagger.GNOME/Controls/ComboBoxDialog.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Linq;
using static Nickvision.Aura.Localization.Gettext;

Expand Down Expand Up @@ -34,9 +35,11 @@ public partial class ComboBoxDialog
/// <param name="message">The message of the dialog</param>
/// <param name="choicesTitle">The title of the choices of the dialog</param>
/// <param name="choices">The choices of the dialog</param>
/// <param name="supportCustom">Whether or not a custom entry is supported</param>
/// <param name="previousChoice">The previous choice used if available</param>
/// <param name="cancelText">The text of the cancel button</param>
/// <param name="suggestedText">The text of the suggested button</param>
public ComboBoxDialog(Gtk.Window parentWindow, string iconName, string title, string message, string choicesTitle, string[] choices, bool supportCustom, string cancelText, string suggestedText)
public ComboBoxDialog(Gtk.Window parentWindow, string iconName, string title, string message, string choicesTitle, string[] choices, bool supportCustom, string? previousChoice, string cancelText, string suggestedText)
{
Response = "";
_choices = choices;
Expand Down Expand Up @@ -76,6 +79,16 @@ public ComboBoxDialog(Gtk.Window parentWindow, string iconName, string title, st
_dialog.SetDefaultResponse("suggested");
_dialog.SetCloseResponse("cancel");
_dialog.OnResponse += (sender, e) => SetResponse(e.Response);
var previous = Array.IndexOf(_choices, previousChoice);
if (previous != -1)
{
_choicesRow.SetSelected((uint)previous);
}
else if (!string.IsNullOrEmpty(previousChoice))
{
_choicesRow.SetSelected((uint)(_choices.Length - 1));
_customRow.SetText(previousChoice);
}
}

public event GObject.SignalHandler<Adw.MessageDialog, Adw.MessageDialog.ResponseSignalArgs> OnResponse
Expand Down
1 change: 1 addition & 0 deletions NickvisionTagger.GNOME/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public Program(string[] args)
* Added an option in Preferences to limit file name characters to those only supported by Windows
* Tagger will now watch a music folder library for changes on disk and prompt the user to reload if necessary
* Tagger will now display front album art within a music file row itself if available
* Tagger will now remember previously used format strings for file name to tag and tag to file name conversions
* Fixed an issue where downloaded lyrics would sometimes contain html encoded characters
* Fixed an issue where file names containing the ""<"" character caused the music file row to not display
* Improved create playlist dialog ux
Expand Down
12 changes: 10 additions & 2 deletions NickvisionTagger.GNOME/Views/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public struct TaggerDateTime
[Gtk.Connect] private readonly Adw.EntryRow _publisherRow;
[Gtk.Connect] private readonly Gtk.MenuButton _publishingDateButton;
[Gtk.Connect] private readonly Gtk.Calendar _publishingDateCalendar;
[Gtk.Connect] private readonly Gtk.Button _clearPublishingDateButton;
[Gtk.Connect] private readonly Adw.PreferencesGroup _customPropertiesGroup;
[Gtk.Connect] private readonly Gtk.Label _fingerprintLabel;
[Gtk.Connect] private readonly Gtk.Button _copyFingerprintButton;
Expand Down Expand Up @@ -339,6 +340,13 @@ private MainWindow(Gtk.Builder builder, MainWindowController controller, Adw.App
}
_updatePublishingDate = true;
};
_clearPublishingDateButton.OnClicked += (sender, e) =>
{
_updatePublishingDate = false;
_publishingDateButton.SetLabel(_("Pick a date"));
gtk_calendar_select_day(_publishingDateCalendar.Handle, ref g_date_time_new_local(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 0, 0, 0));
TagPropertyChanged();
};
_fingerprintLabel.SetEllipsize(Pango.EllipsizeMode.End);
_copyFingerprintButton.OnClicked += CopyFingerprintToClipboard;
OnNotify += (sender, e) =>
Expand Down Expand Up @@ -1016,7 +1024,7 @@ private void RemoveFromPlaylist(Gio.SimpleAction sender, EventArgs e)
/// <param name="e">EventArgs</param>
private void FilenameToTag(Gio.SimpleAction sender, EventArgs e)
{
var dialog = new ComboBoxDialog(this, _controller.AppInfo.ID, _("File Name to Tag"), _("Please select a format string."), _("Format String"), _controller.FormatStrings, true, _("Cancel"), _("Convert"));
var dialog = new ComboBoxDialog(this, _controller.AppInfo.ID, _("File Name to Tag"), _("Please select a format string."), _("Format String"), _controller.FormatStrings, true, _controller.PreviousFTTFormatString, _("Cancel"), _("Convert"));
dialog.OnResponse += async (s, ea) =>
{
if (!string.IsNullOrEmpty(dialog.Response))
Expand All @@ -1035,7 +1043,7 @@ private void FilenameToTag(Gio.SimpleAction sender, EventArgs e)
/// <param name="e">EventArgs</param>
private void TagToFilename(Gio.SimpleAction sender, EventArgs e)
{
var dialog = new ComboBoxDialog(this, _controller.AppInfo.ID, _("Tag to File Name"), _("Please select a format string."), _("Format String"), _controller.FormatStrings, true, _("Cancel"), _("Convert"));
var dialog = new ComboBoxDialog(this, _controller.AppInfo.ID, _("Tag to File Name"), _("Please select a format string."), _("Format String"), _controller.FormatStrings, true, _controller.PreviousTTFFormatString, _("Cancel"), _("Convert"));
dialog.OnResponse += async (s, ea) =>
{
if (!string.IsNullOrEmpty(dialog.Response))
Expand Down
6 changes: 3 additions & 3 deletions NickvisionTagger.GNOME/nuget-sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -694,10 +694,10 @@
},
{
"type": "file",
"url": "https://api.nuget.org/v3-flatcontainer/z440.atl.core/5.10.0/z440.atl.core.5.10.0.nupkg",
"sha512": "9aa0b7a763f69db5675cba28b53be5f095ef1d220b82c359a4be4aca21e9d87f3b59fce653fca6a6266ae937cea6b47c72f6ed0c8f60162985d127f54b825bf8",
"url": "https://api.nuget.org/v3-flatcontainer/z440.atl.core/5.11.0/z440.atl.core.5.11.0.nupkg",
"sha512": "8a2dbb6e206698afa8ad08a5e408232d4cfdb0b2d76e688af40696faeefbb623a94472e3622c33c84abee5c7a5417d0c966e87197bfd645755cce6501787dcef",
"dest": "nuget-sources",
"dest-filename": "z440.atl.core.5.10.0.nupkg"
"dest-filename": "z440.atl.core.5.11.0.nupkg"
},
{
"type": "file",
Expand Down
12 changes: 12 additions & 0 deletions NickvisionTagger.Shared/Controllers/MainWindowController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ public class MainWindowController : IDisposable
/// The list of paths to corrupted music files in the music library
/// </summary>
public List<string> CorruptedFiles => _musicLibrary?.CorruptedFiles ?? new List<string>();
/// <summary>
/// The previous format string used by filename to tag
/// </summary>
public string PreviousFTTFormatString => Configuration.Current.PreviousFTTFormatString;
/// <summary>
/// The previous format string used by tag to filename
/// </summary>
public string PreviousTTFFormatString => Configuration.Current.PreviousTTFFormatString;

/// <summary>
/// Occurs when a notification is sent
Expand Down Expand Up @@ -969,6 +977,8 @@ await Task.Run(() =>
if (success > 0)
{
UpdateSelectedMusicFilesProperties();
Configuration.Current.PreviousFTTFormatString = formatString;
Aura.Active.SaveConfig("config");
}
MusicFileSaveStatesChanged?.Invoke(this, MusicFileSaveStates.Any(x => !x));
NotificationSent?.Invoke(this, new NotificationSentEventArgs(_n("Converted {0} file name to tag successfully", "Converted {0} file names to tags successfully", success, success), NotificationSeverity.Success, "format"));
Expand Down Expand Up @@ -1003,6 +1013,8 @@ await Task.Run(() =>
if (success > 0)
{
UpdateSelectedMusicFilesProperties();
Configuration.Current.PreviousTTFFormatString = formatString;
Aura.Active.SaveConfig("config");
}
MusicFileSaveStatesChanged?.Invoke(this, MusicFileSaveStates.Any(x => !x));
NotificationSent?.Invoke(this, new NotificationSentEventArgs(_n("Converted {0} tag to file name successfully", "Converted {0} tags to file names successfully", success, success), NotificationSeverity.Success, "format"));
Expand Down
10 changes: 10 additions & 0 deletions NickvisionTagger.Shared/Models/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ public class Configuration : ConfigurationBase
/// </summary>
public string AcoustIdUserAPIKey { get; set; }
/// <summary>
/// The previous format string used by filename to tag
/// </summary>
public string PreviousFTTFormatString { get; set; }
/// <summary>
/// The previous format string used by tag to filename
/// </summary>
public string PreviousTTFFormatString { get; set; }
/// <summary>
/// Whether or not to show the Extras Pane
/// </summary>
/// <remarks>Used on WinUI only</remarks>
Expand All @@ -110,6 +118,8 @@ public Configuration()
OverwriteAlbumArtWithMusicBrainz = true;
OverwriteLyricsWithWebService = true;
AcoustIdUserAPIKey = "";
PreviousFTTFormatString = "";
PreviousTTFFormatString = "";
ExtrasPane = true;
}

Expand Down
52 changes: 42 additions & 10 deletions NickvisionTagger.Shared/Models/MusicFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1165,11 +1165,27 @@ public override bool Equals(object? obj)
SortBy.Filename => CompareFilename(a?.Filename, b?.Filename) == -1,
SortBy.Path => ComparePath(a?.Path, b?.Path) == -1,
SortBy.Title => a?.Title.CompareTo(b?.Title) == -1,
SortBy.Artist => a?.Artist.CompareTo(b?.Artist) == -1 || a?.Artist == b?.Artist && a?.Album.CompareTo(b?.Album) == -1 || a?.Artist == b?.Artist && a?.Album == b?.Album && a?.Track < b?.Track || a?.Artist == b?.Artist && a?.Album == b?.Album && a?.Track == b?.Track && a?.Title.CompareTo(b?.Title) == -1,
SortBy.Album => a?.Album.CompareTo(b?.Album) == -1 || a?.Album == b?.Album && a?.Track < b?.Track || a?.Album == b?.Album && a?.Track == b?.Track && a?.Title.CompareTo(b?.Title) == -1,
SortBy.Year => a?.Year.CompareTo(b?.Year) == -1 || a?.Year == b?.Year && a?.Album.CompareTo(b?.Album) == -1 || a?.Year == b?.Year && a?.Album == b?.Album && a?.Track < b?.Track || a?.Year == b?.Year && a?.Album == b?.Album && a?.Track == b?.Track && a?.Title.CompareTo(b?.Title) == -1,
SortBy.Track => a?.Track.CompareTo(b?.Track) == -1 || a?.Track == b?.Track && a?.Title.CompareTo(b?.Title) == -1,
SortBy.Genre => a?.Genre.CompareTo(b?.Genre) == -1 || a?.Genre == b?.Genre && a?.Album.CompareTo(b?.Album) == -1 || a?.Genre == b?.Genre && a?.Album == b?.Album && a?.Track < b?.Track || a?.Genre == b?.Genre && a?.Album == b?.Album && a?.Track == b?.Track && a?.Title.CompareTo(b?.Title) == -1,
SortBy.Artist => a?.Artist.CompareTo(b?.Artist) == -1
|| a?.Artist == b?.Artist && a?.Album.CompareTo(b?.Album) == -1
|| a?.Artist == b?.Artist && a?.Album == b?.Album && a?.DiscNumber < b?.DiscNumber
|| a?.Artist == b?.Artist && a?.Album == b?.Album && a?.DiscNumber == b?.DiscNumber && a?.Track < b?.Track
|| a?.Artist == b?.Artist && a?.Album == b?.Album && a?.DiscNumber == b?.DiscNumber && a?.Track == b?.Track && a?.Title.CompareTo(b?.Title) == -1,
SortBy.Album => a?.Album.CompareTo(b?.Album) == -1
|| a?.Album == b?.Album && a?.DiscNumber < b?.DiscNumber
|| a?.Album == b?.Album && a?.DiscNumber == b?.DiscNumber && a?.Track < b?.Track
|| a?.Album == b?.Album && a?.DiscNumber == b?.DiscNumber && a?.Track == b?.Track && a?.Title.CompareTo(b?.Title) == -1,
SortBy.Year => a?.Year.CompareTo(b?.Year) == -1
|| a?.Year == b?.Year && a?.Album.CompareTo(b?.Album) == -1
|| a?.Year == b?.Year && a?.Album == b?.Album && a?.DiscNumber < b?.DiscNumber
|| a?.Year == b?.Year && a?.Album == b?.Album && a?.DiscNumber == b?.DiscNumber && a?.Track < b?.Track
|| a?.Year == b?.Year && a?.Album == b?.Album && a?.DiscNumber == b?.DiscNumber && a?.Track == b?.Track && a?.Title.CompareTo(b?.Title) == -1,
SortBy.Track => a?.Track.CompareTo(b?.Track) == -1
|| a?.Track == b?.Track && a?.Title.CompareTo(b?.Title) == -1,
SortBy.Genre => a?.Genre.CompareTo(b?.Genre) == -1
|| a?.Genre == b?.Genre && a?.Album.CompareTo(b?.Album) == -1
|| a?.Genre == b?.Genre && a?.Album == b?.Album && a?.DiscNumber < b?.DiscNumber
|| a?.Genre == b?.Genre && a?.Album == b?.Album && a?.DiscNumber == b?.DiscNumber && a?.Track < b?.Track
|| a?.Genre == b?.Genre && a?.Album == b?.Album && a?.DiscNumber == b?.DiscNumber && a?.Track == b?.Track && a?.Title.CompareTo(b?.Title) == -1,
_ => false
};
}
Expand All @@ -1187,11 +1203,27 @@ public override bool Equals(object? obj)
SortBy.Filename => CompareFilename(a?.Filename, b?.Filename) == 1,
SortBy.Path => ComparePath(a?.Path, b?.Path) == 1,
SortBy.Title => a?.Title.CompareTo(b?.Title) == 1,
SortBy.Artist => a?.Artist.CompareTo(b?.Artist) == 1 || a?.Artist == b?.Artist && a?.Album.CompareTo(b?.Album) == 1 || a?.Artist == b?.Artist && a?.Album == b?.Album && a?.Track > b?.Track || a?.Artist == b?.Artist && a?.Album == b?.Album && a?.Track == b?.Track && a?.Title.CompareTo(b?.Title) == 1,
SortBy.Album => a?.Album.CompareTo(b?.Album) == 1 || a?.Album == b?.Album && a?.Track > b?.Track || a?.Album == b?.Album && a?.Track == b?.Track && a?.Title.CompareTo(b?.Title) == 1,
SortBy.Year => a?.Year.CompareTo(b?.Year) == 1 || a?.Year == b?.Year && a?.Album.CompareTo(b?.Album) == 1 || a?.Year == b?.Year && a?.Album == b?.Album && a?.Track > b?.Track || a?.Year == b?.Year && a?.Album == b?.Album && a?.Track == b?.Track && a?.Title.CompareTo(b?.Title) == 1,
SortBy.Track => a?.Track.CompareTo(b?.Track) == 1 || a?.Track == b?.Track && a?.Title.CompareTo(b?.Title) == 1,
SortBy.Genre => a?.Genre.CompareTo(b?.Genre) == 1 || a?.Genre == b?.Genre && a?.Album.CompareTo(b?.Album) == 1 || a?.Genre == b?.Genre && a?.Album == b?.Album && a?.Track > b?.Track || a?.Genre == b?.Genre && a?.Album == b?.Album && a?.Track == b?.Track && a?.Title.CompareTo(b?.Title) == 1,
SortBy.Artist => a?.Artist.CompareTo(b?.Artist) == 1
|| a?.Artist == b?.Artist && a?.Album.CompareTo(b?.Album) == 1
|| a?.Artist == b?.Artist && a?.Album == b?.Album && a?.DiscNumber > b?.DiscNumber
|| a?.Artist == b?.Artist && a?.Album == b?.Album && a?.DiscNumber == b?.DiscNumber && a?.Track > b?.Track
|| a?.Artist == b?.Artist && a?.Album == b?.Album && a?.DiscNumber == b?.DiscNumber && a?.Track == b?.Track && a?.Title.CompareTo(b?.Title) == 1,
SortBy.Album => a?.Album.CompareTo(b?.Album) == 1
|| a?.Album == b?.Album && a?.DiscNumber > b?.DiscNumber
|| a?.Album == b?.Album && a?.DiscNumber == b?.DiscNumber && a?.Track > b?.Track
|| a?.Album == b?.Album && a?.DiscNumber == b?.DiscNumber && a?.Track == b?.Track && a?.Title.CompareTo(b?.Title) == 1,
SortBy.Year => a?.Year.CompareTo(b?.Year) == 1
|| a?.Year == b?.Year && a?.Album.CompareTo(b?.Album) == 1
|| a?.Year == b?.Year && a?.Album == b?.Album && a?.DiscNumber > b?.DiscNumber
|| a?.Year == b?.Year && a?.Album == b?.Album && a?.DiscNumber == b?.DiscNumber && a?.Track > b?.Track
|| a?.Year == b?.Year && a?.Album == b?.Album && a?.DiscNumber == b?.DiscNumber && a?.Track == b?.Track && a?.Title.CompareTo(b?.Title) == 1,
SortBy.Track => a?.Track.CompareTo(b?.Track) == 1
|| a?.Track == b?.Track && a?.Title.CompareTo(b?.Title) == 1,
SortBy.Genre => a?.Genre.CompareTo(b?.Genre) == 1
|| a?.Genre == b?.Genre && a?.Album.CompareTo(b?.Album) == 1
|| a?.Genre == b?.Genre && a?.Album == b?.Album && a?.DiscNumber > b?.DiscNumber
|| a?.Genre == b?.Genre && a?.Album == b?.Album && a?.DiscNumber == b?.DiscNumber && a?.Track > b?.Track
|| a?.Genre == b?.Genre && a?.Album == b?.Album && a?.DiscNumber == b?.DiscNumber && a?.Track == b?.Track && a?.Title.CompareTo(b?.Title) == 1,
_ => false
};
}
Expand Down
2 changes: 1 addition & 1 deletion NickvisionTagger.Shared/NickvisionTagger.Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
<PackageReference Include="AcoustID.NET" Version="1.3.3" />
<PackageReference Include="Nickvision.Aura" Version="2023.10.1.3" />
<PackageReference Include="z440.atl.core" Version="5.10.0" />
<PackageReference Include="z440.atl.core" Version="5.11.0" />
<PackageReference Include="MetaBrainz.MusicBrainz" Version="5.0.0" />
<PackageReference Include="MetaBrainz.MusicBrainz.CoverArt" Version="5.0.0" />
<PackageReference Include="FuzzySharp" Version="2.0.2" />
Expand Down
Loading

0 comments on commit a3bfd37

Please sign in to comment.