persist favorites page view settings
This commit is contained in:
+12
-2
@@ -24,6 +24,11 @@ type AlbumPageConfig struct {
|
|||||||
TracklistColumns []string
|
TracklistColumns []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type FavoritesPageConfig struct {
|
||||||
|
InitialView string
|
||||||
|
TracklistColumns []string
|
||||||
|
}
|
||||||
|
|
||||||
type NowPlayingPageConfig struct {
|
type NowPlayingPageConfig struct {
|
||||||
TracklistColumns []string
|
TracklistColumns []string
|
||||||
}
|
}
|
||||||
@@ -40,6 +45,7 @@ type Config struct {
|
|||||||
Application AppConfig
|
Application AppConfig
|
||||||
Servers []*ServerConfig
|
Servers []*ServerConfig
|
||||||
AlbumPage AlbumPageConfig
|
AlbumPage AlbumPageConfig
|
||||||
|
FavoritesPage FavoritesPageConfig
|
||||||
NowPlayingPage NowPlayingPageConfig
|
NowPlayingPage NowPlayingPageConfig
|
||||||
PlaylistPage PlaylistPageConfig
|
PlaylistPage PlaylistPageConfig
|
||||||
LocalPlayback LocalPlaybackConfig
|
LocalPlayback LocalPlaybackConfig
|
||||||
@@ -52,10 +58,14 @@ func DefaultConfig() *Config {
|
|||||||
WindowHeight: 800,
|
WindowHeight: 800,
|
||||||
},
|
},
|
||||||
AlbumPage: AlbumPageConfig{
|
AlbumPage: AlbumPageConfig{
|
||||||
TracklistColumns: []string{"Artist", "Time", "Plays"},
|
TracklistColumns: []string{"Artist", "Time", "Plays", "Favorite"},
|
||||||
|
},
|
||||||
|
FavoritesPage: FavoritesPageConfig{
|
||||||
|
TracklistColumns: []string{"Artist", "Album", "Time", "Plays"},
|
||||||
|
InitialView: "Albums",
|
||||||
},
|
},
|
||||||
NowPlayingPage: NowPlayingPageConfig{
|
NowPlayingPage: NowPlayingPageConfig{
|
||||||
TracklistColumns: []string{"Artist", "Album", "Time"},
|
TracklistColumns: []string{"Artist", "Album", "Time", "Plays"},
|
||||||
},
|
},
|
||||||
PlaylistPage: PlaylistPageConfig{
|
PlaylistPage: PlaylistPageConfig{
|
||||||
TracklistColumns: []string{"Artist", "Album", "Time", "Plays"},
|
TracklistColumns: []string{"Artist", "Album", "Time", "Plays"},
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import (
|
|||||||
type FavoritesPage struct {
|
type FavoritesPage struct {
|
||||||
widget.BaseWidget
|
widget.BaseWidget
|
||||||
|
|
||||||
|
cfg *backend.FavoritesPageConfig
|
||||||
contr controller.Controller
|
contr controller.Controller
|
||||||
pm *backend.PlaybackManager
|
pm *backend.PlaybackManager
|
||||||
im *backend.ImageManager
|
im *backend.ImageManager
|
||||||
@@ -41,8 +42,9 @@ type FavoritesPage struct {
|
|||||||
container *fyne.Container
|
container *fyne.Container
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewFavoritesPage(contr controller.Controller, sm *backend.ServerManager, pm *backend.PlaybackManager, lm *backend.LibraryManager, im *backend.ImageManager, nav func(Route)) *FavoritesPage {
|
func NewFavoritesPage(cfg *backend.FavoritesPageConfig, contr controller.Controller, sm *backend.ServerManager, pm *backend.PlaybackManager, lm *backend.LibraryManager, im *backend.ImageManager, nav func(Route)) *FavoritesPage {
|
||||||
a := &FavoritesPage{
|
a := &FavoritesPage{
|
||||||
|
cfg: cfg,
|
||||||
contr: contr,
|
contr: contr,
|
||||||
pm: pm,
|
pm: pm,
|
||||||
lm: lm,
|
lm: lm,
|
||||||
@@ -55,6 +57,13 @@ func NewFavoritesPage(contr controller.Controller, sm *backend.ServerManager, pm
|
|||||||
a.grid = widgets.NewAlbumGrid(a.lm.StarredIter(), a.im, false)
|
a.grid = widgets.NewAlbumGrid(a.lm.StarredIter(), a.im, false)
|
||||||
a.connectGridActions()
|
a.connectGridActions()
|
||||||
a.createContainer(false)
|
a.createContainer(false)
|
||||||
|
if cfg.InitialView == "Artists" {
|
||||||
|
a.toggleBtns.SetActivatedButton(1)
|
||||||
|
a.onShowFavoriteArtists()
|
||||||
|
} else if cfg.InitialView == "Songs" {
|
||||||
|
a.toggleBtns.SetActivatedButton(2)
|
||||||
|
a.onShowFavoriteSongs()
|
||||||
|
}
|
||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,6 +100,7 @@ func (a *FavoritesPage) createContainer(searchGrid bool) {
|
|||||||
|
|
||||||
func restoreFavoritesPage(saved *savedFavoritesPage) *FavoritesPage {
|
func restoreFavoritesPage(saved *savedFavoritesPage) *FavoritesPage {
|
||||||
a := &FavoritesPage{
|
a := &FavoritesPage{
|
||||||
|
cfg: saved.cfg,
|
||||||
contr: saved.contr,
|
contr: saved.contr,
|
||||||
pm: saved.pm,
|
pm: saved.pm,
|
||||||
lm: saved.lm,
|
lm: saved.lm,
|
||||||
@@ -158,7 +168,12 @@ func (a *FavoritesPage) Reload() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *FavoritesPage) Save() SavedPage {
|
func (a *FavoritesPage) Save() SavedPage {
|
||||||
|
if a.tracklistCtr != nil {
|
||||||
|
tl := a.tracklistCtr.Objects[0].(*widgets.Tracklist)
|
||||||
|
a.cfg.TracklistColumns = tl.VisibleColumns()
|
||||||
|
}
|
||||||
sf := &savedFavoritesPage{
|
sf := &savedFavoritesPage{
|
||||||
|
cfg: a.cfg,
|
||||||
contr: a.contr,
|
contr: a.contr,
|
||||||
pm: a.pm,
|
pm: a.pm,
|
||||||
sm: a.sm,
|
sm: a.sm,
|
||||||
@@ -223,6 +238,7 @@ func (a *FavoritesPage) doSearchAlbums(query string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *FavoritesPage) onShowFavoriteAlbums() {
|
func (a *FavoritesPage) onShowFavoriteAlbums() {
|
||||||
|
a.cfg.InitialView = "Albums" // save setting
|
||||||
a.searcher.Entry.Show()
|
a.searcher.Entry.Show()
|
||||||
if a.searchText == "" {
|
if a.searchText == "" {
|
||||||
a.container.Objects[0] = a.grid
|
a.container.Objects[0] = a.grid
|
||||||
@@ -233,7 +249,8 @@ func (a *FavoritesPage) onShowFavoriteAlbums() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *FavoritesPage) onShowFavoriteArtists() {
|
func (a *FavoritesPage) onShowFavoriteArtists() {
|
||||||
a.searcher.Entry.Hide() // disable search on artists for now
|
a.cfg.InitialView = "Artists" // save setting
|
||||||
|
a.searcher.Entry.Hide() // disable search on artists for now
|
||||||
if a.artistListCtr == nil {
|
if a.artistListCtr == nil {
|
||||||
if a.pendingViewSwitch {
|
if a.pendingViewSwitch {
|
||||||
return
|
return
|
||||||
@@ -277,7 +294,8 @@ func buildArtistListModel(artists []*subsonic.ArtistID3) []widgets.ArtistGenrePl
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *FavoritesPage) onShowFavoriteSongs() {
|
func (a *FavoritesPage) onShowFavoriteSongs() {
|
||||||
a.searcher.Entry.Hide() // disable search on songs for now
|
a.cfg.InitialView = "Songs" // save setting
|
||||||
|
a.searcher.Entry.Hide() // disable search on songs for now
|
||||||
if a.tracklistCtr == nil {
|
if a.tracklistCtr == nil {
|
||||||
if a.pendingViewSwitch {
|
if a.pendingViewSwitch {
|
||||||
return
|
return
|
||||||
@@ -291,8 +309,7 @@ func (a *FavoritesPage) onShowFavoriteSongs() {
|
|||||||
}
|
}
|
||||||
tracklist := widgets.NewTracklist(s.Song)
|
tracklist := widgets.NewTracklist(s.Song)
|
||||||
tracklist.AutoNumber = true
|
tracklist.AutoNumber = true
|
||||||
// TODO: get visible columns from config
|
tracklist.SetVisibleColumns(a.cfg.TracklistColumns)
|
||||||
tracklist.SetVisibleColumns([]string{"Artist", "Album", "Plays"})
|
|
||||||
tracklist.SetNowPlaying(a.nowPlayingID)
|
tracklist.SetNowPlaying(a.nowPlayingID)
|
||||||
a.contr.ConnectTracklistActions(tracklist)
|
a.contr.ConnectTracklistActions(tracklist)
|
||||||
a.tracklistCtr = container.New(
|
a.tracklistCtr = container.New(
|
||||||
@@ -326,6 +343,7 @@ func (a *FavoritesPage) CreateRenderer() fyne.WidgetRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type savedFavoritesPage struct {
|
type savedFavoritesPage struct {
|
||||||
|
cfg *backend.FavoritesPageConfig
|
||||||
contr controller.Controller
|
contr controller.Controller
|
||||||
pm *backend.PlaybackManager
|
pm *backend.PlaybackManager
|
||||||
sm *backend.ServerManager
|
sm *backend.ServerManager
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ func (r Router) CreatePage(rte Route) Page {
|
|||||||
case Artists:
|
case Artists:
|
||||||
return NewArtistsGenresPage(false, r.App.ServerManager, r.OpenRoute)
|
return NewArtistsGenresPage(false, r.App.ServerManager, r.OpenRoute)
|
||||||
case Favorites:
|
case Favorites:
|
||||||
return NewFavoritesPage(r.Controller, r.App.ServerManager, r.App.PlaybackManager, r.App.LibraryManager, r.App.ImageManager, r.OpenRoute)
|
return NewFavoritesPage(&r.App.Config.FavoritesPage, r.Controller, r.App.ServerManager, r.App.PlaybackManager, r.App.LibraryManager, r.App.ImageManager, r.OpenRoute)
|
||||||
case Genre:
|
case Genre:
|
||||||
return NewGenrePage(rte.Arg, r.App.PlaybackManager, r.App.LibraryManager, r.App.ImageManager, r.OpenRoute)
|
return NewGenrePage(rte.Arg, r.App.PlaybackManager, r.App.LibraryManager, r.App.ImageManager, r.OpenRoute)
|
||||||
case Genres:
|
case Genres:
|
||||||
|
|||||||
@@ -43,19 +43,24 @@ func (t *ToggleButtonGroup) ActivatedButtonIndex() int {
|
|||||||
return t.activeBtnIdx
|
return t.activeBtnIdx
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *ToggleButtonGroup) onTapped(btnIdx int) bool {
|
func (t *ToggleButtonGroup) SetActivatedButton(idx int) {
|
||||||
|
changed := t.activeBtnIdx != idx
|
||||||
|
t.activeBtnIdx = idx
|
||||||
for i, b := range t.buttonContainer.Objects {
|
for i, b := range t.buttonContainer.Objects {
|
||||||
if i == btnIdx {
|
if i == idx {
|
||||||
b.(*widget.Button).Importance = widget.HighImportance
|
b.(*widget.Button).Importance = widget.HighImportance
|
||||||
} else {
|
} else {
|
||||||
b.(*widget.Button).Importance = widget.MediumImportance
|
b.(*widget.Button).Importance = widget.MediumImportance
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
changed := t.activeBtnIdx != btnIdx
|
|
||||||
t.activeBtnIdx = btnIdx
|
|
||||||
if changed {
|
if changed {
|
||||||
t.Refresh()
|
t.Refresh()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *ToggleButtonGroup) onTapped(btnIdx int) bool {
|
||||||
|
changed := t.activeBtnIdx != btnIdx
|
||||||
|
t.SetActivatedButton(btnIdx)
|
||||||
return changed
|
return changed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user