From c7eb7234a2ad43f51f25dc3df2d8daec39a9214b Mon Sep 17 00:00:00 2001 From: Jakub Date: Wed, 2 Mar 2022 11:10:48 +0100 Subject: [PATCH] GODT-1507: Enable autostart after Qt setup. --- internal/bridge/bridge.go | 4 ---- internal/frontend/qt/frontend.go | 1 + internal/frontend/qt/frontend_init.go | 2 ++ internal/frontend/qt/frontend_settings.go | 9 +++++++++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/internal/bridge/bridge.go b/internal/bridge/bridge.go index 8cd9c508..f3b64b4f 100644 --- a/internal/bridge/bridge.go +++ b/internal/bridge/bridge.go @@ -108,10 +108,6 @@ func New( if err := b.SendMetric(metrics.New(metrics.Setup, metrics.FirstStart, metrics.Label(constants.Version))); err != nil { logrus.WithError(err).Error("Failed to send metric") } - - if err := b.EnableAutostart(); err != nil { - log.WithError(err).Error("Failed to enable autostart") - } setting.SetBool(settings.FirstStartKey, false) } diff --git a/internal/frontend/qt/frontend.go b/internal/frontend/qt/frontend.go index ceff57b2..0383d1c0 100644 --- a/internal/frontend/qt/frontend.go +++ b/internal/frontend/qt/frontend.go @@ -61,6 +61,7 @@ type FrontendQt struct { log *logrus.Entry initializing sync.WaitGroup initializationDone sync.Once + firstTimeAutostart sync.Once app *widgets.QApplication engine *qml.QQmlEngine diff --git a/internal/frontend/qt/frontend_init.go b/internal/frontend/qt/frontend_init.go index 8ce778a6..17bfbdad 100644 --- a/internal/frontend/qt/frontend_init.go +++ b/internal/frontend/qt/frontend_init.go @@ -44,6 +44,8 @@ func (f *FrontendQt) initiateQtApplication() error { core.QCoreApplication_SetApplicationName(f.programName) core.QCoreApplication_SetApplicationVersion(f.programVersion) + core.QCoreApplication_SetOrganizationName("Proton AG") + core.QCoreApplication_SetOrganizationDomain("proton.ch") // High DPI scaling for windows. core.QCoreApplication_SetAttribute(core.Qt__AA_EnableHighDpiScaling, false) diff --git a/internal/frontend/qt/frontend_settings.go b/internal/frontend/qt/frontend_settings.go index 5fd8e481..c3b97203 100644 --- a/internal/frontend/qt/frontend_settings.go +++ b/internal/frontend/qt/frontend_settings.go @@ -76,6 +76,15 @@ func (f *FrontendQt) changeLocalCache(enableDiskCache bool, diskCachePath *core. } func (f *FrontendQt) setIsAutostartOn() { + // GODT-1507 Windows: autostart needs to be created after Qt is initialized. + f.firstTimeAutostart.Do(func() { + if !f.bridge.IsFirstStart() { + return + } + if err := f.bridge.EnableAutostart(); err != nil { + f.log.WithError(err).Error("Failed to enable autostart") + } + }) f.qml.SetIsAutostartOn(f.bridge.IsAutostartEnabled()) }