mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-15 14:56:42 +00:00
GODT-1298: signal GUI is ready and rise window
This commit is contained in:
@ -33,6 +33,7 @@ import (
|
||||
"github.com/ProtonMail/proton-bridge/pkg/listener"
|
||||
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/therecipe/qt/core"
|
||||
"github.com/therecipe/qt/qml"
|
||||
"github.com/therecipe/qt/widgets"
|
||||
)
|
||||
@ -57,8 +58,10 @@ type FrontendQt struct {
|
||||
|
||||
newVersionInfo updater.VersionInfo
|
||||
|
||||
log *logrus.Entry
|
||||
usersMtx sync.Mutex
|
||||
log *logrus.Entry
|
||||
usersMtx sync.Mutex
|
||||
initializing sync.WaitGroup
|
||||
initializationDone sync.Once
|
||||
|
||||
app *widgets.QApplication
|
||||
engine *qml.QQmlApplicationEngine
|
||||
@ -81,7 +84,9 @@ func New(
|
||||
autostart *autostart.App,
|
||||
restarter types.Restarter,
|
||||
) *FrontendQt {
|
||||
return &FrontendQt{
|
||||
userAgent.SetPlatform(core.QSysInfo_PrettyProductName())
|
||||
|
||||
f := &FrontendQt{
|
||||
programName: "Proton Mail Bridge",
|
||||
programVersion: version,
|
||||
log: logrus.WithField("pkg", "frontend/qt"),
|
||||
@ -96,6 +101,19 @@ func New(
|
||||
autostart: autostart,
|
||||
restarter: restarter,
|
||||
}
|
||||
|
||||
// Initializing.Done is only called sync.Once. Please keep the increment
|
||||
// set to 1
|
||||
f.initializing.Add(1)
|
||||
|
||||
if showWindowOnStart {
|
||||
go func() {
|
||||
f.initializing.Wait()
|
||||
f.qml.ShowMainWindow()
|
||||
}()
|
||||
}
|
||||
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *FrontendQt) Loop() error {
|
||||
@ -142,5 +160,5 @@ func (f *FrontendQt) NotifySilentUpdateError(err error) {
|
||||
}
|
||||
|
||||
func (f *FrontendQt) WaitUntilFrontendIsReady() {
|
||||
// TODO: Implement
|
||||
f.initializing.Wait()
|
||||
}
|
||||
|
||||
@ -178,3 +178,7 @@ func (f *FrontendQt) quit() {
|
||||
f.log.Warn("Your wish is my command.. I quit!")
|
||||
f.app.Exit(0)
|
||||
}
|
||||
|
||||
func (f *FrontendQt) guiReady() {
|
||||
f.initializationDone.Do(f.initializing.Done)
|
||||
}
|
||||
|
||||
@ -33,6 +33,7 @@ type QMLBackend struct {
|
||||
core.QObject
|
||||
|
||||
_ func() *core.QPoint `slot:"getCursorPos"`
|
||||
_ func() `slot:"guiReady"`
|
||||
_ func() `slot:"quit"`
|
||||
_ func() `slot:"restart"`
|
||||
|
||||
@ -141,6 +142,7 @@ func (q *QMLBackend) setup(f *FrontendQt) {
|
||||
q.ConnectGetCursorPos(getCursorPos)
|
||||
q.ConnectQuit(f.quit)
|
||||
q.ConnectRestart(f.restart)
|
||||
q.ConnectGuiReady(f.guiReady)
|
||||
|
||||
q.ConnectIsDockIconVisible(func() bool {
|
||||
return dockIcon.GetDockIconVisibleState()
|
||||
|
||||
Reference in New Issue
Block a user