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 {
|
||||
WindowWidth int
|
||||
WindowHeight int
|
||||
LastCheckedVersion string
|
||||
LastLaunchedVersion string
|
||||
EnableSystemTray bool
|
||||
CloseToSystemTray bool
|
||||
StartupPage string
|
||||
SettingsTab string
|
||||
AllowMultiInstance bool
|
||||
MaxImageCacheSizeMB int
|
||||
SavePlayQueue bool
|
||||
DefaultPlaylistID string
|
||||
WindowWidth int
|
||||
WindowHeight int
|
||||
LastCheckedVersion string
|
||||
LastLaunchedVersion string
|
||||
EnableSystemTray bool
|
||||
CloseToSystemTray bool
|
||||
StartupPage string
|
||||
SettingsTab string
|
||||
AllowMultiInstance bool
|
||||
MaxImageCacheSizeMB int
|
||||
SavePlayQueue bool
|
||||
DefaultPlaylistID string
|
||||
ShowTrackChangeNotification bool
|
||||
|
||||
// Experimental - may be removed in future
|
||||
FontNormalTTF string
|
||||
@@ -138,18 +139,19 @@ var SupportedStartupPages = []string{"Albums", "Favorites", "Playlists"}
|
||||
func DefaultConfig(appVersionTag string) *Config {
|
||||
return &Config{
|
||||
Application: AppConfig{
|
||||
WindowWidth: 1000,
|
||||
WindowHeight: 800,
|
||||
LastCheckedVersion: appVersionTag,
|
||||
LastLaunchedVersion: "",
|
||||
EnableSystemTray: true,
|
||||
CloseToSystemTray: false,
|
||||
StartupPage: "Albums",
|
||||
SettingsTab: "General",
|
||||
AllowMultiInstance: false,
|
||||
MaxImageCacheSizeMB: 50,
|
||||
UIScaleSize: "Normal",
|
||||
SavePlayQueue: false,
|
||||
WindowWidth: 1000,
|
||||
WindowHeight: 800,
|
||||
LastCheckedVersion: appVersionTag,
|
||||
LastLaunchedVersion: "",
|
||||
EnableSystemTray: true,
|
||||
CloseToSystemTray: false,
|
||||
StartupPage: "Albums",
|
||||
SettingsTab: "General",
|
||||
AllowMultiInstance: false,
|
||||
MaxImageCacheSizeMB: 50,
|
||||
UIScaleSize: "Normal",
|
||||
SavePlayQueue: false,
|
||||
ShowTrackChangeNotification: false,
|
||||
},
|
||||
AlbumPage: AlbumPageConfig{
|
||||
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",
|
||||
binding.BindBool(&s.config.Application.SavePlayQueue))
|
||||
trackNotif := widget.NewCheckWithData("Show notification on track change",
|
||||
binding.BindBool(&s.config.Application.ShowTrackChangeNotification))
|
||||
|
||||
// Scrobble settings
|
||||
|
||||
@@ -251,6 +253,7 @@ func (s *SettingsDialog) createGeneralTab() *container.TabItem {
|
||||
),
|
||||
container.NewHBox(systemTrayEnable, closeToTray),
|
||||
container.NewHBox(saveQueue),
|
||||
container.NewHBox(trackNotif),
|
||||
s.newSectionSeparator(),
|
||||
|
||||
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.Window.SetContent(m.container)
|
||||
m.Window.Resize(size)
|
||||
app.PlaybackManager.OnSongChange(func(song, _ *mediaprovider.Track) {
|
||||
if song == nil {
|
||||
app.PlaybackManager.OnSongChange(func(track, _ *mediaprovider.Track) {
|
||||
if track == nil {
|
||||
m.Window.SetTitle(displayAppName)
|
||||
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() {
|
||||
m.RunOnServerConnectedTasks(app, displayAppName)
|
||||
|
||||
Reference in New Issue
Block a user