- QList<KUrlRequester *> allUrls = m_view.vob_list->findChildren<KUrlRequester *>();
- int count = allUrls.count();
- kDebug() << "// FOUND " << count << " URLS";
- if (count == 1) {
- if (text.isEmpty()) return;
- // insert second urlrequester
- KUrlRequester *vob = new KUrlRequester(this);
- vob->setFilter("video/mpeg");
- m_view.vob_list->layout()->addWidget(vob);
- connect(vob, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckVobList(const QString &)));
- } else if (text.isEmpty()) {
- if (allUrls.at(count - 1)->url().path().isEmpty() && allUrls.at(count - 2)->url().path().isEmpty()) {
- // The last 2 urlrequesters are empty, remove last one
- KUrlRequester *vob = allUrls.takeLast();
- delete vob;
- }
- } else {
- if (allUrls.at(count - 1)->url().path().isEmpty()) return;
- KUrlRequester *vob = new KUrlRequester(this);
- vob->setFilter("video/mpeg");
- m_view.vob_list->layout()->addWidget(vob);
- connect(vob, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckVobList(const QString &)));
+ int max = m_vobList->topLevelItemCount();
+ QTreeWidgetItem *item = m_vobList->currentItem();
+ bool hasItem = true;
+ if (item == NULL) hasItem = false;
+ m_view.button_delete->setEnabled(hasItem);
+ if (hasItem && m_vobList->indexOfTopLevelItem(item) == 0) m_view.button_up->setEnabled(false);
+ else m_view.button_up->setEnabled(hasItem);
+ if (hasItem && m_vobList->indexOfTopLevelItem(item) == max - 1) m_view.button_down->setEnabled(false);
+ else m_view.button_down->setEnabled(hasItem);
+
+ qint64 totalSize = 0;
+ for (int i = 0; i < max; i++) {
+ item = m_vobList->topLevelItem(i);
+ if (item) totalSize += (qint64) item->data(2, Qt::UserRole).toInt();
+ }
+
+ qint64 maxSize = (qint64) 47000 * 100000;
+ m_capacityBar->setValue(100 * totalSize / maxSize);
+ m_capacityBar->setText(KIO::convertSize(totalSize));
+}
+
+void DvdWizardVob::slotItemUp()
+{
+ QTreeWidgetItem *item = m_vobList->currentItem();
+ if (item == NULL) return;
+ int index = m_vobList->indexOfTopLevelItem(item);
+ if (index == 0) return;
+ m_vobList->insertTopLevelItem(index - 1, m_vobList->takeTopLevelItem(index));
+}
+
+void DvdWizardVob::slotItemDown()
+{
+ int max = m_vobList->topLevelItemCount();
+ QTreeWidgetItem *item = m_vobList->currentItem();
+ if (item == NULL) return;
+ int index = m_vobList->indexOfTopLevelItem(item);
+ if (index == max - 1) return;
+ m_vobList->insertTopLevelItem(index + 1, m_vobList->takeTopLevelItem(index));
+}
+
+DVDFORMAT DvdWizardVob::dvdFormat() const
+{
+ return (DVDFORMAT) m_view.dvd_profile->currentIndex();
+}
+
+const QString DvdWizardVob::dvdProfile() const
+{
+ QString profile;
+ switch (m_view.dvd_profile->currentIndex()) {
+ case PAL_WIDE:
+ profile = "dv_pal_wide";
+ break;
+ case NTSC:
+ profile = "dv_ntsc";
+ break;
+ case NTSC_WIDE:
+ profile = "dv_ntsc_wide";
+ break;
+ default:
+ profile = "dv_pal";
+ }
+ return profile;
+}
+
+//static
+QString DvdWizardVob::getDvdProfile(DVDFORMAT format)
+{
+ QString profile;
+ switch (format) {
+ case PAL_WIDE:
+ profile = "dv_pal_wide";
+ break;
+ case NTSC:
+ profile = "dv_ntsc";
+ break;
+ case NTSC_WIDE:
+ profile = "dv_ntsc_wide";
+ break;
+ default:
+ profile = "dv_pal";
+ }
+ return profile;
+}
+
+void DvdWizardVob::setProfile(const QString& profile)
+{
+ if (profile == "dv_pal_wide") m_view.dvd_profile->setCurrentIndex(PAL_WIDE);
+ else if (profile == "dv_ntsc") m_view.dvd_profile->setCurrentIndex(NTSC);
+ else if (profile == "dv_ntsc_wide") m_view.dvd_profile->setCurrentIndex(NTSC_WIDE);
+ else m_view.dvd_profile->setCurrentIndex(PAL);
+}
+
+void DvdWizardVob::clear()
+{
+ m_vobList->clear();
+}
+
+void DvdWizardVob::slotTranscodeFiles()
+{
+ // Find transcoding infos related to selected DVD profile
+ KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc", KConfig::CascadeConfig);
+ KConfigGroup transConfig(config, "Transcoding");
+ // read the entries
+ QString profileEasyName;
+ QSize destSize;
+ QSize finalSize;
+ switch (m_view.dvd_profile->currentIndex()) {
+ case PAL_WIDE:
+ profileEasyName = "DVD PAL 16:9";
+ destSize = QSize(1024, 576);
+ finalSize = QSize(720, 576);
+ break;
+ case NTSC:
+ profileEasyName = "DVD NTSC 4:3";
+ destSize = QSize(640, 480);
+ finalSize = QSize(720, 480);
+ break;
+ case NTSC_WIDE:
+ profileEasyName = "DVD NTSC 16:9";
+ destSize = QSize(853, 480);
+ finalSize = QSize(720, 480);
+ break;
+ default:
+ profileEasyName = "DVD PAL 4:3";
+ destSize = QSize(768, 576);
+ finalSize = QSize(720, 576);
+ }
+ QString params = transConfig.readEntry(profileEasyName);
+
+ // Transcode files that do not match selected profile
+ int max = m_vobList->topLevelItemCount();
+ int format = m_view.dvd_profile->currentIndex();
+ for (int i = 0; i < max; i++) {
+ QTreeWidgetItem *item = m_vobList->topLevelItem(i);
+ if (item->data(0, Qt::UserRole + 1).toInt() != format) {
+ // File needs to be transcoded
+ m_transcodeAction->setEnabled(false);
+ QSize original = item->data(0, Qt::UserRole + 2).toSize();
+ double input_aspect= (double) original.width() / original.height();
+ QStringList postParams;
+ if (input_aspect > (double) destSize.width() / destSize.height()) {
+ // letterboxing
+ int conv_height = (int) (destSize.width() / input_aspect);
+ int conv_pad = (int) (((double) (destSize.height() - conv_height)) / 2.0);
+ if (conv_pad %2 == 1) conv_pad --;
+ postParams << "-vf" << QString("scale=%1:%2,pad=%3:%4:0:%5,setdar=%6").arg(finalSize.width()).arg(destSize.height() - 2 * conv_pad).arg(finalSize.width()).arg(finalSize.height()).arg(conv_pad).arg(input_aspect);
+ } else {
+ // pillarboxing
+ int conv_width = (int) (destSize.height() * input_aspect);
+ int conv_pad = (int) (((double) (destSize.width() - conv_width)) / destSize.width() * finalSize.width() / 2.0);
+ if (conv_pad %2 == 1) conv_pad --;
+ postParams << "-vf" << QString("scale=%1:%2,pad=%3:%4:%5:0,setdar=%6").arg(finalSize.width() - 2 * conv_pad).arg(destSize.height()).arg(finalSize.width()).arg(finalSize.height()).arg(conv_pad).arg(input_aspect);
+ }
+ ClipTranscode *d = new ClipTranscode(KUrl::List () << KUrl(item->text(0)), params.section(';', 0, 0), postParams, i18n("Transcoding to DVD format"), true, this);
+ connect(d, SIGNAL(transcodedClip(KUrl,KUrl)), this, SLOT(slotTranscodedClip(KUrl, KUrl)));
+ d->slotStartTransCode();
+ d->show();
+
+ }
+ }
+}
+
+void DvdWizardVob::slotTranscodedClip(KUrl src, KUrl transcoded)
+{
+ if (transcoded.isEmpty()) {
+ // Transcoding canceled or failed
+ m_transcodeAction->setEnabled(true);
+ return;