add more info to dialog and adjust layout
This commit is contained in:
@@ -102,7 +102,17 @@ type Track struct {
|
|||||||
PlayCount int
|
PlayCount int
|
||||||
FilePath string
|
FilePath string
|
||||||
BitRate int
|
BitRate int
|
||||||
|
ContentType string
|
||||||
Comment string
|
Comment string
|
||||||
|
BPM int
|
||||||
|
ReplayGain ReplayGainInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
type ReplayGainInfo struct {
|
||||||
|
TrackGain float64
|
||||||
|
AlbumGain float64
|
||||||
|
TrackPeak float64
|
||||||
|
AlbumPeak float64
|
||||||
}
|
}
|
||||||
|
|
||||||
type Playlist struct {
|
type Playlist struct {
|
||||||
|
|||||||
@@ -493,6 +493,13 @@ func toTrack(ch *subsonic.Child) *mediaprovider.Track {
|
|||||||
artistIDs = append(artistIDs, ch.ArtistID)
|
artistIDs = append(artistIDs, ch.ArtistID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var rGain mediaprovider.ReplayGainInfo
|
||||||
|
if rg := ch.ReplayGain; rg != nil {
|
||||||
|
rGain.AlbumGain = rg.AlbumGain
|
||||||
|
rGain.TrackGain = rg.TrackGain
|
||||||
|
rGain.AlbumPeak = rg.AlbumPeak
|
||||||
|
rGain.TrackPeak = rg.TrackPeak
|
||||||
|
}
|
||||||
return &mediaprovider.Track{
|
return &mediaprovider.Track{
|
||||||
ID: ch.ID,
|
ID: ch.ID,
|
||||||
CoverArtID: ch.CoverArt,
|
CoverArtID: ch.CoverArt,
|
||||||
@@ -513,7 +520,9 @@ func toTrack(ch *subsonic.Child) *mediaprovider.Track {
|
|||||||
FilePath: ch.Path,
|
FilePath: ch.Path,
|
||||||
Size: ch.Size,
|
Size: ch.Size,
|
||||||
BitRate: ch.BitRate,
|
BitRate: ch.BitRate,
|
||||||
|
ContentType: ch.ContentType,
|
||||||
Comment: ch.Comment,
|
Comment: ch.Comment,
|
||||||
|
BPM: ch.BPM,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ require (
|
|||||||
github.com/dweymouth/fyne-lyrics v0.0.0-20240528234907-15eee7ce5e64
|
github.com/dweymouth/fyne-lyrics v0.0.0-20240528234907-15eee7ce5e64
|
||||||
github.com/dweymouth/go-jellyfin v0.0.0-20240517151952-5ceca61cb645
|
github.com/dweymouth/go-jellyfin v0.0.0-20240517151952-5ceca61cb645
|
||||||
github.com/dweymouth/go-mpv v0.0.0-20230406003141-7f1858e503ee
|
github.com/dweymouth/go-mpv v0.0.0-20230406003141-7f1858e503ee
|
||||||
github.com/dweymouth/go-subsonic v0.0.0-20240603150834-605046e7c78a
|
github.com/dweymouth/go-subsonic v0.0.0-20240716154859-c40a4519e1e0
|
||||||
github.com/godbus/dbus/v5 v5.1.0
|
github.com/godbus/dbus/v5 v5.1.0
|
||||||
github.com/google/uuid v1.3.0
|
github.com/google/uuid v1.3.0
|
||||||
github.com/pelletier/go-toml/v2 v2.0.8
|
github.com/pelletier/go-toml/v2 v2.0.8
|
||||||
|
|||||||
@@ -87,6 +87,8 @@ github.com/dweymouth/go-mpv v0.0.0-20230406003141-7f1858e503ee h1:ZGyJ6wp7CAfT31
|
|||||||
github.com/dweymouth/go-mpv v0.0.0-20230406003141-7f1858e503ee/go.mod h1:Ov0ieN90M7i+0k3OxhA/g1dozGs+UcPHDsMKqPgRDk0=
|
github.com/dweymouth/go-mpv v0.0.0-20230406003141-7f1858e503ee/go.mod h1:Ov0ieN90M7i+0k3OxhA/g1dozGs+UcPHDsMKqPgRDk0=
|
||||||
github.com/dweymouth/go-subsonic v0.0.0-20240603150834-605046e7c78a h1:jcHDGzvpsyvEt8i0vqB92jHIfWJUt106QITrPoYjSWo=
|
github.com/dweymouth/go-subsonic v0.0.0-20240603150834-605046e7c78a h1:jcHDGzvpsyvEt8i0vqB92jHIfWJUt106QITrPoYjSWo=
|
||||||
github.com/dweymouth/go-subsonic v0.0.0-20240603150834-605046e7c78a/go.mod h1:OWtcumdQsan8uM6wmx6PqKhldaCthH10CQ+vb+94kzo=
|
github.com/dweymouth/go-subsonic v0.0.0-20240603150834-605046e7c78a/go.mod h1:OWtcumdQsan8uM6wmx6PqKhldaCthH10CQ+vb+94kzo=
|
||||||
|
github.com/dweymouth/go-subsonic v0.0.0-20240716154859-c40a4519e1e0 h1:Zf27NWT1N889/toYK7/x7y7ERw8iJfAHBHGiMyYxaLY=
|
||||||
|
github.com/dweymouth/go-subsonic v0.0.0-20240716154859-c40a4519e1e0/go.mod h1:OWtcumdQsan8uM6wmx6PqKhldaCthH10CQ+vb+94kzo=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dialogs
|
package dialogs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"fyne.io/fyne/v2"
|
"fyne.io/fyne/v2"
|
||||||
@@ -30,8 +31,8 @@ func NewTrackInfoDialog(track *mediaprovider.Track) *TrackInfoDialog {
|
|||||||
|
|
||||||
func (t *TrackInfoDialog) CreateRenderer() fyne.WidgetRenderer {
|
func (t *TrackInfoDialog) CreateRenderer() fyne.WidgetRenderer {
|
||||||
c := container.New(layout.NewFormLayout())
|
c := container.New(layout.NewFormLayout())
|
||||||
c.Add(newFormText("Title", true))
|
|
||||||
c.Add(newFormText(t.track.Title, false))
|
addFormRow(c, "Title", t.track.Title)
|
||||||
|
|
||||||
c.Add(newFormText("Artist", true))
|
c.Add(newFormText("Artist", true))
|
||||||
artists := widgets.NewMultiHyperlink()
|
artists := widgets.NewMultiHyperlink()
|
||||||
@@ -52,29 +53,55 @@ func (t *TrackInfoDialog) CreateRenderer() fyne.WidgetRenderer {
|
|||||||
}
|
}
|
||||||
c.Add(album)
|
c.Add(album)
|
||||||
|
|
||||||
c.Add(newFormText("File Path", true))
|
addFormRow(c, "Duration", util.SecondsToTimeString(float64(t.track.Duration)))
|
||||||
path := widgets.NewMaxRowsLabel(2, t.track.FilePath)
|
addFormRow(c, "File path", t.track.FilePath)
|
||||||
//path.Segments[0].(*widget.TextSegment).Style.SizeName = myTheme.SizeNameSubText
|
addFormRow(c, "Comment", t.track.Comment)
|
||||||
path.Wrapping = fyne.TextWrapWord
|
addFormRow(c, "Year", strconv.Itoa(t.track.Year))
|
||||||
path.Truncation = fyne.TextTruncateEllipsis
|
addFormRow(c, "Track number", strconv.Itoa(t.track.TrackNumber))
|
||||||
c.Add(path)
|
addFormRow(c, "Disc number", strconv.Itoa(t.track.DiscNumber))
|
||||||
|
|
||||||
c.Add(newFormText("Comment", true))
|
if t.track.BPM > 0 {
|
||||||
c.Add(newFormText(t.track.Comment, false))
|
addFormRow(c, "BPM", strconv.Itoa(t.track.BPM))
|
||||||
|
}
|
||||||
|
|
||||||
c.Add(newFormText("Year", true))
|
addFormRow(c, "Content type", t.track.ContentType)
|
||||||
c.Add(newFormText(strconv.Itoa(t.track.Year), false))
|
addFormRow(c, "Bit rate", fmt.Sprintf("%d kbps", t.track.BitRate))
|
||||||
|
addFormRow(c, "File size", util.BytesToSizeString(t.track.Size))
|
||||||
|
addFormRow(c, "Play count", strconv.Itoa(t.track.PlayCount))
|
||||||
|
|
||||||
c.Add(newFormText("Bit Rate", true))
|
if t.track.ReplayGain.TrackPeak > 0 {
|
||||||
c.Add(newFormText(strconv.Itoa(t.track.BitRate)+"kbps", false))
|
addFormRow(c, "Track gain", fmt.Sprintf("%0.2f dB", t.track.ReplayGain.TrackGain))
|
||||||
|
addFormRow(c, "Track peak", fmt.Sprintf("%0.6f", t.track.ReplayGain.TrackPeak))
|
||||||
|
}
|
||||||
|
if t.track.ReplayGain.AlbumPeak > 0 {
|
||||||
|
addFormRow(c, "Album gain", fmt.Sprintf("%0.2f dB", t.track.ReplayGain.AlbumGain))
|
||||||
|
addFormRow(c, "Album peak", fmt.Sprintf("%0.6f", t.track.ReplayGain.AlbumPeak))
|
||||||
|
}
|
||||||
|
|
||||||
c.Add(newFormText("File Size", true))
|
title := widget.NewRichTextWithText("Track Info")
|
||||||
c.Add(newFormText(util.BytesToSizeString(t.track.Size), false))
|
title.Segments[0].(*widget.TextSegment).Style.TextStyle.Bold = true
|
||||||
|
dismissBtn := widget.NewButton("Close", func() {
|
||||||
|
if t.OnDismiss != nil {
|
||||||
|
t.OnDismiss()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
c.Add(newFormText("Play Count", true))
|
return widget.NewSimpleRenderer(
|
||||||
c.Add(newFormText(strconv.Itoa(t.track.PlayCount), false))
|
container.NewBorder(
|
||||||
|
/*top*/ container.NewHBox(layout.NewSpacer(), title, layout.NewSpacer()),
|
||||||
|
/*bottom*/ container.NewVBox(
|
||||||
|
widget.NewSeparator(),
|
||||||
|
container.NewHBox(layout.NewSpacer(), dismissBtn),
|
||||||
|
),
|
||||||
|
/*left/right*/ nil, nil,
|
||||||
|
/*center*/ container.NewScroll(c),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return widget.NewSimpleRenderer(c)
|
func addFormRow(c *fyne.Container, left, right string) {
|
||||||
|
c.Add(newFormText(left, true))
|
||||||
|
c.Add(newFormText(right, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
func newFormText(text string, leftCol bool) *widget.RichText {
|
func newFormText(text string, leftCol bool) *widget.RichText {
|
||||||
@@ -82,7 +109,7 @@ func newFormText(text string, leftCol bool) *widget.RichText {
|
|||||||
if leftCol {
|
if leftCol {
|
||||||
alignment = fyne.TextAlignTrailing
|
alignment = fyne.TextAlignTrailing
|
||||||
}
|
}
|
||||||
return widget.NewRichText(
|
rt := widget.NewRichText(
|
||||||
&widget.TextSegment{
|
&widget.TextSegment{
|
||||||
Text: text,
|
Text: text,
|
||||||
Style: widget.RichTextStyle{
|
Style: widget.RichTextStyle{
|
||||||
@@ -91,4 +118,8 @@ func newFormText(text string, leftCol bool) *widget.RichText {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
if !leftCol {
|
||||||
|
rt.Wrapping = fyne.TextWrapWord
|
||||||
|
}
|
||||||
|
return rt
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user