+void MainWindow::replayStart()
+{
+ if (!m_replayProcess) {
+#ifdef Q_OS_WIN
+ QString format = QLatin1String("%1;");
+#else
+ QString format = QLatin1String("%1:");
+#endif
+ QString buildPath = format.arg(BUILD_DIR);
+ QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
+ env.insert("PATH", buildPath + env.value("PATH"));
+
+ qputenv("PATH", env.value("PATH").toLatin1());
+
+ m_replayProcess = new QProcess(this);
+ m_replayProcess->setProcessEnvironment(env);
+
+ connect(m_replayProcess, SIGNAL(finished(int, QProcess::ExitStatus)),
+ this, SLOT(replayFinished()));
+ connect(m_replayProcess, SIGNAL(error(QProcess::ProcessError)),
+ this, SLOT(replayError(QProcess::ProcessError)));
+ }
+
+ if (m_traceFileName.isEmpty())
+ return;
+
+ QStringList arguments;
+ arguments << m_traceFileName;
+
+ m_replayProcess->start(QLatin1String("glretrace"),
+ arguments);
+
+ m_ui.actionStop->setEnabled(true);
+ m_ui.actionReplay->setEnabled(false);
+}
+
+void MainWindow::replayStop()
+{
+ if (m_replayProcess) {
+ m_replayProcess->kill();
+
+ m_ui.actionStop->setEnabled(false);
+ m_ui.actionReplay->setEnabled(true);
+ }
+}
+
+void MainWindow::newTraceFile(const QString &fileName)
+{
+ m_traceFileName = fileName;
+
+ if (m_traceFileName.isEmpty()) {
+ m_ui.actionReplay->setEnabled(false);
+ } else {
+ m_ui.actionReplay->setEnabled(true);
+ }
+}
+
+void MainWindow::replayFinished()
+{
+ m_ui.actionStop->setEnabled(false);
+ m_ui.actionReplay->setEnabled(true);
+
+ QString output = m_replayProcess->readAllStandardOutput();
+
+#if 0
+ qDebug()<<"Process finished = ";
+ qDebug()<<"\terr = "<<m_replayProcess->readAllStandardError();
+ qDebug()<<"\tout = "<<output;
+#endif
+
+ if (output.length() < 80) {
+ statusBar()->showMessage(output);
+ }
+}
+
+void MainWindow::replayError(QProcess::ProcessError err)
+{
+ m_ui.actionStop->setEnabled(false);
+ m_ui.actionReplay->setEnabled(true);
+
+ qDebug()<<"Process error = "<<err;
+ qDebug()<<"\terr = "<<m_replayProcess->readAllStandardError();
+ qDebug()<<"\tout = "<<m_replayProcess->readAllStandardOutput();
+ QMessageBox::warning(
+ this, tr("Replay Failed"),
+ tr("Couldn't execute the replay file '%1'").arg(m_traceFileName));
+}
+