]> git.sesse.net Git - kdenlive/commitdiff
Add warning to Config Wizard in case of missing codecs, and link to our online manual...
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 30 Dec 2012 14:45:08 +0000 (15:45 +0100)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 30 Dec 2012 14:45:08 +0000 (15:45 +0100)
Introduces a new string, but will save time for everyone.

src/wizard.cpp
src/wizard.h

index 4b79d072050fafb0e03279f1cfaa5e1bbe5b8736..218cbaceb808000fd5c3b123dcfc202d6f2088e0 100644 (file)
 #include <KService>
 #include <KMimeTypeTrader>
 
+#if KDE_IS_VERSION(4,7,0)
+#include <KMessageWidget>
+#endif
+
 #include <QLabel>
 #include <QFile>
 #include <QXmlStreamWriter>
@@ -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 (const 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 (const QString &)), this, SLOT(slotOpenManual()));
+#endif
+    }
+    
+}
+
 void Wizard::slotCheckPrograms()
 {
     QSize itemSize(20, fontMetrics().height() * 2.5);
@@ -682,6 +767,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);
index 134e4e0be63771f2c73670ffd99aee748d78d3ec..769bf766ad5452019e935aff6a7de4ed52d9193d 100644 (file)
@@ -88,11 +88,13 @@ private:
     Ui::WizardCheck_UI m_check;
     QVBoxLayout *m_startLayout;
     bool m_systemCheckIsOk;
+    QLabel *m_welcomeLabel;
     QMap <QString, QString> m_dvProfiles;
     QMap <QString, QString> m_hdvProfiles;
     QMap <QString, QString> m_otherProfiles;
     void slotCheckPrograms();
     void checkMltComponents();
+    void checkMissingCodecs();
     KIcon m_okIcon;
     KIcon m_badIcon;
 
@@ -106,6 +108,7 @@ private slots:
     void slotUpdateCaptureParameters();
     void slotSaveCaptureFormat();
     void slotUpdateDecklinkDevice(int captureCard);
+    void slotOpenManual();
 };
 
 #endif