]> git.sesse.net Git - kdenlive/blobdiff - src/wizard.cpp
Use const'ref.
[kdenlive] / src / wizard.cpp
index 4539a3fcac4498932b27838e4cad6712d791bc69..a66a0ec10b65a6ccf8e6b12a4ddeb056700c9099 100644 (file)
 #include <KService>
 #include <KMimeTypeTrader>
 
+#if KDE_IS_VERSION(4,7,0)
+#include <KMessageWidget>
+#endif
+
 #include <QLabel>
 #include <QFile>
 #include <QXmlStreamWriter>
@@ -45,7 +49,7 @@
 // Recommended MLT version
 const int mltVersionMajor = 0;
 const int mltVersionMinor = 8;
-const int mltVersionRevision = 0;
+const int mltVersionRevision = 8;
 
 static const char kdenlive_version[] = VERSION;
 
@@ -58,14 +62,13 @@ Wizard::Wizard(bool upgrade, QWidget *parent) :
 
     QWizardPage *page1 = new QWizardPage;
     page1->setTitle(i18n("Welcome"));
-    QLabel *label;
     if (upgrade)
-        label = new QLabel(i18n("Your Kdenlive version was upgraded to version %1. Please take some time to review the basic settings", QString(kdenlive_version).section(' ', 0, 0)));
+        m_welcomeLabel = new QLabel(i18n("Your Kdenlive version was upgraded to version %1. Please take some time to review the basic settings", QString(kdenlive_version).section(' ', 0, 0)), this);
     else
-        label = new QLabel(i18n("This is the first time you run Kdenlive. This wizard will let you adjust some basic settings, you will be ready to edit your first movie in a few seconds..."));
-    label->setWordWrap(true);
+        m_welcomeLabel = new QLabel(i18n("This is the first time you run Kdenlive. This wizard will let you adjust some basic settings, you will be ready to edit your first movie in a few seconds..."), this);
+    m_welcomeLabel->setWordWrap(true);
     m_startLayout = new QVBoxLayout;
-    m_startLayout->addWidget(label);
+    m_startLayout->addWidget(m_welcomeLabel);
     QPushButton *but = new QPushButton(KIcon("help-about"), i18n("Discover the features of this Kdenlive release"), this);
     connect(but, SIGNAL(clicked()), this, SLOT(slotShowWebInfos()));
     m_startLayout->addStretch();
@@ -357,6 +360,7 @@ void Wizard::checkMltComponents()
                 result << QString(formats.get(i));
             m_mltCheck.formats_list->addItems(result);
             KdenliveSettings::setSupportedformats(result);
+           checkMissingCodecs();
             delete consumer;
         }
 
@@ -405,6 +409,87 @@ void Wizard::checkMltComponents()
     }
 }
 
