]> git.sesse.net Git - kdenlive/blobdiff - src/kdenlivesettingsdialog.cpp
use qAbs() instead of abs()
[kdenlive] / src / kdenlivesettingsdialog.cpp
index 4a73a877a18556a17d63ffc9bd0276fe74f48df8..85651bc08678942edb4768b3d9ea7475270e2d80 100644 (file)
  ***************************************************************************/
 
 #include <QDir>
+#include <QTimer>
 
 #include <KStandardDirs>
 #include <KDebug>
 
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <linux/input.h>
+
 #include "profilesdialog.h"
 #include "kdenlivesettings.h"
 #include "kdenlivesettingsdialog.h"
@@ -53,6 +60,9 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(QWidget * parent): KConfigDialog(
 
     QWidget *p5 = new QWidget;
     m_configShuttle.setupUi(p5);
+    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());
     page5 = addPage(p5, i18n("JogShuttle"), "input-mouse");
 
     QStringList actions;
@@ -74,18 +84,50 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(QWidget * parent): KConfigDialog(
     connect(m_configCapture.kcfg_video4size, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
     connect(m_configCapture.kcfg_video4rate, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
 
+
     QStringList profilesNames = ProfilesDialog::getProfileNames();
-    m_configMisc.profiles_list->addItems(profilesNames);
-    m_defaulfProfile = ProfilesDialog::getSettingsFromFile(KdenliveSettings::default_profile()).value("description");
-    if (profilesNames.contains(m_defaulfProfile)) m_configMisc.profiles_list->setCurrentItem(m_defaulfProfile);
+    m_configMisc.kcfg_profiles_list->addItems(profilesNames);
+    m_defaultProfile = ProfilesDialog::getSettingsFromFile(KdenliveSettings::default_profile()).value("description");
+    if (profilesNames.contains(m_defaultProfile)) {
+        m_configMisc.kcfg_profiles_list->setCurrentItem(m_defaultProfile);
+        KdenliveSettings::setProfiles_list(profilesNames.indexOf(m_defaultProfile));
+    }
 
     slotUpdateDisplay();
-    connect(m_configMisc.profiles_list, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateDisplay()));
+
+    connect(m_configMisc.kcfg_profiles_list, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateDisplay()));
 }
 
 KdenliveSettingsDialog::~KdenliveSettingsDialog() {}
 
 
+void KdenliveSettingsDialog::slotCheckShuttle(int state) {
+    m_configShuttle.config_group->setEnabled(state);
+    if (m_configShuttle.shuttledevicelist->count() == 0) {
+        // parse devices
+        QString baseName = "/dev/input/event";
+        int fd;
+        for (int i = 0; i < 30; i++) {
+            QString filename = baseName + QString::number(i);
+            kDebug() << "/// CHECKING OFR: " << filename;
+
+            char name[256] = "unknown";
+            fd = ::open((char *) filename.toUtf8().data(), O_RDONLY);
+            if (fd >= 0 && ioctl(fd, EVIOCGNAME(sizeof(name)), name) >= 0) {
+                m_configShuttle.shuttledevicelist->addItem(name, filename);
+            }
+            ::close(fd);
+        }
+        if (KdenliveSettings::shuttledevice().isEmpty()) QTimer::singleShot(1500, this, SLOT(slotUpdateShuttleDevice()));
+    }
+}
+
+void KdenliveSettingsDialog::slotUpdateShuttleDevice(int ix) {
+    QString device = m_configShuttle.shuttledevicelist->itemData(ix).toString();
+    //KdenliveSettings::setShuttledevice(device);
+    m_configShuttle.kcfg_shuttledevice->setText(device);
+}
+
 void KdenliveSettingsDialog::rebuildVideo4Commands() {
     QString captureCommand;
     if (!m_configCapture.kcfg_video4adevice->text().isEmpty()) captureCommand = "-f " + m_configCapture.kcfg_video4aformat->text() + " -i " + m_configCapture.kcfg_video4adevice->text();
@@ -99,13 +141,20 @@ void KdenliveSettingsDialog::rebuildVideo4Commands() {
 }
 
 bool KdenliveSettingsDialog::hasChanged() {
-    kDebug() << "// // // KCONFIG hasChanged called";
-    if (m_configMisc.profiles_list->currentText() != m_defaulfProfile) return true;
+    kDebug() << "// // // KCONFIG hasChanged called: " << m_configMisc.kcfg_profiles_list->currentText() << ", " << m_defaultProfile;
+    if (m_configMisc.kcfg_profiles_list->currentText() != m_defaultProfile) return true;
     return KConfigDialog::hasChanged();
 }
 
+void KdenliveSettingsDialog::updateSettings() {
+    kDebug() << "// // // KCONFIG UPDATE called";
+    m_defaultProfile = m_configMisc.kcfg_profiles_list->currentText();
+    KdenliveSettings::setDefault_profile(m_defaultPath);
+    KConfigDialog::updateSettings();
+}
+
 void KdenliveSettingsDialog::slotUpdateDisplay() {
-    QString currentProfile = m_configMisc.profiles_list->currentText();
+    QString currentProfile = m_configMisc.kcfg_profiles_list->currentText();
     QMap< QString, QString > values = ProfilesDialog::getSettingsForProfile(currentProfile);
     m_configMisc.p_size->setText(values.value("width") + "x" + values.value("height"));
     m_configMisc.p_fps->setText(values.value("frame_rate_num") + "/" + values.value("frame_rate_den"));
@@ -113,6 +162,7 @@ void KdenliveSettingsDialog::slotUpdateDisplay() {
     m_configMisc.p_display->setText(values.value("display_aspect_num") + "/" + values.value("display_aspect_den"));
     if (values.value("progressive").toInt() == 0) m_configMisc.p_progressive->setText(i18n("Interlaced"));
     else m_configMisc.p_progressive->setText(i18n("Progressive"));
+    m_defaultPath = values.value("path");
 }