From 972c6fddd0087987ba0a2093d196b8e898f82186 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 25 Oct 2019 10:06:26 +0200 Subject: Enable shadow-building the sensor_explorer example on Windows When package-testing, a shadow-build of the example fails due to the import plugin not finding "main.moc", which is apparently caused by the directory structure and using DESTDIR = ./ Add header "main.h" to avoid having to deal with "main.moc". Change-Id: I04024c8d282b4f56d9942c0c8414d0b6ff9b1d20 Reviewed-by: Alex Blasche --- examples/sensors/sensor_explorer/import/import.pro | 1 + examples/sensors/sensor_explorer/import/main.cpp | 28 +++------- examples/sensors/sensor_explorer/import/main.h | 64 ++++++++++++++++++++++ 3 files changed, 74 insertions(+), 19 deletions(-) create mode 100644 examples/sensors/sensor_explorer/import/main.h (limited to 'examples') diff --git a/examples/sensors/sensor_explorer/import/import.pro b/examples/sensors/sensor_explorer/import/import.pro index 49a437e8..48509214 100644 --- a/examples/sensors/sensor_explorer/import/import.pro +++ b/examples/sensors/sensor_explorer/import/import.pro @@ -15,6 +15,7 @@ SOURCES = \ propertyinfo.cpp HEADERS = \ + main.h \ explorer.h \ sensoritem.h \ propertyinfo.h diff --git a/examples/sensors/sensor_explorer/import/main.cpp b/examples/sensors/sensor_explorer/import/main.cpp index b43ea339..4199b2f4 100644 --- a/examples/sensors/sensor_explorer/import/main.cpp +++ b/examples/sensors/sensor_explorer/import/main.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtSensors module of the Qt Toolkit. @@ -48,28 +48,18 @@ ** ****************************************************************************/ -#include -#include +#include "main.h" #include "explorer.h" -#include QT_BEGIN_NAMESPACE -class SensorExplorerDeclarativeModule : public QQmlExtensionPlugin +void SensorExplorerDeclarativeModule::registerTypes(const char *uri) { - Q_OBJECT - Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid FILE "import.json") -public: - void registerTypes(const char *uri) override - { - Q_ASSERT(QLatin1String(uri) == QLatin1String("Explorer")); - // @uri Explorer - qmlRegisterType(uri, 1, 0, "SensorExplorer"); - qmlRegisterType(uri, 1, 0, "SensorItem"); - qmlRegisterType(uri, 1, 0, "PropertyInfo"); - } -}; + Q_ASSERT(QLatin1String(uri) == QLatin1String("Explorer")); + // @uri Explorer + qmlRegisterType(uri, 1, 0, "SensorExplorer"); + qmlRegisterType(uri, 1, 0, "SensorItem"); + qmlRegisterType(uri, 1, 0, "PropertyInfo"); +} QT_END_NAMESPACE - -#include "main.moc" diff --git a/examples/sensors/sensor_explorer/import/main.h b/examples/sensors/sensor_explorer/import/main.h new file mode 100644 index 00000000..6964bec6 --- /dev/null +++ b/examples/sensors/sensor_explorer/import/main.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtSensors module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +QT_BEGIN_NAMESPACE + +class SensorExplorerDeclarativeModule : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid FILE "import.json") +public: + void registerTypes(const char *uri) override; +}; + +QT_END_NAMESPACE -- cgit v1.2.3