+void KdenliveSettingsDialog::updateSettings()
+{
+ // Save changes to settings (for example when user pressed "Apply" or "Ok")
+ // kDebug() << "// // // KCONFIG UPDATE called";
+ m_defaultProfile = m_configProject.kcfg_profiles_list->currentText();
+ KdenliveSettings::setDefault_profile(m_defaultPath);
+
+ bool resetProfile = false;
+ bool updateCapturePath = false;
+
+ /*if (m_configShuttle.shuttledevicelist->count() > 0) {
+ QString device = m_configShuttle.shuttledevicelist->itemData(m_configShuttle.shuttledevicelist->currentIndex()).toString();
+ if (device != KdenliveSettings::shuttledevice()) KdenliveSettings::setShuttledevice(device);
+ }*/
+
+ if (m_configEnv.kcfg_capturetoprojectfolder->isChecked() != KdenliveSettings::capturetoprojectfolder()) {
+ KdenliveSettings::setCapturetoprojectfolder(m_configEnv.kcfg_capturetoprojectfolder->isChecked());
+ updateCapturePath = true;
+ }
+
+ if (m_configEnv.capturefolderurl->url().path() != KdenliveSettings::capturefolder()) {
+ KdenliveSettings::setCapturefolder(m_configEnv.capturefolderurl->url().path());
+ updateCapturePath = true;
+ }
+
+ if (m_configCapture.kcfg_dvgrabfilename->text() != KdenliveSettings::dvgrabfilename()) {
+ KdenliveSettings::setDvgrabfilename(m_configCapture.kcfg_dvgrabfilename->text());
+ updateCapturePath = true;
+ }
+
+ if ((uint) m_configCapture.kcfg_firewireformat->currentIndex() != KdenliveSettings::firewireformat()) {
+ KdenliveSettings::setFirewireformat(m_configCapture.kcfg_firewireformat->currentIndex());
+ updateCapturePath = true;
+ }
+
+ if ((uint) m_configCapture.kcfg_v4l_format->currentIndex() != KdenliveSettings::v4l_format()) {
+ saveCurrentV4lProfile();
+ KdenliveSettings::setV4l_format(0);
+ }
+
+ // 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()) {
+ 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()) {
+ 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()) {
+ KdenliveSettings::setProxyparams(data.section(";", 0, 0));
+ KdenliveSettings::setProxyextension(data.section(";", 1, 1));
+ }
+
+
+ if (updateCapturePath) emit updateCaptureFolder();
+
+ QString value = m_configCapture.kcfg_rmd_alsa_device->itemData(m_configCapture.kcfg_rmd_alsa_device->currentIndex()).toString();
+ if (value != KdenliveSettings::rmd_alsadevicename()) {
+ KdenliveSettings::setRmd_alsadevicename(value);
+ }
+
+ value = m_configCapture.kcfg_v4l_alsadevice->itemData(m_configCapture.kcfg_v4l_alsadevice->currentIndex()).toString();
+ if (value != KdenliveSettings::v4l_alsadevicename()) {
+ KdenliveSettings::setV4l_alsadevicename(value);
+ }
+
+ value = m_configCapture.kcfg_rmd_audio_freq->itemText(m_configCapture.kcfg_rmd_audio_freq->currentIndex());
+ kDebug() << "// AUDIO FREQ VALUE: " << value << ", CURRENT: " << KdenliveSettings::rmd_freq() << ", IX: " << m_configCapture.kcfg_rmd_audio_freq->currentIndex();
+ if (value != KdenliveSettings::rmd_freq()) {
+ kDebug() << "// SETTING AUDIO FREQ TO: " << value;
+ KdenliveSettings::setRmd_freq(value);
+ }
+
+ if (m_configSdl.kcfg_external_display->isChecked() != KdenliveSettings::external_display()) {
+ KdenliveSettings::setExternal_display(m_configSdl.kcfg_external_display->isChecked());
+ resetProfile = true;
+ }
+
+ value = m_configSdl.kcfg_audio_driver->itemData(m_configSdl.kcfg_audio_driver->currentIndex()).toString();
+ if (value != KdenliveSettings::audiodrivername()) {
+ KdenliveSettings::setAudiodrivername(value);
+ resetProfile = true;
+ }
+
+ if (value == "alsa") {
+ // Audio device setting is only valid for alsa driver
+ value = m_configSdl.kcfg_audio_device->itemData(m_configSdl.kcfg_audio_device->currentIndex()).toString();
+ if (value != KdenliveSettings::audiodevicename()) {
+ KdenliveSettings::setAudiodevicename(value);
+ resetProfile = true;
+ }
+ } else if (KdenliveSettings::audiodevicename().isEmpty() == false) {
+ KdenliveSettings::setAudiodevicename(QString::null);
+ resetProfile = true;
+ }
+
+ value = m_configSdl.kcfg_video_driver->itemData(m_configSdl.kcfg_video_driver->currentIndex()).toString();
+ if (value != KdenliveSettings::videodrivername()) {
+ KdenliveSettings::setVideodrivername(value);
+ resetProfile = true;
+ }
+
+ if (m_configSdl.kcfg_window_background->color() != KdenliveSettings::window_background()) {
+ KdenliveSettings::setWindow_background(m_configSdl.kcfg_window_background->color());
+ resetProfile = true;
+ }
+
+ if (m_configSdl.kcfg_volume->value() != KdenliveSettings::volume()) {
+ KdenliveSettings::setVolume(m_configSdl.kcfg_volume->value());
+ resetProfile = true;
+ }
+
+ if (m_modified) {
+ // The transcoding profiles were modified, save.
+ m_modified = false;
+ saveTranscodeProfiles();
+ }
+
+#ifdef USE_JOGSHUTTLE
+ m_shuttleModified = false;
+
+ QStringList actions;
+ actions << "monitor_pause"; // the Job rest position action.
+ foreach (KComboBox* button, m_shuttle_buttons) {
+ actions << m_mappable_actions[button->currentText()];
+ }
+ QString maps = JogShuttleConfig::actionMap(actions);
+ //fprintf(stderr, "Shuttle config: %s\n", JogShuttleConfig::actionMap(actions).toAscii().constData());
+ if (KdenliveSettings::shuttlebuttons() != maps)
+ KdenliveSettings::setShuttlebuttons(maps);
+#endif
+
+#if KDE_IS_VERSION(4,3,0)
+ KConfigDialog::settingsChangedSlot();
+#endif
+
+ //KConfigDialog::updateSettings();
+ if (resetProfile) emit doResetProfile();
+}
+
+void KdenliveSettingsDialog::slotUpdateDisplay()
+{
+ QString currentProfile = m_configProject.kcfg_profiles_list->itemData(m_configProject.kcfg_profiles_list->currentIndex()).toString();
+ QMap< QString, QString > values = ProfilesDialog::getSettingsFromFile(currentProfile);
+ m_configProject.p_size->setText(values.value("width") + 'x' + values.value("height"));
+ m_configProject.p_fps->setText(values.value("frame_rate_num") + '/' + values.value("frame_rate_den"));
+ m_configProject.p_aspect->setText(values.value("sample_aspect_num") + '/' + values.value("sample_aspect_den"));
+ m_configProject.p_display->setText(values.value("display_aspect_num") + '/' + values.value("display_aspect_den"));
+ if (values.value("progressive").toInt() == 0)
+ m_configProject.p_progressive->setText(i18n("Interlaced"));
+ else
+ m_configProject.p_progressive->setText(i18n("Progressive"));
+ m_defaultProfile = m_configProject.kcfg_profiles_list->itemText(m_configProject.kcfg_profiles_list->currentIndex());
+ m_defaultPath = currentProfile;
+}
+
+void KdenliveSettingsDialog::slotCheckAlsaDriver()
+{
+ QString value = m_configSdl.kcfg_audio_driver->itemData(m_configSdl.kcfg_audio_driver->currentIndex()).toString();
+ m_configSdl.kcfg_audio_device->setEnabled(value == "alsa");
+}
+
+void KdenliveSettingsDialog::loadTranscodeProfiles()
+{
+ KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
+ KConfigGroup transConfig(config, "Transcoding");
+ // read the entries
+ m_configTranscode.profiles_list->blockSignals(true);
+ QMap< QString, QString > profiles = transConfig.entryMap();
+ QMapIterator<QString, QString> i(profiles);
+ while (i.hasNext()) {
+ i.next();
+ QTreeWidgetItem *item = new QTreeWidgetItem(m_configTranscode.profiles_list, QStringList() << i.key() << i.value());
+ item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
+ }
+ m_configTranscode.profiles_list->blockSignals(false);
+}
+
+void KdenliveSettingsDialog::saveTranscodeProfiles()
+{
+ KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
+ //KSharedConfigPtr config = KGlobal::config();
+ KConfigGroup transConfig(config, "Transcoding");
+ // read the entries
+ transConfig.deleteGroup();
+ int max = m_configTranscode.profiles_list->topLevelItemCount();
+ for (int i = 0; i < max; i++) {
+ QTreeWidgetItem *item = m_configTranscode.profiles_list->topLevelItem(i);
+ transConfig.writeEntry(item->text(0), item->text(1));
+ }
+ config->sync();
+}
+
+void KdenliveSettingsDialog::slotAddTranscode()
+{
+ QTreeWidgetItem *item = new QTreeWidgetItem(m_configTranscode.profiles_list, QStringList() << i18n("Name") << i18n("Parameters"));
+ item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
+ m_configTranscode.profiles_list->setCurrentItem(item);
+ m_configTranscode.profiles_list->editItem(item);
+ slotDialogModified();
+}
+
+void KdenliveSettingsDialog::slotDeleteTranscode()
+{
+ QTreeWidgetItem *item = m_configTranscode.profiles_list->currentItem();
+ if (item == NULL) return;
+ delete item;
+ slotDialogModified();
+}
+
+void KdenliveSettingsDialog::slotShuttleModified()
+{
+#ifdef USE_JOGSHUTTLE
+ QStringList actions;
+ actions << "monitor_pause"; // the Job rest position action.
+ foreach (KComboBox* button, m_shuttle_buttons) {
+ actions << m_mappable_actions[button->currentText()];
+ }
+ 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
+bool KdenliveSettingsDialog::hasChanged()
+{
+ if (m_modified || m_shuttleModified) return true;