Skip to content

Commit 33eb081

Browse files
committed
save selected sidebar tab
1 parent 694e59d commit 33eb081

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

backend/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ type AppConfig struct {
5959
EnableOSMediaPlayerAPIs bool
6060
ShowSidebar bool
6161
SidebarWidthFraction float64
62+
SidebarTab string
6263

6364
FontNormalTTF string
6465
FontBoldTTF string

ui/mainwindow.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ func NewMainWindow(fyneApp fyne.App, appName, displayAppName, appVersion string,
7070
m.Controller = controller.New(app, appVersion, m.Window)
7171
m.BrowsingPane = browsing.NewBrowsingPane(app.PlaybackManager, m.Controller, func() { m.Router.NavigateTo(m.StartupPage()) })
7272
m.Sidebar = NewSidebar(m.Controller, m.App.PlaybackManager, m.App.ImageManager, m.App.LyricsManager)
73+
if m.App.Config.Application.SidebarTab == "Lyrics" {
74+
m.Sidebar.SetSelectedIndex(1)
75+
}
7376
m.ToastOverlay = NewToastOverlay()
7477
m.Router = browsing.NewRouter(app, m.Controller, m.BrowsingPane)
7578
goHomeFn := func() { m.Router.NavigateTo(m.StartupPage()) }
@@ -533,6 +536,12 @@ func (m *MainWindow) SaveWindowSettings() {
533536
&m.App.Config.Application.WindowHeight)
534537
m.App.Config.Application.ShowSidebar = !m.Sidebar.Hidden
535538
m.App.Config.Application.SidebarWidthFraction = m.splitContainer.Offset
539+
switch m.Sidebar.SelectedIndex() {
540+
case 1:
541+
m.App.Config.Application.SidebarTab = "Lyrics"
542+
default:
543+
m.App.Config.Application.SidebarTab = "Play Queue"
544+
}
536545
}
537546

538547
// widget just so we can catch a tap event that doesn't land anywhere else

ui/sidebar.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ func NewSidebar(contr *controller.Controller, pm *backend.PlaybackManager, im *b
7171
return s
7272
}
7373

74+
func (s *Sidebar) SelectedIndex() int {
75+
return s.tabs.SelectedIndex()
76+
}
77+
78+
func (s *Sidebar) SetSelectedIndex(idx int) {
79+
s.tabs.SelectIndex(idx)
80+
}
81+
7482
func (s *Sidebar) SetQueueTracks(items []mediaprovider.MediaItem) {
7583
s.queueList.SetItems(items)
7684
}

0 commit comments

Comments
 (0)