Added cancel button on render dialog

This commit is contained in:
Michaël Lemaire 2015-09-14 01:35:25 +02:00
parent 005c24fa85
commit 84cb69e127
9 changed files with 70 additions and 17 deletions

View file

@ -131,8 +131,6 @@ void MainModelerWindow::keyReleaseEvent(QKeyEvent *event)
if (event->key() == Qt::Key_Escape) if (event->key() == Qt::Key_Escape)
{ {
render_process->stopRender(); render_process->stopRender();
setState(rootObject()->property("previous_state").toString());
} }
} }
else else

View file

@ -15,6 +15,7 @@ RenderPreviewProvider::RenderPreviewProvider() :
{ {
canvas = NULL; canvas = NULL;
pixbuf = new QImage(1, 1, QImage::Format_ARGB32); pixbuf = new QImage(1, 1, QImage::Format_ARGB32);
hide();
} }
RenderPreviewProvider::~RenderPreviewProvider() RenderPreviewProvider::~RenderPreviewProvider()
@ -42,6 +43,7 @@ void RenderPreviewProvider::setCanvas(const Canvas *canvas)
if (not this->canvas) if (not this->canvas)
{ {
this->canvas = canvas; this->canvas = canvas;
pixbuf->fill(Qt::black);
canvas->getPreview()->initLive(this); canvas->getPreview()->initLive(this);
} }
} }
@ -55,6 +57,11 @@ void RenderPreviewProvider::releaseCanvas()
} }
} }
void RenderPreviewProvider::hide()
{
pixbuf->fill(Qt::black);
}
void RenderPreviewProvider::setToneMapping(const ColorProfile &profile) void RenderPreviewProvider::setToneMapping(const ColorProfile &profile)
{ {
if (canvas) if (canvas)

View file

@ -30,6 +30,11 @@ public:
*/ */
void releaseCanvas(); void releaseCanvas();
/**
* Call when the image is hidden, to clear it for next render.
*/
void hide();
/** /**
* Set the tone mapping to apply to pixel colors. * Set the tone mapping to apply to pixel colors.
*/ */

View file

@ -2,6 +2,7 @@
#include <QSize> #include <QSize>
#include <QTime> #include <QTime>
#include <QQuickItem>
#include "MainModelerWindow.h" #include "MainModelerWindow.h"
#include "SoftwareCanvasRenderer.h" #include "SoftwareCanvasRenderer.h"
#include "RenderPreviewProvider.h" #include "RenderPreviewProvider.h"
@ -55,6 +56,11 @@ RenderProcess::RenderProcess(MainModelerWindow *window, RenderPreviewProvider *d
connect(button_show, SIGNAL(clicked()), this, SLOT(showPreviousRender())); connect(button_show, SIGNAL(clicked()), this, SLOT(showPreviousRender()));
} }
QObject *button_cancel = window->findQmlObject("render_cancel");
if (button_cancel) {
connect(button_cancel, SIGNAL(clicked()), this, SLOT(stopRender()));
}
startTimer(100); startTimer(100);
} }
@ -107,7 +113,7 @@ void RenderProcess::startRender(Scenery *scenery, const RenderConfig &config)
// Resize preview // Resize preview
QSize preview_size = getPreviewSize(); QSize preview_size = getPreviewSize();
QObject *image = window->findQmlObject("preview_image"); QObject *image = window->findQmlObject("render_preview_image");
if (image) { if (image) {
image->setProperty("width", preview_size.width()); image->setProperty("width", preview_size.width());
image->setProperty("height", preview_size.height()); image->setProperty("height", preview_size.height());
@ -143,6 +149,9 @@ void RenderProcess::showPreviousRender()
{ {
if (not rendering and has_render) if (not rendering and has_render)
{ {
destination->setCanvas(renderer->getCanvas());
destination->releaseCanvas();
window->setState("Render Dialog"); window->setState("Render Dialog");
} }
} }
@ -153,6 +162,11 @@ void RenderProcess::stopRender()
{ {
renderer->interrupt(); renderer->interrupt();
} }
else
{
destination->hide();
window->setState(window->rootObject()->property("previous_state").toString());
}
} }
const QSize RenderProcess::getPreviewSize() const QSize RenderProcess::getPreviewSize()

View file

@ -21,11 +21,6 @@ public:
*/ */
void startRender(Scenery *scenery, const RenderConfig &config); void startRender(Scenery *scenery, const RenderConfig &config);
/**
* Stop any currently running render.
*/
void stopRender();
/** /**
* Get the size of the preview image. * Get the size of the preview image.
*/ */
@ -54,6 +49,11 @@ public slots:
*/ */
void showPreviousRender(); void showPreviousRender();
/**
* Stop any currently running render.
*/
void stopRender();
protected: protected:
virtual void timerEvent(QTimerEvent *event) override; virtual void timerEvent(QTimerEvent *event) override;

View file

@ -1,9 +1,11 @@
import QtQuick 2.2 import QtQuick 2.2
import QtQuick.Controls 1.2 import QtQuick.Controls 1.2
import QtGraphicalEffects 1.0
BaseRectangle { BaseRectangle {
width: 400 width: 400
height: 300 height: 300
color: "#222429"
function refresh() { function refresh() {
preview_image.source = ""; preview_image.source = "";
@ -18,9 +20,29 @@ BaseRectangle {
} }
} }
ToolbarButton {
id: render_cancel
objectName: "render_cancel"
picture: "images/icon_cancel.png"
anchors.top: parent.top
anchors.right: parent.right
anchors.margins: 10
checkable: false
image_width: 48
image_height: 48
}
RectangularGlow {
anchors.fill: preview_image
glowRadius: 8
spread: 0.2
color: "#e0e0e8"
cornerRadius: glowRadius
}
Image { Image {
id: preview_image id: preview_image
objectName: "preview_image" objectName: "render_preview_image"
anchors.centerIn: parent anchors.centerIn: parent
width: 100 width: 100
height: 100 height: 100
@ -43,6 +65,7 @@ BaseRectangle {
anchors.top: render_progress.bottom anchors.top: render_progress.bottom
anchors.horizontalCenter: render_progress.horizontalCenter anchors.horizontalCenter: render_progress.horizontalCenter
anchors.topMargin: 20 anchors.topMargin: 20
color: "#dddddd"
} }
Timer { Timer {

View file

@ -9,6 +9,7 @@ Item {
property bool checked: false property bool checked: false
property bool hovered: false property bool hovered: false
property bool toggle: false property bool toggle: false
property bool checkable: true
property ExclusiveGroup exclusiveGroup: null property ExclusiveGroup exclusiveGroup: null
property string helptext property string helptext
property string hovertext property string hovertext
@ -98,18 +99,22 @@ Item {
return; return;
} }
button.checked = !button.checked; if (button.checkable)
if (!button.toggle)
{ {
if (button.checked) button.checked = !button.checked;
if (!button.toggle)
{ {
tooltip_widget.helptext = helptext; if (button.checked)
} {
else tooltip_widget.helptext = helptext;
{ }
tooltip_widget.helptext = ""; else
{
tooltip_widget.helptext = "";
}
} }
} }
button.clicked(); button.clicked();
} }
} }

View file

@ -51,5 +51,6 @@
<file>images/icon_preset.png</file> <file>images/icon_preset.png</file>
<file>images/icon_render_medium.png</file> <file>images/icon_render_medium.png</file>
<file>images/icon_render_final.png</file> <file>images/icon_render_final.png</file>
<file>images/icon_cancel.png</file>
</qresource> </qresource>
</RCC> </RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB