qtui: Show core connection dialog only after initialization
authorManuel Nickschas <sputnick@quassel-irc.org>
Thu, 14 Jun 2018 19:12:17 +0000 (21:12 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Fri, 15 Jun 2018 23:30:32 +0000 (01:30 +0200)
Showing a blocking dialog in init() is a bad idea, because then
initialization doesn't actually finish until the dialog is closed.
For example, this delays the setup of the tray icon.

Instead, go through the event loop before showing the initial
connection dialog.

src/qtui/mainwin.cpp
src/qtui/mainwin.h

index 07c47a4..00f8372 100644 (file)
@@ -299,11 +299,7 @@ void MainWin::init()
     // restore locked state of docks
     QtUi::actionCollection("General")->action("LockLayout")->setChecked(s.value("LockLayout", false).toBool());
 
     // restore locked state of docks
     QtUi::actionCollection("General")->action("LockLayout")->setChecked(s.value("LockLayout", false).toBool());
 
-    CoreConnection *conn = Client::coreConnection();
-    if (!conn->connectToCore()) {
-        // No autoconnect selected (or no accounts)
-        showCoreConnectionDlg();
-    }
+    QTimer::singleShot(0, this, SLOT(doAutoConnect()));
 }
 
 
 }
 
 
@@ -1217,6 +1213,15 @@ void MainWin::saveMainToolBarStatus(bool enabled)
 }
 
 
 }
 
 
+void MainWin::doAutoConnect()
+{
+    if (!Client::coreConnection()->connectToCore()) {
+        // No autoconnect selected (or no accounts)
+        showCoreConnectionDlg();
+    }
+}
+
+
 void MainWin::connectedToCore()
 {
     Q_CHECK_PTR(Client::bufferViewManager());
 void MainWin::connectedToCore()
 {
     Q_CHECK_PTR(Client::bufferViewManager());
index 6f741f5..e5b6ba2 100644 (file)
@@ -135,6 +135,8 @@ private slots:
     void showNewTransferDlg(const QUuid &transferId);
     void onFullScreenToggled();
 
     void showNewTransferDlg(const QUuid &transferId);
     void onFullScreenToggled();
 
+    void doAutoConnect();
+
     void handleCoreConnectionError(const QString &errorMsg);
     void userAuthenticationRequired(CoreAccount *, bool *valid, const QString &errorMessage);
     void handleNoSslInClient(bool *accepted);
     void handleCoreConnectionError(const QString &errorMsg);
     void userAuthenticationRequired(CoreAccount *, bool *valid, const QString &errorMessage);
     void handleNoSslInClient(bool *accepted);