summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Rødal <sroedal@trolltech.com>2008-12-01 21:30:24 +0100
committerSamuel Rødal <sroedal@trolltech.com>2008-12-01 21:30:24 +0100
commit49fb6ed12422d48cf3b32d5c7bfbed3ba6b4e354 (patch)
treee031e836ad3c6a7da29e61d0f5dc3fcda931ffa5
parent90fcdd2349f231a4347582008b246d55cb0fb4d5 (diff)
Only show web views when load has finished.
Also make model item redraw correctly when OpenGL is disabled.
-rw-r--r--mazescene.cpp21
-rw-r--r--mazescene.h1
-rw-r--r--modelitem.cpp12
-rw-r--r--modelitem.h1
4 files changed, 34 insertions, 1 deletions
diff --git a/mazescene.cpp b/mazescene.cpp
index 5d59b6d..3e0972d 100644
--- a/mazescene.cpp
+++ b/mazescene.cpp
@@ -164,6 +164,14 @@ void MazeScene::addWall(const QPointF &a, const QPointF &b, int type)
m_player = static_cast<MediaPlayer *>(item->childItem()->widget());
}
#endif
+
+ QGraphicsProxyWidget *proxy = item->childItem();
+ QWebView *view = proxy ? qobject_cast<QWebView *>(proxy->widget()) : 0;
+ if (view) {
+ connect(view, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished()));
+ proxy->setVisible(false);
+ }
+
item->setVisible(false);
addProjectedItem(item);
m_walls << item;
@@ -180,6 +188,19 @@ void MazeScene::addWall(const QPointF &a, const QPointF &b, int type)
}
}
+void MazeScene::loadFinished()
+{
+ QWidget *widget = qobject_cast<QWidget *>(sender());
+
+ if (widget) {
+ foreach (WallItem *item, m_walls) {
+ QGraphicsProxyWidget *proxy = item->childItem();
+ if (proxy && proxy->widget() == widget)
+ proxy->setVisible(true);
+ }
+ }
+}
+
static inline QTransform rotatingTransform(qreal angle)
{
QTransform transform;
diff --git a/mazescene.h b/mazescene.h
index fb0a67c..32a9e62 100644
--- a/mazescene.h
+++ b/mazescene.h
@@ -163,6 +163,7 @@ public slots:
void move();
void toggleRenderer();
void toggleDoors();
+ void loadFinished();
private slots:
void moveDoors(qreal value);
diff --git a/modelitem.cpp b/modelitem.cpp
index 42cf0ca..90e3714 100644
--- a/modelitem.cpp
+++ b/modelitem.cpp
@@ -43,9 +43,19 @@ void ModelItem::updateTransform(const Camera &camera, qreal time)
QRectF ModelItem::boundingRect() const
{
+ if (!scene()->views().isEmpty()) {
+ QGraphicsView *view = scene()->views().at(0);
+ return view->mapToScene(view->rect()).boundingRect();
+ }
+
return scene()->sceneRect();
}
+void ModelItem::updateItem()
+{
+ ProjectedItem::update();
+}
+
void ModelItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
if (!m_model)
@@ -68,7 +78,7 @@ void ModelItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidg
modelMatrix *= Matrix4x4::fromRotation(m_rotation.y, Qt::YAxis);
modelMatrix *= Matrix4x4::fromRotation(m_rotation.x, Qt::XAxis);
- ProjectedItem::update();
+ QTimer::singleShot(10, this, SLOT(updateItem()));
if (painter->paintEngine()->type() != QPaintEngine::OpenGL) {
m_wireframe->setEnabled(false);
diff --git a/modelitem.h b/modelitem.h
index 69d34ef..2396231 100644
--- a/modelitem.h
+++ b/modelitem.h
@@ -57,6 +57,7 @@ public slots:
void loadModel();
void loadModel(const QString &filePath);
void modelLoaded();
+ void updateItem();
private:
void setModel(Model *model);