+ connect(m_view.marker_save, SIGNAL(clicked()), this, SLOT(slotSaveMarkers()));
+ connect(m_view.marker_load, SIGNAL(clicked()), this, SLOT(slotLoadMarkers()));
+ connect(m_view.markers_list, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(slotEditMarker()));
+
+ connect(m_view.analysis_delete, SIGNAL(clicked()), this, SLOT(slotDeleteAnalysis()));
+ connect(m_view.analysis_save, SIGNAL(clicked()), this, SLOT(slotSaveAnalysis()));
+ connect(m_view.analysis_load, SIGNAL(clicked()), this, SLOT(slotLoadAnalysis()));
+
+ connect(this, SIGNAL(accepted()), this, SLOT(slotApplyProperties()));
+ connect(m_view.buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(slotApplyProperties()));
+ m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
+
+ m_view.metadata_list->resizeColumnToContents(0);
+ m_view.clip_vproperties->resizeColumnToContents(0);
+ m_view.clip_aproperties->resizeColumnToContents(0);
+ adjustSize();
+}
+
+
+// Used for multiple clips editing
+ClipProperties::ClipProperties(const QList <DocClipBase *> &cliplist, const Timecode &tc, const QMap <QString, QString> &commonproperties, QWidget * parent) :
+ QDialog(parent),
+ m_clip(NULL),
+ m_tc(tc),
+ m_fps(0),
+ m_count(0),
+ m_clipNeedsRefresh(false),
+ m_clipNeedsReLoad(false)
+{
+ setFont(KGlobalSettings::toolBarFont());
+ m_view.setupUi(this);
+ QString title = windowTitle();
+ title.append(' ' + i18np("(%1 clip)", "(%1 clips)", cliplist.count()));
+ setWindowTitle(title);
+ QMap <QString, QString> props = cliplist.at(0)->properties();
+ m_old_props = commonproperties;
+
+ if (commonproperties.contains("force_aspect_num") && !commonproperties.value("force_aspect_num").isEmpty() && commonproperties.value("force_aspect_den").toInt() > 0) {
+ m_view.clip_force_ar->setChecked(true);
+ m_view.clip_ar_num->setEnabled(true);
+ m_view.clip_ar_den->setEnabled(true);
+ m_view.clip_ar_num->setValue(commonproperties.value("force_aspect_num").toInt());
+ m_view.clip_ar_den->setValue(commonproperties.value("force_aspect_den").toInt());
+ }
+
+ if (commonproperties.contains("force_fps") && !commonproperties.value("force_fps").isEmpty() && commonproperties.value("force_fps").toDouble() > 0) {
+ m_view.clip_force_framerate->setChecked(true);
+ m_view.clip_framerate->setEnabled(true);
+ m_view.clip_framerate->setValue(commonproperties.value("force_fps").toDouble());
+ }
+
+ if (commonproperties.contains("force_progressive") && !commonproperties.value("force_progressive").isEmpty()) {
+ m_view.clip_force_progressive->setChecked(true);
+ m_view.clip_progressive->setEnabled(true);
+ m_view.clip_progressive->setCurrentIndex(commonproperties.value("force_progressive").toInt());
+ }
+
+ if (commonproperties.contains("force_tff") && !commonproperties.value("force_tff").isEmpty()) {
+ m_view.clip_force_fieldorder->setChecked(true);
+ m_view.clip_fieldorder->setEnabled(true);
+ m_view.clip_fieldorder->setCurrentIndex(commonproperties.value("force_tff").toInt());
+ }
+
+ if (commonproperties.contains("threads") && !commonproperties.value("threads").isEmpty() && commonproperties.value("threads").toInt() != 1) {
+ m_view.clip_force_threads->setChecked(true);
+ m_view.clip_threads->setEnabled(true);
+ m_view.clip_threads->setValue(commonproperties.value("threads").toInt());
+ }
+
+ if (commonproperties.contains("video_index") && !commonproperties.value("video_index").isEmpty() && commonproperties.value("video_index").toInt() != 0) {
+ m_view.clip_force_vindex->setChecked(true);
+ m_view.clip_vindex->setEnabled(true);
+ m_view.clip_vindex->setValue(commonproperties.value("video_index").toInt());
+ }
+
+ if (commonproperties.contains("audio_index") && !commonproperties.value("audio_index").isEmpty() && commonproperties.value("audio_index").toInt() != 0) {
+ m_view.clip_force_aindex->setChecked(true);
+ m_view.clip_aindex->setEnabled(true);
+ m_view.clip_aindex->setValue(commonproperties.value("audio_index").toInt());
+ }
+
+ if (props.contains("audio_max")) {
+ m_view.clip_aindex->setMaximum(props.value("audio_max").toInt());
+ }
+
+ if (props.contains("video_max")) {
+ m_view.clip_vindex->setMaximum(props.value("video_max").toInt());
+ }
+
+ m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(601), 601);
+ m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(709), 709);
+ m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(240), 240);
+
+ if (commonproperties.contains("force_colorspace") && !commonproperties.value("force_colorspace").isEmpty() && commonproperties.value("force_colorspace").toInt() != 0) {
+ m_view.clip_force_colorspace->setChecked(true);
+ m_view.clip_colorspace->setEnabled(true);
+ m_view.clip_colorspace->setCurrentIndex(m_view.clip_colorspace->findData(commonproperties.value("force_colorspace").toInt()));
+ }
+
+ if (commonproperties.contains("full_luma") && !commonproperties.value("full_luma").isEmpty()) {
+ m_view.clip_full_luma->setChecked(true);
+ }
+
+ if (commonproperties.contains("transparency")) {
+ // image transparency checkbox
+ int transparency = commonproperties.value("transparency").toInt();
+ if (transparency == 0) {
+ m_view.clip_force_transparency->setChecked(true);
+ }
+ else if (transparency == 1) {
+ m_view.clip_force_transparency->setChecked(true);
+ m_view.clip_transparency->setCurrentIndex(1);
+ }
+ }
+ else {
+ m_view.clip_force_transparency->setHidden(true);
+ m_view.clip_transparency->setHidden(true);
+ }
+
+
+ connect(m_view.clip_force_transparency, SIGNAL(toggled(bool)), m_view.clip_transparency, SLOT(setEnabled(bool)));
+ connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar_num, SLOT(setEnabled(bool)));
+ connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar_den, SLOT(setEnabled(bool)));
+ connect(m_view.clip_force_progressive, SIGNAL(toggled(bool)), m_view.clip_progressive, SLOT(setEnabled(bool)));
+ connect(m_view.clip_force_threads, SIGNAL(toggled(bool)), m_view.clip_threads, SLOT(setEnabled(bool)));
+ connect(m_view.clip_force_vindex, SIGNAL(toggled(bool)), m_view.clip_vindex, SLOT(setEnabled(bool)));
+ connect(m_view.clip_force_aindex, SIGNAL(toggled(bool)), m_view.clip_aindex, SLOT(setEnabled(bool)));
+ connect(m_view.clip_force_out, SIGNAL(toggled(bool)), m_view.clip_out, SLOT(setEnabled(bool)));
+ connect(m_view.clip_force_colorspace, SIGNAL(toggled(bool)), m_view.clip_colorspace, SLOT(setEnabled(bool)));
+
+ m_view.tabWidget->removeTab(METATAB);
+ m_view.tabWidget->removeTab(MARKERTAB);
+ m_view.tabWidget->removeTab(IMAGETAB);
+ m_view.tabWidget->removeTab(SLIDETAB);
+ m_view.tabWidget->removeTab(COLORTAB);
+ m_view.tabWidget->removeTab(AUDIOTAB);
+ m_view.tabWidget->removeTab(VIDEOTAB);
+
+ m_view.clip_path->setHidden(true);
+ m_view.label_path->setHidden(true);
+ m_view.label_description->setHidden(true);
+ m_view.label_size->setHidden(true);
+ m_view.clip_filesize->setHidden(true);
+ m_view.clip_filesize->setHidden(true);
+ m_view.clip_path->setHidden(true);
+ m_view.clip_description->setHidden(true);
+ m_view.clip_thumb->setHidden(true);
+ m_view.label_duration->setHidden(true);
+ m_view.clip_duration->setHidden(true);
+
+ if (commonproperties.contains("out")) {
+ if (commonproperties.value("out").toInt() > 0) {
+ m_view.clip_force_out->setChecked(true);
+ m_view.clip_out->setText(m_tc.getTimecodeFromFrames(commonproperties.value("out").toInt()));
+ } else {
+ m_view.clip_out->setText(KdenliveSettings::image_duration());
+ }
+ } else {
+ m_view.clip_force_out->setHidden(true);
+ m_view.clip_out->setHidden(true);
+ }
+}
+
+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());
+}