+void Wizard::checkMissingCodecs()
+{
+    const QStringList acodecsList = KdenliveSettings::audiocodecs();
+    const QStringList vcodecsList = KdenliveSettings::videocodecs();
+    bool replaceVorbisCodec = false;
+    if (acodecsList.contains("libvorbis")) replaceVorbisCodec = true;
+    bool replaceLibfaacCodec = false;
+    if (!acodecsList.contains("aac") && acodecsList.contains("libfaac")) replaceLibfaacCodec = true;
+    
+    QString exportFolder = KStandardDirs::locateLocal("appdata", "export/");
+    QDir directory = QDir(exportFolder);
+    QStringList filter;
+    filter << "*.xml";
+    QStringList fileList = directory.entryList(filter, QDir::Files);
+    // We should parse customprofiles.xml in last position, so that user profiles
+    // can also override profiles installed by KNewStuff
+    QStringList requiredACodecs;
+    QStringList requiredVCodecs;
+    foreach(const QString &filename, fileList) {
+       QDomDocument doc;
+       QFile file(exportFolder + filename);
+       doc.setContent(&file, false);
+       file.close();
+       QString std;
+       QString format;
+       QDomNodeList profiles = doc.elementsByTagName("profile");
+       for (int i = 0; i < profiles.count(); i++) {
+           std = profiles.at(i).toElement().attribute("args");
+           format.clear();
+            if (std.startsWith("acodec=")) format = std.section("acodec=", 1, 1);
+           else if (std.contains(" acodec=")) format = std.section(" acodec=", 1, 1);
+            if (!format.isEmpty()) requiredACodecs << format.section(' ', 0, 0).toLower();
+           format.clear();
+            if (std.startsWith("vcodec=")) format = std.section("vcodec=", 1, 1);
+           else if (std.contains(" vcodec=")) format = std.section(" vcodec=", 1, 1);
+            if (!format.isEmpty()) requiredVCodecs << format.section(' ', 0, 0).toLower();
+       }
+    }
+    requiredACodecs.removeDuplicates();
+    requiredVCodecs.removeDuplicates();
+    if (replaceVorbisCodec) requiredACodecs.replaceInStrings("vorbis", "libvorbis");
+    if (replaceLibfaacCodec) requiredACodecs.replaceInStrings("aac", "libfaac");
+
+    for (int i = 0; i < acodecsList.count(); i++)
+       requiredACodecs.removeAll(acodecsList.at(i));
+    for (int i = 0; i < vcodecsList.count(); i++)
+       requiredVCodecs.removeAll(vcodecsList.at(i));
+    if (!requiredACodecs.isEmpty() || !requiredVCodecs.isEmpty()) {
+       QString missing = requiredACodecs.join(",");
+       if (!missing.isEmpty() && !requiredVCodecs.isEmpty()) missing.append(',');
+       missing.append(requiredVCodecs.join(","));
+       missing.prepend(i18n("The following codecs were not found on your system. Check our <a href=''>online manual</a> if you need them: "));
+       // Some codecs required for rendering are not present on this system, warn user
+       show();
+#if KDE_IS_VERSION(4,7,0)
+        KMessageWidget *infoMessage = new KMessageWidget(this);
+        m_startLayout->insertWidget(1, infoMessage);
+        infoMessage->setCloseButtonVisible(false);
+        infoMessage->setWordWrap(true);
+       infoMessage->setMessageType(KMessageWidget::Warning);
+#if KDE_IS_VERSION(4,10,0)
+       connect(infoMessage, SIGNAL(linkActivated(QString)), this, SLOT(slotOpenManual()));
+       infoMessage->setText(missing);
+#else
+       // clickable text in kmessagewidget only available since KDE 4.10
+       // remove link from text
+       missing.remove(QRegExp("<[^>]*>"));
+        infoMessage->setText(missing);
+       QAction *manualAction = new QAction(i18n("Check online manual"), this);
+       connect(manualAction, SIGNAL(triggered()), this, SLOT(slotOpenManual()));
+       infoMessage->addAction(manualAction);
+#endif
+        infoMessage->animatedShow();
+#else
+       m_welcomeLabel->setText(m_welcomeLabel->text() + "<br><hr />" + missing);
+       connect(m_welcomeLabel, SIGNAL(linkActivated(QString)), this, SLOT(slotOpenManual()));
+#endif
+    }
+    
+}
+
 void Wizard::slotCheckPrograms()
 {
     QSize itemSize(20, fontMetrics().height() * 2.5);
@@ -412,7 +497,7 @@ void Wizard::slotCheckPrograms()
     m_check.programList->setIconSize(QSize(24, 24));
 
     QTreeWidgetItem *item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("FFmpeg & ffplay"));
-    item->setData(1, Qt::UserRole, i18n("Required for webcam capture"));
+    item->setData(1, Qt::UserRole, i18n("Required for proxy clips, transcoding and screen capture"));
     item->setSizeHint(0, itemSize);
     QString exepath = KStandardDirs::findExe("ffmpeg");
     QString playpath = KStandardDirs::findExe("ffplay");
@@ -431,12 +516,6 @@ void Wizard::slotCheckPrograms()
     if (!playpath.isEmpty()) KdenliveSettings::setFfplaypath(playpath);
 
 #ifndef Q_WS_MAC
-    item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("recordmydesktop"));
-    item->setData(1, Qt::UserRole, i18n("Required for screen capture"));
-    item->setSizeHint(0, itemSize);
-    if (KStandardDirs::findExe("recordmydesktop").isEmpty()) item->setIcon(0, m_badIcon);
-    else item->setIcon(0, m_okIcon);
-
     item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("dvgrab"));
     item->setData(1, Qt::UserRole, i18n("Required for firewire capture"));
     item->setSizeHint(0, itemSize);
@@ -464,7 +543,13 @@ void Wizard::slotCheckPrograms()
     item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("xine"));
     item->setData(1, Qt::UserRole, i18n("Required to preview your DVD"));
     item->setSizeHint(0, itemSize);
-    if (KStandardDirs::findExe("xine").isEmpty()) item->setIcon(0, m_badIcon);
+    if (KStandardDirs::findExe("xine").isEmpty()) {
+       if (!KStandardDirs::findExe("vlc").isEmpty()) {
+           item->setText(1, i18n("vlc"));
+           item->setIcon(0, m_okIcon);
+       }
+       else item->setIcon(0, m_badIcon);
+    }
     else item->setIcon(0, m_okIcon);
 
     // set up some default applications
@@ -676,6 +761,11 @@ bool Wizard::isOk() const
     return m_systemCheckIsOk;
 }
 
+void Wizard::slotOpenManual()
+{
+    KRun::runUrl(KUrl("http://kdenlive.org/troubleshooting"), "text/html", this);
+}
+
 void Wizard::slotShowWebInfos()
 {
     KRun::runUrl(KUrl("http://kdenlive.org/discover/" + QString(kdenlive_version).section(' ', 0, 0)), "text/html", this);