summaryrefslogtreecommitdiffstats
path: root/creatorplugin
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2016-05-27 15:50:49 +0300
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2016-05-30 08:38:46 +0000
commit61fd2a395935e88b341ad9391110c360da478bfb (patch)
tree67109cccec88df7d515e218ccf5beaac5bc45bac /creatorplugin
parent499626978af7c8186be046943f245a20806dcfe7 (diff)
Refactor editor to support launching it from creator plugin
Editor functionality is moved into a library, which is used from both a new standalone application and a creator plugin. Currently creator plugin just launches the editor in a separate window. Change-Id: Ia549d43e8b3d282ea5f96ad0cf661cf3b53aadfc Reviewed-by: Tomi Korpipää <tomi.korpipaa@theqtcompany.com>
Diffstat (limited to 'creatorplugin')
-rw-r--r--creatorplugin/Qt3DSceneEditorPlugin.json.in36
-rw-r--r--creatorplugin/creatorplugin.pro67
-rw-r--r--creatorplugin/qt3dsceneeditorplugin.cpp110
-rw-r--r--creatorplugin/qt3dsceneeditorplugin.h59
-rw-r--r--creatorplugin/qt3dsceneeditorplugin_global.h9
-rw-r--r--creatorplugin/qt3dsceneeditorpluginconstants.h10
6 files changed, 291 insertions, 0 deletions
diff --git a/creatorplugin/Qt3DSceneEditorPlugin.json.in b/creatorplugin/Qt3DSceneEditorPlugin.json.in
new file mode 100644
index 0000000..0f3e0cb
--- /dev/null
+++ b/creatorplugin/Qt3DSceneEditorPlugin.json.in
@@ -0,0 +1,36 @@
+{
+ \"Name\" : \"Qt3DSceneEditorPlugin\",
+ \"Version\" : \"0.0.1\",
+ \"CompatVersion\" : \"0.0.1\",
+ \"Vendor\" : \"The Qt Company Ltd\",
+ \"Copyright\" : \"(C) 2016 TheQtCompany Ltd\",
+ \"License\" : \"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.
+
+ GNU Lesser General Public License Usage
+ Alternatively, this file may be used under the terms of the GNU Lesser
+ General Public License version 3 as published by the Free Software
+ Foundation and appearing in the file LICENSE.LGPL3 included in the
+ packaging of this file. Please review the following information to
+ ensure the GNU Lesser General Public License version 3 requirements
+ will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+
+ GNU General Public License Usage
+ Alternatively, this file may be used under the terms of the GNU
+ General Public License version 2.0 or (at your option) the GNU General
+ Public license version 3 or any later version approved by the KDE Free
+ Qt Foundation. The licenses are as published by the Free Software
+ Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+ included in the packaging of this file. Please review the following
+ information to ensure the GNU General Public License requirements will
+ be met: https://www.gnu.org/licenses/gpl-2.0.html and
+ https://www.gnu.org/licenses/gpl-3.0.html.\",
+ \"Description\" : \"Qt Creator plugin of Qt3D Scene Editor\",
+ \"Url\" : \"http://www.qt.io\",
+ $$dependencyList
+}
diff --git a/creatorplugin/creatorplugin.pro b/creatorplugin/creatorplugin.pro
new file mode 100644
index 0000000..a1babdb
--- /dev/null
+++ b/creatorplugin/creatorplugin.pro
@@ -0,0 +1,67 @@
+DEFINES += QT3DSCENEEDITORPLUGIN_LIBRARY
+
+QT += qml quick
+
+DEPENDPATH += ../editorlib
+INCLUDEPATH += ../editorlib
+
+# Qt3DSceneEditorPlugin files
+
+SOURCES += qt3dsceneeditorplugin.cpp
+
+HEADERS += qt3dsceneeditorplugin.h \
+ qt3dsceneeditorplugin_global.h \
+ qt3dsceneeditorpluginconstants.h
+
+# Qt Creator linking
+
+## Either set the IDE_SOURCE_TREE when running qmake,
+## or set the QTC_SOURCE environment variable, to override the default setting
+isEmpty(IDE_SOURCE_TREE): IDE_SOURCE_TREE = $$(QTC_SOURCE)
+isEmpty(IDE_SOURCE_TREE): IDE_SOURCE_TREE = "/dev/qt/qt-creator"
+
+## Either set the IDE_BUILD_TREE when running qmake,
+## or set the QTC_BUILD environment variable, to override the default setting
+isEmpty(IDE_BUILD_TREE): IDE_BUILD_TREE = $$(QTC_BUILD)
+isEmpty(IDE_BUILD_TREE): IDE_BUILD_TREE = "/dev/qt/build-qtcreator"
+
+## uncomment to build plugin into user config directory
+## <localappdata>/plugins/<ideversion>
+## where <localappdata> is e.g.
+## "%LOCALAPPDATA%\QtProject\qtcreator" on Windows Vista and later
+## "$XDG_DATA_HOME/data/QtProject/qtcreator" or "~/.local/share/data/QtProject/qtcreator" on Linux
+## "~/Library/Application Support/QtProject/Qt Creator" on OS X
+# USE_USER_DESTDIR = yes
+
+###### If the plugin can be depended upon by other plugins, this code needs to be outsourced to
+###### <dirname>_dependencies.pri, where <dirname> is the name of the directory containing the
+###### plugin's sources.
+
+QTC_PLUGIN_NAME = Qt3DSceneEditorPlugin
+QTC_LIB_DEPENDS += \
+ # nothing here at this time
+
+QTC_PLUGIN_DEPENDS += \
+ coreplugin
+
+QTC_PLUGIN_RECOMMENDS += \
+ # optional plugin dependencies. nothing here at this time
+
+###### End _dependencies.pri contents ######
+
+include($$IDE_SOURCE_TREE/src/qtcreatorplugin.pri)
+
+# Copy editorlib under creator
+win32 {
+ EDITORLIBNAME = qt3dsceneeditor.dll
+ CONFIG (release, debug|release): EDITORLIBDIR = $$OUT_PWD/../editorlib/release
+ else:CONFIG (debug, debug|release): EDITORLIBDIR = $$OUT_PWD/../editorlib/debug
+} else {
+ EDITORLIBNAME = qt3dsceneeditor.so
+ EDITORLIBDIR = $$OUT_PWD/../editorlib
+}
+
+LIBS += -L$$EDITORLIBDIR -lqt3dsceneeditor
+
+QMAKE_POST_LINK += $$QMAKE_COPY $$shell_path($$EDITORLIBDIR$${QMAKE_DIR_SEP}$${EDITORLIBNAME} \
+ $${IDE_BIN_PATH}$${QMAKE_DIR_SEP}$${EDITORLIBNAME})
diff --git a/creatorplugin/qt3dsceneeditorplugin.cpp b/creatorplugin/qt3dsceneeditorplugin.cpp
new file mode 100644
index 0000000..68011fc
--- /dev/null
+++ b/creatorplugin/qt3dsceneeditorplugin.cpp
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D Editor of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** 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.
+**
+** 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 with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qt3dsceneeditorplugin.h"
+#include "qt3dsceneeditorpluginconstants.h"
+#include "../editorlib/src/qt3dsceneeditor.h"
+
+#include <coreplugin/icore.h>
+#include <coreplugin/icontext.h>
+#include <coreplugin/actionmanager/actionmanager.h>
+#include <coreplugin/actionmanager/command.h>
+#include <coreplugin/actionmanager/actioncontainer.h>
+#include <coreplugin/coreconstants.h>
+
+#include <QAction>
+#include <QMessageBox>
+#include <QMainWindow>
+#include <QMenu>
+
+namespace Qt3DSceneEditorPlugin {
+namespace Internal {
+
+Qt3DSceneEditorPluginPlugin::Qt3DSceneEditorPluginPlugin() :
+ m_qmlEngine(nullptr)
+{
+ // Create your members
+}
+
+Qt3DSceneEditorPluginPlugin::~Qt3DSceneEditorPluginPlugin()
+{
+ // Unregister objects from the plugin manager's object pool
+ // Delete members
+}
+
+bool Qt3DSceneEditorPluginPlugin::initialize(const QStringList &arguments, QString *errorString)
+{
+ // Register objects in the plugin manager's object pool
+ // Load settings
+ // Add actions to menus
+ // Connect to other plugins' signals
+ // In the initialize function, a plugin can be sure that the plugins it
+ // depends on have initialized their members.
+
+ Q_UNUSED(arguments)
+ Q_UNUSED(errorString)
+
+ QAction *action = new QAction(tr("Launch External Qt3D Scene Editor..."), this);
+ Core::Command *cmd = Core::ActionManager::registerAction(action, Constants::ACTION_ID,
+ Core::Context(Core::Constants::C_GLOBAL));
+ connect(action, SIGNAL(triggered()), this, SLOT(triggerAction()));
+
+ Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::MENU_ID);
+ menu->menu()->setTitle(tr("Qt3D Scene Editor"));
+ menu->addAction(cmd);
+ Core::ActionManager::actionContainer(Core::Constants::M_TOOLS)->addMenu(menu);
+
+ return true;
+}
+
+void Qt3DSceneEditorPluginPlugin::extensionsInitialized()
+{
+ // Retrieve objects from the plugin manager's object pool
+ // In the extensionsInitialized function, a plugin can be sure that all
+ // plugins that depend on it are completely initialized.
+}
+
+ExtensionSystem::IPlugin::ShutdownFlag Qt3DSceneEditorPluginPlugin::aboutToShutdown()
+{
+ // Save settings
+ // Disconnect from signals that are not needed during shutdown
+ // Hide UI (if you add UI that is not in the main window directly)
+ return SynchronousShutdown;
+}
+
+void Qt3DSceneEditorPluginPlugin::triggerAction()
+{
+ // TODO: How to handle application lifecycle? Currently closing the window doesn't destroy scene
+ if (!m_qmlEngine) {
+ register3DSceneEditorQML();
+ m_qmlEngine = new QQmlApplicationEngine(this);
+ }
+ m_qmlEngine->load(QUrl(QStringLiteral("qrc:/qt3deditorlib/main.qml")));
+}
+
+} // namespace Internal
+} // namespace Qt3DSceneEditorPlugin
diff --git a/creatorplugin/qt3dsceneeditorplugin.h b/creatorplugin/qt3dsceneeditorplugin.h
new file mode 100644
index 0000000..bb6373f
--- /dev/null
+++ b/creatorplugin/qt3dsceneeditorplugin.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D Editor of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** 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.
+**
+** 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 with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#pragma once
+
+#include "qt3dsceneeditorplugin_global.h"
+
+#include <extensionsystem/iplugin.h>
+#include <QtQml/QQmlApplicationEngine>
+
+namespace Qt3DSceneEditorPlugin {
+namespace Internal {
+
+class Qt3DSceneEditorPluginPlugin : public ExtensionSystem::IPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Qt3DSceneEditorPlugin.json")
+
+public:
+ Qt3DSceneEditorPluginPlugin();
+ ~Qt3DSceneEditorPluginPlugin();
+
+ bool initialize(const QStringList &arguments, QString *errorString);
+ void extensionsInitialized();
+ ShutdownFlag aboutToShutdown();
+
+private slots:
+ void triggerAction();
+
+private:
+ QQmlApplicationEngine *m_qmlEngine;
+};
+
+} // namespace Internal
+} // namespace Qt3DSceneEditorPlugin
diff --git a/creatorplugin/qt3dsceneeditorplugin_global.h b/creatorplugin/qt3dsceneeditorplugin_global.h
new file mode 100644
index 0000000..c5c5ac4
--- /dev/null
+++ b/creatorplugin/qt3dsceneeditorplugin_global.h
@@ -0,0 +1,9 @@
+#pragma once
+
+#include <QtGlobal>
+
+#if defined(QT3DSCENEEDITORPLUGIN_LIBRARY)
+# define QT3DSCENEEDITORPLUGINSHARED_EXPORT Q_DECL_EXPORT
+#else
+# define QT3DSCENEEDITORPLUGINSHARED_EXPORT Q_DECL_IMPORT
+#endif
diff --git a/creatorplugin/qt3dsceneeditorpluginconstants.h b/creatorplugin/qt3dsceneeditorpluginconstants.h
new file mode 100644
index 0000000..281e1ca
--- /dev/null
+++ b/creatorplugin/qt3dsceneeditorpluginconstants.h
@@ -0,0 +1,10 @@
+#pragma once
+
+namespace Qt3DSceneEditorPlugin {
+namespace Constants {
+
+const char ACTION_ID[] = "Qt3DSceneEditorPlugin.Action";
+const char MENU_ID[] = "Qt3DSceneEditorPlugin.Menu";
+
+} // namespace Qt3DSceneEditorPlugin
+} // namespace Constants