Improved basic quick ui usability

This commit is contained in:
Michaël Lemaire 2015-07-22 18:05:24 +02:00
parent 404b54a865
commit 2c877953e7
6 changed files with 56 additions and 4 deletions

View file

@ -11,6 +11,7 @@
#include "RenderConfig.h"
#include <QQmlEngine>
#include <QGuiApplication>
MainModelerWindow::MainModelerWindow()
{
@ -73,4 +74,11 @@ void MainModelerWindow::keyReleaseEvent(QKeyEvent *event)
rootObject()->setProperty("state", QString("Init"));
}
else if (event->key() == Qt::Key_Q)
{
if (event->modifiers() & Qt::ControlModifier)
{
QGuiApplication::instance()->exit();
}
}
}

View file

@ -35,12 +35,24 @@ ModelerCameras::~ModelerCameras()
void ModelerCameras::processZoom(double value)
{
active->strafeForward(value);
validate();
}
void ModelerCameras::processScroll(double xvalue, double yvalue)
{
active->strafeRight(xvalue);
active->strafeUp(yvalue);
validate();
}
void ModelerCameras::processPanning(double xvalue, double yvalue)
{
active->rotateYaw(xvalue);
active->rotatePitch(yvalue);
validate();
}
void ModelerCameras::timerEvent(QTimerEvent *)
@ -51,6 +63,13 @@ void ModelerCameras::timerEvent(QTimerEvent *)
renderer->setCamera(current);
}
void ModelerCameras::validate()
{
if (active == render) {
parent->getScenery()->setCamera(active);
}
}
void ModelerCameras::changeActiveCamera(const QString &name)
{
if (name == "Render camera")

View file

@ -29,9 +29,19 @@ public:
*/
void processScroll(double xvalue, double yvalue);
/**
* Process a panning rotation.
*/
void processPanning(double xvalue, double yvalue);
protected:
void timerEvent(QTimerEvent *event);
/**
* Validate current camera, pushing it to rendered scenery if needed.
*/
void validate();
public slots:
void changeActiveCamera(const QString &name);

View file

@ -76,10 +76,14 @@ void OpenGLView::mouseReleaseEvent(QMouseEvent *)
void OpenGLView::mouseMoveEvent(QMouseEvent *event)
{
QPointF diff = event->windowPos() - mouse_pos;
if (mouse_button == Qt::MidButton)
if (mouse_button == Qt::LeftButton)
{
window->getCamera()->processScroll(-0.1 * diff.x(), 0.1 * diff.y());
}
else if (mouse_button == Qt::RightButton)
{
window->getCamera()->processPanning(0.006 * diff.x(), 0.002 * diff.y());
}
mouse_pos = event->windowPos();
}

View file

@ -70,8 +70,8 @@ void RenderPreviewProvider::canvasResized(int width, int height)
{
delete pixbuf;
pixbuf = new QImage(width, height, QImage::Format_ARGB32);
pixbuf->fill(Qt::black);
}
pixbuf->fill(Qt::black);
}
void RenderPreviewProvider::canvasCleared(const Color &col)

View file

@ -4,6 +4,18 @@ Rectangle {
width: 400
height: 300
function refresh() {
preview_image.source = "";
preview_image.source = "image://renderpreviewprovider/live";
}
onOpacityChanged: {
refresh();
}
onVisibleChanged: {
refresh();
}
Image {
id: preview_image
objectName: "preview_image"
@ -20,8 +32,7 @@ Rectangle {
repeat: true
onTriggered: {
preview_image.source = "";
preview_image.source = "image://renderpreviewprovider/live";
refresh();
}
}
}