diff --git a/.travis.yml b/.travis.yml index 0e54ebcfa..c0d2a0335 100644 --- a/.travis.yml +++ b/.travis.yml @@ -116,7 +116,7 @@ matrix: env: FLAVOR=qt5 BUILDTYPE=Release _CXX=g++-4.9 _CC=gcc-4.9 addons: *qt5 script: - - make qt-app + - make qt-app qt-qml-app cache: directories: diff --git a/Makefile b/Makefile index 182d14b76..2b6212149 100644 --- a/Makefile +++ b/Makefile @@ -188,6 +188,14 @@ qt-app: run-qt-app: qt-app $(RUN) PLATFORM=qt run-qt-app +.PHONY: qt-qml-app +qt-qml-app: + $(RUN) PLATFORM=qt Makefile/qt-qml-app + +.PHONY: run-qt-qml-app +run-qt-qml-app: qt-qml-app + $(RUN) PLATFORM=qt run-qt-qml-app + .PHONY: test-qt test-qt: node_modules/express $(RUN) PLATFORM=qt test-* diff --git a/platform/qt/platform.gyp b/platform/qt/platform.gyp index dcf916955..f73b92052 100644 --- a/platform/qt/platform.gyp +++ b/platform/qt/platform.gyp @@ -10,6 +10,11 @@ ], 'qtlibversion': '1.0.0', }, + 'conditions': [ + ['qt_version == 5', { + 'includes': [ 'qmlapp/qquickmapboxgl.gypi' ], + }], + ], 'includes': [ 'app/qmapboxgl.gypi', '../../mbgl.gypi', diff --git a/platform/qt/qmlapp/main.cpp b/platform/qt/qmlapp/main.cpp new file mode 100644 index 000000000..df12663ca --- /dev/null +++ b/platform/qt/qmlapp/main.cpp @@ -0,0 +1,17 @@ +#include +#include +#include + +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + qmlRegisterType("QQuickMapboxGL", 1, 0, "QQuickMapboxGL"); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + + return app.exec(); +} diff --git a/platform/qt/qmlapp/main.qml b/platform/qt/qmlapp/main.qml new file mode 100644 index 000000000..b5b1fc349 --- /dev/null +++ b/platform/qt/qmlapp/main.qml @@ -0,0 +1,33 @@ +import QtQuick 2.4 +import QtQuick.Controls 1.3 +import QtQuick.Window 2.2 +import QtQuick.Dialogs 1.2 +import QQuickMapboxGL 1.0 + +ApplicationWindow { + id: window + title: qsTr("Mapbox GL QML example") + width: 1024 + height: 768 + visible: true + + Rectangle { + id: rect + width: 800 + height: 600 + anchors.centerIn: parent + + NumberAnimation on x { + from: 0; + to: 100; + loops: Animation.Infinite; + duration: 1000; + } + + QQuickMapboxGL { + id: map + anchors.fill: parent + } // QQuickMapboxGL + + } // Rectangle +} diff --git a/platform/qt/qmlapp/mapbox.png b/platform/qt/qmlapp/mapbox.png new file mode 100644 index 000000000..4879089b5 Binary files /dev/null and b/platform/qt/qmlapp/mapbox.png differ diff --git a/platform/qt/qmlapp/qml.qrc b/platform/qt/qmlapp/qml.qrc new file mode 100644 index 000000000..5f6483ac3 --- /dev/null +++ b/platform/qt/qmlapp/qml.qrc @@ -0,0 +1,5 @@ + + + main.qml + + diff --git a/platform/qt/qmlapp/qquickmapboxgl.gypi b/platform/qt/qmlapp/qquickmapboxgl.gypi new file mode 100644 index 000000000..c5f0aebb0 --- /dev/null +++ b/platform/qt/qmlapp/qquickmapboxgl.gypi @@ -0,0 +1,56 @@ +{ + 'targets': [ + { + 'target_name': 'qt-qml-app', + 'product_name': 'qquickmapboxgl', + 'type': 'executable', + + 'includes': [ + '../qt.gypi', + ], + + 'dependencies': [ + 'qt-lib', + ], + + 'sources': [ + 'main.cpp', + 'qml.qrc', + ], + + 'include_dirs': [ + '../include', + ], + + 'variables': { + 'cflags': [ + '<@(opengl_cflags)', + '<@(qt_core_cflags)', + '<@(qt_gui_cflags)', + '<@(qt_qml_cflags)', + '<@(qt_quick_cflags)', + '-fPIC', + ], + 'ldflags': [ + '<@(opengl_ldflags)', + '<@(qt_core_ldflags)', + '<@(qt_gui_ldflags)', + '<@(qt_qml_ldflags)', + '<@(qt_quick_ldflags)', + ], + }, + + 'conditions': [ + ['OS == "mac"', { + 'xcode_settings': { + 'OTHER_CPLUSPLUSFLAGS': [ '<@(cflags)' ], + 'OTHER_LDFLAGS': [ '<@(ldflags)' ], + }, + }, { + 'cflags_cc': [ '<@(cflags)' ], + 'libraries': [ '<@(ldflags)' ], + }], + ], + }, + ], +} diff --git a/scripts/main.mk b/scripts/main.mk index aa1ce2b0c..fa4ac8e19 100644 --- a/scripts/main.mk +++ b/scripts/main.mk @@ -151,6 +151,9 @@ run-glfw-app: run-qt-app: cd $(PLATFORM_OUTPUT)/$(BUILDTYPE) && ./qmapboxgl +run-qt-qml-app: + cd $(PLATFORM_OUTPUT)/$(BUILDTYPE) && ./qquickmapboxgl + run-valgrind-glfw-app: cd $(PLATFORM_OUTPUT)/$(BUILDTYPE) && valgrind --leak-check=full --suppressions=../../../scripts/valgrind.sup ./mapbox-glfw