Fix #745: add option to prevent screensaver on Now Playing page
This commit is contained in:
+26
-23
@@ -61,6 +61,8 @@ type AppConfig struct {
|
||||
SidebarWidthFraction float64
|
||||
SidebarTab string
|
||||
|
||||
PreventScreensaverOnNowPlayingPage bool
|
||||
|
||||
FontNormalTTF string
|
||||
FontBoldTTF string
|
||||
UIScaleSize string
|
||||
@@ -189,29 +191,30 @@ var SupportedStartupPages = []string{"Albums", "Favorites", "Playlists", "Artist
|
||||
func DefaultConfig(appVersionTag string) *Config {
|
||||
return &Config{
|
||||
Application: AppConfig{
|
||||
WindowWidth: 1000,
|
||||
WindowHeight: 800,
|
||||
LastCheckedVersion: appVersionTag,
|
||||
LastLaunchedVersion: "",
|
||||
EnableSystemTray: true,
|
||||
CloseToSystemTray: false,
|
||||
StartupPage: "Albums",
|
||||
SettingsTab: "General",
|
||||
AllowMultiInstance: false,
|
||||
MaxImageCacheSizeMB: 50,
|
||||
UIScaleSize: "Normal",
|
||||
SavePlayQueue: true,
|
||||
SaveQueueToServer: false,
|
||||
ShowTrackChangeNotification: false,
|
||||
EnableLrcLib: true,
|
||||
EnablePasswordStorage: true,
|
||||
SkipSSLVerify: false,
|
||||
EnqueueBatchSize: 100,
|
||||
Language: "auto",
|
||||
EnableAutoUpdateChecker: true,
|
||||
RequestTimeoutSeconds: 15,
|
||||
EnableOSMediaPlayerAPIs: true,
|
||||
SidebarWidthFraction: 0.8,
|
||||
WindowWidth: 1000,
|
||||
WindowHeight: 800,
|
||||
LastCheckedVersion: appVersionTag,
|
||||
LastLaunchedVersion: "",
|
||||
EnableSystemTray: true,
|
||||
CloseToSystemTray: false,
|
||||
StartupPage: "Albums",
|
||||
SettingsTab: "General",
|
||||
AllowMultiInstance: false,
|
||||
MaxImageCacheSizeMB: 50,
|
||||
UIScaleSize: "Normal",
|
||||
SavePlayQueue: true,
|
||||
SaveQueueToServer: false,
|
||||
ShowTrackChangeNotification: false,
|
||||
EnableLrcLib: true,
|
||||
EnablePasswordStorage: true,
|
||||
SkipSSLVerify: false,
|
||||
EnqueueBatchSize: 100,
|
||||
Language: "auto",
|
||||
EnableAutoUpdateChecker: true,
|
||||
RequestTimeoutSeconds: 15,
|
||||
EnableOSMediaPlayerAPIs: true,
|
||||
SidebarWidthFraction: 0.8,
|
||||
PreventScreensaverOnNowPlayingPage: false,
|
||||
},
|
||||
AlbumPage: AlbumPageConfig{
|
||||
TracklistColumns: []string{"Artist", "Time", "Plays", "Favorite", "Rating"},
|
||||
|
||||
@@ -279,6 +279,7 @@
|
||||
"Remove from queue": "Remove from queue",
|
||||
"Play albums": "Play albums",
|
||||
"Play song radio": "Play song radio",
|
||||
"Prevent screensaver on Now Playing page": "Prevent screensaver on Now Playing page",
|
||||
"to": "to",
|
||||
"by": "by",
|
||||
"Jan": "Jan",
|
||||
|
||||
@@ -17,6 +17,8 @@ type Router struct {
|
||||
Controller *controller.Controller
|
||||
Nav NavigationHandler
|
||||
widgetPool *util.WidgetPool
|
||||
|
||||
OnNavigateTo func(controller.Route)
|
||||
}
|
||||
|
||||
func NewRouter(app *backend.App, controller *controller.Controller, nav NavigationHandler) Router {
|
||||
@@ -63,8 +65,11 @@ func (r Router) CreatePage(rte controller.Route) Page {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r Router) NavigateTo(rte controller.Route) {
|
||||
func (r *Router) NavigateTo(rte controller.Route) {
|
||||
if rte != r.Nav.CurrentPage() {
|
||||
r.Nav.SetPage(r.CreatePage(rte))
|
||||
}
|
||||
if r.OnNavigateTo != nil {
|
||||
r.OnNavigateTo(rte)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -634,12 +634,16 @@ func (s *SettingsDialog) createAdvancedTab() *container.TabItem {
|
||||
})
|
||||
osMediaAPIs.Checked = s.config.Application.EnableOSMediaPlayerAPIs
|
||||
|
||||
preventScreensaver := widget.NewCheckWithData(lang.L("Prevent screensaver on Now Playing page"),
|
||||
binding.BindBool(&s.config.Application.PreventScreensaverOnNowPlayingPage))
|
||||
|
||||
return container.NewTabItem(lang.L("Advanced"), container.NewVBox(
|
||||
multi,
|
||||
sslSkip,
|
||||
update,
|
||||
lrclib,
|
||||
osMediaAPIs,
|
||||
preventScreensaver,
|
||||
imgCacheCfg,
|
||||
))
|
||||
}
|
||||
|
||||
@@ -51,6 +51,8 @@ type MainWindow struct {
|
||||
|
||||
// updated when changing servers or libraries
|
||||
librarySubmenu *fyne.Menu
|
||||
|
||||
isScreensaverDisabled bool
|
||||
}
|
||||
|
||||
func NewMainWindow(fyneApp fyne.App, appName, displayAppName, appVersion string, app *backend.App) MainWindow {
|
||||
@@ -156,6 +158,18 @@ func NewMainWindow(fyneApp fyne.App, appName, displayAppName, appVersion string,
|
||||
m.Window.SetContent(fynetooltip.AddWindowToolTipLayer(m.content, m.Window.Canvas()))
|
||||
m.setInitialSize()
|
||||
|
||||
m.Router.OnNavigateTo = func(r controller.Route) {
|
||||
if r.Page == controller.NowPlayingRoute().Page {
|
||||
if m.App.Config.Application.PreventScreensaverOnNowPlayingPage && !m.isScreensaverDisabled {
|
||||
fyne.CurrentApp().Driver().SetDisableScreenBlanking(true)
|
||||
m.isScreensaverDisabled = true
|
||||
}
|
||||
} else if m.isScreensaverDisabled {
|
||||
fyne.CurrentApp().Driver().SetDisableScreenBlanking(false)
|
||||
m.isScreensaverDisabled = false
|
||||
}
|
||||
}
|
||||
|
||||
m.Window.SetCloseIntercept(func() {
|
||||
m.SaveWindowSettings()
|
||||
if app.Config.Application.CloseToSystemTray && m.HaveSystemTray() {
|
||||
|
||||
Reference in New Issue
Block a user