Fix #316: Add setting to show notification on track change
This commit is contained in:
+26
-24
@@ -31,18 +31,19 @@ type ServerConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type AppConfig struct {
|
type AppConfig struct {
|
||||||
WindowWidth int
|
WindowWidth int
|
||||||
WindowHeight int
|
WindowHeight int
|
||||||
LastCheckedVersion string
|
LastCheckedVersion string
|
||||||
LastLaunchedVersion string
|
LastLaunchedVersion string
|
||||||
EnableSystemTray bool
|
EnableSystemTray bool
|
||||||
CloseToSystemTray bool
|
CloseToSystemTray bool
|
||||||
StartupPage string
|
StartupPage string
|
||||||
SettingsTab string
|
SettingsTab string
|
||||||
AllowMultiInstance bool
|
AllowMultiInstance bool
|
||||||
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
|
||||||
@@ -138,18 +139,19 @@ var SupportedStartupPages = []string{"Albums", "Favorites", "Playlists"}
|
|||||||
func DefaultConfig(appVersionTag string) *Config {
|
func DefaultConfig(appVersionTag string) *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
Application: AppConfig{
|
Application: AppConfig{
|
||||||
WindowWidth: 1000,
|
WindowWidth: 1000,
|
||||||
WindowHeight: 800,
|
WindowHeight: 800,
|
||||||
LastCheckedVersion: appVersionTag,
|
LastCheckedVersion: appVersionTag,
|
||||||
LastLaunchedVersion: "",
|
LastLaunchedVersion: "",
|
||||||
EnableSystemTray: true,
|
EnableSystemTray: true,
|
||||||
CloseToSystemTray: false,
|
CloseToSystemTray: false,
|
||||||
StartupPage: "Albums",
|
StartupPage: "Albums",
|
||||||
SettingsTab: "General",
|
SettingsTab: "General",
|
||||||
AllowMultiInstance: false,
|
AllowMultiInstance: false,
|
||||||
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"},
|
||||||
|
|||||||
@@ -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
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user