extend searchdialog / SearchResult to properly support headphone profiles

This commit is contained in:
Drew Weymouth
2026-02-06 08:27:52 -08:00
parent 7e3b102fa4
commit daf0440fbc
5 changed files with 41 additions and 15 deletions
+11 -1
View File
@@ -1,6 +1,10 @@
package mediaprovider package mediaprovider
import "time" import (
"time"
"fyne.io/fyne/v2"
)
// Bit field flag for the ReleaseTypes property // Bit field flag for the ReleaseTypes property
type ReleaseType = int32 type ReleaseType = int32
@@ -282,6 +286,7 @@ const (
ContentTypeTrack ContentTypeTrack
ContentTypeGenre ContentTypeGenre
ContentTypeRadioStation ContentTypeRadioStation
ContentTypeOther
) )
func (c ContentType) String() string { func (c ContentType) String() string {
@@ -298,6 +303,8 @@ func (c ContentType) String() string {
return "Genre" return "Genre"
case ContentTypeRadioStation: case ContentTypeRadioStation:
return "Radio station" return "Radio station"
case ContentTypeOther:
return "Other"
default: default:
return "Unknown" return "Unknown"
} }
@@ -309,6 +316,9 @@ type SearchResult struct {
CoverID string CoverID string
Type ContentType Type ContentType
// Optional icon to display instead of the default for this content type
Icon fyne.Resource
// for Album / Playlist: track count // for Album / Playlist: track count
// Artist / Genre: album count // Artist / Genre: album count
// Track: length (seconds) // Track: length (seconds)
+3 -1
View File
@@ -12,6 +12,7 @@ import (
"github.com/dweymouth/supersonic/backend" "github.com/dweymouth/supersonic/backend"
"github.com/dweymouth/supersonic/backend/mediaprovider" "github.com/dweymouth/supersonic/backend/mediaprovider"
"github.com/dweymouth/supersonic/sharedutil" "github.com/dweymouth/supersonic/sharedutil"
"github.com/dweymouth/supersonic/ui/theme"
"github.com/dweymouth/supersonic/ui/util" "github.com/dweymouth/supersonic/ui/util"
) )
@@ -70,8 +71,9 @@ func (ab *AutoEQBrowser) profileToSearchResult(profile backend.AutoEQProfileMeta
return &mediaprovider.SearchResult{ return &mediaprovider.SearchResult{
Name: profile.Name, Name: profile.Name,
Icon: theme.HeadphonesIcon, // Use headphone icon for all profiles
ID: profile.Path, // Store path as ID for retrieval ID: profile.Path, // Store path as ID for retrieval
Type: mediaprovider.ContentTypeAlbum, // Use album icon (looks like headphones) Type: mediaprovider.ContentTypeOther, // Use "Other" content type for AutoEQ profiles
ArtistName: subtitle, ArtistName: subtitle,
Size: 0, // Don't show track count Size: 0, // Don't show track count
} }
+15 -1
View File
@@ -272,7 +272,11 @@ func (s *searchResult) Update(result *mediaprovider.SearchResult) {
} }
s.id = result.ID s.id = result.ID
s.contentType = result.Type s.contentType = result.Type
if result.Icon != nil {
s.image.PlaceholderIcon = result.Icon
} else {
s.image.PlaceholderIcon = placeholderIconForContentType(result.Type) s.image.PlaceholderIcon = placeholderIconForContentType(result.Type)
}
s.imageLoader.Load(result.CoverID) s.imageLoader.Load(result.CoverID)
s.title.SetText(result.Name) s.title.SetText(result.Name)
@@ -300,19 +304,29 @@ func (s *searchResult) Update(result *mediaprovider.SearchResult) {
} else { } else {
secondaryText = "" secondaryText = ""
} }
case mediaprovider.ContentTypeOther:
secondaryText = result.ArtistName
} }
if result.Type == mediaprovider.ContentTypeOther {
s.secondary.Segments = []widget.RichTextSegment{}
} else {
s.secondary.Segments = []widget.RichTextSegment{ s.secondary.Segments = []widget.RichTextSegment{
&widget.TextSegment{ &widget.TextSegment{
Text: result.Type.String(), Text: result.Type.String(),
Style: widget.RichTextStyle{SizeName: theme.SizeNameCaptionText, TextStyle: fyne.TextStyle{Bold: true}, Inline: true}, Style: widget.RichTextStyle{SizeName: theme.SizeNameCaptionText, TextStyle: fyne.TextStyle{Bold: true}, Inline: true},
}, },
} }
}
if secondaryText != "" { if secondaryText != "" {
if len(s.secondary.Segments) > 0 {
s.secondary.Segments = append(s.secondary.Segments, s.secondary.Segments = append(s.secondary.Segments,
&widget.TextSegment{ &widget.TextSegment{
Text: " · ", Text: " · ",
Style: widget.RichTextStyle{SizeName: theme.SizeNameCaptionText, Inline: true}, Style: widget.RichTextStyle{SizeName: theme.SizeNameCaptionText, Inline: true},
}, })
}
s.secondary.Segments = append(s.secondary.Segments,
&widget.TextSegment{ &widget.TextSegment{
Text: secondaryText, Text: secondaryText,
Style: widget.RichTextStyle{SizeName: theme.SizeNameCaptionText, Inline: true}, Style: widget.RichTextStyle{SizeName: theme.SizeNameCaptionText, Inline: true},
+1 -1
View File
@@ -54,7 +54,7 @@ var (
RadioIcon fyne.Resource = theme.NewThemedResource(res.ResBroadcastSvg) RadioIcon fyne.Resource = theme.NewThemedResource(res.ResBroadcastSvg)
FavoriteIcon fyne.Resource = theme.NewThemedResource(res.ResHeartFilledSvg) FavoriteIcon fyne.Resource = theme.NewThemedResource(res.ResHeartFilledSvg)
NotFavoriteIcon fyne.Resource = theme.NewThemedResource(res.ResHeartOutlineSvg) NotFavoriteIcon fyne.Resource = theme.NewThemedResource(res.ResHeartOutlineSvg)
NowPlayingIcon fyne.Resource = theme.NewThemedResource(res.ResHeadphonesSvg) HeadphonesIcon fyne.Resource = theme.NewThemedResource(res.ResHeadphonesSvg)
PlaylistIcon fyne.Resource = theme.NewThemedResource(res.ResPlaylistSvg) PlaylistIcon fyne.Resource = theme.NewThemedResource(res.ResPlaylistSvg)
PlayNextIcon fyne.Resource = theme.NewThemedResource(res.ResPlaylistAddNextSvg) PlayNextIcon fyne.Resource = theme.NewThemedResource(res.ResPlaylistAddNextSvg)
PlayQueueIcon fyne.Resource = theme.NewThemedResource(res.ResPlayqueueSvg) PlayQueueIcon fyne.Resource = theme.NewThemedResource(res.ResPlayqueueSvg)
+1 -1
View File
@@ -146,7 +146,7 @@ func (t *Toolbar) CreateRenderer() fyne.WidgetRenderer {
} }
func (t *Toolbar) setupNavigationButtons(navigateFn func(controller.Route)) { func (t *Toolbar) setupNavigationButtons(navigateFn func(controller.Route)) {
t.addNavigationButton(myTheme.NowPlayingIcon, controller.NowPlaying, func() { t.addNavigationButton(myTheme.HeadphonesIcon, controller.NowPlaying, func() {
navigateFn(controller.NowPlayingRoute()) navigateFn(controller.NowPlayingRoute())
}) })
t.addNavigationButton(myTheme.FavoriteIcon, controller.Favorites, func() { t.addNavigationButton(myTheme.FavoriteIcon, controller.Favorites, func() {