QmlDesigner.NodeInstance: Update the screen object if the root item size changed

Change-Id: Ifc06131f4a57a30ab9b20687372150b23c8416cb
Reviewed-on: http://codereview.qt.nokia.com/2285
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
This commit is contained in:
Marco Bubke
2011-07-27 14:46:12 +02:00
parent e4286b7dc2
commit 8870c86ad5
2 changed files with 47 additions and 0 deletions
@@ -146,4 +146,45 @@ void Qt4NodeInstanceServer::refreshBindings()
engine()->rootContext()->setContextProperty(QString("__%1").arg(counter++), 0); // refreshing bindings
}
void Qt4NodeInstanceServer::changeAuxiliaryValues(const ChangeAuxiliaryCommand &command)
{
NodeInstanceServer::changeAuxiliaryValues(command);
refreshScreenObject();
}
void Qt4NodeInstanceServer::changePropertyValues(const ChangeValuesCommand &command)
{
NodeInstanceServer::changePropertyValues(command);
refreshScreenObject();
}
void Qt4NodeInstanceServer::changePropertyBindings(const ChangeBindingsCommand &command)
{
NodeInstanceServer::changePropertyBindings(command);
refreshScreenObject();
}
void Qt4NodeInstanceServer::removeProperties(const RemovePropertiesCommand &command)
{
NodeInstanceServer::removeProperties(command);
refreshScreenObject();
}
void Qt4NodeInstanceServer::refreshScreenObject()
{
if (declarativeView()) {
QObject *screen = rootContext()->contextProperty("screen").value<QObject*>();
if (screen) {
screen->metaObject()->invokeMethod(screen,
"privateSetDisplay",
Q_ARG(int, rootNodeInstance().size().width()),
Q_ARG(int, rootNodeInstance().size().height()),
Q_ARG(qreal, 210)); // TODO: dpi should be setable
}
}
}
} // QmlDesigner
@@ -53,12 +53,18 @@ public:
QDeclarativeEngine *engine() const;
void refreshBindings();
void changeAuxiliaryValues(const ChangeAuxiliaryCommand &command);
void changePropertyValues(const ChangeValuesCommand &command);
void changePropertyBindings(const ChangeBindingsCommand &command);
void removeProperties(const RemovePropertiesCommand &command);
protected:
void initializeView(const QVector<AddImportContainer> &importVector);
void resizeCanvasSizeToRootItemSize();
void resetAllItems();
bool nonInstanceChildIsDirty(QGraphicsObject *graphicsObject) const;
QList<ServerNodeInstance> setupScene(const CreateSceneCommand &command);
void refreshScreenObject();
private:
QWeakPointer<QDeclarativeView> m_declarativeView;