Prototype of experimental UI using Qt Quick

This commit is contained in:
Michaël Lemaire 2014-08-19 15:49:08 +02:00
parent 57c55970da
commit 9f438a3f84
9 changed files with 201 additions and 0 deletions

View file

@ -0,0 +1,44 @@
#include "OpenGLView.h"
#include <QQuickWindow>
// TEMP
#include "OpenGLRenderer.h"
#include "Scenery.h"
static OpenGLRenderer renderer;
static Scenery scenery;
OpenGLView::OpenGLView(QQuickItem *parent) :
QQuickItem(parent)
{
initialized = false;
connect(this, SIGNAL(windowChanged(QQuickWindow*)), this, SLOT(handleWindowChanged(QQuickWindow*)));
scenery.autoPreset();
renderer.setScenery(&scenery);
}
void OpenGLView::handleWindowChanged(QQuickWindow *win)
{
if (win)
{
connect(window(), SIGNAL(beforeRendering()), this, SLOT(paint()), Qt::DirectConnection);
win->setClearBeforeRendering(false);
initialized = false;
}
}
void OpenGLView::paint()
{
if (not initialized)
{
renderer.initialize();
initialized = true;
}
renderer.resize(window()->width(), window()->height());
renderer.paint();
}

View file

@ -0,0 +1,28 @@
#ifndef OPENGLVIEW_H
#define OPENGLVIEW_H
#include "quick_global.h"
#include <QQuickItem>
namespace paysages {
namespace quick {
class OpenGLView : public QQuickItem
{
Q_OBJECT
public:
explicit OpenGLView(QQuickItem *parent = 0);
public slots:
void handleWindowChanged(QQuickWindow *win);
void paint();
private:
bool initialized;
};
}
}
#endif // OPENGLVIEW_H

View file

@ -0,0 +1,27 @@
android-no-sdk {
target.path = /data/user/qt
export(target.path)
INSTALLS += target
} else:android {
x86 {
target.path = /libs/x86
} else: armeabi-v7a {
target.path = /libs/armeabi-v7a
} else {
target.path = /libs/armeabi
}
export(target.path)
INSTALLS += target
} else:unix {
isEmpty(target.path) {
qnx {
target.path = /tmp/$${TARGET}/bin
} else {
target.path = /opt/$${TARGET}/bin
}
export(target.path)
}
INSTALLS += target
}
export(INSTALLS)

View file

@ -0,0 +1,19 @@
#include <QGuiApplication>
#include <QQuickView>
#include <QtQml>
#include "OpenGLView.h"
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
qmlRegisterType<OpenGLView>("Paysages", 1, 0, "OpenGLView");
QQuickView view;
view.setResizeMode(QQuickView::SizeRootObjectToView);
view.setSource(QUrl("qrc:///main.qml"));
view.show();
return app.exec();
}

View file

@ -0,0 +1,11 @@
import QtQuick 2.2
import Paysages 1.0
Item {
width: 640
height: 480
OpenGLView {
}
}

View file

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

View file

@ -0,0 +1,50 @@
TEMPLATE = app
QT += qml quick widgets
include(../../common.pri)
SOURCES += main.cpp \
OpenGLView.cpp
RESOURCES += qml.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

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

View file

@ -10,5 +10,6 @@ SUBDIRS = \
render/opengl \
interface/commandline \
interface/desktop \
interface/quick \
tests/googletest \
tests