#include <QTreeWidgetItem>
#include <QHeaderView>
-DvdWizardVob::DvdWizardVob(const QString &profile, QWidget *parent) :
+DvdWizardVob::DvdWizardVob(QWidget *parent) :
QWizardPage(parent)
{
m_view.setupUi(this);
m_view.intro_vob->setEnabled(false);
m_view.intro_vob->setFilter("video/mpeg");
- m_view.button_add->setIcon(KIcon("document-new"));
- m_view.button_delete->setIcon(KIcon("edit-delete"));
+ m_view.button_add->setIcon(KIcon("list-add"));
+ m_view.button_delete->setIcon(KIcon("list-remove"));
m_view.button_up->setIcon(KIcon("go-up"));
m_view.button_down->setIcon(KIcon("go-down"));
connect(m_view.use_intro, SIGNAL(toggled(bool)), m_view.intro_vob, SLOT(setEnabled(bool)));
connect(m_view.button_up, SIGNAL(clicked()), this, SLOT(slotItemUp()));
connect(m_view.button_down, SIGNAL(clicked()), this, SLOT(slotItemDown()));
connect(m_view.vobs_list, SIGNAL(itemSelectionChanged()), this, SLOT(slotCheckVobList()));
+
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")));
else m_view.error_message->setText(m_errorMessage);
m_view.dvd_profile->addItems(QStringList() << i18n("PAL 4:3") << i18n("PAL 16:9") << i18n("NTSC 4:3") << i18n("NTSC 16:9"));
- if (profile == "dv_pal_wide") m_view.dvd_profile->setCurrentIndex(1);
- else if (profile == "dv_ntsc") m_view.dvd_profile->setCurrentIndex(2);
- else if (profile == "dv_ntsc_wide") m_view.dvd_profile->setCurrentIndex(3);
connect(m_view.dvd_profile, SIGNAL(activated(int)), this, SLOT(changeFormat()));
+ connect(m_view.dvd_profile, SIGNAL(activated(int)), this, SLOT(slotCheckProfiles()));
m_view.vobs_list->header()->setStretchLastSection(false);
m_view.vobs_list->header()->setResizeMode(0, QHeaderView::Stretch);
m_view.vobs_list->header()->setResizeMode(1, QHeaderView::Custom);
m_view.vobs_list->header()->setResizeMode(2, QHeaderView::Custom);
m_capacityBar = new KCapacityBar(KCapacityBar::DrawTextInline, this);
- QHBoxLayout *layout = new QHBoxLayout;
- layout->addWidget(m_capacityBar);
- m_view.size_box->setLayout(layout);
+ QHBoxLayout *lay = new QHBoxLayout;
+ lay->addWidget(m_capacityBar);
+ m_view.size_box->setLayout(lay);
+
+ m_view.vobs_list->setItemDelegate(new DvdViewDelegate(m_view.vobs_list));
+
+#if KDE_IS_VERSION(4,7,0)
+ m_warnMessage = new KMessageWidget;
+ m_warnMessage->setText(i18n("Conflicting video standards, check DVD profile and clips"));
+ m_warnMessage->setMessageType(KMessageWidget::Warning);
+ QGridLayout *s = static_cast <QGridLayout*> (layout());
+ s->addWidget(m_warnMessage, 3, 0, 1, -1);
+ m_warnMessage->hide();
+#endif
+
slotCheckVobList();
}
delete m_capacityBar;
}
+void DvdWizardVob::slotCheckProfiles()
+{
+#if KDE_IS_VERSION(4,7,0)
+ bool conflict = false;
+ int comboProfile = m_view.dvd_profile->currentIndex();
+ for (int i = 0; i < m_view.vobs_list->topLevelItemCount(); i++) {
+ QTreeWidgetItem *item = m_view.vobs_list->topLevelItem(i);
+ if (item->data(0, Qt::UserRole + 1).toInt() != comboProfile) {
+ conflict = true;
+ break;
+ }
+ }
+
+ if (conflict) {
+ m_warnMessage->animatedShow();
+ }
+ else m_warnMessage->animatedHide();
+#endif
+}
void DvdWizardVob::slotAddVobFile(KUrl url, const QString &chapters)
{
if (url.isEmpty()) return;
QFile f(url.path());
qint64 fileSize = f.size();
- QString profilename;
- switch (m_view.dvd_profile->currentIndex()) {
- case 1:
- profilename = "dv_pal_wide";
- break;
- case 2:
- profilename = "dv_ntsc";
- break;
- case 3:
- profilename = "dv_ntsc_wide";
- break;
- default:
- profilename = "dv_pal";
- break;
- }
- Mlt::Profile profile(profilename.toUtf8().data());
+ Mlt::Profile profile;
+ profile.set_explicit(false);
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);
-
+ item->setData(0, Qt::DecorationRole, KIcon("video-x-generic").pixmap(60, 45));
+ item->setToolTip(0, url.path());
+
Mlt::Producer *producer = new Mlt::Producer(profile, url.path().toUtf8().data());
-
- if (producer->is_blank() == false) {
+ if (producer && producer->is_valid() && !producer->is_blank()) {
+ //Mlt::Frame *frame = producer->get_frame();
+ //delete frame;
+ profile.from_producer(*producer);
int width = 45.0 * profile.dar();
int swidth = 45.0 * profile.width() / profile.height();
if (width % 2 == 1) width++;
- item->setIcon(0, QPixmap::fromImage(KThumb::getFrame(producer, 0, swidth, width, 45)));
+ item->setData(0, Qt::DecorationRole, 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);
+ int standard = -1;
+ int aspect = profile.dar() * 100;
+ if (profile.height() == 576) {
+ if (aspect > 150) standard = 1;
+ else standard = 0;
+ }
+ else if (profile.height() == 480) {
+ if (aspect > 150) standard = 3;
+ else standard = 2;
+ }
+ QString standardName;
+ switch (standard) {
+ case 3:
+ standardName = i18n("NTSC 16:9");
+ break;
+ case 2:
+ standardName = i18n("NTSC 4:3");
+ break;
+ case 1:
+ standardName = i18n("PAL 16:9");
+ break;
+ case 0:
+ standardName = i18n("PAL 4:3");
+ break;
+ default:
+ standardName = i18n("Unknown");
+ }
+ item->setData(0, Qt::UserRole, standardName);
+ item->setData(0, Qt::UserRole + 1, standard);
+ if (m_view.vobs_list->topLevelItemCount() == 1) {
+ // This is the first added movie, auto select DVD format
+ if (standard >= 0) {
+ m_view.dvd_profile->blockSignals(true);
+ m_view.dvd_profile->setCurrentIndex(standard);
+ m_view.dvd_profile->blockSignals(false);
+ }
+ }
+
}
- delete producer;
+ if (producer) delete producer;
if (chapters.isEmpty() == false) {
item->setData(1, Qt::UserRole + 1, chapters);
QFile file(url.path() + ".dvdchapter");
if (file.open(QIODevice::ReadOnly)) {
QDomDocument doc;
- doc.setContent(&file);
+ if (doc.setContent(&file) == false) {
+ file.close();
+ return;
+ }
file.close();
QDomNodeList chapters = doc.elementsByTagName("chapter");
QStringList chaptersList;
item->setData(1, Qt::UserRole + 1, "0");
slotCheckVobList();
+ slotCheckProfiles();
}
void DvdWizardVob::changeFormat()
break;
}
- Mlt::Profile profile(profilename.toUtf8().data());
+ Mlt::Profile profile(profilename.toUtf8().constData());
QPixmap pix(180, 135);
for (int i = 0; i < max; i++) {
if (item == NULL) return;
delete item;
slotCheckVobList();
+ slotCheckProfiles();
}
m_view.vobs_list->insertTopLevelItem(index + 1, m_view.vobs_list->takeTopLevelItem(index));
}
-bool DvdWizardVob::isPal() const
+DVDFORMAT DvdWizardVob::dvdFormat() const
{
- return m_view.dvd_profile->currentIndex() < 2;
+ return (DVDFORMAT) m_view.dvd_profile->currentIndex();
}
-bool DvdWizardVob::isWide() const
+const QString DvdWizardVob::dvdProfile() const
{
- return (m_view.dvd_profile->currentIndex() == 1 || m_view.dvd_profile->currentIndex() == 3);
+ 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") m_view.dvd_profile->setCurrentIndex(0);
- else if (profile == "dv_pal_wide") m_view.dvd_profile->setCurrentIndex(1);
- else if (profile == "dv_ntsc") m_view.dvd_profile->setCurrentIndex(2);
- else if (profile == "dv_ntsc_wide") m_view.dvd_profile->setCurrentIndex(3);
+ if (profile == "dv_pal") m_view.dvd_profile->setCurrentIndex(PAL);
+ else 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);
}
void DvdWizardVob::clear()