Fix initial backlock fetch with >= qt-4.6.0-rc1
authorManuel Nickschas <sputnick@quassel-irc.org>
Wed, 18 Nov 2009 19:48:26 +0000 (20:48 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 18 Nov 2009 19:48:26 +0000 (20:48 +0100)
We don't get unnecessary show events anymore on mainwin state restore, so we
need to make sure that docks are not shown before we load the layout.

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

index b3f1942..1191d88 100644 (file)
@@ -126,7 +126,8 @@ MainWin::MainWin(QWidget *parent)
     sslLabel(new QLabel()),
     msgProcessorStatusWidget(new MsgProcessorStatusWidget()),
     _titleSetter(this),
-    _awayLog(0)
+    _awayLog(0),
+    _layoutLoaded(false)
 {
 #ifdef Q_WS_WIN
   dwTickCount = 0;
@@ -443,12 +444,11 @@ void MainWin::addBufferView(ClientBufferViewConfig *config) {
   BufferView *view = new BufferView(dock);
   view->setFilteredModel(Client::bufferModel(), config);
   view->installEventFilter(_inputWidget); // for key presses
-  view->show();
 
   Client::bufferModel()->synchronizeView(view);
 
   dock->setWidget(view);
-  dock->show();
+  dock->setVisible(_layoutLoaded); // don't show before state has been restored
 
   addDockWidget(Qt::LeftDockWidgetArea, dock);
   _bufferViewsMenu->addAction(dock->toggleViewAction());
@@ -468,6 +468,7 @@ void MainWin::removeBufferView(int bufferViewConfigId) {
     dock = qobject_cast<BufferViewDock *>(action->parent());
     if(dock && actionData.toInt() == bufferViewConfigId) {
       removeAction(action);
+      _bufferViews.removeAll(dock);
       dock->deleteLater();
     }
   }
@@ -741,6 +742,7 @@ void MainWin::loadLayout() {
   QtUiSettings s;
   int accountId = Client::currentCoreAccount().toInt();
   restoreState(s.value(QString("MainWinState-%1").arg(accountId)).toByteArray(), accountId);
+  _layoutLoaded = true;
 }
 
 void MainWin::saveLayout() {
@@ -761,6 +763,8 @@ void MainWin::updateLagIndicator(int lag) {
 void MainWin::disconnectedFromCore() {
   // save core specific layout and remove bufferviews;
   saveLayout();
+  _layoutLoaded = false;
+
   QVariant actionData;
   BufferViewDock *dock;
   foreach(QAction *action, _bufferViewsMenu->actions()) {
@@ -771,9 +775,11 @@ void MainWin::disconnectedFromCore() {
     dock = qobject_cast<BufferViewDock *>(action->parent());
     if(dock && actionData.toInt() != -1) {
       removeAction(action);
+      _bufferViews.removeAll(dock);
       dock->deleteLater();
     }
   }
+
   QtUiSettings s;
   restoreState(s.value("MainWinState").toByteArray());
   setDisconnectedState();
index c22d32d..bee2cd2 100644 (file)
@@ -196,6 +196,8 @@ class MainWin
 
     QWidget *_awayLog;
 
+    bool _layoutLoaded;
+
     QSize _normalSize; //!< Size of the non-maximized window
     QPoint _normalPos; //!< Position of the non-maximized window