void qAnimationDlg::onItemChanged(QListWidgetItem*) { //update total duration updateTotalDuration(); onCurrentStepChanged(stepSelectionList->currentRow()); }
void qAnimationDlg::onStepTimeChanged(double time_sec) { m_videoSteps[ getCurrentStepIndex() ].duration_sec = time_sec; //update total duration updateTotalDuration(); //update current step updateCurrentStepDuration(); }
qAnimationDlg::qAnimationDlg( std::vector<VideoStepItem>& videoSteps, ccGLWindow* view3d, QWidget* parent) : QDialog(parent) , Ui::AnimationDialog() , m_videoSteps(videoSteps) , m_view3d(view3d) { setupUi(this); setWindowFlags(Qt::Tool/*Qt::Dialog | Qt::WindowStaysOnTopHint*/); for ( size_t i=0; i<m_videoSteps.size(); ++i ) { cc2DViewportObject* viewport1 = m_videoSteps[i].interpolator.view1(); stepSelectionList->addItem( viewport1->getName() ); //check if the (1st) viewport has a duration in meta data (from a previous run) double duration_sec = 2.0; if (viewport1->hasMetaData(s_stepDurationKey)) { duration_sec = viewport1->getMetaData(s_stepDurationKey).toDouble(); } m_videoSteps[i].duration_sec = duration_sec; } //read persistent settings { QSettings settings; settings.beginGroup("qAnimation"); QString defaultDir; #ifdef _MSC_VER defaultDir = QApplication::applicationDirPath(); #else defaultDir = QDir::homePath(); #endif QString lastFilename = settings.value("filename", defaultDir + "/animation.mpg" ).toString(); #ifndef QFFMPEG_SUPPORT lastFilename = QFileInfo(lastFilename).absolutePath(); #endif outputFileLineEdit->setText( lastFilename ); settings.endGroup(); } connect ( fpsSpinBox, SIGNAL( valueChanged(double) ), this, SLOT( onFPSChanged(double) ) ); connect ( totalTimeDoubleSpinBox, SIGNAL( valueChanged(double) ), this, SLOT( onTotalTimeChanged(double) ) ); connect ( stepTimeDoubleSpinBox, SIGNAL( valueChanged(double) ), this, SLOT( onStepTimeChanged(double) ) ); connect ( stepSelectionList, SIGNAL( currentRowChanged(int) ), this, SLOT( onCurrentStepChanged(int) ) ); connect ( browseButton, SIGNAL( clicked() ), this, SLOT( onBrowseButtonClicked() ) ); connect ( previewButton, SIGNAL( clicked() ), this, SLOT( preview() ) ); connect ( renderButton, SIGNAL( clicked() ), this, SLOT( render() ) ); connect ( buttonBox, SIGNAL( accepted() ), this, SLOT( onAccept() ) ); stepSelectionList->setCurrentRow(0); //select the first one by default onCurrentStepChanged(getCurrentStepIndex()); updateTotalDuration(); }
bool qAnimationDlg::init(const std::vector<cc2DViewportObject*>& viewports) { if (viewports.size() < 2) { assert(false); return false; } try { m_videoSteps.resize(viewports.size()); } catch (const std::bad_alloc&) { //not enough memory return false; } for (size_t i=0; i<viewports.size(); ++i) { cc2DViewportObject* vp = viewports[i]; //check if the (1st) viewport has a duration in meta data (from a previous run) double duration_sec = 2.0; if (vp->hasMetaData(s_stepDurationKey)) { duration_sec = vp->getMetaData(s_stepDurationKey).toDouble(); } bool isChecked = true; if (vp->hasMetaData(s_stepEnabledKey)) { isChecked = vp->getMetaData(s_stepEnabledKey).toBool(); } QString itemName = QString("step %1 (%2)").arg(QString::number(i+1), vp->getName()); QListWidgetItem* item = new QListWidgetItem(itemName, stepSelectionList); item->setFlags(item->flags() | Qt::ItemIsUserCheckable); // set checkable flag item->setCheckState(isChecked ? Qt::Checked : Qt::Unchecked); // initialize check state stepSelectionList->addItem(item); m_videoSteps[i].viewport = vp; m_videoSteps[i].duration_sec = duration_sec; } connect ( stepSelectionList, SIGNAL( currentRowChanged(int) ), this, SLOT( onCurrentStepChanged(int) ) ); connect ( stepSelectionList, SIGNAL( itemChanged(QListWidgetItem*) ), this, SLOT( onItemChanged(QListWidgetItem*) ) ); stepSelectionList->setCurrentRow(0); //select the first one by default onCurrentStepChanged(getCurrentStepIndex()); updateTotalDuration(); return true; }
void qAnimationDlg::onLoopToggled(bool) { updateTotalDuration(); onCurrentStepChanged(stepSelectionList->currentRow()); }