diff --git a/MainWindow.cpp b/MainWindow.cpp index 2a49b92..ee4a0e2 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -43,6 +43,9 @@ MainWindow::MainWindow() _hasCurrentMapping = false; currentSelectedItem = NULL; + // Play state. + _isPlaying = false; + // Create everything. videoTimer = new QTimer(this); videoTimer->setInterval(1000/30); @@ -425,6 +428,11 @@ void MainWindow::play() // Start all paints. for (int i=0; inPaints(); i++) mappingManager->getPaint(i)->play(); + + // Update buttons. + _isPlaying = true; + playAction->setEnabled(!_isPlaying); + pauseAction->setEnabled(_isPlaying); } void MainWindow::pause() @@ -432,6 +440,11 @@ void MainWindow::pause() // Pause all paints. for (int i=0; inPaints(); i++) mappingManager->getPaint(i)->pause(); + + // Update buttons. + _isPlaying = false; + playAction->setEnabled(!_isPlaying); + pauseAction->setEnabled(_isPlaying); } void MainWindow::rewind() @@ -1024,6 +1037,7 @@ void MainWindow::createActions() playAction->setIcon(QIcon(":/images/draw-ellipse-2.png")); playAction->setStatusTip(tr("Play")); connect(playAction, SIGNAL(triggered()), this, SLOT(play())); + playAction->setEnabled(!_isPlaying); // Pause. pauseAction = new QAction(tr("Pause"), this); @@ -1031,6 +1045,7 @@ void MainWindow::createActions() pauseAction->setIcon(QIcon(":/images/draw-ellipse-2.png")); pauseAction->setStatusTip(tr("Pause")); connect(pauseAction, SIGNAL(triggered()), this, SLOT(pause())); + pauseAction->setEnabled(_isPlaying); // Pause. rewindAction = new QAction(tr("Rewind"), this); @@ -1337,6 +1352,11 @@ bool MainWindow::importMediaFile(const QString &fileName, Paint::ptr oldPaint) std::tr1::shared_ptr media = std::tr1::static_pointer_cast(mappingManager->getPaintById(mediaId)); Q_CHECK_PTR(media); + if (_isPlaying) + media->play(); + else + media->pause(); + media->setPosition((sourceCanvas->width() - media->getWidth() ) / 2.0f, (sourceCanvas->height() - media->getHeight()) / 2.0f ); @@ -1358,6 +1378,12 @@ bool MainWindow::addColorPaint(const QColor& color, Paint::ptr oldPaint) std::tr1::shared_ptr colorPaint = std::tr1::static_pointer_cast(mappingManager->getPaintById(colorId)); Q_CHECK_PTR(colorPaint); + // Does not do anything... + if (_isPlaying) + colorPaint->play(); + else + colorPaint->pause(); + QApplication::restoreOverrideCursor(); statusBar()->showMessage(tr("Color paint added"), 2000); diff --git a/MainWindow.h b/MainWindow.h index 9e9617f..b111c5b 100644 --- a/MainWindow.h +++ b/MainWindow.h @@ -289,6 +289,7 @@ private: uid currentMappingId; bool _hasCurrentMapping; bool _hasCurrentPaint; + bool _isPlaying; // Keeps track of the current selected item, wether it's a paint or mapping. QListWidgetItem* currentSelectedItem;