]> git.sesse.net Git - kdenlive/blobdiff - src/mainwindow.cpp
Fix compile warning
[kdenlive] / src / mainwindow.cpp
index 0c862d07d69b19ecdc7c52ae0eed465937b431c6..b9bb02d941a6c6717c5940c942611c7d274d7c99 100644 (file)
@@ -70,6 +70,7 @@
 #include <kstandarddirs.h>
 #include <KUrlRequesterDialog>
 #include <KTemporaryFile>
+#include <KProcess>
 #include <KActionMenu>
 #include <KMenu>
 #include <locale.h>
@@ -173,6 +174,8 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent
                        actionCollection());
     readOptions();
 
+    slotDetectAudioDriver();
+
     m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
     m_clipMonitorDock->setObjectName("clip_monitor");
     m_clipMonitor = new Monitor("clip", m_monitorManager, this);
@@ -377,7 +380,10 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent
 void MainWindow::queryQuit()
 {
     kDebug() << "----- SAVING CONFUIG";
-    if (queryClose()) kapp->quit();
+    if (queryClose()) {
+        Mlt::Factory::close();
+        kapp->quit();
+    }
 }
 
 //virtual
@@ -801,7 +807,7 @@ void MainWindow::setupActions()
     collection->addAction("manage_profiles", profilesAction);
     connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
 
-    KNS::standardAction(i18n("Download New Lumas..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
+    KNS::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
 
     KNS::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
 
@@ -1210,6 +1216,7 @@ void MainWindow::newFile(bool showProjectSettings)
     if (!showProjectSettings && m_timelineArea->count() == 0) {
         if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
         profileName = KdenliveSettings::default_profile();
+        projectFolder = KdenliveSettings::defaultprojectfolder();
     } else {
         ProjectSettings *w = new ProjectSettings(projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, this);
         if (w->exec() != QDialog::Accepted) return;
@@ -1402,7 +1409,7 @@ void MainWindow::openFile(const KUrl &url)
 
 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
 {
-    KdenliveDoc *doc = new KdenliveDoc(url, KUrl(), m_commandStack, QString(), QPoint(3, 2), m_projectMonitor->render, this);
+    KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
     if (stale == NULL) {
         stale = new KAutoSaveFile(url, doc);
         doc->m_autosave = stale;
@@ -1520,6 +1527,31 @@ void MainWindow::slotEditProfiles()
     delete w;
 }
 
+void MainWindow::slotDetectAudioDriver()
+{
+    //decide which audio driver is really best, in some cases SDL is wrong
+    if (KdenliveSettings::audiodrivername().isEmpty()) {
+        QString driver;
+        KProcess readProcess;
+        //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
+        if (!KStandardDirs::findExe("pactl").isEmpty()) {
+            readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
+            readProcess.setProgram("pactl", QStringList() << "stat");
+            readProcess.execute(2000); // Kill it after 2 seconds
+
+            QString result = QString(readProcess.readAllStandardOutput());
+            kDebug() << "// / / / / / READING PACTL: ";
+            kDebug() << result;
+            if (!result.isEmpty()) {
+                driver = "pulse";
+                kDebug() << "// / / / / PULSEAUDIO DETECTED";
+            }
+        }
+        //put others here
+        KdenliveSettings::setAutoaudiodrivername(driver);
+    }
+}
+
 void MainWindow::slotEditProjectSettings()
 {
     QPoint p = m_activeDocument->getTracksCount();
@@ -1921,6 +1953,7 @@ void MainWindow::slotPreferences(int page, int option)
     // create it :
     KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
     connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
+    connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
     connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
     connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
     connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
@@ -2298,6 +2331,7 @@ void MainWindow::slotShowClipProperties(DocClipBase *clip)
             //m_clipManager->slotEditTextClipFile(id, dia_ui->xml().toString());
             QMap <QString, QString> newprops;
             newprops.insert("xmldata", dia_ui->xml().toString());
+            newprops.insert("frame_size", QString::number(pix.width()) + 'x' + QString::number(pix.height()));
             EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
             m_activeDocument->commandStack()->push(command);
             m_clipMonitor->refreshMonitor(true);
@@ -2562,6 +2596,7 @@ void MainWindow::slotGetNewLumaStuff()
     }
     qDeleteAll(entries);
     initEffects::refreshLumas();
+    m_activeTimeline->projectView()->reloadTransitionLumas();
 }
 
 void MainWindow::slotGetNewRenderStuff()