KeyframeImport::KeyframeImport(ItemInfo srcInfo, ItemInfo dstInfo, QMap<QString, QString> data, const Timecode &tc, QDomElement xml, ProfileInfo profile, QWidget *parent) : QDialog(parent) , m_xml(xml) , m_profile(profile) , m_supportsAnim(false) { QVBoxLayout *lay = new QVBoxLayout(this); QHBoxLayout *l1 = new QHBoxLayout; QLabel *lab = new QLabel(i18n("Data to import: "), this); l1->addWidget(lab); m_dataCombo = new QComboBox(this); l1->addWidget(m_dataCombo); l1->addStretch(10); lay->addLayout(l1); // Set up data int ix = 0; QMap<QString, QString>::const_iterator i = data.constBegin(); while (i != data.constEnd()) { m_dataCombo->insertItem(ix, i.key()); m_dataCombo->setItemData(ix, i.value(), Qt::UserRole); ++i; ix++; } m_previewLabel = new QLabel(this); m_previewLabel->setMinimumSize(100, 150); m_previewLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); m_previewLabel->setScaledContents(true); lay->addWidget(m_previewLabel); m_keyframeView = new KeyframeView(0, this); // Zone in / out m_inPoint = new PositionEdit(i18n("In"), srcInfo.cropStart.frames(tc.fps()), srcInfo.cropStart.frames(tc.fps()), (srcInfo.cropStart + srcInfo.cropDuration).frames(tc.fps()), tc, this); connect(m_inPoint, SIGNAL(parameterChanged(int)), this, SLOT(updateDisplay())); lay->addWidget(m_inPoint); m_outPoint = new PositionEdit(i18n("Out"), (srcInfo.cropStart + srcInfo.cropDuration).frames(tc.fps()), srcInfo.cropStart.frames(tc.fps()), (srcInfo.cropStart + srcInfo.cropDuration).frames(tc.fps()), tc, this); connect(m_outPoint, SIGNAL(parameterChanged(int)), this, SLOT(updateDisplay())); lay->addWidget(m_outPoint); // Check what kind of parameters are in our target QDomNodeList params = xml.elementsByTagName(QStringLiteral("parameter")); for (int i = 0; i < params.count(); i++) { QDomElement e = params.at(i).toElement(); QString pType = e.attribute(QStringLiteral("type")); if (pType == QLatin1String("animatedrect") || pType == QLatin1String("geometry")) { if (pType == QLatin1String("animatedrect")) m_supportsAnim = true; QDomElement na = e.firstChildElement(QStringLiteral("name")); QString paramName = na.isNull() ? e.attribute(QStringLiteral("name")) : i18n(na.text().toUtf8().data()); m_geometryTargets.insert(paramName, e.attribute(QStringLiteral("name"))); } else if (pType == QLatin1String("animated")) { QDomElement na = e.firstChildElement(QStringLiteral("name")); QString paramName = na.isNull() ? e.attribute(QStringLiteral("name")) : i18n(na.text().toUtf8().data()); m_simpleTargets.insert(paramName, e.attribute(QStringLiteral("name"))); } } l1 = new QHBoxLayout; m_targetCombo = new QComboBox(this); m_sourceCombo = new QComboBox(this); ix = 0; if (!m_geometryTargets.isEmpty()) { m_sourceCombo->insertItem(ix, i18n("Geometry")); m_sourceCombo->setItemData(ix, QString::number(10), Qt::UserRole); ix++; } if (!m_simpleTargets.isEmpty()) { m_sourceCombo->insertItem(ix, i18n("X")); m_sourceCombo->setItemData(ix, QString::number(0), Qt::UserRole); ix++; m_sourceCombo->insertItem(ix, i18n("Y")); m_sourceCombo->setItemData(ix, QString::number(1), Qt::UserRole); ix++; m_sourceCombo->insertItem(ix, i18n("Width")); m_sourceCombo->setItemData(ix, QString::number(2), Qt::UserRole); ix++; m_sourceCombo->insertItem(ix, i18n("Height")); m_sourceCombo->setItemData(ix, QString::number(3), Qt::UserRole); ix++; } connect(m_sourceCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateRange())); lab = new QLabel(i18n("Map "), this); QLabel *lab2 = new QLabel(i18n(" to "), this); l1->addWidget(lab); l1->addWidget(m_sourceCombo); l1->addWidget(lab2); l1->addWidget(m_targetCombo); l1->addStretch(10); ix = 0; QMap<QString, QString>::const_iterator j = m_geometryTargets.constBegin(); while (j != m_geometryTargets.constEnd()) { m_targetCombo->insertItem(ix, j.key()); m_targetCombo->setItemData(ix, j.value(), Qt::UserRole); ++j; ix++; } ix = 0; j = m_simpleTargets.constBegin(); while (j != m_simpleTargets.constEnd()) { m_targetCombo->insertItem(ix, j.key()); m_targetCombo->setItemData(ix, j.value(), Qt::UserRole); ++j; ix++; } if (m_simpleTargets.count() + m_geometryTargets.count() > 1) { // Target contains several animatable parameters, propose choice } lay->addLayout(l1); // Output offset m_offsetPoint = new PositionEdit(i18n("Offset"), 0, 0, dstInfo.cropDuration.frames(tc.fps()), tc, this); lay->addWidget(m_offsetPoint); // Source range m_sourceRangeLabel = new QLabel(i18n("Source range %1 to %2", 0, 100), this); lay->addWidget(m_sourceRangeLabel); // update range info connect(m_targetCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateDestinationRange())); // Destination range l1 = new QHBoxLayout; lab = new QLabel(i18n("Destination range"), this); l1->addWidget(lab); l1->addWidget(&m_destMin); l1->addWidget(&m_destMax); lay->addLayout(l1); l1 = new QHBoxLayout; m_limitRange = new QCheckBox(i18n("Actual range only"), this); connect(m_limitRange, SIGNAL(toggled(bool)), this, SLOT(updateRange())); connect(m_limitRange, SIGNAL(toggled(bool)), this, SLOT(updateDisplay())); l1->addWidget(m_limitRange); l1->addStretch(10); lay->addLayout(l1); l1 = new QHBoxLayout; m_limitKeyframes = new QCheckBox(i18n("Limit keyframe number"), this); m_limitKeyframes->setChecked(true); m_limitNumber = new QSpinBox(this); m_limitNumber->setMinimum(1); m_limitNumber->setValue(20); l1->addWidget(m_limitKeyframes); l1->addWidget(m_limitNumber); l1->addStretch(10); lay->addLayout(l1); connect(m_limitKeyframes, &QCheckBox::toggled, m_limitNumber, &QSpinBox::setEnabled); connect(m_limitKeyframes, SIGNAL(toggled(bool)), this, SLOT(updateDisplay())); connect(m_limitNumber, SIGNAL(valueChanged(int)), this, SLOT(updateDisplay())); connect(m_dataCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateDataDisplay())); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel); connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); lay->addWidget(buttonBox); updateDestinationRange(); updateDataDisplay(); }