Prototype of experimental UI using Qt Quick
This commit is contained in:
parent
57c55970da
commit
9f438a3f84
9 changed files with 201 additions and 0 deletions
44
src/interface/quick/OpenGLView.cpp
Normal file
44
src/interface/quick/OpenGLView.cpp
Normal 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();
|
||||
}
|
28
src/interface/quick/OpenGLView.h
Normal file
28
src/interface/quick/OpenGLView.h
Normal 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
|
27
src/interface/quick/deployment.pri
Normal file
27
src/interface/quick/deployment.pri
Normal 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)
|
19
src/interface/quick/main.cpp
Normal file
19
src/interface/quick/main.cpp
Normal 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();
|
||||
}
|
11
src/interface/quick/main.qml
Normal file
11
src/interface/quick/main.qml
Normal file
|
@ -0,0 +1,11 @@
|
|||
import QtQuick 2.2
|
||||
import Paysages 1.0
|
||||
|
||||
Item {
|
||||
|
||||
width: 640
|
||||
height: 480
|
||||
|
||||
OpenGLView {
|
||||
}
|
||||
}
|
5
src/interface/quick/qml.qrc
Normal file
5
src/interface/quick/qml.qrc
Normal file
|
@ -0,0 +1,5 @@
|
|||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>main.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
50
src/interface/quick/quick.pro
Normal file
50
src/interface/quick/quick.pro
Normal 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
|
16
src/interface/quick/quick_global.h
Normal file
16
src/interface/quick/quick_global.h
Normal 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
|
|
@ -10,5 +10,6 @@ SUBDIRS = \
|
|||
render/opengl \
|
||||
interface/commandline \
|
||||
interface/desktop \
|
||||
interface/quick \
|
||||
tests/googletest \
|
||||
tests
|
||||
|
|
Loading…
Reference in a new issue