(partial) Fix #742: add Date Added column
This commit is contained in:
@@ -435,6 +435,7 @@ func toTrack(ch *jellyfin.Song) *mediaprovider.Track {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lastPlayed, _ := time.Parse(time.RFC3339Nano, ch.UserData.LastPlayedDate)
|
lastPlayed, _ := time.Parse(time.RFC3339Nano, ch.UserData.LastPlayedDate)
|
||||||
|
dateAdded, _ := time.Parse(time.RFC3339Nano, ch.DateCreated)
|
||||||
|
|
||||||
t := &mediaprovider.Track{
|
t := &mediaprovider.Track{
|
||||||
ID: ch.Id,
|
ID: ch.Id,
|
||||||
@@ -454,6 +455,7 @@ func toTrack(ch *jellyfin.Song) *mediaprovider.Track {
|
|||||||
Favorite: ch.UserData.IsFavorite,
|
Favorite: ch.UserData.IsFavorite,
|
||||||
PlayCount: ch.UserData.PlayCount,
|
PlayCount: ch.UserData.PlayCount,
|
||||||
LastPlayed: lastPlayed,
|
LastPlayed: lastPlayed,
|
||||||
|
DateAdded: dateAdded,
|
||||||
}
|
}
|
||||||
if len(ch.MediaSources) > 0 {
|
if len(ch.MediaSources) > 0 {
|
||||||
t.FilePath = ch.MediaSources[0].Path
|
t.FilePath = ch.MediaSources[0].Path
|
||||||
|
|||||||
@@ -152,6 +152,7 @@ type Track struct {
|
|||||||
SampleRate int
|
SampleRate int
|
||||||
BitDepth int
|
BitDepth int
|
||||||
Channels int
|
Channels int
|
||||||
|
DateAdded time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
type ReplayGainInfo struct {
|
type ReplayGainInfo struct {
|
||||||
|
|||||||
@@ -589,6 +589,7 @@ func toTrack(ch *subsonic.Child) *mediaprovider.Track {
|
|||||||
Favorite: !ch.Starred.IsZero(),
|
Favorite: !ch.Starred.IsZero(),
|
||||||
PlayCount: int(ch.PlayCount),
|
PlayCount: int(ch.PlayCount),
|
||||||
LastPlayed: ch.Played,
|
LastPlayed: ch.Played,
|
||||||
|
DateAdded: ch.Created,
|
||||||
FilePath: ch.Path,
|
FilePath: ch.Path,
|
||||||
Size: ch.Size,
|
Size: ch.Size,
|
||||||
BitRate: ch.BitRate,
|
BitRate: ch.BitRate,
|
||||||
|
|||||||
@@ -62,6 +62,7 @@
|
|||||||
"Content type": "Content type",
|
"Content type": "Content type",
|
||||||
"Could not reach server": "Could not reach server",
|
"Could not reach server": "Could not reach server",
|
||||||
"Create new playlist": "Create new playlist",
|
"Create new playlist": "Create new playlist",
|
||||||
|
"Date added": "Date added",
|
||||||
"day": "day",
|
"day": "day",
|
||||||
"days": "days",
|
"days": "days",
|
||||||
"Delete Playlist": "Delete Playlist",
|
"Delete Playlist": "Delete Playlist",
|
||||||
@@ -290,12 +291,10 @@
|
|||||||
"Oct": "Oct",
|
"Oct": "Oct",
|
||||||
"Nov": "Nov",
|
"Nov": "Nov",
|
||||||
"Dec": "Dec",
|
"Dec": "Dec",
|
||||||
|
|
||||||
"playlist.addedtracks": {
|
"playlist.addedtracks": {
|
||||||
"one": "Added one track to playlist",
|
"one": "Added one track to playlist",
|
||||||
"other": "Added {{.trackCount}} tracks to playlist"
|
"other": "Added {{.trackCount}} tracks to playlist"
|
||||||
},
|
},
|
||||||
|
|
||||||
"x_minutes_ago": {
|
"x_minutes_ago": {
|
||||||
"one": "a minute ago",
|
"one": "a minute ago",
|
||||||
"other": "{{.minutes}} minutes ago"
|
"other": "{{.minutes}} minutes ago"
|
||||||
@@ -316,4 +315,4 @@
|
|||||||
"one": "a year ago",
|
"one": "a year ago",
|
||||||
"other": "{{.years}} years ago"
|
"other": "{{.years}} years ago"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -115,6 +115,11 @@ func (t *TrackInfoDialog) CreateRenderer() fyne.WidgetRenderer {
|
|||||||
addFormRow(c, lang.L("Channels"), strconv.Itoa(t.track.Channels))
|
addFormRow(c, lang.L("Channels"), strconv.Itoa(t.track.Channels))
|
||||||
}
|
}
|
||||||
addFormRow(c, lang.L("File size"), util.BytesToSizeString(t.track.Size))
|
addFormRow(c, lang.L("File size"), util.BytesToSizeString(t.track.Size))
|
||||||
|
|
||||||
|
if !t.track.DateAdded.IsZero() {
|
||||||
|
addFormRow(c, lang.L("Date added"), t.track.DateAdded.Format(time.RFC1123))
|
||||||
|
}
|
||||||
|
|
||||||
addFormRow(c, lang.L("Play count"), strconv.Itoa(t.track.PlayCount))
|
addFormRow(c, lang.L("Play count"), strconv.Itoa(t.track.PlayCount))
|
||||||
|
|
||||||
if !t.track.LastPlayed.IsZero() {
|
if !t.track.LastPlayed.IsZero() {
|
||||||
|
|||||||
@@ -100,6 +100,23 @@ func FormatItemDate(date mediaprovider.ItemDate) string {
|
|||||||
return sb.String()
|
return sb.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func FormatDate(t time.Time) string {
|
||||||
|
if t.IsZero() {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
df := dateFormatForLocale(fyne.CurrentDevice().Locale().String())
|
||||||
|
switch df {
|
||||||
|
case DateFormatDMY:
|
||||||
|
return t.Format("2 Jan 2006")
|
||||||
|
case DateFormatMDY:
|
||||||
|
return t.Format("Jan 2 2006")
|
||||||
|
case DateFormatYMD:
|
||||||
|
return t.Format("2006 Jan 2")
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func LastPlayedDisplayString(t time.Time) string {
|
func LastPlayedDisplayString(t time.Time) string {
|
||||||
if t.IsZero() {
|
if t.IsZero() {
|
||||||
return lang.L("never")
|
return lang.L("never")
|
||||||
|
|||||||
@@ -461,6 +461,8 @@ func (t *Tracklist) doSortTracks() {
|
|||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
})
|
})
|
||||||
|
case ColumnDateAdded:
|
||||||
|
t.intSort(func(tr *util.TrackListModel) int64 { return tr.Track().DateAdded.Unix() })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ const (
|
|||||||
ColumnBPM = "BPM"
|
ColumnBPM = "BPM"
|
||||||
ColumnBitrate = "Bitrate"
|
ColumnBitrate = "Bitrate"
|
||||||
ColumnSize = "Size"
|
ColumnSize = "Size"
|
||||||
|
ColumnDateAdded = "DateAdded"
|
||||||
ColumnPath = "Path"
|
ColumnPath = "Path"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -93,6 +94,7 @@ var (
|
|||||||
bpm := lang.L("BPM")
|
bpm := lang.L("BPM")
|
||||||
bitrate := lang.L("Bit rate")
|
bitrate := lang.L("Bit rate")
|
||||||
size := lang.L("Size")
|
size := lang.L("Size")
|
||||||
|
dateAdded := lang.L("Date added")
|
||||||
filepath := lang.L("File path")
|
filepath := lang.L("File path")
|
||||||
|
|
||||||
CompactTracklistRowColumns = []TracklistColumn{
|
CompactTracklistRowColumns = []TracklistColumn{
|
||||||
@@ -111,6 +113,7 @@ var (
|
|||||||
{Name: ColumnBPM, Col: ListColumn{Text: bpm, Alignment: fyne.TextAlignTrailing, CanToggleVisible: true}},
|
{Name: ColumnBPM, Col: ListColumn{Text: bpm, Alignment: fyne.TextAlignTrailing, CanToggleVisible: true}},
|
||||||
{Name: ColumnBitrate, Col: ListColumn{Text: bitrate, Alignment: fyne.TextAlignTrailing, CanToggleVisible: true}},
|
{Name: ColumnBitrate, Col: ListColumn{Text: bitrate, Alignment: fyne.TextAlignTrailing, CanToggleVisible: true}},
|
||||||
{Name: ColumnSize, Col: ListColumn{Text: size, Alignment: fyne.TextAlignTrailing, CanToggleVisible: true}},
|
{Name: ColumnSize, Col: ListColumn{Text: size, Alignment: fyne.TextAlignTrailing, CanToggleVisible: true}},
|
||||||
|
{Name: ColumnDateAdded, Col: ListColumn{Text: dateAdded, Alignment: fyne.TextAlignLeading, CanToggleVisible: true}},
|
||||||
{Name: ColumnPath, Col: ListColumn{Text: filepath, Alignment: fyne.TextAlignLeading, CanToggleVisible: true}},
|
{Name: ColumnPath, Col: ListColumn{Text: filepath, Alignment: fyne.TextAlignLeading, CanToggleVisible: true}},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,6 +132,7 @@ var (
|
|||||||
{Name: ColumnBPM, Col: ListColumn{Text: bpm, Alignment: fyne.TextAlignTrailing, CanToggleVisible: true}},
|
{Name: ColumnBPM, Col: ListColumn{Text: bpm, Alignment: fyne.TextAlignTrailing, CanToggleVisible: true}},
|
||||||
{Name: ColumnBitrate, Col: ListColumn{Text: bitrate, Alignment: fyne.TextAlignTrailing, CanToggleVisible: true}},
|
{Name: ColumnBitrate, Col: ListColumn{Text: bitrate, Alignment: fyne.TextAlignTrailing, CanToggleVisible: true}},
|
||||||
{Name: ColumnSize, Col: ListColumn{Text: size, Alignment: fyne.TextAlignTrailing, CanToggleVisible: true}},
|
{Name: ColumnSize, Col: ListColumn{Text: size, Alignment: fyne.TextAlignTrailing, CanToggleVisible: true}},
|
||||||
|
{Name: ColumnDateAdded, Col: ListColumn{Text: dateAdded, Alignment: fyne.TextAlignLeading, CanToggleVisible: true}},
|
||||||
{Name: ColumnPath, Col: ListColumn{Text: filepath, Alignment: fyne.TextAlignLeading, CanToggleVisible: true}},
|
{Name: ColumnPath, Col: ListColumn{Text: filepath, Alignment: fyne.TextAlignLeading, CanToggleVisible: true}},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,6 +156,10 @@ var (
|
|||||||
widget.NewLabel(lang.LocalizePluralKey("x_minutes_ago", "59 minutes ago", 59, map[string]string{"minutes": "59"})).MinSize().Width,
|
widget.NewLabel(lang.LocalizePluralKey("x_minutes_ago", "59 minutes ago", 59, map[string]string{"minutes": "59"})).MinSize().Width,
|
||||||
widget.NewLabel(lastPlayed).MinSize().Width+sortIconWidth,
|
widget.NewLabel(lastPlayed).MinSize().Width+sortIconWidth,
|
||||||
)
|
)
|
||||||
|
dateAddedColWidth := fyne.Max(
|
||||||
|
widget.NewLabel("2006 Jan 30").MinSize().Width,
|
||||||
|
widget.NewLabel(dateAdded).MinSize().Width+sortIconWidth,
|
||||||
|
)
|
||||||
bpmColWidth := fyne.Max(
|
bpmColWidth := fyne.Max(
|
||||||
widget.NewLabel(bpm+" ").MinSize().Width,
|
widget.NewLabel(bpm+" ").MinSize().Width,
|
||||||
widget.NewLabel("9999").MinSize().Width)
|
widget.NewLabel("9999").MinSize().Width)
|
||||||
@@ -162,10 +170,10 @@ var (
|
|||||||
widget.NewLabel("99.9 MB").MinSize().Width,
|
widget.NewLabel("99.9 MB").MinSize().Width,
|
||||||
widget.NewLabel(size).MinSize().Width+sortIconWidth)
|
widget.NewLabel(size).MinSize().Width+sortIconWidth)
|
||||||
|
|
||||||
// #, Title, Artist, Album, Composer, Time, Year, Favorite, Rating, Plays, LastPlayed, Comment, BPM, Bitrate, Size, Path
|
// #, Title, Artist, Album, Composer, Time, Year, Favorite, Rating, Plays, LastPlayed, Comment, BPM, Bitrate, Size, DateAdded, Path
|
||||||
CompactTracklistRowColumnWidths = []float32{numColWidth, -1, -1, -1, -1, timeColWidth, yearColWidth, favColWidth, ratingColWidth, playsColWidth, lastPlayedColWidth, -1, bpmColWidth, bitrateColWidth, sizeColWidth, -1}
|
CompactTracklistRowColumnWidths = []float32{numColWidth, -1, -1, -1, -1, timeColWidth, yearColWidth, favColWidth, ratingColWidth, playsColWidth, lastPlayedColWidth, -1, bpmColWidth, bitrateColWidth, sizeColWidth, dateAddedColWidth, -1}
|
||||||
// #, Title/Artist, Album, Composer, Time, Year, Favorite, Rating, Plays, LastPlayed, Comment, BPM, Bitrate, Size, Path
|
// #, Title/Artist, Album, Composer, Time, Year, Favorite, Rating, Plays, LastPlayed, Comment, BPM, Bitrate, Size, DateAdded, Path
|
||||||
ExpandedTracklistRowColumnWidths = []float32{numColWidth, -1, -1, -1, timeColWidth, yearColWidth, favColWidth, ratingColWidth, playsColWidth, lastPlayedColWidth, -1, bpmColWidth, bitrateColWidth, sizeColWidth, -1}
|
ExpandedTracklistRowColumnWidths = []float32{numColWidth, -1, -1, -1, timeColWidth, yearColWidth, favColWidth, ratingColWidth, playsColWidth, lastPlayedColWidth, -1, bpmColWidth, bitrateColWidth, sizeColWidth, dateAddedColWidth, -1}
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -208,6 +216,7 @@ type tracklistRowBase struct {
|
|||||||
comment *ttwidget.Label
|
comment *ttwidget.Label
|
||||||
bpm *widget.Label
|
bpm *widget.Label
|
||||||
size *widget.Label
|
size *widget.Label
|
||||||
|
dateAdded *widget.Label
|
||||||
path *ttwidget.Label
|
path *ttwidget.Label
|
||||||
|
|
||||||
// must be injected by extending widget
|
// must be injected by extending widget
|
||||||
@@ -262,7 +271,7 @@ func NewExpandedTracklistRow(tracklist *Tracklist, im *backend.ImageManager, pla
|
|||||||
|
|
||||||
v := makeVerticallyCentered // func alias
|
v := makeVerticallyCentered // func alias
|
||||||
container := container.New(tracklist.colLayout,
|
container := container.New(tracklist.colLayout,
|
||||||
v(t.num), titleArtistImg, v(t.album), v(t.composer), v(t.dur), v(t.year), v(t.favorite), v(t.rating), v(t.plays), v(t.lastPlayed), v(t.comment), v(t.bpm), v(t.bitrate), v(t.size), v(t.path))
|
v(t.num), titleArtistImg, v(t.album), v(t.composer), v(t.dur), v(t.year), v(t.favorite), v(t.rating), v(t.plays), v(t.lastPlayed), v(t.comment), v(t.bpm), v(t.bitrate), v(t.size), v(t.dateAdded), v(t.path))
|
||||||
t.Content = container
|
t.Content = container
|
||||||
t.setColVisibility = func(colNum int, vis bool) bool {
|
t.setColVisibility = func(colNum int, vis bool) bool {
|
||||||
c := container.Objects[colNum].(*fyne.Container)
|
c := container.Objects[colNum].(*fyne.Container)
|
||||||
@@ -290,7 +299,7 @@ func NewCompactTracklistRow(tracklist *Tracklist, playingIcon fyne.CanvasObject)
|
|||||||
t.playingIcon = playingIcon
|
t.playingIcon = playingIcon
|
||||||
|
|
||||||
t.Content = container.New(tracklist.colLayout,
|
t.Content = container.New(tracklist.colLayout,
|
||||||
t.num, t.name, t.artist, t.album, t.composer, t.dur, t.year, t.favorite, t.rating, t.plays, t.lastPlayed, t.comment, t.bpm, t.bitrate, t.size, t.path)
|
t.num, t.name, t.artist, t.album, t.composer, t.dur, t.year, t.favorite, t.rating, t.plays, t.lastPlayed, t.comment, t.bpm, t.bitrate, t.size, t.dateAdded, t.path)
|
||||||
|
|
||||||
colHiddenPtrMap := map[int]*bool{
|
colHiddenPtrMap := map[int]*bool{
|
||||||
2: &t.artist.Hidden,
|
2: &t.artist.Hidden,
|
||||||
@@ -306,7 +315,8 @@ func NewCompactTracklistRow(tracklist *Tracklist, playingIcon fyne.CanvasObject)
|
|||||||
12: &t.bpm.Hidden,
|
12: &t.bpm.Hidden,
|
||||||
13: &t.bitrate.Hidden,
|
13: &t.bitrate.Hidden,
|
||||||
14: &t.size.Hidden,
|
14: &t.size.Hidden,
|
||||||
15: &t.path.Hidden,
|
15: &t.dateAdded.Hidden,
|
||||||
|
16: &t.path.Hidden,
|
||||||
}
|
}
|
||||||
t.setColVisibility = func(colNum int, vis bool) bool {
|
t.setColVisibility = func(colNum int, vis bool) bool {
|
||||||
ptr, ok := colHiddenPtrMap[colNum]
|
ptr, ok := colHiddenPtrMap[colNum]
|
||||||
@@ -355,6 +365,7 @@ func (t *tracklistRowBase) create(tracklist *Tracklist) {
|
|||||||
t.bpm = util.NewTrailingAlignLabel()
|
t.bpm = util.NewTrailingAlignLabel()
|
||||||
t.bitrate = util.NewTrailingAlignLabel()
|
t.bitrate = util.NewTrailingAlignLabel()
|
||||||
t.size = util.NewTrailingAlignLabel()
|
t.size = util.NewTrailingAlignLabel()
|
||||||
|
t.dateAdded = util.NewTruncatingLabel()
|
||||||
t.path = util.NewTruncatingTooltipLabel()
|
t.path = util.NewTruncatingTooltipLabel()
|
||||||
t.path.OnMouseIn = t.MouseIn
|
t.path.OnMouseIn = t.MouseIn
|
||||||
t.path.OnMouseOut = t.MouseOut
|
t.path.OnMouseOut = t.MouseOut
|
||||||
@@ -422,6 +433,7 @@ func (t *tracklistRowBase) doUpdate(tm *util.TrackListModel, rowNum int) {
|
|||||||
t.bpm.Text = strconv.Itoa(tr.BPM)
|
t.bpm.Text = strconv.Itoa(tr.BPM)
|
||||||
t.bitrate.Text = strconv.Itoa(tr.BitRate)
|
t.bitrate.Text = strconv.Itoa(tr.BitRate)
|
||||||
t.size.Text = util.BytesToSizeString(tr.Size)
|
t.size.Text = util.BytesToSizeString(tr.Size)
|
||||||
|
t.dateAdded.Text = util.FormatDate(tr.DateAdded)
|
||||||
t.path.Text = tr.FilePath
|
t.path.Text = tr.FilePath
|
||||||
t.path.SetToolTip(tr.FilePath)
|
t.path.SetToolTip(tr.FilePath)
|
||||||
changed = true
|
changed = true
|
||||||
|
|||||||
Reference in New Issue
Block a user