From 90ad39dd2d51f6aad49ca17ee01056cbe31b4ce4 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Thu, 25 Sep 2008 11:46:01 +0000 Subject: [PATCH] Check that MLT's avformat is ok at first start, it should help detect startup crashes caused by MLT. svn path=/branches/KDE4/; revision=2409 --- src/mainwindow.cpp | 10 +++++++--- src/wizard.cpp | 50 ++++++++++++++++++++++++++++++++++++++-------- src/wizard.h | 5 +++++ 3 files changed, 54 insertions(+), 11 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 1db221c1..bb8f3c12 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -769,11 +769,15 @@ void MainWindow::readOptions() { if (!initialGroup.exists()) { // this is our first run, show Wizard Wizard *w = new Wizard(this); - if (w->exec() == QDialog::Accepted) { + if (w->exec() == QDialog::Accepted && w->isOk()) { w->adjustSettings(); initialGroup.writeEntry("version", "0.7"); + delete w; + } else { + delete w; + // TODO: find a better way to exit application faster + QTimer::singleShot(1000, this, SLOT(queryQuit())); } - delete w; } } @@ -978,7 +982,7 @@ void MainWindow::parseProfiles() { if (KdenliveSettings::rendererpath().isEmpty()) { // Cannot find the MLT inigo renderer, ask for location - KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this); + KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this); getUrl->exec(); KUrl rendererPath = getUrl->selectedUrl(); delete getUrl; diff --git a/src/wizard.cpp b/src/wizard.cpp index 3a16b883..014d5358 100644 --- a/src/wizard.cpp +++ b/src/wizard.cpp @@ -18,9 +18,10 @@ ***************************************************************************/ #include -#include #include #include +#include +#include #include #include @@ -36,15 +37,15 @@ Wizard::Wizard(QWidget *parent): QWizard(parent) { QWizardPage *page1 = new QWizardPage; page1->setTitle("Welcome"); - QLabel *label = new QLabel("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..."); + QLabel *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); - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(label); - page1->setLayout(layout); + m_startLayout = new QVBoxLayout; + m_startLayout->addWidget(label); + page1->setLayout(m_startLayout); addPage(page1); QWizardPage *page2 = new QWizardPage; - page2->setTitle("Video Standard"); + page2->setTitle(i18n("Video Standard")); m_standard.setupUi(page2); m_standard.profiles_list->setMaximumHeight(100); connect(m_standard.button_pal, SIGNAL(toggled(bool)), this, SLOT(slotCheckStandard())); @@ -54,7 +55,7 @@ Wizard::Wizard(QWidget *parent): QWizard(parent) { addPage(page2); QWizardPage *page3 = new QWizardPage; - page3->setTitle("Additional Settings"); + page3->setTitle(i18n("Additional Settings")); m_extra.setupUi(page3); m_extra.videothumbs->setChecked(KdenliveSettings::videothumbnails()); m_extra.audiothumbs->setChecked(KdenliveSettings::audiothumbnails()); @@ -63,6 +64,7 @@ Wizard::Wizard(QWidget *parent): QWizard(parent) { connect(m_extra.audiothumbs, SIGNAL(stateChanged(int)), this, SLOT(slotCheckThumbs())); slotCheckThumbs(); addPage(page3); + QTimer::singleShot(500, this, SLOT(slotCheckMlt())); } void Wizard::installExtraMimes(QString baseName, QStringList globs) { @@ -115,7 +117,7 @@ void Wizard::installExtraMimes(QString baseName, QStringList globs) { void Wizard::runUpdateMimeDatabase() { const QString localPackageDir = KStandardDirs::locateLocal("xdgdata-mime", QString()); - Q_ASSERT(!localPackageDir.isEmpty()); + //Q_ASSERT(!localPackageDir.isEmpty()); KProcess proc; proc << "update-mime-database"; proc << localPackageDir; @@ -188,4 +190,36 @@ void Wizard::adjustSettings() { } } +void Wizard::slotCheckMlt() { + QString errorMessage; + if (KdenliveSettings::rendererpath().isEmpty()) { + 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("Error starting MLT's command line player (inigo).\n"); + + checkProcess.waitForFinished(); + + QByteArray result = checkProcess.readAllStandardError(); + if (!result.contains("avformat")) errorMessage.append(i18n("MLT's avformat (FFMPEG) module not found. Please check your FFMPEG and MLT install. Kdenlive will not work until this issue is fixed.\n")); + + if (!errorMessage.isEmpty()) { + QLabel *pix = new QLabel(); + pix->setPixmap(KIcon("process-stop").pixmap(30)); + QLabel *label = new QLabel(errorMessage); + label->setWordWrap(true); + m_startLayout->addSpacing(40); + m_startLayout->addWidget(pix); + m_startLayout->addWidget(label); + m_systemCheckIsOk = false; + button(QWizard::NextButton)->setEnabled(false); + } else m_systemCheckIsOk = true; +} + +bool Wizard::isOk() const { + return m_systemCheckIsOk; +} + #include "wizard.moc" diff --git a/src/wizard.h b/src/wizard.h index ba9fa422..36ea34bd 100644 --- a/src/wizard.h +++ b/src/wizard.h @@ -22,6 +22,7 @@ #define WIZARD_H #include +#include #include #include "ui_wizardstandard_ui.h" @@ -35,15 +36,19 @@ public: void installExtraMimes(QString baseName, QStringList globs); void runUpdateMimeDatabase(); void adjustSettings(); + bool isOk() const; private: Ui::WizardStandard_UI m_standard; Ui::WizardExtra_UI m_extra; + QVBoxLayout *m_startLayout; + bool m_systemCheckIsOk; private slots: void slotCheckThumbs(); void slotCheckStandard(); void slotCheckSelectedItem(); + void slotCheckMlt(); }; #endif -- 2.39.5