save playlists page view setting
This commit is contained in:
@@ -59,6 +59,10 @@ type PlaylistPageConfig struct {
|
|||||||
TracklistColumns []string
|
TracklistColumns []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PlaylistsPageConfig struct {
|
||||||
|
InitialView string
|
||||||
|
}
|
||||||
|
|
||||||
type TracksPageConfig struct {
|
type TracksPageConfig struct {
|
||||||
TracklistColumns []string
|
TracklistColumns []string
|
||||||
}
|
}
|
||||||
@@ -91,6 +95,7 @@ type Config struct {
|
|||||||
FavoritesPage FavoritesPageConfig
|
FavoritesPage FavoritesPageConfig
|
||||||
NowPlayingPage NowPlayingPageConfig
|
NowPlayingPage NowPlayingPageConfig
|
||||||
PlaylistPage PlaylistPageConfig
|
PlaylistPage PlaylistPageConfig
|
||||||
|
PlaylistsPage PlaylistsPageConfig
|
||||||
TracksPage TracksPageConfig
|
TracksPage TracksPageConfig
|
||||||
LocalPlayback LocalPlaybackConfig
|
LocalPlayback LocalPlaybackConfig
|
||||||
Scrobbling ScrobbleConfig
|
Scrobbling ScrobbleConfig
|
||||||
@@ -126,6 +131,9 @@ func DefaultConfig(appVersionTag string) *Config {
|
|||||||
PlaylistPage: PlaylistPageConfig{
|
PlaylistPage: PlaylistPageConfig{
|
||||||
TracklistColumns: []string{"Artist", "Album", "Time", "Plays"},
|
TracklistColumns: []string{"Artist", "Album", "Time", "Plays"},
|
||||||
},
|
},
|
||||||
|
PlaylistsPage: PlaylistsPageConfig{
|
||||||
|
InitialView: "List",
|
||||||
|
},
|
||||||
TracksPage: TracksPageConfig{
|
TracksPage: TracksPageConfig{
|
||||||
TracklistColumns: []string{"Artist", "Album", "Time", "Plays"},
|
TracklistColumns: []string{"Artist", "Album", "Time", "Plays"},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import (
|
|||||||
type PlaylistsPage struct {
|
type PlaylistsPage struct {
|
||||||
widget.BaseWidget
|
widget.BaseWidget
|
||||||
|
|
||||||
|
cfg *backend.PlaylistsPageConfig
|
||||||
contr *controller.Controller
|
contr *controller.Controller
|
||||||
sm *backend.ServerManager
|
sm *backend.ServerManager
|
||||||
playlists []*subsonic.Playlist
|
playlists []*subsonic.Playlist
|
||||||
@@ -36,12 +37,17 @@ type PlaylistsPage struct {
|
|||||||
gridView *widgets.GridView
|
gridView *widgets.GridView
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPlaylistsPage(contr *controller.Controller, sm *backend.ServerManager) *PlaylistsPage {
|
func NewPlaylistsPage(contr *controller.Controller, cfg *backend.PlaylistsPageConfig, sm *backend.ServerManager) *PlaylistsPage {
|
||||||
return newPlaylistsPage(contr, sm, "", 0)
|
activeView := 0
|
||||||
|
if cfg.InitialView == "Grid" {
|
||||||
|
activeView = 1
|
||||||
|
}
|
||||||
|
return newPlaylistsPage(contr, cfg, sm, "", activeView)
|
||||||
}
|
}
|
||||||
|
|
||||||
func newPlaylistsPage(contr *controller.Controller, sm *backend.ServerManager, searchText string, activeView int) *PlaylistsPage {
|
func newPlaylistsPage(contr *controller.Controller, cfg *backend.PlaylistsPageConfig, sm *backend.ServerManager, searchText string, activeView int) *PlaylistsPage {
|
||||||
a := &PlaylistsPage{
|
a := &PlaylistsPage{
|
||||||
|
cfg: cfg,
|
||||||
sm: sm,
|
sm: sm,
|
||||||
contr: contr,
|
contr: contr,
|
||||||
titleDisp: widget.NewRichTextWithText("Playlists"),
|
titleDisp: widget.NewRichTextWithText("Playlists"),
|
||||||
@@ -95,6 +101,7 @@ func (a *PlaylistsPage) createGridView(playlists []*subsonic.Playlist) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *PlaylistsPage) showListView() {
|
func (a *PlaylistsPage) showListView() {
|
||||||
|
a.cfg.InitialView = "List" // save setting
|
||||||
if a.listView == nil {
|
if a.listView == nil {
|
||||||
a.createListView()
|
a.createListView()
|
||||||
if a.searcher.Entry.Text != "" {
|
if a.searcher.Entry.Text != "" {
|
||||||
@@ -108,6 +115,7 @@ func (a *PlaylistsPage) showListView() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *PlaylistsPage) showGridView() {
|
func (a *PlaylistsPage) showGridView() {
|
||||||
|
a.cfg.InitialView = "Grid" // save setting
|
||||||
if a.gridView == nil {
|
if a.gridView == nil {
|
||||||
playlists := a.playlists
|
playlists := a.playlists
|
||||||
if a.searcher.Entry.Text != "" {
|
if a.searcher.Entry.Text != "" {
|
||||||
@@ -190,6 +198,7 @@ func (a *PlaylistsPage) Reload() {
|
|||||||
func (a *PlaylistsPage) Save() SavedPage {
|
func (a *PlaylistsPage) Save() SavedPage {
|
||||||
return &savedPlaylistsPage{
|
return &savedPlaylistsPage{
|
||||||
contr: a.contr,
|
contr: a.contr,
|
||||||
|
cfg: a.cfg,
|
||||||
sm: a.sm,
|
sm: a.sm,
|
||||||
searchText: a.searcher.Entry.Text,
|
searchText: a.searcher.Entry.Text,
|
||||||
activeView: a.viewToggle.ActivatedButtonIndex(),
|
activeView: a.viewToggle.ActivatedButtonIndex(),
|
||||||
@@ -198,13 +207,14 @@ func (a *PlaylistsPage) Save() SavedPage {
|
|||||||
|
|
||||||
type savedPlaylistsPage struct {
|
type savedPlaylistsPage struct {
|
||||||
contr *controller.Controller
|
contr *controller.Controller
|
||||||
|
cfg *backend.PlaylistsPageConfig
|
||||||
sm *backend.ServerManager
|
sm *backend.ServerManager
|
||||||
searchText string
|
searchText string
|
||||||
activeView int
|
activeView int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *savedPlaylistsPage) Restore() Page {
|
func (s *savedPlaylistsPage) Restore() Page {
|
||||||
return newPlaylistsPage(s.contr, s.sm, s.searchText, s.activeView)
|
return newPlaylistsPage(s.contr, s.cfg, s.sm, s.searchText, s.activeView)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *PlaylistsPage) buildContainer(initialView fyne.CanvasObject) {
|
func (a *PlaylistsPage) buildContainer(initialView fyne.CanvasObject) {
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ func (r Router) CreatePage(rte controller.Route) Page {
|
|||||||
case controller.Playlist:
|
case controller.Playlist:
|
||||||
return NewPlaylistPage(rte.Arg, &r.App.Config.PlaylistPage, r.Controller, r.App.ServerManager, r.App.PlaybackManager, r.App.ImageManager)
|
return NewPlaylistPage(rte.Arg, &r.App.Config.PlaylistPage, r.Controller, r.App.ServerManager, r.App.PlaybackManager, r.App.ImageManager)
|
||||||
case controller.Playlists:
|
case controller.Playlists:
|
||||||
return NewPlaylistsPage(r.Controller, r.App.ServerManager)
|
return NewPlaylistsPage(r.Controller, &r.App.Config.PlaylistsPage, r.App.ServerManager)
|
||||||
case controller.Tracks:
|
case controller.Tracks:
|
||||||
return NewTracksPage(r.Controller, &r.App.Config.TracksPage, r.App.LibraryManager)
|
return NewTracksPage(r.Controller, &r.App.Config.TracksPage, r.App.LibraryManager)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user