]> git.sesse.net Git - kdenlive/blobdiff - src/wizard.cpp
Fix corruption when changing the project profile
[kdenlive] / src / wizard.cpp
index c4043ef778fc99fa8350189e90cde24b6dba9f85..7dce64887836902dec5acbb227e4e685cbe64f64 100644 (file)
 #include "wizard.h"
 #include "kdenlivesettings.h"
 #include "profilesdialog.h"
+#include "kdenlive-config.h"
 
 #include <KStandardDirs>
 #include <KLocale>
 #include <KProcess>
 #include <kmimetype.h>
+#include <KRun>
+#include <KService>
+#include <KMimeTypeTrader>
 
 #include <QLabel>
 #include <QFile>
 #include <QXmlStreamWriter>
 #include <QTimer>
 
-const double recommendedMltVersion = 40;
+const double recommendedMltVersion = 45;
+static const char version[] = VERSION;
 
 Wizard::Wizard(bool upgrade, QWidget *parent) :
         QWizard(parent)
 {
-    setWindowTitle("Config Wizard");
+    setWindowTitle(i18n("Config Wizard"));
     setPixmap(QWizard::WatermarkPixmap, QPixmap(KStandardDirs::locate("appdata", "banner.png")));
 
     QWizardPage *page1 = new QWizardPage;
     page1->setTitle(i18n("Welcome"));
     QLabel *label;
     if (upgrade)
-        label = new QLabel(i18n("Your Kdenlive version was upgraded. Please take some time to review the basic settings"));
+        label = new QLabel(i18n("Your Kdenlive version was upgraded to version %1. Please take some time to review the basic settings", QString(version).section(' ', 0, 0)));
     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_startLayout = new QVBoxLayout;
     m_startLayout->addWidget(label);
+    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();
+    m_startLayout->addWidget(but);
+
+
     page1->setLayout(m_startLayout);
     addPage(page1);
 
@@ -85,7 +96,7 @@ Wizard::Wizard(bool upgrade, QWidget *parent) :
     slotCheckStandard();
     connect(m_standard.profiles_list, SIGNAL(itemSelectionChanged()), this, SLOT(slotCheckSelectedItem()));
 
-
+    // select default profile
     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()) {
@@ -96,19 +107,13 @@ Wizard::Wizard(bool upgrade, QWidget *parent) :
         }
     }
 
-    // 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(KdenliveSettings::defaultprojectfolder());
+    m_extra.projectfolder->setUrl(KUrl(KdenliveSettings::defaultprojectfolder()));
     m_extra.videothumbs->setChecked(KdenliveSettings::videothumbnails());
     m_extra.audiothumbs->setChecked(KdenliveSettings::audiothumbnails());
     m_extra.autosave->setChecked(KdenliveSettings::crashrecovery());
@@ -132,9 +137,6 @@ Wizard::Wizard(bool upgrade, QWidget *parent) :
 
 void Wizard::checkMltComponents()
 {
-    m_mltCheck.programList->setColumnCount(2);
-    m_mltCheck.programList->setRootIsDecorated(false);
-    m_mltCheck.programList->setHeaderHidden(true);
     QSize itemSize(20, fontMetrics().height() * 2.5);
     m_mltCheck.programList->setColumnWidth(0, 30);
     m_mltCheck.programList->setIconSize(QSize(24, 24));
@@ -168,7 +170,6 @@ void Wizard::checkMltComponents()
         } else {
             avformatItem->setIcon(0, m_okIcon);
             // Make sure we have MLT > 0.3.4
-            bool recentMlt = false;
             int version = 0;
             QString mltVersion;
             QString exepath = KStandardDirs::findExe("pkg-config");
@@ -181,7 +182,6 @@ void Wizard::checkMltComponents()
                     mltVersion = checkProcess.readAllStandardOutput();
                     version = 100 * mltVersion.section('.', 0, 0).toInt() + 10 * mltVersion.section('.', 1, 1).toInt() + mltVersion.section('.', 2, 2).toInt();
                     kDebug() << "// FOUND MLT's pkgconfig version: " << version;
-                    if (version > 34) recentMlt = true;
                 }
             }
             if (version == 0) {
@@ -195,21 +195,22 @@ 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 >= 40) recentMlt = true;
                 }
             }
 
             mltitem->setText(1, i18n("MLT version: %1", mltVersion.simplified()));
             mltitem->setSizeHint(0, itemSize);
