static void connectProcessSlots(ProgressTaskInfo* task, ProcessHandler* process) { QObject::connect(task,SIGNAL(taskCanceled()),process,SLOT(onProcessCanceled())); QObject::connect(process,SIGNAL(processCanceled()),task,SLOT(onProcessCanceled())); QObject::connect(process,SIGNAL(frameRendered(int,double)),task,SLOT(onRenderEngineFrameComputed(int,double))); QObject::connect(process,SIGNAL(processFinished(int)),task,SLOT(onRenderEngineStopped(int))); }
void ProcessHandler::onProcessCanceled(){ emit processCanceled(); if(!_bgProcessInputSocket) { _earlyCancel = true; } else { _bgProcessInputSocket->write((QString(kAbortRenderingStringShort) + '\n').toUtf8()); _bgProcessInputSocket->flush(); } }
void RenderingProgressDialog::onProcessDeleted() { assert(_imp->_process); QObject::disconnect( this,SIGNAL(canceled()),_imp->_process.get(),SLOT(onProcessCanceled()) ); QObject::disconnect( _imp->_process.get(),SIGNAL(processCanceled()),this,SLOT(onProcessCanceled()) ); QObject::disconnect( _imp->_process.get(),SIGNAL(frameRendered(int)),this,SLOT(onFrameRendered(int,double)) ); QObject::disconnect( _imp->_process.get(),SIGNAL(processFinished(int)),this,SLOT(onProcessFinished(int)) ); QObject::disconnect( _imp->_process.get(),SIGNAL(deleted()),this,SLOT(onProcessDeleted()) ); }
void ProcessHandler::onProcessCanceled() { Q_EMIT processCanceled(); if (!_bgProcessInputSocket) { _earlyCancel = true; } else { _bgProcessInputSocket->write( ( QString::fromUtf8(kAbortRenderingStringShort) + QLatin1Char('\n') ).toUtf8() ); _bgProcessInputSocket->flush(); } }
void MainWindow::startProcess(const QString &name, const QStringList &args) { //Create progress dialog progress = new QProgressDialog(tr("Performing operation..."), tr("Cancel"), 0, 0, this); connect(progress, SIGNAL(canceled()), this, SLOT(processCanceled())); progress->setWindowModality(Qt::WindowModal); progress->show(); //Create process processWasCanceled = false; process = new QProcess(this); connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(processFinished(int, QProcess::ExitStatus))); process->start(name, args); }
RenderingProgressDialog::RenderingProgressDialog(Gui* gui, const QString & sequenceName, int firstFrame, int lastFrame, int frameStep, const boost::shared_ptr<ProcessHandler> & process, QWidget* parent) : QDialog(parent,Qt::WindowStaysOnTopHint) , _imp( new RenderingProgressDialogPrivate(gui,sequenceName,firstFrame,lastFrame,frameStep,process) ) { setMinimumWidth(fontMetrics().width(_imp->_sequenceName) + 100); setWindowTitle(_imp->_sequenceName); _imp->_mainLayout = new QVBoxLayout(this); setLayout(_imp->_mainLayout); _imp->_mainLayout->setContentsMargins(5, 5, 0, 0); _imp->_mainLayout->setSpacing(5); QWidget* totalProgressContainer = new QWidget(this); QHBoxLayout* totalProgressLayout = new QHBoxLayout(totalProgressContainer); _imp->_mainLayout->addWidget(totalProgressContainer); _imp->_totalProgressLabel = new Label(tr("Total progress:"),totalProgressContainer); totalProgressLayout->addWidget(_imp->_totalProgressLabel); _imp->_totalProgressInfo = new Label("0%",totalProgressContainer); totalProgressLayout->addWidget(_imp->_totalProgressInfo); QWidget* waitTimeContainer = new QWidget(this); QHBoxLayout* waitTimeLayout = new QHBoxLayout(waitTimeContainer); _imp->_mainLayout->addWidget(waitTimeContainer); _imp->_estimatedWaitTimeLabel = new Label(tr("Time remaining:"),waitTimeContainer); waitTimeLayout->addWidget(_imp->_estimatedWaitTimeLabel); _imp->_estimatedWaitTimeInfo = new Label("...",waitTimeContainer); waitTimeLayout->addWidget(_imp->_estimatedWaitTimeInfo); _imp->_totalProgressBar = new QProgressBar(this); _imp->_totalProgressBar->setRange(0, 100); _imp->_totalProgressBar->setMinimumWidth(150); _imp->_mainLayout->addWidget(_imp->_totalProgressBar); _imp->_cancelButton = new Button(tr("Cancel"),this); _imp->_cancelButton->setMaximumWidth(50); _imp->_mainLayout->addWidget(_imp->_cancelButton); QObject::connect( _imp->_cancelButton, SIGNAL(clicked()), this, SLOT(onCancelButtonClicked()) ); if (process) { QObject::connect( this,SIGNAL(canceled()),process.get(),SLOT(onProcessCanceled()) ); QObject::connect( process.get(),SIGNAL(processCanceled()),this,SLOT(onProcessCanceled()) ); QObject::connect( process.get(),SIGNAL(frameRendered(int,double)),this,SLOT(onFrameRendered(int,double)) ); QObject::connect( process.get(),SIGNAL(processFinished(int)),this,SLOT(onProcessFinished(int)) ); QObject::connect( process.get(),SIGNAL(deleted()),this,SLOT(onProcessDeleted()) ); } }