Fix #55: show disc number and disc count for multi-disc albums

This commit is contained in:
Drew Weymouth
2023-04-09 13:14:39 -07:00
parent ca6792cb41
commit aee6221691
3 changed files with 24 additions and 3 deletions
+1
View File
@@ -11,6 +11,7 @@
- **todo-commithash** Don't show update available prompt if the found version is the same as the running app version
- [#120](https://github.com/dweymouth/supersonic/issues/120),[#87](https://github.com/dweymouth/supersonic/issues/87) Update Mac build process to support OS versions back to High Sierra (thanks @whorfin!)
- [#125](https://github.com/dweymouth/supersonic/issues/125) Navigating back twice to an albums page with search result clears search state
- [#55](https://github.com/dweymouth/supersonic/issues/55) Show disc number and disc count for multi-disc albums
## [0.1.0-beta] - 2023-04-01
+6 -1
View File
@@ -121,6 +121,7 @@ func (a *AlbumPage) load() {
return
}
a.header.Update(album, a.im)
a.tracklist.ShowDiscNumber = album.Song[0].DiscNumber != album.Song[len(album.Song)-1].DiscNumber
a.tracklist.Tracks = album.Song
a.tracklist.SetNowPlaying(a.nowPlayingID)
}
@@ -236,7 +237,11 @@ func (a *AlbumPageHeader) showPopUpCover() {
}
func formatMiscLabelStr(a *subsonic.AlbumID3) string {
return fmt.Sprintf("%d · %d tracks · %s", a.Year, a.SongCount, util.SecondsToTimeString(float64(a.Duration)))
var discs string
if discCount := a.Song[len(a.Song)-1].DiscNumber; discCount > 1 {
discs = fmt.Sprintf("%d discs · ", discCount)
}
return fmt.Sprintf("%d · %d tracks · %s%s", a.Year, a.SongCount, discs, util.SecondsToTimeString(float64(a.Duration)))
}
func (s *albumPageState) Restore() Page {
+17 -2
View File
@@ -1,6 +1,7 @@
package widgets
import (
"fmt"
"log"
"strconv"
"supersonic/res"
@@ -40,6 +41,10 @@ type Tracklist struct {
// or to use the number from the track's metadata
AutoNumber bool
// ShowDiscNumber sets whether to display the disc number as part of the '#' column,
// (with format %d.%02d). Only applies if AutoNumber==false.
ShowDiscNumber bool
// AuxiliaryMenuItems sets additional menu items appended to the context menu
// must be set before the context menu is shown for the first time
AuxiliaryMenuItems []*fyne.MenuItem
@@ -77,7 +82,7 @@ func NewTracklist(tracks []*subsonic.Child) *Tracklist {
t.ExtendBaseWidget(t)
t.selectionMgr = util.NewListSelectionManager(func() int { return len(t.Tracks) })
// #, Title, Artist, Album, Time, Year, Favorite, Plays, Bitrate, Size, Path
t.colLayout = layouts.NewColumnsLayout([]float32{35, -1, -1, -1, 60, 60, 47, 65, 75, 70, -1})
t.colLayout = layouts.NewColumnsLayout([]float32{40, -1, -1, -1, 60, 60, 47, 65, 75, 70, -1})
t.buildHeader()
t.hdr.OnColumnVisibilityChanged = t.setColumnVisible
t.hdr.OnColumnVisibilityMenuShown = func(pop *widget.PopUp) {
@@ -438,11 +443,21 @@ func (t *TrackRow) Update(tr *subsonic.Child, isPlaying bool, rowNum int) {
// Update track num if needed
// (which can change based on bound *subsonic.Child or tracklist.AutoNumber)
if t.trackNum != rowNum {
discNum := -1
var str string
if rowNum < 0 {
rowNum = tr.Track
if t.tracklist.ShowDiscNumber {
discNum = tr.DiscNumber
}
}
t.trackNum = rowNum
t.num.Segments[0].(*widget.TextSegment).Text = strconv.Itoa(rowNum)
if discNum >= 0 {
str = fmt.Sprintf("%d.%02d", discNum, rowNum)
} else {
str = strconv.Itoa(rowNum)
}
t.num.Segments[0].(*widget.TextSegment).Text = str
}
// Update play count if needed