+bool ProjectList::adjustProjectProfileToItem(ProjectItem *item)
+{
+ if (item == NULL) {
+ if (m_listView->currentItem() && m_listView->currentItem()->type() != PROJECTFOLDERTYPE)
+ item = static_cast <ProjectItem*>(m_listView->currentItem());
+ }
+ if (item == NULL || item->referencedClip() == NULL) {
+ KMessageBox::information(kapp->activeWindow(), i18n("Cannot find profile from current clip"));
+ return false;
+ }
+ bool profileUpdated = false;
+ QString size = item->referencedClip()->getProperty("frame_size");
+ int width = size.section('x', 0, 0).toInt();
+ int height = size.section('x', -1).toInt();
+ double fps = item->referencedClip()->getProperty("fps").toDouble();
+ double par = item->referencedClip()->getProperty("aspect_ratio").toDouble();
+ if (item->clipType() == IMAGE || item->clipType() == AV || item->clipType() == VIDEO) {
+ if (ProfilesDialog::matchProfile(width, height, fps, par, item->clipType() == IMAGE, m_doc->mltProfile()) == false) {
+ // get a list of compatible profiles
+ QMap <QString, QString> suggestedProfiles = ProfilesDialog::getProfilesFromProperties(width, height, fps, par, item->clipType() == IMAGE);
+ if (!suggestedProfiles.isEmpty()) {
+ KDialog *dialog = new KDialog(this);
+ dialog->setCaption(i18n("Change project profile"));
+ dialog->setButtons(KDialog::Ok | KDialog::Cancel);
+
+ QWidget container;
+ QVBoxLayout *l = new QVBoxLayout;
+ QLabel *label = new QLabel(i18n("Your clip does not match current project's profile.\nDo you want to change the project profile?\n\nThe following profiles match the clip (size: %1, fps: %2)", size, fps));
+ l->addWidget(label);
+ QListWidget *list = new QListWidget;
+ list->setAlternatingRowColors(true);
+ QMapIterator<QString, QString> i(suggestedProfiles);
+ while (i.hasNext()) {
+ i.next();
+ QListWidgetItem *item = new QListWidgetItem(i.value(), list);
+ item->setData(Qt::UserRole, i.key());
+ item->setToolTip(i.key());
+ }
+ list->setCurrentRow(0);
+ l->addWidget(list);
+ container.setLayout(l);
+ dialog->setButtonText(KDialog::Ok, i18n("Update profile"));
+ dialog->setMainWidget(&container);
+ if (dialog->exec() == QDialog::Accepted) {
+ //Change project profile
+ profileUpdated = true;
+ if (list->currentItem())
+ emit updateProfile(list->currentItem()->data(Qt::UserRole).toString());
+ }
+ delete list;
+ delete label;
+ } else KMessageBox::information(kapp->activeWindow(), i18n("Your clip does not match current project's profile.\nNo existing profile found to match the clip's properties.\nClip size: %1\nFps: %2\n", size, fps));
+ }
+ }
+ return profileUpdated;
+}
+