]> git.sesse.net Git - kdenlive/blobdiff - src/kdenlivesettingsdialog.cpp
* Play audio when previewing in v4l capture mode
[kdenlive] / src / kdenlivesettingsdialog.cpp
index b13a82be476981499a8d61dbbde10c999925efd3..ca975e37aa6f7cc47001b5c44ef4aca7c256873f 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "kdenlivesettingsdialog.h"
 #include "profilesdialog.h"
-#if !defined(Q_OS_FREEBSD) && !defined(Q_OS_KFREEBSD)
+#ifdef USE_V4L
 #include "v4l/v4lcapture.h"
 #endif
 #include "blackmagic/devices.h"
 #include <stdio.h>
 #include <unistd.h>
 #include <fcntl.h>
-#ifndef NO_JOGSHUTTLE
+#ifdef USE_JOGSHUTTLE
 #include "jogaction.h"
 #include "jogshuttleconfig.h"
 #include <linux/input.h>
-#endif /* NO_JOGSHUTTLE */
+#endif
 
 
 KdenliveSettingsDialog::KdenliveSettingsDialog(const QMap<QString, QString>& mappable_actions, QWidget * parent) :
@@ -83,7 +83,7 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(const QMap<QString, QString>& map
     m_configEnv.mltpathurl->setMode(KFile::Directory);
     m_configEnv.mltpathurl->lineEdit()->setObjectName("kcfg_mltpath");
     m_configEnv.rendererpathurl->lineEdit()->setObjectName("kcfg_rendererpath");
-    m_configEnv.kcfg_mltthreads->setMaximum(QThread::idealThreadCount());
+    m_configEnv.kcfg_mltthreads->setMaximum( QThread::idealThreadCount() < 4 ? QThread::idealThreadCount() : 3 );
     m_configEnv.tmppathurl->setMode(KFile::Directory);
     m_configEnv.tmppathurl->lineEdit()->setObjectName("kcfg_currenttmpfolder");
     m_configEnv.projecturl->setMode(KFile::Directory);
@@ -97,7 +97,7 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(const QMap<QString, QString>& map
     QWidget *p4 = new QWidget;
     m_configCapture.setupUi(p4);
 
-#if !defined(Q_WS_MAC) && !defined(Q_OS_FREEBSD) && !defined(Q_OS_KFREEBSD)
+#ifdef USE_V4L
 
     // Video 4 Linux device detection
     for (int i = 0; i < 10; i++) {
@@ -123,15 +123,12 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(const QMap<QString, QString>& map
 #ifdef Q_WS_MAC
     m_configCapture.tabWidget->setEnabled(false);
     m_configCapture.kcfg_defaultcapture->setEnabled(false);
-    m_configCapture.label->setText(i18n("Capture is not yet available on OS X."));
+    m_configCapture.label->setText(i18n("Capture is not yet available on Mac OS X."));
 #endif
 
     QWidget *p5 = new QWidget;
     m_configShuttle.setupUi(p5);
-#ifdef NO_JOGSHUTTLE
-    m_configShuttle.kcfg_enableshuttle->hide();
-    m_configShuttle.kcfg_enableshuttle->setDisabled(true);
-#else
+#ifdef USE_JOGSHUTTLE
     connect(m_configShuttle.kcfg_enableshuttle, SIGNAL(stateChanged(int)), this, SLOT(slotCheckShuttle(int)));
     connect(m_configShuttle.shuttledevicelist, SIGNAL(activated(int)), this, SLOT(slotUpdateShuttleDevice(int)));
     slotCheckShuttle(KdenliveSettings::enableshuttle());
@@ -171,13 +168,16 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(const QMap<QString, QString>& map
       if (i < actions_map.size())
         button->setCurrentIndex(action_pos[actions_map[i]]);
     }
-#endif /* NO_JOGSHUTTLE */
+#else /* ! USE_JOGSHUTTLE */
+    m_configShuttle.kcfg_enableshuttle->hide();
+    m_configShuttle.kcfg_enableshuttle->setDisabled(true);
+#endif /* USE_JOGSHUTTLE */
     m_page5 = addPage(p5, i18n("JogShuttle"), "input-mouse");
 
     QWidget *p6 = new QWidget;
     m_configSdl.setupUi(p6);
 
-#if not defined(Q_WS_MAC) && not defined(USE_OPEN_GL)
+#ifndef USE_OPENGL
     m_configSdl.kcfg_openglmonitors->setHidden(true);
 #endif
 
@@ -400,6 +400,10 @@ void KdenliveSettingsDialog::initDevices()
             file.close();
         }
     }
+    
+    // Add pulseaudio capture option
+    m_configCapture.kcfg_v4l_alsadevice->addItem(i18n("PulseAudio"), "pulse");
+    
     if (!KdenliveSettings::audiodevicename().isEmpty()) {
         // Select correct alsa device
         int ix = m_configSdl.kcfg_audio_device->findData(KdenliveSettings::audiodevicename());
@@ -432,8 +436,8 @@ void KdenliveSettingsDialog::slotReadAudioDevices()
     kDebug() << result;
     QStringList lines = result.split('\n');
     foreach(const QString & data, lines) {
-        kDebug() << "// READING LINE: " << data;
-        if (data.simplified().startsWith("card")) {
+        //kDebug() << "// READING LINE: " << data;
+        if (!data.startsWith(" ") && data.count(':') > 1) {
             QString card = data.section(':', 0, 0).section(' ', -1);
             QString device = data.section(':', 1, 1).section(' ', -1);
             m_configSdl.kcfg_audio_device->addItem(data.section(':', -1), "plughw:" + card + ',' + device);
@@ -506,7 +510,7 @@ void KdenliveSettingsDialog::slotEditImageApplication()
     m_configEnv.kcfg_defaultimageapp->setText(service->exec());
 }
 
-#ifndef NO_JOGSHUTTLE
+#ifdef USE_JOGSHUTTLE
 void KdenliveSettingsDialog::slotCheckShuttle(int state)
 {
     m_configShuttle.config_group->setEnabled(state);
@@ -536,13 +540,13 @@ void KdenliveSettingsDialog::slotUpdateShuttleDevice(int ix)
     m_configShuttle.kcfg_shuttledevice->setText(device);
 }
 
-#endif /* NO_JOGSHUTTLE */
+#endif /* USE_JOGSHUTTLE */
 
 void KdenliveSettingsDialog::updateWidgets()
 {
     // Revert widgets to last saved state (for example when user pressed "Cancel")
     // kDebug() << "// // // KCONFIG Revert called";
-#ifndef NO_JOGSHUTTLE
+#ifdef USE_JOGSHUTTLE
     // revert jog shuttle device
     if (m_configShuttle.shuttledevicelist->count() > 0) {
        for (int i = 0; i < m_configShuttle.shuttledevicelist->count(); i++) {
@@ -573,7 +577,7 @@ void KdenliveSettingsDialog::updateWidgets()
       if (i < actions_map.size())
         button->setCurrentIndex(action_pos[actions_map[i]]);
     }
-#endif
+#endif /* USE_JOGSHUTTLE */
 }
 
 void KdenliveSettingsDialog::updateSettings()
@@ -618,17 +622,17 @@ void KdenliveSettingsDialog::updateSettings()
 
     // Check encoding profiles
     QString data = m_configCapture.kcfg_v4l_profile->itemData(m_configCapture.kcfg_v4l_profile->currentIndex()).toString();
-    if (!data.isEmpty() && data.section(";", 0, 0) != KdenliveSettings::v4l_parameters()) {
+    if (!data.isEmpty() && (data.section(";", 0, 0) != KdenliveSettings::v4l_parameters() || data.section(";", 1, 1) != KdenliveSettings::v4l_extension())) {
         KdenliveSettings::setV4l_parameters(data.section(";", 0, 0));
         KdenliveSettings::setV4l_extension(data.section(";", 1, 1));
     }
     data = m_configCapture.kcfg_decklink_profile->itemData(m_configCapture.kcfg_decklink_profile->currentIndex()).toString();
-    if (!data.isEmpty() && data.section(";", 0, 0) != KdenliveSettings::decklink_parameters()) {
+    if (!data.isEmpty() && (data.section(";", 0, 0) != KdenliveSettings::decklink_parameters() || data.section(";", 1, 1) != KdenliveSettings::decklink_extension())) {
         KdenliveSettings::setDecklink_parameters(data.section(";", 0, 0));
         KdenliveSettings::setDecklink_extension(data.section(";", 1, 1));
     }
     data = m_configProject.kcfg_proxy_profile->itemData(m_configProject.kcfg_proxy_profile->currentIndex()).toString();
-    if (!data.isEmpty() && data.section(";", 0, 0) != KdenliveSettings::proxyparams()) {
+    if (!data.isEmpty() && (data.section(";", 0, 0) != KdenliveSettings::proxyparams() || data.section(";", 1, 1) != KdenliveSettings::proxyextension())) {
         KdenliveSettings::setProxyparams(data.section(";", 0, 0));
         KdenliveSettings::setProxyextension(data.section(";", 1, 1));
     }
@@ -698,7 +702,7 @@ void KdenliveSettingsDialog::updateSettings()
         saveTranscodeProfiles();
     }
 
-#ifndef NO_JOGSHUTTLE
+#ifdef USE_JOGSHUTTLE
     m_shuttleModified = false;
 
     QStringList actions;
@@ -712,10 +716,7 @@ void KdenliveSettingsDialog::updateSettings()
        KdenliveSettings::setShuttlebuttons(maps);
 #endif
 
-#if KDE_IS_VERSION(4,3,0)
     KConfigDialog::settingsChangedSlot();
-#endif
-
     //KConfigDialog::updateSettings();
     if (resetProfile) emit doResetProfile();
 }
@@ -792,7 +793,7 @@ void KdenliveSettingsDialog::slotDeleteTranscode()
 
 void KdenliveSettingsDialog::slotShuttleModified()
 {
-#ifndef NO_JOGSHUTTLE
+#ifdef USE_JOGSHUTTLE
     QStringList actions;
     actions << "monitor_pause";  // the Job rest position action.
     foreach (KComboBox* button, m_shuttle_buttons) {
@@ -801,17 +802,13 @@ void KdenliveSettingsDialog::slotShuttleModified()
     QString maps = JogShuttleConfig::actionMap(actions);
     m_shuttleModified = KdenliveSettings::shuttlebuttons() != maps;
 #endif
-#if KDE_IS_VERSION(4,3,0)
     KConfigDialog::updateButtons();
-#endif
 }
 
 void KdenliveSettingsDialog::slotDialogModified()
 {
     m_modified = true;
-#if KDE_IS_VERSION(4,3,0)
     KConfigDialog::updateButtons();
-#endif
 }
 
 //virtual
@@ -934,16 +931,7 @@ void KdenliveSettingsDialog::slotManageEncodingProfile()
 
 void KdenliveSettingsDialog::loadEncodingProfiles()
 {
-    QString profileFile = KStandardDirs::locateLocal("appdata", "encodingprofiles.rc");
-    KConfig conf(profileFile, KConfig::SimpleConfig);
-    if (!QFile::exists(profileFile)) {
-        KConfigGroup g1(&conf, "video4linux");
-        g1.writeEntry("Normal MPEG", KdenliveSettings::v4l_parameters() + ";" + KdenliveSettings::v4l_extension());
-        KConfigGroup g2(&conf, "decklink");
-        g2.writeEntry("Normal MPEG", KdenliveSettings::decklink_parameters() + ";" + KdenliveSettings::decklink_extension());
-        KConfigGroup g3(&conf, "proxy");
-        g3.writeEntry("Normal MPEG", KdenliveSettings::proxyparams() + ";" + KdenliveSettings::proxyextension());
-    }
+    KConfig conf("encodingprofiles.rc", KConfig::FullConfig, "appdata");
 
     // Load v4l profiles
     m_configCapture.kcfg_v4l_profile->blockSignals(true);
@@ -984,8 +972,10 @@ void KdenliveSettingsDialog::loadEncodingProfiles()
         k.next();
         if (!k.key().isEmpty()) m_configProject.kcfg_proxy_profile->addItem(k.key(), k.value());
     }
-    m_configProject.kcfg_proxy_profile->blockSignals(false);
     if (!currentItem.isEmpty()) m_configProject.kcfg_proxy_profile->setCurrentIndex(m_configProject.kcfg_proxy_profile->findText(currentItem));
+    m_configProject.kcfg_proxy_profile->blockSignals(false);
+    slotUpdateProxyProfile();
+    
 }
 
 void KdenliveSettingsDialog::slotUpdateDecklinkProfile(int ix)