Fix #316: Add setting to show notification on track change

This commit is contained in:
Drew Weymouth
2024-01-20 14:42:22 -08:00
parent edc3ef7bfa
commit 91aa92706d
3 changed files with 40 additions and 27 deletions
+2
View File
@@ -43,6 +43,7 @@ type AppConfig struct {
MaxImageCacheSizeMB int MaxImageCacheSizeMB int
SavePlayQueue bool SavePlayQueue bool
DefaultPlaylistID string DefaultPlaylistID string
ShowTrackChangeNotification bool
// Experimental - may be removed in future // Experimental - may be removed in future
FontNormalTTF string FontNormalTTF string
@@ -150,6 +151,7 @@ func DefaultConfig(appVersionTag string) *Config {
MaxImageCacheSizeMB: 50, MaxImageCacheSizeMB: 50,
UIScaleSize: "Normal", UIScaleSize: "Normal",
SavePlayQueue: false, SavePlayQueue: false,
ShowTrackChangeNotification: false,
}, },
AlbumPage: AlbumPageConfig{ AlbumPage: AlbumPageConfig{
TracklistColumns: []string{"Artist", "Time", "Plays", "Favorite", "Rating"}, TracklistColumns: []string{"Artist", "Time", "Plays", "Favorite", "Rating"},
+3
View File
@@ -161,6 +161,8 @@ func (s *SettingsDialog) createGeneralTab() *container.TabItem {
saveQueue := widget.NewCheckWithData("Save play queue on exit", saveQueue := widget.NewCheckWithData("Save play queue on exit",
binding.BindBool(&s.config.Application.SavePlayQueue)) binding.BindBool(&s.config.Application.SavePlayQueue))
trackNotif := widget.NewCheckWithData("Show notification on track change",
binding.BindBool(&s.config.Application.ShowTrackChangeNotification))
// Scrobble settings // Scrobble settings
@@ -251,6 +253,7 @@ func (s *SettingsDialog) createGeneralTab() *container.TabItem {
), ),
container.NewHBox(systemTrayEnable, closeToTray), container.NewHBox(systemTrayEnable, closeToTray),
container.NewHBox(saveQueue), container.NewHBox(saveQueue),
container.NewHBox(trackNotif),
s.newSectionSeparator(), s.newSectionSeparator(),
widget.NewRichText(&widget.TextSegment{Text: "Scrobbling", Style: util.BoldRichTextStyle}), widget.NewRichText(&widget.TextSegment{Text: "Scrobbling", Style: util.BoldRichTextStyle}),
+11 -3
View File
@@ -85,12 +85,20 @@ func NewMainWindow(fyneApp fyne.App, appName, displayAppName, appVersion string,
m.container = container.NewBorder(nil, m.BottomPanel, nil, nil, m.BrowsingPane) m.container = container.NewBorder(nil, m.BottomPanel, nil, nil, m.BrowsingPane)
m.Window.SetContent(m.container) m.Window.SetContent(m.container)
m.Window.Resize(size) m.Window.Resize(size)
app.PlaybackManager.OnSongChange(func(song, _ *mediaprovider.Track) { app.PlaybackManager.OnSongChange(func(track, _ *mediaprovider.Track) {
if song == nil { if track == nil {
m.Window.SetTitle(displayAppName) m.Window.SetTitle(displayAppName)
return return
} }
m.Window.SetTitle(fmt.Sprintf("%s %s · %s", song.Name, strings.Join(song.ArtistNames, ", "), displayAppName)) artistDisp := strings.Join(track.ArtistNames, ", ")
m.Window.SetTitle(fmt.Sprintf("%s %s · %s", track.Name, artistDisp, displayAppName))
if m.App.Config.Application.ShowTrackChangeNotification {
// TODO: Once Fyne issue #2935 is resolved, show album cover
fyne.CurrentApp().SendNotification(&fyne.Notification{
Title: track.Name,
Content: artistDisp,
})
}
}) })
app.ServerManager.OnServerConnected(func() { app.ServerManager.OnServerConnected(func() {
m.RunOnServerConnectedTasks(app, displayAppName) m.RunOnServerConnectedTasks(app, displayAppName)