mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-18 16:17:03 +00:00
GODT-1336: Fix showing window on startup
This commit is contained in:
@ -54,4 +54,5 @@ func SetupEvents(listener listener.Listener) {
|
|||||||
listener.SetBuffer(InternetOffEvent)
|
listener.SetBuffer(InternetOffEvent)
|
||||||
listener.SetBuffer(UpgradeApplicationEvent)
|
listener.SetBuffer(UpgradeApplicationEvent)
|
||||||
listener.SetBuffer(TLSCertIssue)
|
listener.SetBuffer(TLSCertIssue)
|
||||||
|
listener.SetBuffer(UserRefreshEvent)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -330,6 +330,16 @@ Window {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CheckBox {
|
||||||
|
id: showOnStartupCheckbox
|
||||||
|
colorScheme: root.colorScheme
|
||||||
|
text: "Show on startup"
|
||||||
|
checked: root.showOnStartup
|
||||||
|
onCheckedChanged: {
|
||||||
|
root.showOnStartup = checked
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
colorScheme: root.colorScheme
|
colorScheme: root.colorScheme
|
||||||
//Layout.fillWidth: true
|
//Layout.fillWidth: true
|
||||||
@ -338,7 +348,6 @@ Window {
|
|||||||
enabled: bridge === undefined || bridge === null
|
enabled: bridge === undefined || bridge === null
|
||||||
onClicked: {
|
onClicked: {
|
||||||
bridge = bridgeComponent.createObject()
|
bridge = bridgeComponent.createObject()
|
||||||
if (true) bridge._mainWindow.showAndRise()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -630,6 +639,7 @@ Window {
|
|||||||
|
|
||||||
property string goos: "linux"
|
property string goos: "linux"
|
||||||
|
|
||||||
|
property bool showOnStartup: true // this actually needs to be false, but since we use Bridge_test for testing purpose - lets default this to true just for convenience
|
||||||
property bool dockIconVisible: false
|
property bool dockIconVisible: false
|
||||||
|
|
||||||
// this signals are used only when trying to login with new user (i.e. not in users model)
|
// this signals are used only when trying to login with new user (i.e. not in users model)
|
||||||
|
|||||||
@ -224,13 +224,7 @@ Item {
|
|||||||
Layout.preferredWidth: 320
|
Layout.preferredWidth: 320
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
username: {
|
username: root.backend.users.count === 1 && root.backend.users.get(0) && root.backend.users.get(0).loggedIn === false ? root.backend.users.get(0).username : ""
|
||||||
if (root.backend.users.count !== 1) return ""
|
|
||||||
var user = root.backend.users.get(0)
|
|
||||||
if (user) return ""
|
|
||||||
if (user.loggedIn) return ""
|
|
||||||
return user.username
|
|
||||||
}
|
|
||||||
backend: root.backend
|
backend: root.backend
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with ProtonMail Bridge. If not, see <https://www.gnu.org/licenses/>.
|
// along with ProtonMail Bridge. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//go:build build_qt
|
||||||
// +build build_qt
|
// +build build_qt
|
||||||
|
|
||||||
// Package qt provides communication between Qt/QML frontend and Go backend
|
// Package qt provides communication between Qt/QML frontend and Go backend
|
||||||
@ -64,7 +65,7 @@ type FrontendQt struct {
|
|||||||
initializationDone sync.Once
|
initializationDone sync.Once
|
||||||
|
|
||||||
app *widgets.QApplication
|
app *widgets.QApplication
|
||||||
engine *qml.QQmlApplicationEngine
|
engine *qml.QQmlEngine
|
||||||
qml *QMLBackend
|
qml *QMLBackend
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with ProtonMail Bridge. If not, see <https://www.gnu.org/licenses/>.
|
// along with ProtonMail Bridge. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//go:build build_qt
|
||||||
// +build build_qt
|
// +build build_qt
|
||||||
|
|
||||||
package qt
|
package qt
|
||||||
@ -47,7 +48,8 @@ func (f *FrontendQt) initiateQtApplication() error {
|
|||||||
f.app.SetQuitOnLastWindowClosed(false)
|
f.app.SetQuitOnLastWindowClosed(false)
|
||||||
|
|
||||||
// QML Engine and path
|
// QML Engine and path
|
||||||
f.engine = qml.NewQQmlApplicationEngine(f.app)
|
f.engine = qml.NewQQmlEngine(f.app)
|
||||||
|
rootComponent := qml.NewQQmlComponent2(f.engine, f.engine)
|
||||||
|
|
||||||
f.qml = NewQMLBackend(f.engine)
|
f.qml = NewQMLBackend(f.engine)
|
||||||
f.qml.setup(f)
|
f.qml.setup(f)
|
||||||
@ -60,14 +62,25 @@ func (f *FrontendQt) initiateQtApplication() error {
|
|||||||
quickcontrols2.QQuickStyle_AddStylePath("qrc:/qml/")
|
quickcontrols2.QQuickStyle_AddStylePath("qrc:/qml/")
|
||||||
quickcontrols2.QQuickStyle_SetStyle("Proton")
|
quickcontrols2.QQuickStyle_SetStyle("Proton")
|
||||||
|
|
||||||
f.engine.Load(core.NewQUrl3("qrc:/qml/Bridge.qml", 0))
|
// Before loading a component we should load translations.
|
||||||
|
// See https://github.com/qt/qtdeclarative/blob/bedef212a74a62452ed31d7f65536a6c67881fc4/src/qml/qml/qqmlapplicationengine.cpp#L69 as example.
|
||||||
|
|
||||||
// Check QML is loaded properly.
|
rootComponent.LoadUrl(core.NewQUrl3("qrc:/qml/Bridge.qml", 0))
|
||||||
if len(f.engine.RootObjects()) == 0 {
|
|
||||||
|
if rootComponent.Status() != qml.QQmlComponent__Ready {
|
||||||
return errors.New("QML not loaded properly")
|
return errors.New("QML not loaded properly")
|
||||||
}
|
}
|
||||||
|
|
||||||
f.engine.RootObjects()[0].SetProperty("backend", f.qml.ToVariant())
|
// Instead of creating component right away we use BeginCreate to stop right before binding evaluation.
|
||||||
|
// That is needed to set backend property so all bindings will be calculated properly.
|
||||||
|
rootObject := rootComponent.BeginCreate(f.engine.RootContext())
|
||||||
|
// Check QML is loaded properly.
|
||||||
|
if rootObject == nil {
|
||||||
|
return errors.New("QML not created properly")
|
||||||
|
}
|
||||||
|
|
||||||
|
rootObject.SetProperty("backend", f.qml.ToVariant())
|
||||||
|
rootComponent.CompleteCreate()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user