diff --git a/src/interface/modeler/quickapp/MainModelerWindow.cpp b/src/interface/modeler/quickapp/MainModelerWindow.cpp index 6f0b9aa..b93a975 100644 --- a/src/interface/modeler/quickapp/MainModelerWindow.cpp +++ b/src/interface/modeler/quickapp/MainModelerWindow.cpp @@ -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 diff --git a/src/interface/modeler/quickapp/RenderPreviewProvider.cpp b/src/interface/modeler/quickapp/RenderPreviewProvider.cpp index 68eb364..f562466 100644 --- a/src/interface/modeler/quickapp/RenderPreviewProvider.cpp +++ b/src/interface/modeler/quickapp/RenderPreviewProvider.cpp @@ -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) diff --git a/src/interface/modeler/quickapp/RenderPreviewProvider.h b/src/interface/modeler/quickapp/RenderPreviewProvider.h index d11708c..4164c73 100644 --- a/src/interface/modeler/quickapp/RenderPreviewProvider.h +++ b/src/interface/modeler/quickapp/RenderPreviewProvider.h @@ -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. */ diff --git a/src/interface/modeler/quickapp/RenderProcess.cpp b/src/interface/modeler/quickapp/RenderProcess.cpp index ce2958b..c625ea7 100644 --- a/src/interface/modeler/quickapp/RenderProcess.cpp +++ b/src/interface/modeler/quickapp/RenderProcess.cpp @@ -2,6 +2,7 @@ #include #include +#include #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() diff --git a/src/interface/modeler/quickapp/RenderProcess.h b/src/interface/modeler/quickapp/RenderProcess.h index 273f6ca..e5dc0b7 100644 --- a/src/interface/modeler/quickapp/RenderProcess.h +++ b/src/interface/modeler/quickapp/RenderProcess.h @@ -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; diff --git a/src/interface/modeler/quickapp/qml/RenderDialog.qml b/src/interface/modeler/quickapp/qml/RenderDialog.qml index 20b2c47..5b088bd 100644 --- a/src/interface/modeler/quickapp/qml/RenderDialog.qml +++ b/src/interface/modeler/quickapp/qml/RenderDialog.qml @@ -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 { diff --git a/src/interface/modeler/quickapp/qml/ToolbarButton.qml b/src/interface/modeler/quickapp/qml/ToolbarButton.qml index 2453030..9ec71c7 100644 --- a/src/interface/modeler/quickapp/qml/ToolbarButton.qml +++ b/src/interface/modeler/quickapp/qml/ToolbarButton.qml @@ -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,18 +99,22 @@ Item { return; } - button.checked = !button.checked; - if (!button.toggle) + if (button.checkable) { - if (button.checked) + button.checked = !button.checked; + if (!button.toggle) { - tooltip_widget.helptext = helptext; - } - else - { - tooltip_widget.helptext = ""; + if (button.checked) + { + tooltip_widget.helptext = helptext; + } + else + { + tooltip_widget.helptext = ""; + } } } + button.clicked(); } } diff --git a/src/interface/modeler/quickapp/qml/app.qrc b/src/interface/modeler/quickapp/qml/app.qrc index b4b14f1..81d6070 100644 --- a/src/interface/modeler/quickapp/qml/app.qrc +++ b/src/interface/modeler/quickapp/qml/app.qrc @@ -51,5 +51,6 @@ images/icon_preset.png images/icon_render_medium.png images/icon_render_final.png + images/icon_cancel.png diff --git a/src/interface/modeler/quickapp/qml/images/icon_cancel.png b/src/interface/modeler/quickapp/qml/images/icon_cancel.png new file mode 100644 index 0000000..121c3ba Binary files /dev/null and b/src/interface/modeler/quickapp/qml/images/icon_cancel.png differ