From 09a8c01db6e7b990e982fb7b025da194fd275630 Mon Sep 17 00:00:00 2001 From: Rodrigo Goncalves de Oliveira Date: Thu, 20 Sep 2012 17:58:20 -0400 Subject: [PATCH 1/3] Adjusting plugin macro on Qt5 Signed-off-by: Rodrigo Goncalves de Oliveira --- src/plugins.cpp | 2 ++ src/plugins.h | 3 +++ src/plugins.json | 3 +++ src/src.pro | 2 ++ 4 files changed, 10 insertions(+) create mode 100644 src/plugins.json diff --git a/src/plugins.cpp b/src/plugins.cpp index b384d4a..da34ac2 100644 --- a/src/plugins.cpp +++ b/src/plugins.cpp @@ -75,4 +75,6 @@ void Plugins::registerTypes(const char *uri) qmlRegisterType("QuasiGame", 1, 0, "QuasiFixture"); } +#if QT_VERSION <= 0x048000 Q_EXPORT_PLUGIN2(QuasiGame, Plugins); +#endif diff --git a/src/plugins.h b/src/plugins.h index f113eca..e113c70 100644 --- a/src/plugins.h +++ b/src/plugins.h @@ -35,6 +35,9 @@ class Plugins : public QDeclarativeExtensionPlugin #endif { Q_OBJECT +#if QT_VERSION >= 0x050000 + Q_PLUGIN_METADATA(IID "QuasiGame" FILE "plugins.json") +#endif public: void registerTypes(const char *uri); diff --git a/src/plugins.json b/src/plugins.json new file mode 100644 index 0000000..74a31d8 --- /dev/null +++ b/src/plugins.json @@ -0,0 +1,3 @@ +{ + "Keys": ["QuasiGame"] +} diff --git a/src/src.pro b/src/src.pro index db5177c..661e22d 100644 --- a/src/src.pro +++ b/src/src.pro @@ -85,6 +85,8 @@ SOURCES += entity.cpp \ fixture.cpp \ material.cpp +OTHER_FILES += plugins.json + QMAKE_POST_LINK = $$QMAKE_COPY $$PWD/qmldir $$OUT_PWD/imports/QuasiGame !isEmpty(QTPATH): target.path = $$QTPATH/imports/$$TARGETPATH From 4abb3c9b18b56fcba172de6efb2e1d3654bfc56a Mon Sep 17 00:00:00 2001 From: Rodrigo Goncalves de Oliveira Date: Tue, 30 Oct 2012 11:34:05 -0400 Subject: [PATCH 2/3] Removing QQuickCanvas references This is deprecated, Qt5 is using QQuickWindow instead now. Signed-off-by: Rodrigo Goncalves de Oliveira --- src/box2dmousejoint.cpp | 4 ++-- src/game.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/box2dmousejoint.cpp b/src/box2dmousejoint.cpp index 23aad8f..f59f7e6 100644 --- a/src/box2dmousejoint.cpp +++ b/src/box2dmousejoint.cpp @@ -25,7 +25,7 @@ #include "game.h" #if QT_VERSION >= 0x050000 -#include +#include #else #include #endif @@ -150,7 +150,7 @@ void Box2DMouseJoint::synchronize() QPoint mousePos; #if QT_VERSION >= 0x050000 - mousePos = canvas()->mapFromGlobal(QCursor::pos()); + mousePos = window()->mapFromGlobal(QCursor::pos()); #else m_mousePos = QCursor::pos(); QWidget *widget = QApplication::widgetAt(m_mousePos); diff --git a/src/game.cpp b/src/game.cpp index 9b980b2..d5e48cb 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -24,7 +24,7 @@ #include "scene.h" #if QT_VERSION >= 0x050000 -#include +#include #else #include #endif @@ -107,7 +107,7 @@ void Game::update() QPointF Game::mouse() { #if QT_VERSION >= 0x050000 - return canvas()->mapFromGlobal(QCursor::pos()); + return window()->mapFromGlobal(QCursor::pos()); #else m_mousePos = QCursor::pos(); QWidget *widget = QApplication::widgetAt(m_mousePos); From 7082e59712336b8ad2a077093f10ba06a0dae999 Mon Sep 17 00:00:00 2001 From: Rodrigo Goncalves de Oliveira Date: Thu, 20 Sep 2012 17:59:08 -0400 Subject: [PATCH 3/3] Adjusting Qt5 scripting system changes On Qt5 we need to use QQmlExplression and QQmlScriptString instead of QDeclarativeExpression and QDeclarativeSriptString. Note: Scripts are not working on Qt5 now (Qt5 problem). Signed-off-by: Rodrigo Goncalves de Oliveira --- src/scriptbehavior.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/scriptbehavior.cpp b/src/scriptbehavior.cpp index d49b141..ad8c3b5 100644 --- a/src/scriptbehavior.cpp +++ b/src/scriptbehavior.cpp @@ -23,6 +23,8 @@ #if QT_VERSION >= 0x050000 #include +#include +#include #else #include #endif @@ -56,15 +58,21 @@ void ScriptBehavior::setScript(const QQmlScriptString &script) void ScriptBehavior::setScript(const QDeclarativeScriptString &script) #endif { - if (m_script.script() != script.script()) { +#if QT_VERSION >= 0x050000 + if (m_script.stringLiteral() != script.stringLiteral()){ // XXX scripts are not working on Qt5 D: m_script = script; if (m_expression) delete m_expression; -#if QT_VERSION >= 0x050000 - m_expression = new QQmlExpression(m_script.context(), m_script.scopeObject(), m_script.script()); + m_expression = new QQmlExpression(m_script); #else + if (m_script.script() != script.script()) { + m_script = script; + + if (m_expression) + delete m_expression; + m_expression = new QDeclarativeExpression(m_script.context(), m_script.scopeObject(), m_script.script()); #endif