-            if (version < recommendedMltVersion) {
-                mltitem->setData(1, Qt::UserRole, i18n("Please upgrade to the latest MLT version"));
+            if (version < 40) {
+                mltitem->setData(1, Qt::UserRole, i18n("Your MLT version is unsupported!!!"));
                 mltitem->setIcon(0, m_badIcon);
             } else {
-                mltitem->setData(1, Qt::UserRole, i18n("MLT version is correct"));
-                mltitem->setIcon(0, m_okIcon);
-            }
-
-            if (recentMlt) {
+                if (version < recommendedMltVersion) {
+                    mltitem->setData(1, Qt::UserRole, i18n("Please upgrade to the latest MLT version"));
+                    mltitem->setIcon(0, m_badIcon);
+                } else {
+                    mltitem->setData(1, Qt::UserRole, i18n("MLT version is correct"));
+                    mltitem->setIcon(0, m_okIcon);
+                }
                 // Check installed audio codecs
                 QProcess checkProcess2;
                 checkProcess2.start(KdenliveSettings::rendererpath(), QStringList() << "noise:" << "-consumer" << "avformat" << "acodec=list");
@@ -303,9 +304,6 @@ void Wizard::checkMltComponents()
 
 void Wizard::slotCheckPrograms()
 {
-    m_check.programList->setColumnCount(2);
-    m_check.programList->setRootIsDecorated(false);
-    m_check.programList->setHeaderHidden(true);
     QSize itemSize(20, fontMetrics().height() * 2.5);
     m_check.programList->setColumnWidth(0, 30);
     m_check.programList->setIconSize(QSize(24, 24));
@@ -342,6 +340,23 @@ void Wizard::slotCheckPrograms()
     if (KStandardDirs::findExe("mkisofs").isEmpty()) item->setIcon(0, m_badIcon);
     else item->setIcon(0, m_okIcon);
 
+    // set up some default applications
+    QString program;
+    if (KdenliveSettings::defaultimageapp().isEmpty()) {
+        program = KStandardDirs::findExe("gimp");
+        if (program.isEmpty()) program = KStandardDirs::findExe("krita");
+        if (!program.isEmpty()) KdenliveSettings::setDefaultimageapp(program);
+    }
+    if (KdenliveSettings::defaultaudioapp().isEmpty()) {
+        program = KStandardDirs::findExe("audacity");
+        if (program.isEmpty()) program = KStandardDirs::findExe("traverso");
+        if (!program.isEmpty()) KdenliveSettings::setDefaultaudioapp(program);
+    }
+    if (KdenliveSettings::defaultplayerapp().isEmpty()) {
+        KService::Ptr offer = KMimeTypeTrader::self()->preferredService("video/mpeg");
+        if (offer)
+            KdenliveSettings::setDefaultplayerapp(KRun::binaryName(offer->exec(), true));
+    }
 }
 
 void Wizard::installExtraMimes(QString baseName, QStringList globs)
@@ -491,8 +506,9 @@ void Wizard::adjustSettings()
         KdenliveSettings::setDefault_profile(selectedProfile);
     }
     QString path = m_extra.projectfolder->url().path();
-    if (KStandardDirs::makeDir(path) == false) kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
-    KdenliveSettings::setDefaultprojectfolder(path);
+    if (KStandardDirs::makeDir(path) == false) {
+        kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
+    } else KdenliveSettings::setDefaultprojectfolder(path);
 
 }
 
@@ -544,4 +560,9 @@ bool Wizard::isOk() const
     return m_systemCheckIsOk;
 }
 
+void Wizard::slotShowWebInfos()
+{
+    KRun::runUrl(KUrl("http://kdenlive.org/discover/" + QString(version).section(' ', 0, 0)), "text/html", this);
+}
+
 #include "wizard.moc"