X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fkdenlivesettingsdialog.cpp;h=64f9aaeb2668bccaf2d258f44e622912a09f745b;hb=56aee6aedeeed3efd10ada8fe3c229eddc01ef05;hp=755cbab7ca76eb7ba435adbc917f93bb2b9b2c91;hpb=ebc919bf530e7ff6dce5ebfb43d496ccc38823c0;p=kdenlive diff --git a/src/kdenlivesettingsdialog.cpp b/src/kdenlivesettingsdialog.cpp index 755cbab7..64f9aaeb 100644 --- a/src/kdenlivesettingsdialog.cpp +++ b/src/kdenlivesettingsdialog.cpp @@ -44,10 +44,11 @@ #include #include #include + #ifdef USE_JOGSHUTTLE -#include "jogaction.h" -#include "jogshuttleconfig.h" -#include + #include "jogaction.h" + #include "jogshuttleconfig.h" + #include #endif @@ -105,8 +106,8 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(const QMap& map #ifdef USE_V4L // Video 4 Linux device detection - for (int i = 0; i < 10; i++) { - QString path = "/dev/video" + QString::number(i); + for (int i = 0; i < 10; ++i) { + QString path = QLatin1String("/dev/video") + QString::number(i); if (QFile::exists(path)) { QStringList deviceInfo = V4lCaptureHandler::getDeviceName(path); if (!deviceInfo.isEmpty()) { @@ -132,14 +133,20 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(const QMap& map QWidget *p5 = new QWidget; m_configShuttle.setupUi(p5); + m_configShuttle.toolBtnReload->setIcon(KIcon("view-refresh")); #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))); + connect(m_configShuttle.toolBtnReload, SIGNAL(clicked(bool)), this, SLOT(slotReloadShuttleDevices())); + slotCheckShuttle(KdenliveSettings::enableshuttle()); m_configShuttle.shuttledisabled->hide(); // Store the button pointers into an array for easier handling them in the other functions. // TODO: impl enumerator or live with cut and paste :-))) + setupJogshuttleBtns(KdenliveSettings::shuttledevice()); + +#if 0 m_shuttle_buttons.push_back(m_configShuttle.shuttle1); m_shuttle_buttons.push_back(m_configShuttle.shuttle2); m_shuttle_buttons.push_back(m_configShuttle.shuttle3); @@ -155,34 +162,8 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(const QMap& map m_shuttle_buttons.push_back(m_configShuttle.shuttle13); m_shuttle_buttons.push_back(m_configShuttle.shuttle14); m_shuttle_buttons.push_back(m_configShuttle.shuttle15); +#endif - // populate the buttons with the current configuration. The items are sorted - // according to the user-selected language, so they do not appear in random order. - QList action_names = mappable_actions.keys(); - qSort(action_names); - - // Here we need to compute the action_id -> index-in-action_names. We iterate over the - // action_names, as the sorting may depend on the user-language. - QStringList actions_map = JogShuttleConfig::actionMap(KdenliveSettings::shuttlebuttons()); - QMap action_pos; - foreach (const QString& action_id, actions_map) { - // This loop find out at what index is the string that would map to the action_id. - for (int i = 0; i < action_names.size(); i++) { - if (mappable_actions[action_names[i]] == action_id) { - action_pos[action_id] = i; - break; - } - } - } - - int i = 0; - foreach (KComboBox* button, m_shuttle_buttons) { - button->addItems(action_names); - connect(button, SIGNAL(activated(int)), this, SLOT(slotShuttleModified())); - ++i; - if (i < actions_map.size()) - button->setCurrentIndex(action_pos[actions_map[i]]); - } #else /* ! USE_JOGSHUTTLE */ m_configShuttle.kcfg_enableshuttle->hide(); m_configShuttle.kcfg_enableshuttle->setDisabled(true); @@ -194,10 +175,6 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(const QMap& map m_configSdl.reload_blackmagic->setIcon(KIcon("view-refresh")); connect(m_configSdl.reload_blackmagic, SIGNAL(clicked(bool)), this, SLOT(slotReloadBlackMagic())); -#ifndef USE_OPENGL - m_configSdl.kcfg_openglmonitors->setHidden(true); -#endif - m_page6 = addPage(p6, i18n("Playback"), "media-playback-start"); QWidget *p7 = new QWidget; @@ -205,12 +182,12 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(const QMap& map m_page7 = addPage(p7, i18n("Transcode"), "edit-copy"); connect(m_configTranscode.button_add, SIGNAL(clicked()), this, SLOT(slotAddTranscode())); connect(m_configTranscode.button_delete, SIGNAL(clicked()), this, SLOT(slotDeleteTranscode())); - connect(m_configTranscode.profiles_list, SIGNAL(itemChanged(QListWidgetItem *)), this, SLOT(slotDialogModified())); + connect(m_configTranscode.profiles_list, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(slotDialogModified())); connect(m_configTranscode.profiles_list, SIGNAL(currentRowChanged(int)), this, SLOT(slotSetTranscodeProfile())); - connect(m_configTranscode.profile_name, SIGNAL(textChanged(const QString &)), this, SLOT(slotEnableTranscodeUpdate())); - connect(m_configTranscode.profile_description, SIGNAL(textChanged(const QString &)), this, SLOT(slotEnableTranscodeUpdate())); - connect(m_configTranscode.profile_extension, SIGNAL(textChanged(const QString &)), this, SLOT(slotEnableTranscodeUpdate())); + connect(m_configTranscode.profile_name, SIGNAL(textChanged(QString)), this, SLOT(slotEnableTranscodeUpdate())); + connect(m_configTranscode.profile_description, SIGNAL(textChanged(QString)), this, SLOT(slotEnableTranscodeUpdate())); + connect(m_configTranscode.profile_extension, SIGNAL(textChanged(QString)), this, SLOT(slotEnableTranscodeUpdate())); connect(m_configTranscode.profile_parameters, SIGNAL(textChanged()), this, SLOT(slotEnableTranscodeUpdate())); connect(m_configTranscode.profile_audioonly, SIGNAL(stateChanged(int)), this, SLOT(slotEnableTranscodeUpdate())); @@ -293,7 +270,7 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(const QMap& map Render::getBlackMagicDeviceList(m_configCapture.kcfg_decklink_capturedevice); if (!Render::getBlackMagicOutputDeviceList(m_configSdl.kcfg_blackmagic_output_device)) { // No blackmagic card found - m_configSdl.kcfg_external_display->setEnabled(false); + m_configSdl.kcfg_external_display->setEnabled(false); } double dvgrabVersion = 0; @@ -317,6 +294,104 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(const QMap& map } else m_configCapture.dvgrab_info->setText(i18n("dvgrab utility not found, please install it for firewire capture")); } +void KdenliveSettingsDialog::setupJogshuttleBtns(QString device) +{ + QList list; + QList list1; + + list << m_configShuttle.shuttle1; + list << m_configShuttle.shuttle2; + list << m_configShuttle.shuttle3; + list << m_configShuttle.shuttle4; + list << m_configShuttle.shuttle5; + list << m_configShuttle.shuttle6; + list << m_configShuttle.shuttle7; + list << m_configShuttle.shuttle8; + list << m_configShuttle.shuttle9; + list << m_configShuttle.shuttle10; + list << m_configShuttle.shuttle11; + list << m_configShuttle.shuttle12; + list << m_configShuttle.shuttle13; + list << m_configShuttle.shuttle14; + list << m_configShuttle.shuttle15; + + list1 << m_configShuttle.label_2; // #1 + list1 << m_configShuttle.label_4; // #2 + list1 << m_configShuttle.label_3; // #3 + list1 << m_configShuttle.label_7; // #4 + list1 << m_configShuttle.label_5; // #5 + list1 << m_configShuttle.label_6; // #6 + list1 << m_configShuttle.label_8; // #7 + list1 << m_configShuttle.label_9; // #8 + list1 << m_configShuttle.label_10; // #9 + list1 << m_configShuttle.label_11; // #10 + list1 << m_configShuttle.label_12; // #11 + list1 << m_configShuttle.label_13; // #12 + list1 << m_configShuttle.label_14; // #13 + list1 << m_configShuttle.label_15; // #14 + list1 << m_configShuttle.label_16; // #15 + + + for (int i = 0; i < list.count(); i++) { + list[i]->hide(); + list1[i]->hide(); + } + +#ifdef USE_JOGSHUTTLE + int keysCount = JogShuttle::keysCount(device); + + for (int i = 0; i < keysCount; i++) { + m_shuttle_buttons.push_back(list[i]); + list[i]->show(); + list1[i]->show(); + } + + // populate the buttons with the current configuration. The items are sorted + // according to the user-selected language, so they do not appear in random order. + QMap mappable_actions(m_mappable_actions); + QList action_names = mappable_actions.keys(); + QList::Iterator iter = action_names.begin(); + kDebug() << "::::::::::::::::"; + while (iter != action_names.end()) { + kDebug() << *iter; + ++iter; + } + + kDebug() << "::::::::::::::::"; + + qSort(action_names); + iter = action_names.begin(); + while (iter != action_names.end()) { + kDebug() << *iter; + ++iter; + } + kDebug() << "::::::::::::::::"; + + // Here we need to compute the action_id -> index-in-action_names. We iterate over the + // action_names, as the sorting may depend on the user-language. + QStringList actions_map = JogShuttleConfig::actionMap(KdenliveSettings::shuttlebuttons()); + QMap action_pos; + foreach (const QString& action_id, actions_map) { + // This loop find out at what index is the string that would map to the action_id. + for (int i = 0; i < action_names.size(); ++i) { + if (mappable_actions[action_names.at(i)] == action_id) { + action_pos[action_id] = i; + break; + } + } + } + + int i = 0; + foreach (KComboBox* button, m_shuttle_buttons) { + button->addItems(action_names); + connect(button, SIGNAL(activated(int)), this, SLOT(slotShuttleModified())); + ++i; + if (i < actions_map.size()) + button->setCurrentIndex(action_pos[actions_map[i]]); + } +#endif +} + KdenliveSettingsDialog::~KdenliveSettingsDialog() {} void KdenliveSettingsDialog::slotUpdateGrabRegionStatus() @@ -340,7 +415,7 @@ void KdenliveSettingsDialog::checkProfile() } if (!KdenliveSettings::default_profile().isEmpty()) { - for (int i = 0; i < m_configProject.kcfg_profiles_list->count(); i++) { + for (int i = 0; i < m_configProject.kcfg_profiles_list->count(); ++i) { if (m_configProject.kcfg_profiles_list->itemData(i).toString() == KdenliveSettings::default_profile()) { m_configProject.kcfg_profiles_list->setCurrentIndex(i); KdenliveSettings::setProfiles_list(i); @@ -364,7 +439,7 @@ void KdenliveSettingsDialog::initDevices() #endif if (!KdenliveSettings::audiodrivername().isEmpty()) - for (int i = 1; i < m_configSdl.kcfg_audio_driver->count(); i++) { + for (int i = 1; i < m_configSdl.kcfg_audio_driver->count(); ++i) { if (m_configSdl.kcfg_audio_driver->itemData(i).toString() == KdenliveSettings::audiodrivername()) { m_configSdl.kcfg_audio_driver->setCurrentIndex(i); KdenliveSettings::setAudio_driver((uint) i); @@ -400,7 +475,7 @@ void KdenliveSettingsDialog::initDevices() QTextStream stream(&file); QString line = stream.readLine(); QString deviceId; - while (!line.isNull()) { + while (!line.isNull()) { if (line.contains("playback")) { deviceId = line.section(':', 0, 0); m_configSdl.kcfg_audio_device->addItem(line.section(':', 1, 1), "plughw:" + QString::number(deviceId.section('-', 0, 0).toInt()) + ',' + QString::number(deviceId.section('-', 1, 1).toInt())); @@ -487,14 +562,11 @@ void KdenliveSettingsDialog::slotEditVideoApplication() { KService::Ptr service; QPointer dlg = new KOpenWithDialog(KUrl::List(), i18n("Select default video player"), m_configEnv.kcfg_defaultplayerapp->text(), this); - if (dlg->exec() != QDialog::Accepted) - { - delete dlg; - return; + if (dlg->exec() == QDialog::Accepted) { + service = dlg->service(); + m_configEnv.kcfg_defaultplayerapp->setText(service->exec()); } - service = dlg->service(); - m_configEnv.kcfg_defaultplayerapp->setText(service->exec()); delete dlg; } @@ -502,14 +574,11 @@ void KdenliveSettingsDialog::slotEditAudioApplication() { KService::Ptr service; QPointer dlg = new KOpenWithDialog(KUrl::List(), i18n("Select default audio editor"), m_configEnv.kcfg_defaultaudioapp->text(), this); - if (dlg->exec() != QDialog::Accepted) - { - delete dlg; - return; + if (dlg->exec() == QDialog::Accepted) { + service = dlg->service(); + m_configEnv.kcfg_defaultaudioapp->setText(service->exec()); } - service = dlg->service(); - m_configEnv.kcfg_defaultaudioapp->setText(service->exec()); delete dlg; } @@ -517,36 +586,28 @@ void KdenliveSettingsDialog::slotEditImageApplication() { KService::Ptr service; QPointer dlg = new KOpenWithDialog(KUrl::List(), i18n("Select default image editor"), m_configEnv.kcfg_defaultimageapp->text(), this); - if (dlg->exec() != QDialog::Accepted) - { - delete dlg; - return; + if (dlg->exec() == QDialog::Accepted) { + service = dlg->service(); + m_configEnv.kcfg_defaultimageapp->setText(service->exec()); } - service = dlg->service(); - m_configEnv.kcfg_defaultimageapp->setText(service->exec()); delete dlg; } void KdenliveSettingsDialog::slotCheckShuttle(int state) { #ifdef USE_JOGSHUTTLE - 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 device: " << filename; - - char name[256] = "unknown"; - fd = KDE_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())); + m_configShuttle.config_group->setEnabled(state); + m_configShuttle.shuttledevicelist->clear(); + + QStringList devNames = KdenliveSettings::shuttledevicenames(); + QStringList devPaths = KdenliveSettings::shuttledevicepaths(); + + if (devNames.count() != devPaths.count()) { + return; + } + for (int i = 0; i < devNames.count(); i++) { + m_configShuttle.shuttledevicelist->addItem( + devNames.at(i), devPaths.at(i)); } #endif /* USE_JOGSHUTTLE */ } @@ -556,6 +617,7 @@ void KdenliveSettingsDialog::slotUpdateShuttleDevice(int ix) #ifdef USE_JOGSHUTTLE QString device = m_configShuttle.shuttledevicelist->itemData(ix).toString(); //KdenliveSettings::setShuttledevice(device); + setupJogshuttleBtns(device); m_configShuttle.kcfg_shuttledevice->setText(device); #endif /* USE_JOGSHUTTLE */ } @@ -567,12 +629,12 @@ void KdenliveSettingsDialog::updateWidgets() #ifdef USE_JOGSHUTTLE // revert jog shuttle device if (m_configShuttle.shuttledevicelist->count() > 0) { - for (int i = 0; i < m_configShuttle.shuttledevicelist->count(); i++) { - if (m_configShuttle.shuttledevicelist->itemData(i) == KdenliveSettings::shuttledevice()) { - m_configShuttle.shuttledevicelist->setCurrentIndex(i); - break; - } - } + for (int i = 0; i < m_configShuttle.shuttledevicelist->count(); ++i) { + if (m_configShuttle.shuttledevicelist->itemData(i) == KdenliveSettings::shuttledevice()) { + m_configShuttle.shuttledevicelist->setCurrentIndex(i); + break; + } + } } // Revert jog shuttle buttons @@ -581,19 +643,19 @@ void KdenliveSettingsDialog::updateWidgets() QStringList actions_map = JogShuttleConfig::actionMap(KdenliveSettings::shuttlebuttons()); QMap action_pos; foreach (const QString& action_id, actions_map) { - // This loop find out at what index is the string that would map to the action_id. - for (int i = 0; i < action_names.size(); i++) { - if (m_mappable_actions[action_names[i]] == action_id) { - action_pos[action_id] = i; - break; - } - } + // This loop find out at what index is the string that would map to the action_id. + for (int i = 0; i < action_names.size(); ++i) { + if (m_mappable_actions[action_names[i]] == action_id) { + action_pos[action_id] = i; + break; + } + } } int i = 0; foreach (KComboBox* button, m_shuttle_buttons) { - ++i; - if (i < actions_map.size()) - button->setCurrentIndex(action_pos[actions_map[i]]); + ++i; + if (i < actions_map.size()) + button->setCurrentIndex(action_pos[actions_map[i]]); } #endif /* USE_JOGSHUTTLE */ } @@ -609,8 +671,8 @@ void KdenliveSettingsDialog::updateSettings() 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); + 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()) { @@ -651,7 +713,7 @@ void KdenliveSettingsDialog::updateSettings() KdenliveSettings::setGrab_parameters(data.section(';', 0, 0)); KdenliveSettings::setGrab_extension(data.section(';', 1, 1)); } - + // decklink data = m_configCapture.kcfg_decklink_profile->itemData(m_configCapture.kcfg_decklink_profile->currentIndex()).toString(); if (!data.isEmpty() && (data.section(';', 0, 0) != KdenliveSettings::decklink_parameters() || data.section(';', 1, 1) != KdenliveSettings::decklink_extension())) { @@ -729,7 +791,7 @@ void KdenliveSettingsDialog::updateSettings() QString maps = JogShuttleConfig::actionMap(actions); //fprintf(stderr, "Shuttle config: %s\n", JogShuttleConfig::actionMap(actions).toAscii().constData()); if (KdenliveSettings::shuttlebuttons() != maps) - KdenliveSettings::setShuttlebuttons(maps); + KdenliveSettings::setShuttlebuttons(maps); #endif KConfigDialog::settingsChangedSlot(); @@ -789,7 +851,7 @@ void KdenliveSettingsDialog::saveTranscodeProfiles() // read the entries transConfig.deleteGroup(); int max = m_configTranscode.profiles_list->count(); - for (int i = 0; i < max; i++) { + for (int i = 0; i < max; ++i) { QListWidgetItem *item = m_configTranscode.profiles_list->item(i); transConfig.writeEntry(item->text(), item->data(Qt::UserRole).toString()); } @@ -806,7 +868,7 @@ void KdenliveSettingsDialog::slotAddTranscode() QString data = m_configTranscode.profile_parameters->toPlainText(); data.append(" %1." + m_configTranscode.profile_extension->text()); data.append(';'); - if (!m_configTranscode.profile_description->text().isEmpty()) + if (!m_configTranscode.profile_description->text().isEmpty()) data.append(m_configTranscode.profile_description->text()); if (m_configTranscode.profile_audioonly->isChecked()) data.append(";audio"); item->setData(Qt::UserRole, data); @@ -917,7 +979,7 @@ void KdenliveSettingsDialog::slotUpdatev4lDevice() QString itemSize; QString pixelFormat; QStringList itemRates; - for (int i = 0; i < pixelformats.count(); i++) { + for (int i = 0; i < pixelformats.count(); ++i) { QString format = pixelformats.at(i).section(':', 0, 0); QStringList sizes = pixelformats.at(i).split(':', QString::SkipEmptyParts); pixelFormat = sizes.takeFirst(); @@ -1001,7 +1063,7 @@ void KdenliveSettingsDialog::slotManageEncodingProfile() { int type = 0; if (currentPage() == m_page4) { - type = m_configCapture.tabWidget->currentIndex(); + type = m_configCapture.tabWidget->currentIndex(); } QPointer d = new EncodingProfilesDialog(type); d->exec(); @@ -1011,7 +1073,7 @@ void KdenliveSettingsDialog::slotManageEncodingProfile() void KdenliveSettingsDialog::loadEncodingProfiles() { - KConfig conf("encodingprofiles.rc", KConfig::FullConfig, "appdata"); + KConfig conf("encodingprofiles.rc", KConfig::CascadeConfig, "appdata"); // Load v4l profiles m_configCapture.kcfg_v4l_profile->blockSignals(true); @@ -1128,10 +1190,50 @@ void KdenliveSettingsDialog::slotReloadBlackMagic() Render::getBlackMagicDeviceList(m_configCapture.kcfg_decklink_capturedevice, true); if (!Render::getBlackMagicOutputDeviceList(m_configSdl.kcfg_blackmagic_output_device), true) { // No blackmagic card found - m_configSdl.kcfg_external_display->setEnabled(false); + m_configSdl.kcfg_external_display->setEnabled(false); } m_configSdl.kcfg_external_display->setEnabled(KdenliveSettings::decklink_device_found()); } + +void KdenliveSettingsDialog::slotReloadShuttleDevices() +{ +#ifdef USE_JOGSHUTTLE + QString devDirStr = "/dev/input/by-id"; + QDir devDir(devDirStr); + if (!devDir.exists()) { + devDirStr = "/dev/input"; + } + + DeviceMap devMap = JogShuttle::enumerateDevices(devDirStr); + if (!devMap.isEmpty()) { + m_configShuttle.shuttledevicelist->clear(); + } + + QStringList devNamesList; + QStringList devPathList; + DeviceMapIter iter = devMap.begin(); + if (iter == devMap.end()) { + KdenliveSettings::shuttledevicenames().clear(); + KdenliveSettings::shuttledevicepaths().clear(); + m_configShuttle.shuttledevicelist->clear(); + } + while (iter != devMap.end()) { + kDebug() << iter.key() << ": " << iter.value(); + m_configShuttle.shuttledevicelist->addItem(iter.key(), iter.value()); + devNamesList << iter.key(); + devPathList << iter.value(); + ++iter; + } + + KdenliveSettings::setShuttledevicenames(devNamesList); + KdenliveSettings::setShuttledevicepaths(devPathList); + QTimer::singleShot(200, this, SLOT(slotUpdateShuttleDevice())); + + kDebug() << "Devices reloaded"; + +#endif //USE_JOGSHUTTLE +} + #include "kdenlivesettingsdialog.moc"