forked from Silverfish/proton-bridge
GODT-1329: Dark mode, with macOS autodetect.
This commit is contained in:
@ -26,6 +26,7 @@ import (
|
||||
|
||||
"github.com/ProtonMail/proton-bridge/internal/config/settings"
|
||||
"github.com/ProtonMail/proton-bridge/internal/frontend/clientconfig"
|
||||
"github.com/ProtonMail/proton-bridge/internal/frontend/theme"
|
||||
"github.com/ProtonMail/proton-bridge/pkg/keychain"
|
||||
"github.com/ProtonMail/proton-bridge/pkg/ports"
|
||||
"github.com/therecipe/qt/core"
|
||||
@ -184,3 +185,21 @@ func (f *FrontendQt) quit() {
|
||||
func (f *FrontendQt) guiReady() {
|
||||
f.initializationDone.Do(f.initializing.Done)
|
||||
}
|
||||
|
||||
func (f *FrontendQt) setColorScheme() {
|
||||
current := f.settings.Get(settings.ColorScheme)
|
||||
if !theme.IsAvailable(theme.Theme(current)) {
|
||||
current = string(theme.DefaultTheme())
|
||||
f.settings.Set(settings.ColorScheme, current)
|
||||
}
|
||||
f.qml.SetColorSchemeName(current)
|
||||
}
|
||||
|
||||
func (f *FrontendQt) changeColorScheme(newScheme string) {
|
||||
if !theme.IsAvailable(theme.Theme(newScheme)) {
|
||||
f.log.WithField("scheme", newScheme).Warn("Color scheme not available")
|
||||
return
|
||||
}
|
||||
f.settings.Set(settings.ColorScheme, newScheme)
|
||||
f.setColorScheme()
|
||||
}
|
||||
|
||||
@ -128,6 +128,8 @@ type QMLBackend struct {
|
||||
_ core.QUrl `property:"releaseNotesLink"`
|
||||
_ core.QUrl `property:"landingPageLink"`
|
||||
|
||||
_ string `property:"colorSchemeName"`
|
||||
_ func(string) `slot:"changeColorScheme"`
|
||||
_ string `property:"currentEmailClient"`
|
||||
_ func() `slot:"updateCurrentMailClient"`
|
||||
_ func(description, address, emailClient string, includeLogs bool) `slot:"reportBug"`
|
||||
@ -262,6 +264,14 @@ func (q *QMLBackend) setup(f *FrontendQt) {
|
||||
// release notes link is set by update
|
||||
f.setLicensePath()
|
||||
|
||||
f.setColorScheme()
|
||||
q.ConnectChangeColorScheme(func(newScheme string) {
|
||||
go func() {
|
||||
defer f.panicHandler.HandlePanic()
|
||||
f.changeColorScheme(newScheme)
|
||||
}()
|
||||
})
|
||||
|
||||
f.setCurrentEmailClient()
|
||||
q.ConnectUpdateCurrentMailClient(func() {
|
||||
go func() {
|
||||
|
||||
Reference in New Issue
Block a user