GODT-1507: Enable autostart after Qt setup.

This commit is contained in:
Jakub
2022-03-02 11:10:48 +01:00
parent 73d1fe2f65
commit c7eb7234a2
4 changed files with 12 additions and 4 deletions

View File

@ -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)
}

View File

@ -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

View File

@ -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)

View File

@ -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())
}