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