Refactored QtQuick UI to work in QtCreator

This commit is contained in:
Michaël Lemaire 2014-08-27 15:18:08 +02:00
parent 078bab62fc
commit 0e2e0a05eb
29 changed files with 202 additions and 73 deletions

View file

@ -0,0 +1,35 @@
TEMPLATE = lib
TARGET = extension
QT += qml quick
CONFIG += qt plugin
TARGET = $$qtLibraryTarget($$TARGET)
uri = Paysages
# Input
SOURCES += \
extension_plugin.cpp \
paysages.cpp
HEADERS += \
extension_plugin.h \
paysages.h
OTHER_FILES = qmldir
!equals(_PRO_FILE_PWD_, $$OUT_PWD) {
copy_qmldir.target = $$OUT_PWD/qmldir
copy_qmldir.depends = $$_PRO_FILE_PWD_/qmldir
copy_qmldir.commands = $(COPY_FILE) \"$$replace(copy_qmldir.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_qmldir.target, /, $$QMAKE_DIR_SEP)\"
QMAKE_EXTRA_TARGETS += copy_qmldir
PRE_TARGETDEPS += $$copy_qmldir.target
}
qmldir.files = qmldir
unix {
installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /)
qmldir.path = $$installPath
target.path = $$installPath
INSTALLS += target qmldir
}

View file

@ -0,0 +1,12 @@
#include "extension_plugin.h"
#include "paysages.h"
#include <qqml.h>
void ExtensionPlugin::registerTypes(const char *uri)
{
// @uri Paysages
qmlRegisterType<Paysages>(uri, 1, 0, "Paysages");
}

View file

@ -0,0 +1,16 @@
#ifndef EXTENSION_PLUGIN_H
#define EXTENSION_PLUGIN_H
#include <QQmlExtensionPlugin>
class ExtensionPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
public:
void registerTypes(const char *uri);
};
#endif // EXTENSION_PLUGIN_H

View file

@ -0,0 +1,16 @@
#include "paysages.h"
Paysages::Paysages(QQuickItem *parent):
QQuickItem(parent)
{
// By default, QQuickItem does not draw anything. If you subclass
// QQuickItem to create a visual item, you will need to uncomment the
// following line and re-implement updatePaintNode()
// setFlag(ItemHasContents, true);
}
Paysages::~Paysages()
{
}

View file

@ -0,0 +1,17 @@
#ifndef PAYSAGES_H
#define PAYSAGES_H
#include <QQuickItem>
class Paysages : public QQuickItem
{
Q_OBJECT
Q_DISABLE_COPY(Paysages)
public:
Paysages(QQuickItem *parent = 0);
~Paysages();
};
#endif // PAYSAGES_H

View file

@ -0,0 +1,3 @@
module Paysages
plugin extension

View file

@ -0,0 +1,5 @@
TEMPLATE = subdirs
SUBDIRS = \
quickapp \
extension

View file

