diff options
author | Dominik Holland <dominik.holland@pelagicore.com> | 2015-10-20 05:09:25 +0200 |
---|---|---|
committer | Alessandro Portale <alessandro.portale@theqtcompany.com> | 2015-12-03 16:26:52 +0000 |
commit | 716bdcc7a9c5c83bdeaf55b33ddd6acefce1a56b (patch) | |
tree | 893e681c4b1d478aaf2e54738b9ed213805fffb1 /examples/contentplugin | |
parent | 4fa1d4f76d44afdf40707fb86f0aeeed1fb1c2ba (diff) |
Import source code from https://github.com/Pelagicore/qmllive
Change-Id: I6888c1c39c5e98c61511f74659b45ddcbb368956
Reviewed-by: Juergen Bocklage-Ryannel <juergen.bocklage-ryannel@pelagicore.com>
Reviewed-by: Alessandro Portale <alessandro.portale@theqtcompany.com>
Diffstat (limited to 'examples/contentplugin')
-rw-r--r-- | examples/contentplugin/contentplugin.pro | 13 | ||||
-rw-r--r-- | examples/contentplugin/mycontentadapterplugin.cpp | 73 | ||||
-rw-r--r-- | examples/contentplugin/mycontentadapterplugin.h | 54 | ||||
-rw-r--r-- | examples/contentplugin/plugin.qml | 45 | ||||
-rw-r--r-- | examples/contentplugin/res.qrc | 5 |
5 files changed, 190 insertions, 0 deletions
diff --git a/examples/contentplugin/contentplugin.pro b/examples/contentplugin/contentplugin.pro new file mode 100644 index 0000000..c142b07 --- /dev/null +++ b/examples/contentplugin/contentplugin.pro @@ -0,0 +1,13 @@ +TEMPLATE = lib +CONFIG += plugin +INCLUDEPATH += ../../src +HEADERS = mycontentadapterplugin.h +SOURCES = mycontentadapterplugin.cpp +TARGET = myContentAdapterPlugin +DESTDIR = ../../bin/plugins + +RESOURCES += res.qrc \ + res.qrc + +OTHER_FILES += \ + plugin.qml diff --git a/examples/contentplugin/mycontentadapterplugin.cpp b/examples/contentplugin/mycontentadapterplugin.cpp new file mode 100644 index 0000000..ab1a6ba --- /dev/null +++ b/examples/contentplugin/mycontentadapterplugin.cpp @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Pelagicore AG +** Contact: http://www.qt.io/ or http://www.pelagicore.com/ +** +** This file is part of the QmlLive tool. +** +** $QT_BEGIN_LICENSE:GPL3-PELAGICORE$ +** Commercial License Usage +** Licensees holding valid commercial Pelagicore Application Manager +** 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 +** Pelagicore. For licensing terms and conditions, contact us at: +** http://www.pelagicore.com. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3 requirements will be +** met: http://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: GPL-3.0 +** +****************************************************************************/ +#include "mycontentadapterplugin.h" + +#include <QtCore/QtPlugin> +#include <QtDeclarative/QDeclarativeContext> + +MyContentAdapterPlugin::MyContentAdapterPlugin(QObject *parent) : + QObject(parent) +{ +} + +//! [2] +bool MyContentAdapterPlugin::canPreview(const QString &path) const +{ + Q_UNUSED(path) + + return false; +} + +QImage MyContentAdapterPlugin::preview(const QString &path, const QSize &requestedSize) +{ + Q_UNUSED(path); + Q_UNUSED(requestedSize); + + return QImage(); +} +//! [2] + +//! [0] +bool MyContentAdapterPlugin::canAdapt(const QUrl &url) const +{ + return url.toLocalFile().endsWith(".png"); +} +//! [0] + +//! [1] +QUrl MyContentAdapterPlugin::adapt(const QUrl &url, QDeclarativeContext *context) +{ + context->setContextProperty("imageSource", url); + + return QString("qrc:/mycontentadatperplugin/plugin.qml"); +} +//! [1] + +Q_EXPORT_PLUGIN2(myContentAdapterPlugin, MyContentAdapterPlugin) diff --git a/examples/contentplugin/mycontentadapterplugin.h b/examples/contentplugin/mycontentadapterplugin.h new file mode 100644 index 0000000..2d21565 --- /dev/null +++ b/examples/contentplugin/mycontentadapterplugin.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Pelagicore AG +** Contact: http://www.qt.io/ or http://www.pelagicore.com/ +** +** This file is part of the QmlLive tool. +** +** $QT_BEGIN_LICENSE:GPL3-PELAGICORE$ +** Commercial License Usage +** Licensees holding valid commercial Pelagicore Application Manager +** 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 +** Pelagicore. For licensing terms and conditions, contact us at: +** http://www.pelagicore.com. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3 requirements will be +** met: http://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: GPL-3.0 +** +****************************************************************************/ +#ifndef MYCONTENTADAPTERPLUGIN_H +#define MYCONTENTADAPTERPLUGIN_H + +#include <contentadapterinterface.h> + +//! [0] +class MyContentAdapterPlugin : public QObject, public ContentAdapterInterface +{ + Q_OBJECT +//! [1] + Q_INTERFACES(ContentAdapterInterface) +//! [1] +public: + explicit MyContentAdapterPlugin(QObject *parent = 0); + + bool canPreview(const QString& path) const; + QImage preview(const QString& path, const QSize &requestedSize); + + bool canAdapt(const QUrl& url) const; + QUrl adapt(const QUrl& url, QDeclarativeContext* context); + +}; +//! [0] + +#endif // MYCONTENTADAPTERPLUGIN_H diff --git a/examples/contentplugin/plugin.qml b/examples/contentplugin/plugin.qml new file mode 100644 index 0000000..20b6afe --- /dev/null +++ b/examples/contentplugin/plugin.qml @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Pelagicore AG +** Contact: http://www.qt.io/ or http://www.pelagicore.com/ +** +** This file is part of the QmlLive tool. +** +** $QT_BEGIN_LICENSE:GPL3-PELAGICORE$ +** Commercial License Usage +** Licensees holding valid commercial Pelagicore Application Manager +** 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 +** Pelagicore. For licensing terms and conditions, contact us at: +** http://www.pelagicore.com. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3 requirements will be +** met: http://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: GPL-3.0 +** +****************************************************************************/ + +//! [0] +import QtQuick 1.1 + +Rectangle { + width: 300 + height: 300 + + Image { + anchors.centerIn: parent + + rotation: 180 + source: imageSource + } +} +//! [0] diff --git a/examples/contentplugin/res.qrc b/examples/contentplugin/res.qrc new file mode 100644 index 0000000..4ff52f2 --- /dev/null +++ b/examples/contentplugin/res.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/mycontentadatperplugin"> + <file>plugin.qml</file> + </qresource> +</RCC> |