+ClipProperties::~ClipProperties()
+{
+ QAbstractItemDelegate *del1 = m_view.clip_vproperties->itemDelegate();
+ delete del1;
+ QAbstractItemDelegate *del2 = m_view.clip_aproperties->itemDelegate();
+ delete del2;
+}
+
+
+void ClipProperties::loadVideoProperties(const QMap <QString, QString> &props)
+{
+ m_view.clip_vproperties->clear();
+ if (props.contains("videocodec"))
+ new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Video codec") << props.value("videocodec"));
+ else if (props.contains("videocodecid"))
+ new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Video codec") << props.value("videocodecid"));
+
+ if (props.contains("frame_size"))
+ new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Frame size") << props.value("frame_size"));
+
+ if (props.contains("fps")) {
+ new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Frame rate") << props.value("fps"));
+ if (!m_view.clip_framerate->isEnabled()) m_view.clip_framerate->setValue(props.value("fps").toDouble());
+ }
+
+ if (props.contains("progressive")) {
+ int scanning = props.value("progressive").toInt();
+ QString txt = scanning == 1 ? i18n("Progressive") : i18n("Interlaced");
+ new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Scanning") << txt);
+ }
+
+ if (props.contains("aspect_ratio"))
+ new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Pixel aspect ratio") << props.value("aspect_ratio"));
+
+ if (props.contains("pix_fmt"))
+ new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Pixel format") << props.value("pix_fmt"));
+
+ if (props.contains("colorspace"))
+ new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Colorspace") << ProfilesDialog::getColorspaceDescription(props.value("colorspace").toInt()));
+}
+
+void ClipProperties::slotGotThumbnail(const QString &id, const QImage &img)
+{
+ if (id != m_clip->getId())
+ return;
+ QPixmap framedPix(img.width(), img.height());
+ framedPix.fill(Qt::transparent);
+ QPainter p(&framedPix);
+ p.setRenderHint(QPainter::Antialiasing, true);
+ QPainterPath path;
+ path.addRoundedRect(0.5, 0.5, framedPix.width() - 1, framedPix.height() - 1, 4, 4);
+ p.setClipPath(path);
+ p.drawImage(0, 0, img);
+ p.end();
+ m_view.clip_thumb->setPixmap(framedPix);
+}
+
+void ClipProperties::slotApplyProperties()
+{
+ if (m_clip != NULL) {
+ QMap <QString, QString> props = properties();
+ emit applyNewClipProperties(m_clip->getId(), m_clip->currentProperties(props), props, needsTimelineRefresh(), needsTimelineReload());
+ QTimer::singleShot(1000, this, SLOT(slotReloadVideoProperties()));
+ if (props.contains("force_aspect_num"))
+ QTimer::singleShot(1000, this, SLOT(slotReloadVideoThumb()));
+ }
+ m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
+}
+
+void ClipProperties::slotReloadVideoProperties()
+{
+ if (m_clip == NULL)
+ return;
+ loadVideoProperties(m_clip->properties());
+}
+
+void ClipProperties::slotReloadVideoThumb()
+{
+ if (m_clip == NULL)
+ return;
+ emit requestThumb(QString('?' + m_clip->getId()), QList<int>() << m_clip->getClipThumbFrame());
+}
+
+void ClipProperties::disableClipId(const QString &id)
+{
+ if (m_clip && m_view.buttonBox->button(QDialogButtonBox::Ok)->isEnabled()) {
+ if (m_clip->getId() == id) {
+ // clip was removed from project, close this properties dialog
+ close();
+ }
+ }
+}
+
+void ClipProperties::slotModified()
+{
+ m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(true);
+}