@ -1,12 +1,12 @@
#ifndef OPENGLVIEW_H
#define OPENGLVIEW_H
#include "quick_global.h"
#include "modeler_global.h"
#include <QQuickItem>
namespace paysages {
namespace quick {
namespace modeler {
class OpenGLView : public QQuickItem
{

View file

@ -11,6 +11,7 @@ int main(int argc, char *argv[])
qmlRegisterType<OpenGLView>("Paysages", 1, 0, "OpenGLView");
QQuickView view;
view.setTitle(QObject::tr("Paysages 3D"));
view.setResizeMode(QQuickView::SizeRootObjectToView);
view.setSource(QUrl("qrc:///main.qml"));
view.show();

View file

@ -1,16 +1,16 @@
#ifndef QUICK_GLOBAL_H
#define QUICK_GLOBAL_H
#ifndef MODELER_GLOBAL_H
#define MODELER_GLOBAL_H
#include "definition_global.h"
#include "software_global.h"
#include "opengl_global.h"
namespace paysages {
namespace quick {
namespace modeler {
class ItemOpenGLView;
}
}
using namespace paysages::quick;
using namespace paysages::modeler;
#endif // QUICK_GLOBAL_H
#endif // MODELER_GLOBAL_H

View file

@ -0,0 +1,7 @@
<RCC>
<qresource prefix="/">
<file>qml/main.qml</file>
<file>qml/ToolbarButton.qml</file>
<file>qml/OpenGLView.qml</file>
</qresource>
</RCC>

View file

@ -0,0 +1,6 @@
import QtQuick 2.0
Rectangle {
width: 100
height: 62
}

View file

@ -1,7 +1,7 @@
import QtQuick 2.0
Item {
property string code
property string picture
property bool selected: false
property bool hovered: false
@ -24,7 +24,7 @@ Item {
Image {
id: image
source: "qrc:///toolbar/primary/tab_" + parent.code + ".png"
source: parent.picture
anchors.centerIn: parent
}

View file

@ -0,0 +1,12 @@
<RCC>
<qresource prefix="/">
<file>ToolbarButton.qml</file>
<file>main.qml</file>
<file>images/tab_atmosphere.png</file>
<file>images/tab_clouds.png</file>
<file>images/tab_render.png</file>
<file>images/tab_terrain.png</file>
<file>images/tab_textures.png</file>
<file>images/tab_water.png</file>
</qresource>
</RCC>

View file

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View file

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View file

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View file

@ -34,27 +34,27 @@ OpenGLView {
ToolbarButton {
id: tool_terrain
code: "terrain"
picture: "images/tab_terrain.png"
}
ToolbarButton {
id: tool_textures
code: "textures"
picture: "images/tab_textures.png"
}
ToolbarButton {
id: tool_water
code: "water"
picture: "images/tab_water.png"
}
ToolbarButton {
id: tool_atmosphere
code: "atmosphere"
picture: "images/tab_atmosphere.png"
}
ToolbarButton {
id: tool_clouds
code: "clouds"
picture: "images/tab_clouds.png"
}
ToolbarButton {
id: tool_render
code: "render"
picture: "images/tab_render.png"
}
}
}

View file

@ -0,0 +1,56 @@
TEMPLATE = app
QT += qml quick widgets
include(../../../common.pri)
SOURCES += main.cpp \
OpenGLView.cpp
RESOURCES += \
qml/app.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH = ../extension
# Default rules for deployment.
include(deployment.pri)
HEADERS += \
OpenGLView.h \
modeler_global.h
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../../system/release/ -lpaysages_system
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../../system/debug/ -lpaysages_system
else:unix: LIBS += -L$$OUT_PWD/../../../system/ -lpaysages_system
INCLUDEPATH += $$PWD/../../../system
DEPENDPATH += $$PWD/../../../system
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../../basics/release/ -lpaysages_basics
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../../basics/debug/ -lpaysages_basics
else:unix: LIBS += -L$$OUT_PWD/../../../basics/ -lpaysages_basics
INCLUDEPATH += $$PWD/../../../basics
DEPENDPATH += $$PWD/../../../basics
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../../definition/release/ -lpaysages_definition
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../../definition/debug/ -lpaysages_definition
else:unix: LIBS += -L$$OUT_PWD/../../../definition/ -lpaysages_definition
INCLUDEPATH += $$PWD/../../../definition
DEPENDPATH += $$PWD/../../../definition
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../../render/software/release/ -lpaysages_render_software
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../../render/software/debug/ -lpaysages_render_software
else:unix: LIBS += -L$$OUT_PWD/../../../render/software/ -lpaysages_render_software
INCLUDEPATH += $$PWD/../../../render/software
DEPENDPATH += $$PWD/../../../render/software
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../../render/opengl/release/ -lpaysages_render_opengl
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../../render/opengl/debug/ -lpaysages_render_opengl
else:unix: LIBS += -L$$OUT_PWD/../../../render/opengl/ -lpaysages_render_opengl
INCLUDEPATH += $$PWD/../../../render/opengl
DEPENDPATH += $$PWD/../../../render/opengl
OTHER_FILES += \
qml/main.qml \
qml/ToolbarButton.qml \
qml/OpenGLView.qml

View file

@ -1,6 +0,0 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>ToolbarButton.qml</file>
</qresource>
</RCC>

View file

@ -1,51 +0,0 @@
TEMPLATE = app
QT += qml quick widgets
include(../../common.pri)
SOURCES += main.cpp \
OpenGLView.cpp
RESOURCES += qml.qrc \
images/images.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Default rules for deployment.
include(deployment.pri)
HEADERS += \
quick_global.h \
OpenGLView.h
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../system/release/ -lpaysages_system
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../system/debug/ -lpaysages_system
else:unix: LIBS += -L$$OUT_PWD/../../system/ -lpaysages_system
INCLUDEPATH += $$PWD/../../system
DEPENDPATH += $$PWD/../../system
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../basics/release/ -lpaysages_basics
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../basics/debug/ -lpaysages_basics
else:unix: LIBS += -L$$OUT_PWD/../../basics/ -lpaysages_basics
INCLUDEPATH += $$PWD/../../basics
DEPENDPATH += $$PWD/../../basics
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../definition/release/ -lpaysages_definition
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../definition/debug/ -lpaysages_definition
else:unix: LIBS += -L$$OUT_PWD/../../definition/ -lpaysages_definition
INCLUDEPATH += $$PWD/../../definition
DEPENDPATH += $$PWD/../../definition
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../render/software/release/ -lpaysages_render_software
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../render/software/debug/ -lpaysages_render_software
else:unix: LIBS += -L$$OUT_PWD/../../render/software/ -lpaysages_render_software
INCLUDEPATH += $$PWD/../../render/software
DEPENDPATH += $$PWD/../../render/software
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../render/opengl/release/ -lpaysages_render_opengl
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../render/opengl/debug/ -lpaysages_render_opengl
else:unix: LIBS += -L$$OUT_PWD/../../render/opengl/ -lpaysages_render_opengl
INCLUDEPATH += $$PWD/../../render/opengl
DEPENDPATH += $$PWD/../../render/opengl

View file

@ -10,7 +10,7 @@ SUBDIRS = \
render/opengl \
interface/commandline \
interface/desktop \
interface/quick
interface/modeler
exists( tests/googletest/sources/src/gtest-all.cc ) {
SUBDIRS += \