Commit e399a1b2 authored by luyikei's avatar luyikei

WorkflowFileRendererDialog: Simplify the calculation of the rendering progress

parent a987aa88
......@@ -34,16 +34,12 @@
#include "Tools/RendererEventWatcher.h"
#include "Backend/IInput.h"
WorkflowFileRendererDialog::WorkflowFileRendererDialog( quint32 width, quint32 height,
qint64 totalFrames, RendererEventWatcher* eventWatcher ) :
WorkflowFileRendererDialog::WorkflowFileRendererDialog( quint32 width, quint32 height ) :
m_width( width ),
m_height( height ),
m_totalFrames( totalFrames )
m_height( height )
{
m_ui.setupUi( this );
connect( m_ui.cancelButton, SIGNAL( clicked() ), this, SLOT( cancel() ) );
connect( eventWatcher, &RendererEventWatcher::positionChanged, this, &WorkflowFileRendererDialog::frameChanged );
}
void
......@@ -69,15 +65,15 @@ WorkflowFileRendererDialog::updatePreview( const uchar* buff )
}
void
WorkflowFileRendererDialog::frameChanged( qint64 frame )
WorkflowFileRendererDialog::frameChanged( qint64 newFrame, qint64 length )
{
// Since frame is 0-indexed
frame++;
if ( frame <= m_totalFrames )
newFrame++;
if ( newFrame <= length )
{
m_ui.frameCounter->setText( tr("Rendering frame %1 / %2").arg( QString::number( frame ),
QString::number( m_totalFrames ) ) );
setProgressBarValue( frame * 100 / m_totalFrames );
m_ui.frameCounter->setText( tr("Rendering frame %1 / %2").arg( QString::number( newFrame ),
QString::number( length ) ) );
setProgressBarValue( newFrame * 100 / length );
}
}
......
......@@ -33,7 +33,7 @@ class WorkflowFileRendererDialog : public QDialog
Q_OBJECT
Q_DISABLE_COPY( WorkflowFileRendererDialog )
public:
WorkflowFileRendererDialog( quint32 width, quint32 height, qint64 totalFrames, RendererEventWatcher* eventWatcher );
WorkflowFileRendererDialog( quint32 width, quint32 height );
void setOutputFileName( const QString& filename );
void setProgressBarValue( int val );
......@@ -41,16 +41,15 @@ private:
Ui::WorkflowFileRendererDialog m_ui;
quint32 m_width;
quint32 m_height;
qint64 m_totalFrames;
signals:
void stop();
public slots:
void updatePreview( const uchar* buff );
void frameChanged( qint64 newFrame, qint64 length );
private slots:
void frameChanged( qint64 );
void cancel();
};
......
......@@ -335,9 +335,10 @@ MainWorkflow::startRenderToFile( const QString &outputFileName, quint32 width, q
output.connect( *input );
#ifdef HAVE_GUI
WorkflowFileRendererDialog dialog( width, height, input->playableLength(), m_renderer->eventWatcher() );
WorkflowFileRendererDialog dialog( width, height );
dialog.setModal( true );
dialog.setOutputFileName( outputFileName );
connect( this, &MainWorkflow::frameChanged, &dialog, &WorkflowFileRendererDialog::frameChanged );
connect( &dialog, &WorkflowFileRendererDialog::stop, this, [&output]{ output.stop(); } );
connect( m_renderer->eventWatcher(), &RendererEventWatcher::positionChanged, &dialog,
[this, input, &dialog, width, height]( qint64 pos )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment