]> git.sesse.net Git - kdenlive/blobdiff - src/wizard.cpp
Add non realtime preview mode to Kdenlive (available from monitor context menu)
[kdenlive] / src / wizard.cpp
index da36d0b516a96fbddf96a070b9d0e915421cee5a..ea928ecc365c937a9a0d3ea006cbf80cb070d6cb 100644 (file)
 #include <QXmlStreamWriter>
 #include <QTimer>
 
-const double recommendedMltVersion = 36;
+const double recommendedMltVersion = 40;
 
-Wizard::Wizard(bool upgrade, QWidget *parent): QWizard(parent) {
+Wizard::Wizard(bool upgrade, QWidget *parent) :
+        QWizard(parent)
+{
+    setWindowTitle(i18n("Config Wizard"));
     setPixmap(QWizard::WatermarkPixmap, QPixmap(KStandardDirs::locate("appdata", "banner.png")));
 
     QWizardPage *page1 = new QWizardPage;
@@ -65,32 +68,47 @@ Wizard::Wizard(bool upgrade, QWidget *parent): QWizard(parent) {
     m_badIcon = KIcon("dialog-close");
 
     // build profiles lists
-    m_profilesInfo = ProfilesDialog::getProfilesInfo();
-    QMap<QString, QString>::const_iterator i = m_profilesInfo.constBegin();
-    while (i != m_profilesInfo.constEnd()) {
+    QMap<QString, QString> profilesInfo = ProfilesDialog::getProfilesInfo();
+    QMap<QString, QString>::const_iterator i = profilesInfo.constBegin();
+    while (i != profilesInfo.constEnd()) {
         QMap< QString, QString > profileData = ProfilesDialog::getSettingsFromFile(i.value());
-        if (profileData.value("width") == "720") m_dvProfiles.append(i.key());
-        else if (profileData.value("width").toInt() >= 1080) m_hdvProfiles.append(i.key());
-        else m_otherProfiles.append(i.key());
+        if (profileData.value("width") == "720") m_dvProfiles.insert(i.key(), i.value());
+        else if (profileData.value("width").toInt() >= 1080) m_hdvProfiles.insert(i.key(), i.value());
+        else m_otherProfiles.insert(i.key(), i.value());
         ++i;
     }
 
+    m_standard.button_all->setChecked(true);
     connect(m_standard.button_all, SIGNAL(toggled(bool)), this, SLOT(slotCheckStandard()));
     connect(m_standard.button_hdv, SIGNAL(toggled(bool)), this, SLOT(slotCheckStandard()));
     connect(m_standard.button_dv, SIGNAL(toggled(bool)), this, SLOT(slotCheckStandard()));
-    m_standard.button_all->setChecked(true);
+    slotCheckStandard();
     connect(m_standard.profiles_list, SIGNAL(itemSelectionChanged()), this, SLOT(slotCheckSelectedItem()));
 
+
+    if (!KdenliveSettings::default_profile().isEmpty()) {
+        for (int i = 0; i < m_standard.profiles_list->count(); i++) {
+            if (m_standard.profiles_list->item(i)->data(Qt::UserRole).toString() == KdenliveSettings::default_profile()) {
+                m_standard.profiles_list->setCurrentRow(i);
+                m_standard.profiles_list->scrollToItem(m_standard.profiles_list->currentItem());
+                break;
+            }
+        }
+    }
+
     // select default profile
+    fprintf(stderr, "LOOKING FOR: %s", ProfilesDialog::getProfileDescription(KdenliveSettings::default_profile()).toUtf8().data());
     QList<QListWidgetItem *> profiles = m_standard.profiles_list->findItems(ProfilesDialog::getProfileDescription(KdenliveSettings::default_profile()), Qt::MatchExactly);
     if (profiles.count() > 0) m_standard.profiles_list->setCurrentItem(profiles.at(0));
+
+    fprintf(stderr, "LOOKING FOR: %s // %d", ProfilesDialog::getProfileDescription(KdenliveSettings::default_profile()).toUtf8().data(), profiles.count());
     addPage(page2);
 
     QWizardPage *page3 = new QWizardPage;
     page3->setTitle(i18n("Additional Settings"));
     m_extra.setupUi(page3);
     m_extra.projectfolder->setMode(KFile::Directory);
-    m_extra.projectfolder->setPath(QDir::homePath() + "/kdenlive");
+    m_extra.projectfolder->setPath(KdenliveSettings::defaultprojectfolder());
     m_extra.videothumbs->setChecked(KdenliveSettings::videothumbnails());
     m_extra.audiothumbs->setChecked(KdenliveSettings::audiothumbnails());
     m_extra.autosave->setChecked(KdenliveSettings::crashrecovery());
@@ -112,7 +130,8 @@ Wizard::Wizard(bool upgrade, QWidget *parent): QWizard(parent) {
 }
 
 
-void Wizard::checkMltComponents() {
+void Wizard::checkMltComponents()
+{
     m_mltCheck.programList->setColumnCount(2);
     m_mltCheck.programList->setRootIsDecorated(false);
     m_mltCheck.programList->setHeaderHidden(true);
@@ -123,17 +142,17 @@ void Wizard::checkMltComponents() {
 
     QTreeWidgetItem *mltitem = new QTreeWidgetItem(m_mltCheck.programList);
 
-    QTreeWidgetItem *inigoitem = new QTreeWidgetItem(m_mltCheck.programList, QStringList() << QString() << i18n("Inigo") + " (" + KdenliveSettings::rendererpath() + ')');
-    inigoitem->setData(1, Qt::UserRole, i18n("Required for rendering (part of MLT package)"));
-    inigoitem->setSizeHint(0, itemSize);
-    inigoitem->setIcon(0, m_okIcon);
+    QTreeWidgetItem *meltitem = new QTreeWidgetItem(m_mltCheck.programList, QStringList() << QString() << i18n("Melt") + " (" + KdenliveSettings::rendererpath() + ')');
+    meltitem->setData(1, Qt::UserRole, i18n("Required for rendering (part of MLT package)"));
+    meltitem->setSizeHint(0, itemSize);
+    meltitem->setIcon(0, m_okIcon);
 
     // Check MLT's installed producers
     QProcess checkProcess;
     checkProcess.start(KdenliveSettings::rendererpath(), QStringList() << "-query" << "producer");
     if (!checkProcess.waitForStarted()) {
-        inigoitem->setIcon(0, m_badIcon);
-        inigoitem->setData(1, Qt::UserRole, i18n("Error starting MLT's command line player (inigo)"));
+        meltitem->setIcon(0, m_badIcon);
+        meltitem->setData(1, Qt::UserRole, i18n("Error starting MLT's command line player (melt)"));
         button(QWizard::NextButton)->setEnabled(false);
     } else {
         checkProcess.waitForFinished();
@@ -154,7 +173,7 @@ void Wizard::checkMltComponents() {
             QString mltVersion;
             QString exepath = KStandardDirs::findExe("pkg-config");
             if (!exepath.isEmpty()) {
-                checkProcess.start(exepath, QStringList() << "--variable=version" << "mlt-framework");
+                checkProcess.start(exepath, QStringList() << "--variable=version" << "mlt++");
                 if (!checkProcess.waitForStarted()) {
                     kDebug() << "// Error querying MLT's version";
                 } else {
@@ -176,7 +195,7 @@ void Wizard::checkMltComponents() {
                     mltVersion = mltVersion.section(' ', -1).simplified();
                     version = 100 * mltVersion.section('.', 0, 0).toInt() + 10 * mltVersion.section('.', 1, 1).toInt() + mltVersion.section('.', 2, 2).toInt();
                     kDebug() << "// FOUND MLT version: " << version;
-                    if (version > 34) recentMlt = true;
+                    if (version >= 40) recentMlt = true;
                 }
             }
 
@@ -282,7 +301,8 @@ void Wizard::checkMltComponents() {
     }
 }
 
-void Wizard::slotCheckPrograms() {
+void Wizard::slotCheckPrograms()
+{
     m_check.programList->setColumnCount(2);
     m_check.programList->setRootIsDecorated(false);
     m_check.programList->setHeaderHidden(true);
@@ -317,14 +337,15 @@ void Wizard::slotCheckPrograms() {
     else item->setIcon(0, m_okIcon);
 
     item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("Mkisofs"));
-    item->setData(1, Qt::UserRole, i18n("Required for creation of DVD iso images"));
+    item->setData(1, Qt::UserRole, i18n("Required for creation of DVD ISO images"));
     item->setSizeHint(0, itemSize);
     if (KStandardDirs::findExe("mkisofs").isEmpty()) item->setIcon(0, m_badIcon);
     else item->setIcon(0, m_okIcon);
 
 }
 
-void Wizard::installExtraMimes(QString baseName, QStringList globs) {
+void Wizard::installExtraMimes(QString baseName, QStringList globs)
+{
     QString mimefile = baseName;
     mimefile.replace('/', '-');
     KMimeType::Ptr mime = KMimeType::mimeType(baseName);
@@ -372,7 +393,8 @@ void Wizard::installExtraMimes(QString baseName, QStringList globs) {
     }
 }
 
-void Wizard::runUpdateMimeDatabase() {
+void Wizard::runUpdateMimeDatabase()
+{
     const QString localPackageDir = KStandardDirs::locateLocal("xdgdata-mime", QString());
     //Q_ASSERT(!localPackageDir.isEmpty());
     KProcess proc;
@@ -384,7 +406,8 @@ void Wizard::runUpdateMimeDatabase() {
     }
 }
 
-void Wizard::slotCheckThumbs() {
+void Wizard::slotCheckThumbs()
+{
     QString pixname = "timeline_vthumbs.png";
     if (!m_extra.audiothumbs->isChecked() && !m_extra.videothumbs->isChecked()) {
         pixname = "timeline_nothumbs.png";
@@ -397,26 +420,43 @@ void Wizard::slotCheckThumbs() {
     m_extra.timeline_preview->setPixmap(QPixmap(KStandardDirs::locate("appdata", pixname)));
 }
 
-void Wizard::slotCheckStandard() {
+void Wizard::slotCheckStandard()
+{
     m_standard.profiles_list->clear();
     QStringList profiles;
-    if (m_standard.button_dv->isChecked()) {
+    if (!m_standard.button_hdv->isChecked()) {
         // DV standard
-        m_standard.profiles_list->addItems(m_dvProfiles);
-    } else if (m_standard.button_hdv->isChecked()) {
+        QMapIterator<QString, QString> i(m_dvProfiles);
+        while (i.hasNext()) {
+            i.next();
+            QListWidgetItem *item = new QListWidgetItem(i.key(), m_standard.profiles_list);
+            item->setData(Qt::UserRole, i.value());
+        }
+    }
+    if (!m_standard.button_dv->isChecked()) {
         // HDV standard
-        m_standard.profiles_list->addItems(m_hdvProfiles);
-    } else {
-        m_standard.profiles_list->addItems(m_dvProfiles);
-        m_standard.profiles_list->addItems(m_hdvProfiles);
-        m_standard.profiles_list->addItems(m_otherProfiles);
+        QMapIterator<QString, QString> i(m_hdvProfiles);
+        while (i.hasNext()) {
+            i.next();
+            QListWidgetItem *item = new QListWidgetItem(i.key(), m_standard.profiles_list);
+            item->setData(Qt::UserRole, i.value());
+        }
+    }
+    if (m_standard.button_all->isChecked()) {
+        QMapIterator<QString, QString> i(m_otherProfiles);
+        while (i.hasNext()) {
+            i.next();
+            QListWidgetItem *item = new QListWidgetItem(i.key(), m_standard.profiles_list);
+            item->setData(Qt::UserRole, i.value());
+        }
         //m_standard.profiles_list->sortItems();
     }
 
     for (int i = 0; i < m_standard.profiles_list->count(); i++) {
         QListWidgetItem *item = m_standard.profiles_list->item(i);
-        MltVideoProfile prof = ProfilesDialog::getVideoProfile(m_profilesInfo.value(item->text()));
-        const QString infoString = ("<strong>" + i18n("Frame size:") + " </strong>%1x%2<br /><strong>" + i18n("Frame rate:") + " </strong>%3/%4<br /><strong>" + i18n("Pixel aspect ratio:") + "</strong>%5/%6<br /><strong>" + i18n("Display aspect ratio:") + " </strong>%7/%8").arg(QString::number(prof.width), QString::number(prof.height), QString::number(prof.frame_rate_num), QString::number(prof.frame_rate_den), QString::number(prof.sample_aspect_num), QString::number(prof.sample_aspect_den), QString::number(prof.display_aspect_num), QString::number(prof.display_aspect_den));
+
+        QMap< QString, QString > values = ProfilesDialog::getSettingsFromFile(item->data(Qt::UserRole).toString());
+        const QString infoString = ("<strong>" + i18n("Frame size:") + " </strong>%1x%2<br /><strong>" + i18n("Frame rate:") + " </strong>%3/%4<br /><strong>" + i18n("Pixel aspect ratio:") + "</strong>%5/%6<br /><strong>" + i18n("Display aspect ratio:") + " </strong>%7/%8").arg(values.value("width"), values.value("height"), values.value("frame_rate_num"), values.value("frame_rate_den"), values.value("sample_aspect_num"), values.value("sample_aspect_den"), values.value("display_aspect_num"), values.value("display_aspect_den"));
         item->setToolTip(infoString);
     }
 
@@ -424,16 +464,18 @@ void Wizard::slotCheckStandard() {
     m_standard.profiles_list->setCurrentRow(0);
 }
 
-void Wizard::slotCheckSelectedItem() {
+void Wizard::slotCheckSelectedItem()
+{
     // Make sure we always have an item highlighted
     m_standard.profiles_list->setCurrentRow(m_standard.profiles_list->currentRow());
 }
 
 
-void Wizard::adjustSettings() {
+void Wizard::adjustSettings()
+{
     if (m_extra.installmimes->isChecked()) {
         QStringList globs;
-        globs << "*.mts" << "*.m2t" << "*.mod" << "*.ts";
+        globs << "*.mts" << "*.m2t" << "*.mod" << "*.ts" << "*.m2ts";
         installExtraMimes("video/mpeg", globs);
         globs.clear();
         globs << "*.dv";
@@ -444,25 +486,26 @@ void Wizard::adjustSettings() {
     KdenliveSettings::setVideothumbnails(m_extra.videothumbs->isChecked());
     KdenliveSettings::setCrashrecovery(m_extra.autosave->isChecked());
     if (m_standard.profiles_list->currentItem()) {
-        QString selectedProfile = m_profilesInfo.value(m_standard.profiles_list->currentItem()->text());
+        QString selectedProfile = m_standard.profiles_list->currentItem()->data(Qt::UserRole).toString();
         if (selectedProfile.isEmpty()) selectedProfile = "dv_pal";
         KdenliveSettings::setDefault_profile(selectedProfile);
     }
     QString path = m_extra.projectfolder->url().path();
-    if (KStandardDirs::makeDir(path) == false) kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
+    if (KStandardDirs::makeDir(path) == false) kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
     KdenliveSettings::setDefaultprojectfolder(path);
 
 }
 
-void Wizard::slotCheckMlt() {
+void Wizard::slotCheckMlt()
+{
     QString errorMessage;
     if (KdenliveSettings::rendererpath().isEmpty()) {
-        errorMessage.append(i18n("your MLT installation cannot be found. Install MLT and restart Kdenlive.\n"));
+        errorMessage.append(i18n("Your MLT installation cannot be found. Install MLT and restart Kdenlive.\n"));
     }
     /*QProcess checkProcess;
     checkProcess.start(KdenliveSettings::rendererpath(), QStringList() << "-query" << "producer");
     if (!checkProcess.waitForStarted())
-        errorMessage.append(i18n("Error starting MLT's command line player (inigo)") + ".\n");
+        errorMessage.append(i18n("Error starting MLT's command line player (melt)") + ".\n");
 
     checkProcess.waitForFinished();
 
@@ -472,7 +515,7 @@ void Wizard::slotCheckMlt() {
     QProcess checkProcess2;
     checkProcess2.start(KdenliveSettings::rendererpath(), QStringList() << "-query" << "consumer");
     if (!checkProcess2.waitForStarted())
-        errorMessage.append(i18n("Error starting MLT's command line player (inigo).") + '\n');
+        errorMessage.append(i18n("Error starting MLT's command line player (melt).") + '\n');
 
     checkProcess2.waitForFinished();
 
@@ -496,7 +539,8 @@ void Wizard::slotCheckMlt() {
     slotCheckPrograms();
 }
 
-bool Wizard::isOk() const {
+bool Wizard::isOk() const
+{
     return m_systemCheckIsOk;
 }