]> git.sesse.net Git - kdenlive/blobdiff - src/dvdwizardchapters.cpp
Fix dvd wizard chapter offset: http://www.kdenlive.org/mantis/view.php?id=864
[kdenlive] / src / dvdwizardchapters.cpp
index 61e5187e045d300e2b516cb7b6eb4413f6f95667..ebd9d38e838a1d9dd36743c4213b9750affbe3b5 100644 (file)
@@ -23,9 +23,9 @@
 
 #include <QFile>
 
-DvdWizardChapters::DvdWizardChapters(bool isPal, QWidget *parent) :
+DvdWizardChapters::DvdWizardChapters(DVDFORMAT format, QWidget *parent) :
         QWizardPage(parent),
-        m_isPal(isPal),
+        m_format(format),
         m_monitor(NULL)
 
 {
@@ -37,8 +37,8 @@ DvdWizardChapters::DvdWizardChapters(bool isPal, QWidget *parent) :
 
     // Build monitor for chapters
 
-    if (m_isPal) m_tc.setFormat(25);
-    else m_tc.setFormat(30000.0 / 1001, true);
+    if (m_format == PAL || m_format == PAL_WIDE) m_tc.setFormat(25);
+    else m_tc.setFormat(30000.0 / 1001);
 
     m_manager = new MonitorManager(this);
     m_manager->resetProfiles(m_tc);
@@ -75,7 +75,7 @@ void DvdWizardChapters::slotUpdateChaptersList()
     // insert chapters
     QStringList chaptersString;
     for (int i = 0; i < currentChaps.count(); i++) {
-        chaptersString.append(Timecode::getStringTimecode(currentChaps.at(i).toInt(), m_tc.fps()));
+        chaptersString.append(Timecode::getStringTimecode(currentChaps.at(i).toInt(), m_tc.fps(), true));
     }
     m_view.chapters_list->clear();
     m_view.chapters_list->addItems(chaptersString);
@@ -98,7 +98,7 @@ void DvdWizardChapters::slotAddChapter()
     QStringList chaptersString;
     currentChaps.clear();
     for (int i = 0; i < chapterTimes.count(); i++) {
-        chaptersString.append(Timecode::getStringTimecode(chapterTimes.at(i), m_tc.fps()));
+        chaptersString.append(Timecode::getStringTimecode(chapterTimes.at(i), m_tc.fps(), true));
         currentChaps.append(QString::number(chapterTimes.at(i)));
     }
     // Save item chapters
@@ -123,7 +123,7 @@ void DvdWizardChapters::slotRemoveChapter()
     // rebuild chapters
     QStringList chaptersString;
     for (int i = 0; i < currentChaps.count(); i++) {
-        chaptersString.append(Timecode::getStringTimecode(currentChaps.at(i).toInt(), m_tc.fps()));
+        chaptersString.append(Timecode::getStringTimecode(currentChaps.at(i).toInt(), m_tc.fps(), true));
     }
     m_view.chapters_list->clear();
     m_view.chapters_list->addItems(chaptersString);
@@ -131,39 +131,36 @@ void DvdWizardChapters::slotRemoveChapter()
 
 void DvdWizardChapters::slotGoToChapter()
 {
-    m_monitor->setTimePos(m_view.chapters_list->currentItem()->text() + ":00");
+    if (m_view.chapters_list->currentItem()) m_monitor->setTimePos(m_tc.reformatSeparators(m_view.chapters_list->currentItem()->text()));
 }
 
-void DvdWizardChapters::setVobFiles(bool isPal, bool isWide, const QStringList movies, const QStringList durations, const QStringList chapters)
+void DvdWizardChapters::setVobFiles(DVDFORMAT format, const QStringList &movies, const QStringList &durations, const QStringList &chapters)
 {
-    m_isPal = isPal;
-    QString profile;
-    if (m_isPal) {
+    m_format = format;
+    QString profile = DvdWizardVob::getDvdProfile(format);
+    if (m_format == PAL || m_format == PAL_WIDE) {
         m_tc.setFormat(25);
-        profile = "dv_pal";
     } else {
-        m_tc.setFormat(30000.0 / 1001, true);
-        profile = "dv_ntsc";
+        m_tc.setFormat(30000.0 / 1001);
     }
-    if (isWide) profile.append("_wide");
     m_manager->resetProfiles(m_tc);
-
     if (m_monitor == NULL) {
-
-        m_monitor = new Monitor("chapter", m_manager, profile, this);
+        m_monitor = new Monitor(Kdenlive::dvdMonitor, m_manager, profile, this);
         //m_monitor->start();
         QVBoxLayout *vbox = new QVBoxLayout;
         vbox->addWidget(m_monitor);
         m_view.monitor_frame->setLayout(vbox);
         /*updateGeometry();
-        adjustSize();*/
+        m_view.monitor_frame->adjustSize();*/
     } else m_monitor->resetProfile(profile);
 
+    m_view.vob_list->blockSignals(true);
     m_view.vob_list->clear();
     for (int i = 0; i < movies.count(); i++) {
         m_view.vob_list->addItem(movies.at(i), durations.at(i));
         m_view.vob_list->setItemData(i, chapters.at(i).split(';'), Qt::UserRole + 1);
     }
+    m_view.vob_list->blockSignals(false);
     slotUpdateChaptersList();
 }
 
@@ -186,7 +183,7 @@ QStringList DvdWizardChapters::selectedTitles() const
         result.append(m_view.vob_list->itemText(i));
         QStringList chapters = m_view.vob_list->itemData(i, Qt::UserRole + 1).toStringList();
         for (int j = 0; j < chapters.count(); j++) {
-            result.append(Timecode::getStringTimecode(chapters.at(j).toInt(), m_tc.fps()));
+            result.append(Timecode::getStringTimecode(chapters.at(j).toInt(), m_tc.fps(), true));
         }
     }
     return result;
@@ -197,7 +194,7 @@ QStringList DvdWizardChapters::chapters(int ix) const
     QStringList result;
     QStringList chapters = m_view.vob_list->itemData(ix, Qt::UserRole + 1).toStringList();
     for (int j = 0; j < chapters.count(); j++) {
-        result.append(Timecode::getStringTimecode(chapters.at(j).toInt(), m_tc.fps()));
+        result.append(Timecode::getStringTimecode(chapters.at(j).toInt(), m_tc.fps(), true));
     }
     return result;
 }
@@ -207,10 +204,11 @@ QStringList DvdWizardChapters::selectedTargets() const
     QStringList result;
     int max = m_view.vob_list->count();
     for (int i = 0; i < max; i++) {
-        result.append("jump title " + QString::number(i + 1));
+        // rightJustified: fill with 0s to make menus with more than 9 buttons work (now up to 99 buttons possible)
+        result.append("jump title " + QString::number(i + 1).rightJustified(2, '0'));
         QStringList chapters = m_view.vob_list->itemData(i, Qt::UserRole + 1).toStringList();
         for (int j = 0; j < chapters.count(); j++) {
-            result.append("jump title " + QString::number(i + 1) + " chapter " + QString::number(j + 1));
+            result.append("jump title " + QString::number(i + 1).rightJustified(2, '0') + " chapter " + QString::number(j + 1).rightJustified(2, '0'));
         }
     }
     return result;