From 6b11c3983062c135e074b20de96ccb18a129bb26 Mon Sep 17 00:00:00 2001
From: Thomas Hartmann <Thomas.Hartmann@nokia.com>
Date: Thu, 25 Nov 2010 11:49:29 +0100
Subject: [PATCH] QmlDesigner.propertyEditor: speedup loading of QmlDesigner

The creation of property pages is now delayed
---
 .../propertyeditor/propertyeditor.cpp         | 26 ++++++++++++++-----
 .../propertyeditor/propertyeditor.h           |  2 ++
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp
index b9b4369e2f5..020110089cb 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp
+++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp
@@ -269,7 +269,8 @@ PropertyEditor::PropertyEditor(QWidget *parent) :
         m_timerId(0),
         m_stackedWidget(new StackedWidget(parent)),
         m_currentType(0),
-        m_locked(false)
+        m_locked(false),
+        m_setupCompleted(false)
 {
     m_updateShortcut = new QShortcut(QKeySequence("F5"), m_stackedWidget);
     connect(m_updateShortcut, SIGNAL(activated()), this, SLOT(reloadQml()));
@@ -334,7 +335,6 @@ void PropertyEditor::setupPane(const QString &typeName)
         type->initialSetup(typeName, qmlSpecificsFile, this);
         ctxt->setContextProperty("finishedNotify", QVariant(true) );
     }
-    m_stackedWidget->setCurrentWidget(type->m_view);
 }
 
 void PropertyEditor::changeValue(const QString &propertyName)
@@ -501,6 +501,22 @@ void PropertyEditor::updateSize()
         frame->resize(m_stackedWidget->size());
 }
 
+void PropertyEditor::setupPanes()
+{
+    QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+    setupPane("Qt/Rectangle");
+    QApplication::processEvents();
+    setupPane("Qt/Text");
+    QApplication::processEvents();
+    setupPane("Qt/TextInput");
+    QApplication::processEvents();
+    setupPane("Qt/TextEdit");
+    QApplication::processEvents();
+    resetView();
+    m_setupCompleted = true;
+    QApplication::restoreOverrideCursor();
+}
+
 void PropertyEditor::otherPropertyChanged(const QmlObjectNode &fxObjectNode, const QString &propertyName)
 {
     QmlModelView::otherPropertyChanged(fxObjectNode, propertyName);
@@ -723,11 +739,9 @@ void PropertyEditor::modelAttached(Model *model)
 
     m_locked = true;
 
-    setupPane("Qt/Rectangle");
-    setupPane("Qt/Text");
-    setupPane("Qt/TextInput");
-    setupPane("Qt/TextEdit");
     resetView();
+    if (!m_setupCompleted)
+        QTimer::singleShot(1000, this, SLOT(setupPanes()));
 
     m_locked = false;
 }
diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.h b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.h
index 70cdedda179..788418f0a08 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.h
+++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.h
@@ -117,6 +117,7 @@ private slots:
     void changeValue(const QString &name);
     void changeExpression(const QString &name);
     void updateSize();
+    void setupPanes();
 
 private: //functions
     QString qmlFileName(const NodeMetaInfo &nodeInfo) const;
@@ -139,6 +140,7 @@ private: //variables
     QHash<QString, NodeType *> m_typeHash;
     NodeType *m_currentType;
     bool m_locked;
+    bool m_setupCompleted;
 };
 
 
-- 
GitLab