Added cancel button on render dialog
This commit is contained in:
parent
005c24fa85
commit
84cb69e127
9 changed files with 70 additions and 17 deletions
|
@ -131,8 +131,6 @@ void MainModelerWindow::keyReleaseEvent(QKeyEvent *event)
|
|||
if (event->key() == Qt::Key_Escape)
|
||||
{
|
||||
render_process->stopRender();
|
||||
|
||||
setState(rootObject()->property("previous_state").toString());
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -15,6 +15,7 @@ RenderPreviewProvider::RenderPreviewProvider() :
|
|||
{
|
||||
canvas = NULL;
|
||||
pixbuf = new QImage(1, 1, QImage::Format_ARGB32);
|
||||
hide();
|
||||
}
|
||||
|
||||
RenderPreviewProvider::~RenderPreviewProvider()
|
||||
|
@ -42,6 +43,7 @@ void RenderPreviewProvider::setCanvas(const Canvas *canvas)
|
|||
if (not this->canvas)
|
||||
{
|
||||
this->canvas = canvas;
|
||||
pixbuf->fill(Qt::black);
|
||||
canvas->getPreview()->initLive(this);
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +57,11 @@ void RenderPreviewProvider::releaseCanvas()
|
|||
}
|
||||
}
|
||||
|
||||
void RenderPreviewProvider::hide()
|
||||
{
|
||||
pixbuf->fill(Qt::black);
|
||||
}
|
||||
|
||||
void RenderPreviewProvider::setToneMapping(const ColorProfile &profile)
|
||||
{
|
||||
if (canvas)
|
||||
|
|
|
@ -30,6 +30,11 @@ public:
|
|||
*/
|
||||
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.
|
||||
*/
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <QSize>
|
||||
#include <QTime>
|
||||
#include <QQuickItem>
|
||||
#include "MainModelerWindow.h"
|
||||
#include "SoftwareCanvasRenderer.h"
|
||||
#include "RenderPreviewProvider.h"
|
||||
|
@ -55,6 +56,11 @@ RenderProcess::RenderProcess(MainModelerWindow *window, RenderPreviewProvider *d
|
|||
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);
|
||||
}
|
||||
|
||||
|
@ -107,7 +113,7 @@ void RenderProcess::startRender(Scenery *scenery, const RenderConfig &config)
|
|||
|
||||
// Resize preview
|
||||
QSize preview_size = getPreviewSize();
|
||||
QObject *image = window->findQmlObject("preview_image");
|
||||
QObject *image = window->findQmlObject("render_preview_image");
|
||||
if (image) {
|
||||
image->setProperty("width", preview_size.width());
|
||||
image->setProperty("height", preview_size.height());
|
||||
|
@ -143,6 +149,9 @@ void RenderProcess::showPreviousRender()
|
|||
{
|
||||
if (not rendering and has_render)
|
||||
{
|
||||
destination->setCanvas(renderer->getCanvas());
|
||||
destination->releaseCanvas();
|
||||
|
||||
window->setState("Render Dialog");
|
||||
}
|
||||
}
|
||||
|
@ -153,6 +162,11 @@ void RenderProcess::stopRender()
|
|||
{
|
||||
renderer->interrupt();
|
||||
}
|
||||
else
|
||||
{
|
||||
destination->hide();
|
||||
window->setState(window->rootObject()->property("previous_state").toString());
|
||||
}
|
||||
}
|
||||
|
||||
const QSize RenderProcess::getPreviewSize()
|
||||
|
|
|
@ -21,11 +21,6 @@ public:
|
|||
*/
|
||||
void startRender(Scenery *scenery, const RenderConfig &config);
|
||||
|
||||
/**
|
||||
* Stop any currently running render.
|
||||
*/
|
||||
void stopRender();
|
||||
|
||||
/**
|
||||
* Get the size of the preview image.
|
||||
*/
|
||||
|
@ -54,6 +49,11 @@ public slots:
|
|||
*/
|
||||
void showPreviousRender();
|
||||
|
||||
/**
|
||||
* Stop any currently running render.
|
||||
*/
|
||||
void stopRender();
|
||||
|
||||
protected:
|
||||
virtual void timerEvent(QTimerEvent *event) override;
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtGraphicalEffects 1.0
|
||||
|
||||
BaseRectangle {
|
||||
width: 400
|
||||
height: 300
|
||||
color: "#222429"
|
||||
|
||||
function refresh() {
|
||||
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 {
|
||||
id: preview_image
|
||||
objectName: "preview_image"
|
||||
objectName: "render_preview_image"
|
||||
anchors.centerIn: parent
|
||||
width: 100
|
||||
height: 100
|
||||
|
@ -43,6 +65,7 @@ BaseRectangle {
|
|||
anchors.top: render_progress.bottom
|
||||
anchors.horizontalCenter: render_progress.horizontalCenter
|
||||
anchors.topMargin: 20
|
||||
color: "#dddddd"
|
||||
}
|
||||
|
||||
Timer {
|
||||
|
|
|
@ -9,6 +9,7 @@ Item {
|
|||
property bool checked: false
|
||||
property bool hovered: false
|
||||
property bool toggle: false
|
||||
property bool checkable: true
|
||||
property ExclusiveGroup exclusiveGroup: null
|
||||
property string helptext
|
||||
property string hovertext
|
||||
|
@ -98,6 +99,8 @@ Item {
|
|||
return;
|
||||
}
|
||||
|
||||
if (button.checkable)
|
||||
{
|
||||
button.checked = !button.checked;
|
||||
if (!button.toggle)
|
||||
{
|
||||
|
@ -110,6 +113,8 @@ Item {
|
|||
tooltip_widget.helptext = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
button.clicked();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,5 +51,6 @@
|
|||
<file>images/icon_preset.png</file>
|
||||
<file>images/icon_render_medium.png</file>
|
||||
<file>images/icon_render_final.png</file>
|
||||
<file>images/icon_cancel.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
BIN
src/interface/modeler/quickapp/qml/images/icon_cancel.png
Normal file
BIN
src/interface/modeler/quickapp/qml/images/icon_cancel.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
Loading…
Reference in a new issue