]> git.sesse.net Git - kdenlive/blobdiff - src/dvdwizardvob.cpp
Effect stack update: enable / disable several effects now triggers only one refresh
[kdenlive] / src / dvdwizardvob.cpp
index b5ef75993252c3cf273997ae90d371fe50e70084..ebc4b8441340a3d79c8648ae2a4bb941fe37838f 100644 (file)
@@ -53,7 +53,7 @@ DvdWizardVob::DvdWizardVob(const QString &profile, QWidget *parent) :
     m_view.vobs_list->setIconSize(QSize(60, 45));
 
     if (KStandardDirs::findExe("dvdauthor").isEmpty()) m_errorMessage.append(i18n("<strong>Program %1 is required for the DVD wizard.</strong>", i18n("dvdauthor")));
-    if (KStandardDirs::findExe("mkisofs").isEmpty()) m_errorMessage.append(i18n("<strong>Program %1 is required for the DVD wizard.</strong>", i18n("mkisofs")));
+    if (KStandardDirs::findExe("mkisofs").isEmpty() && KStandardDirs::findExe("genisoimage").isEmpty()) m_errorMessage.append(i18n("<strong>Program %1 or %2 is required for the DVD wizard.</strong>", i18n("mkisofs"), i18n("genisoimage")));
     if (m_errorMessage.isEmpty()) m_view.error_message->setVisible(false);
     else m_view.error_message->setText(m_errorMessage);
 
@@ -68,22 +68,16 @@ DvdWizardVob::DvdWizardVob(const QString &profile, QWidget *parent) :
     m_view.vobs_list->header()->setResizeMode(1, QHeaderView::Custom);
     m_view.vobs_list->header()->setResizeMode(2, QHeaderView::Custom);
 
-#if KDE_IS_VERSION(4,2,0)
     m_capacityBar = new KCapacityBar(KCapacityBar::DrawTextInline, this);
     QHBoxLayout *layout = new QHBoxLayout;
     layout->addWidget(m_capacityBar);
     m_view.size_box->setLayout(layout);
-#else
-    m_view.size_box->setHidden(true);
-#endif
     slotCheckVobList();
 }
 
 DvdWizardVob::~DvdWizardVob()
 {
-#if KDE_IS_VERSION(4,2,0)
     delete m_capacityBar;
-#endif
 }
 
 
@@ -109,32 +103,29 @@ void DvdWizardVob::slotAddVobFile(KUrl url, const QString &chapters)
         break;
     }
 
-    char *tmp = (char*) qstrdup(profilename.toUtf8().data());
-    Mlt::Profile profile(tmp);
-    delete[] tmp;
+    Mlt::Profile profile(profilename.toUtf8().data());
     QTreeWidgetItem *item = new QTreeWidgetItem(m_view.vobs_list, QStringList() << url.path() << QString() << KIO::convertSize(fileSize));
     item->setData(0, Qt::UserRole, fileSize);
     item->setIcon(0, KIcon("video-x-generic"));
 
     QPixmap pix(60, 45);
 
-    tmp = (char *) qstrdup(url.path().toUtf8().data());
-    Mlt::Producer *producer = new Mlt::Producer(profile, tmp);
-    delete[] tmp;
+    Mlt::Producer *producer = new Mlt::Producer(profile, url.path().toUtf8().data());
 
     if (producer->is_blank() == false) {
         int width = 45.0 * profile.dar();
+        int swidth = 45.0 * profile.width() / profile.height();
         if (width % 2 == 1) width++;
-        pix = KThumb::getFrame(producer, 0, width, 45);
-        item->setIcon(0, pix);
+        item->setIcon(0, QPixmap::fromImage(KThumb::getFrame(producer, 0, swidth, width, 45)));
         int playTime = producer->get_playtime();
         item->setText(1, Timecode::getStringTimecode(playTime, profile.fps()));
         item->setData(1, Qt::UserRole, playTime);
     }
     delete producer;
 
