add settings option to choose startup page
This commit is contained in:
@@ -27,6 +27,7 @@ type AppConfig struct {
|
||||
LastCheckedVersion string
|
||||
EnableSystemTray bool
|
||||
CloseToSystemTray bool
|
||||
StartupPage string
|
||||
|
||||
// Experimental - may be removed in future
|
||||
FontNormalTTF string
|
||||
@@ -102,6 +103,8 @@ type Config struct {
|
||||
ReplayGain ReplayGainConfig
|
||||
}
|
||||
|
||||
var SupportedStartupPages = []string{"Albums", "Favorites", "Playlists"}
|
||||
|
||||
func DefaultConfig(appVersionTag string) *Config {
|
||||
return &Config{
|
||||
Application: AppConfig{
|
||||
@@ -110,6 +113,7 @@ func DefaultConfig(appVersionTag string) *Config {
|
||||
LastCheckedVersion: appVersionTag,
|
||||
EnableSystemTray: true,
|
||||
CloseToSystemTray: false,
|
||||
StartupPage: "Albums",
|
||||
},
|
||||
AlbumPage: AlbumPageConfig{
|
||||
TracklistColumns: []string{"Artist", "Time", "Plays", "Favorite", "Rating"},
|
||||
|
||||
@@ -62,6 +62,13 @@ func NewSettingsDialog(config *backend.Config, audioDeviceList []player.AudioDev
|
||||
}
|
||||
|
||||
func (s *SettingsDialog) createGeneralTab() *container.TabItem {
|
||||
startupPage := widget.NewSelect(backend.SupportedStartupPages, func(choice string) {
|
||||
s.config.Application.StartupPage = choice
|
||||
})
|
||||
startupPage.SetSelected(s.config.Application.StartupPage)
|
||||
if startupPage.Selected == "" {
|
||||
startupPage.SetSelectedIndex(0)
|
||||
}
|
||||
closeToTray := widget.NewCheckWithData("Close to system tray",
|
||||
binding.BindBool(&s.config.Application.CloseToSystemTray))
|
||||
if !s.config.Application.EnableSystemTray {
|
||||
@@ -154,8 +161,8 @@ func (s *SettingsDialog) createGeneralTab() *container.TabItem {
|
||||
scrobbleEnabled.Checked = s.config.Scrobbling.Enabled
|
||||
|
||||
return container.NewTabItem("General", container.NewVBox(
|
||||
systemTrayEnable,
|
||||
closeToTray,
|
||||
container.New(layout.NewFormLayout(), widget.NewLabel("Startup page"), startupPage),
|
||||
container.NewHBox(systemTrayEnable, closeToTray),
|
||||
s.newSectionSeparator(),
|
||||
|
||||
widget.NewRichText(&widget.TextSegment{Text: "Scrobbling", Style: boldStyle}),
|
||||
|
||||
+12
-5
@@ -46,10 +46,6 @@ type MainWindow struct {
|
||||
container *fyne.Container
|
||||
}
|
||||
|
||||
var (
|
||||
HomePage = controller.AlbumsRoute()
|
||||
)
|
||||
|
||||
func NewMainWindow(fyneApp fyne.App, appName, appVersion string, app *backend.App, size fyne.Size) MainWindow {
|
||||
m := MainWindow{
|
||||
App: app,
|
||||
@@ -86,7 +82,7 @@ func NewMainWindow(fyneApp fyne.App, appName, appVersion string, app *backend.Ap
|
||||
})
|
||||
app.ServerManager.OnServerConnected(func() {
|
||||
m.BrowsingPane.EnableNavigationButtons()
|
||||
m.Router.NavigateTo(HomePage)
|
||||
m.Router.NavigateTo(m.StartupPage())
|
||||
// check if found new version on startup
|
||||
if t := app.UpdateChecker.VersionTagFound(); t != "" && t != app.Config.Application.LastCheckedVersion {
|
||||
if t != app.VersionTag() {
|
||||
@@ -129,6 +125,17 @@ func NewMainWindow(fyneApp fyne.App, appName, appVersion string, app *backend.Ap
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *MainWindow) StartupPage() controller.Route {
|
||||
switch m.App.Config.Application.StartupPage {
|
||||
case "Favorites":
|
||||
return controller.FavoritesRoute()
|
||||
case "Playlists":
|
||||
return controller.PlaylistsRoute()
|
||||
default:
|
||||
return controller.AlbumsRoute()
|
||||
}
|
||||
}
|
||||
|
||||
func (m *MainWindow) SetupSystemTrayMenu(appName string, fyneApp fyne.App) {
|
||||
if desk, ok := fyneApp.(desktop.App); ok {
|
||||
menu := fyne.NewMenu(appName,
|
||||
|
||||
Reference in New Issue
Block a user