add more info to dialog and adjust layout
This commit is contained in:
@@ -102,7 +102,17 @@ type Track struct {
|
||||
PlayCount int
|
||||
FilePath string
|
||||
BitRate int
|
||||
ContentType string
|
||||
Comment string
|
||||
BPM int
|
||||
ReplayGain ReplayGainInfo
|
||||
}
|
||||
|
||||
type ReplayGainInfo struct {
|
||||
TrackGain float64
|
||||
AlbumGain float64
|
||||
TrackPeak float64
|
||||
AlbumPeak float64
|
||||
}
|
||||
|
||||
type Playlist struct {
|
||||
|
||||
@@ -493,6 +493,13 @@ func toTrack(ch *subsonic.Child) *mediaprovider.Track {
|
||||
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{
|
||||
ID: ch.ID,
|
||||
CoverArtID: ch.CoverArt,
|
||||
@@ -513,7 +520,9 @@ func toTrack(ch *subsonic.Child) *mediaprovider.Track {
|
||||
FilePath: ch.Path,
|
||||
Size: ch.Size,
|
||||
BitRate: ch.BitRate,
|
||||
ContentType: ch.ContentType,
|
||||
Comment: ch.Comment,
|
||||
BPM: ch.BPM,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ require (
|
||||
github.com/dweymouth/fyne-lyrics v0.0.0-20240528234907-15eee7ce5e64
|
||||
github.com/dweymouth/go-jellyfin v0.0.0-20240517151952-5ceca61cb645
|
||||
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/google/uuid v1.3.0
|
||||
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-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-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.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package dialogs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
@@ -30,8 +31,8 @@ func NewTrackInfoDialog(track *mediaprovider.Track) *TrackInfoDialog {
|
||||
|
||||
func (t *TrackInfoDialog) CreateRenderer() fyne.WidgetRenderer {
|
||||
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))
|
||||
artists := widgets.NewMultiHyperlink()
|
||||
@@ -52,29 +53,55 @@ func (t *TrackInfoDialog) CreateRenderer() fyne.WidgetRenderer {
|
||||
}
|
||||
c.Add(album)
|
||||
|
||||
c.Add(newFormText("File Path", true))
|
||||
path := widgets.NewMaxRowsLabel(2, t.track.FilePath)
|
||||
//path.Segments[0].(*widget.TextSegment).Style.SizeName = myTheme.SizeNameSubText
|
||||
path.Wrapping = fyne.TextWrapWord
|
||||
path.Truncation = fyne.TextTruncateEllipsis
|
||||
c.Add(path)
|
||||
addFormRow(c, "Duration", util.SecondsToTimeString(float64(t.track.Duration)))
|
||||
addFormRow(c, "File path", t.track.FilePath)
|
||||
addFormRow(c, "Comment", t.track.Comment)
|
||||
addFormRow(c, "Year", strconv.Itoa(t.track.Year))
|
||||
addFormRow(c, "Track number", strconv.Itoa(t.track.TrackNumber))
|
||||
addFormRow(c, "Disc number", strconv.Itoa(t.track.DiscNumber))
|
||||
|
||||
c.Add(newFormText("Comment", true))
|
||||
c.Add(newFormText(t.track.Comment, false))
|
||||
if t.track.BPM > 0 {
|
||||
addFormRow(c, "BPM", strconv.Itoa(t.track.BPM))
|
||||
}
|
||||
|
||||
c.Add(newFormText("Year", true))
|
||||
c.Add(newFormText(strconv.Itoa(t.track.Year), false))
|
||||
addFormRow(c, "Content type", t.track.ContentType)
|
||||
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))
|
||||
c.Add(newFormText(strconv.Itoa(t.track.BitRate)+"kbps", false))
|
||||
if t.track.ReplayGain.TrackPeak > 0 {
|
||||
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))
|
||||
c.Add(newFormText(util.BytesToSizeString(t.track.Size), false))
|
||||
title := widget.NewRichTextWithText("Track Info")
|
||||
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))
|
||||
c.Add(newFormText(strconv.Itoa(t.track.PlayCount), false))
|
||||
return widget.NewSimpleRenderer(
|
||||
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 {
|
||||
@@ -82,7 +109,7 @@ func newFormText(text string, leftCol bool) *widget.RichText {
|
||||
if leftCol {
|
||||
alignment = fyne.TextAlignTrailing
|
||||
}
|
||||
return widget.NewRichText(
|
||||
rt := widget.NewRichText(
|
||||
&widget.TextSegment{
|
||||
Text: text,
|
||||
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