-    if (chapters.isEmpty() == false)
+    if (chapters.isEmpty() == false) {
         item->setData(1, Qt::UserRole + 1, chapters);
+    }
     else if (QFile::exists(url.path() + ".dvdchapter")) {
         // insert chapters as children
         QFile file(url.path() + ".dvdchapter");
@@ -174,16 +165,12 @@ void DvdWizardVob::changeFormat()
         break;
     }
 
-    char *tmp = (char*) qstrdup(profilename.toUtf8().data());
-    Mlt::Profile profile(tmp);
-    delete[] tmp;
+    Mlt::Profile profile(profilename.toUtf8().data());
     QPixmap pix(180, 135);
 
     for (int i = 0; i < max; i++) {
         QTreeWidgetItem *item = m_view.vobs_list->topLevelItem(i);
-        tmp = (char *) qstrdup(item->text(0).toUtf8().data());
-        Mlt::Producer *producer = new Mlt::Producer(profile, tmp);
-        delete[] tmp;
+        Mlt::Producer *producer = new Mlt::Producer(profile, item->text(0).toUtf8().data());
 
         if (producer->is_blank() == false) {
             //pix = KThumb::getFrame(producer, 0, 135 * profile.dar(), 135);
@@ -254,7 +241,9 @@ QStringList DvdWizardVob::chapters() const
     int max = m_view.vobs_list->topLevelItemCount();
     for (int i = 0; i < max; i++) {
         QTreeWidgetItem *item = m_view.vobs_list->topLevelItem(i);
-        if (item) result.append(item->data(1, Qt::UserRole + 1).toString());
+        if (item) {
+            result.append(item->data(1, Qt::UserRole + 1).toString());
+        }
     }
     return result;
 }
@@ -264,7 +253,7 @@ void DvdWizardVob::updateChapters(QMap <QString, QString> chaptersdata)
     int max = m_view.vobs_list->topLevelItemCount();
     for (int i = 0; i < max; i++) {
         QTreeWidgetItem *item = m_view.vobs_list->topLevelItem(i);
-        item->setData(1, Qt::UserRole + 1, chaptersdata.value(item->text(0)));
+        if (chaptersdata.contains(item->text(0))) item->setData(1, Qt::UserRole + 1, chaptersdata.value(item->text(0)));
     }
 }
 
@@ -285,7 +274,7 @@ QString DvdWizardVob::introMovie() const
     return m_view.intro_vob->url().path();
 }
 
-void DvdWizardVob::setIntroMovie(const QString path)
+void DvdWizardVob::setIntroMovie(const QString& path)
 {
     m_view.intro_vob->setUrl(KUrl(path));
     m_view.use_intro->setChecked(path.isEmpty() == false);
@@ -305,7 +294,6 @@ void DvdWizardVob::slotCheckVobList()
     if (hasItem && m_view.vobs_list->indexOfTopLevelItem(item) == max - 1) m_view.button_down->setEnabled(false);
     else m_view.button_down->setEnabled(hasItem);
 
-#if KDE_IS_VERSION(4,2,0)
     qint64 totalSize = 0;
     for (int i = 0; i < max; i++) {
         item = m_view.vobs_list->topLevelItem(i);
@@ -315,7 +303,6 @@ void DvdWizardVob::slotCheckVobList()
     qint64 maxSize = (qint64) 47000 * 100000;
     m_capacityBar->setValue(100 * totalSize / maxSize);
     m_capacityBar->setText(KIO::convertSize(totalSize));
-#endif
 }
 
 void DvdWizardVob::slotItemUp()
@@ -347,7 +334,7 @@ bool DvdWizardVob::isWide() const
     return (m_view.dvd_profile->currentIndex() == 1 || m_view.dvd_profile->currentIndex() == 3);
 }
 
-void DvdWizardVob::setProfile(const QString profile)
+void DvdWizardVob::setProfile(const QString& profile)
 {
     if (profile == "dv_pal") m_view.dvd_profile->setCurrentIndex(0);
     else if (profile == "dv_pal_wide") m_view.dvd_profile->setCurrentIndex(1);