void StopmotionWidget::slotShowThumbs(bool show) { KdenliveSettings::setShowstopmotionthumbs(show); if (show) { frame_list->clear(); sequenceNameChanged(sequence_name->currentText()); } else { m_filesList.clear(); frame_list->clear(); } frame_list->setHidden(!show); }
StopmotionWidget::StopmotionWidget(MonitorManager *manager, const QUrl &projectFolder, const QList<QAction *> &actions, QWidget* parent) : QDialog(parent) , Ui::Stopmotion_UI() , m_projectFolder(projectFolder) , m_captureDevice(NULL) , m_sequenceFrame(0) , m_animatedIndex(-1) , m_animate(false) , m_manager(manager) , m_monitor(new StopmotionMonitor(manager, this)) { //setAttribute(Qt::WA_DeleteOnClose); //HACK: the monitor widget is hidden, it is just used to control the capturedevice from monitormanager m_monitor->setHidden(true); connect(m_monitor, SIGNAL(stopCapture()), this, SLOT(slotStopCapture())); m_manager->appendMonitor(m_monitor); QAction* analyze = new QAction(i18n("Send frames to color scopes"), this); analyze->setCheckable(true); analyze->setChecked(KdenliveSettings::analyse_stopmotion()); connect(analyze, SIGNAL(triggered(bool)), this, SLOT(slotSwitchAnalyse(bool))); QAction* mirror = new QAction(i18n("Mirror display"), this); mirror->setCheckable(true); //mirror->setChecked(KdenliveSettings::analyse_stopmotion()); connect(mirror, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMirror(bool))); addActions(actions); setupUi(this); setWindowTitle(i18n("Stop Motion Capture")); setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); live_button->setIcon(QIcon::fromTheme(QStringLiteral("camera-photo"))); m_captureAction = actions.at(0); connect(m_captureAction, SIGNAL(triggered()), this, SLOT(slotCaptureFrame())); m_captureAction->setCheckable(true); m_captureAction->setChecked(false); capture_button->setDefaultAction(m_captureAction); connect(actions.at(1), SIGNAL(triggered()), this, SLOT(slotSwitchLive())); QAction *intervalCapture = new QAction(i18n("Interval capture"), this); intervalCapture->setIcon(QIcon::fromTheme(QStringLiteral("chronometer"))); intervalCapture->setCheckable(true); intervalCapture->setChecked(false); capture_interval->setDefaultAction(intervalCapture); preview_button->setIcon(QIcon::fromTheme(QStringLiteral("media-playback-start"))); capture_button->setEnabled(false); // Build config menu QMenu* confMenu = new QMenu; m_showOverlay = actions.at(2); connect(m_showOverlay, SIGNAL(triggered(bool)), this, SLOT(slotShowOverlay(bool))); overlay_button->setDefaultAction(m_showOverlay); //confMenu->addAction(m_showOverlay); m_effectIndex = KdenliveSettings::stopmotioneffect(); QMenu* effectsMenu = new QMenu(i18n("Overlay effect")); QActionGroup* effectGroup = new QActionGroup(this); QAction* noEffect = new QAction(i18n("No Effect"), effectGroup); noEffect->setData(0); QAction* contrastEffect = new QAction(i18n("Contrast"), effectGroup); contrastEffect->setData(1); QAction* edgeEffect = new QAction(i18n("Edge detect"), effectGroup); edgeEffect->setData(2); QAction* brightEffect = new QAction(i18n("Brighten"), effectGroup); brightEffect->setData(3); QAction* invertEffect = new QAction(i18n("Invert"), effectGroup); invertEffect->setData(4); QAction* thresEffect = new QAction(i18n("Threshold"), effectGroup); thresEffect->setData(5); effectsMenu->addAction(noEffect); effectsMenu->addAction(contrastEffect); effectsMenu->addAction(edgeEffect); effectsMenu->addAction(brightEffect); effectsMenu->addAction(invertEffect); effectsMenu->addAction(thresEffect); QList <QAction*> list = effectsMenu->actions(); for (int i = 0; i < list.count(); ++i) { list.at(i)->setCheckable(true); if (list.at(i)->data().toInt() == m_effectIndex) { list.at(i)->setChecked(true); } } connect(effectsMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotUpdateOverlayEffect(QAction*))); confMenu->addMenu(effectsMenu); QAction* showThumbs = new QAction(QIcon::fromTheme(QStringLiteral("image-x-generic")), i18n("Show sequence thumbnails"), this); showThumbs->setCheckable(true); showThumbs->setChecked(KdenliveSettings::showstopmotionthumbs()); connect(showThumbs, SIGNAL(triggered(bool)), this, SLOT(slotShowThumbs(bool))); QAction* removeCurrent = new QAction(QIcon::fromTheme(QStringLiteral("edit-delete")), i18n("Delete current frame"), this); removeCurrent->setShortcut(Qt::Key_Delete); connect(removeCurrent, SIGNAL(triggered()), this, SLOT(slotRemoveFrame())); QAction* conf = new QAction(QIcon::fromTheme(QStringLiteral("configure")), i18n("Configure"), this); connect(conf, SIGNAL(triggered()), this, SLOT(slotConfigure())); confMenu->addAction(showThumbs); confMenu->addAction(removeCurrent); confMenu->addAction(analyze); confMenu->addAction(mirror); confMenu->addAction(conf); config_button->setIcon(QIcon::fromTheme(QStringLiteral("configure"))); config_button->setMenu(confMenu); connect(sequence_name, SIGNAL(textChanged(QString)), this, SLOT(sequenceNameChanged(QString))); connect(sequence_name, SIGNAL(currentIndexChanged(int)), live_button, SLOT(setFocus())); // Video widget holder QVBoxLayout *layout = new QVBoxLayout; layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); if (KdenliveSettings::decklink_device_found()) { // Found a BlackMagic device } if (QFile::exists(KdenliveSettings::video4vdevice())) { #ifdef USE_V4L // Video 4 Linux device detection for (int i = 0; i < 10; ++i) { QString path = "/dev/video" + QString::number(i); if (QFile::exists(path)) { QStringList deviceInfo = V4lCaptureHandler::getDeviceName(path); if (!deviceInfo.isEmpty()) { capture_device->addItem(deviceInfo.at(0), "v4l"); capture_device->setItemData(capture_device->count() - 1, path, Qt::UserRole + 1); capture_device->setItemData(capture_device->count() - 1, deviceInfo.at(1), Qt::UserRole + 2); if (path == KdenliveSettings::video4vdevice()) capture_device->setCurrentIndex(capture_device->count() - 1); } } } #endif /* USE_V4L */ } connect(capture_device, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateDeviceHandler())); /*if (m_bmCapture) { connect(m_bmCapture, SIGNAL(frameSaved(QString)), this, SLOT(slotNewThumb(QString))); connect(m_bmCapture, SIGNAL(gotFrame(QImage)), this, SIGNAL(gotFrame(QImage))); } else live_button->setEnabled(false);*/ m_frame_preview = new MyLabel(this); connect(m_frame_preview, SIGNAL(seek(bool)), this, SLOT(slotSeekFrame(bool))); connect(m_frame_preview, SIGNAL(switchToLive()), this, SLOT(slotSwitchLive())); layout->addWidget(m_frame_preview); m_frame_preview->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); video_preview->setLayout(layout); ////qDebug()<<video_preview->winId(); QString profilePath; // Create MLT producer data if (capture_device->itemData(capture_device->currentIndex()) == "v4l") { // Capture using a video4linux device profilePath = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/profiles/video4linux"; } else { // Decklink capture profilePath = KdenliveSettings::current_profile(); } /*TODO: //m_captureDevice = new MltDeviceCapture(profilePath, m_monitor->videoSurface, this); m_captureDevice->sendFrameForAnalysis = KdenliveSettings::analyse_stopmotion(); m_monitor->setRender(m_captureDevice); connect(m_captureDevice, SIGNAL(frameSaved(QString)), this, SLOT(slotNewThumb(QString))); */ live_button->setChecked(false); button_addsequence->setEnabled(false); connect(live_button, SIGNAL(toggled(bool)), this, SLOT(slotLive(bool))); connect(button_addsequence, SIGNAL(clicked(bool)), this, SLOT(slotAddSequence())); connect(preview_button, SIGNAL(clicked(bool)), this, SLOT(slotPlayPreview(bool))); connect(frame_list, SIGNAL(currentRowChanged(int)), this, SLOT(slotShowSelectedFrame())); connect(frame_list, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(slotShowSelectedFrame())); connect(this, SIGNAL(doCreateThumbs(QImage,int)), this, SLOT(slotCreateThumbs(QImage,int))); frame_list->addAction(removeCurrent); frame_list->setContextMenuPolicy(Qt::ActionsContextMenu); frame_list->setHidden(!KdenliveSettings::showstopmotionthumbs()); parseExistingSequences(); QTimer::singleShot(500, this, SLOT(slotLive())); connect(&m_intervalTimer, SIGNAL(timeout()), this, SLOT(slotCaptureFrame())); m_intervalTimer.setSingleShot(true); m_intervalTimer.setInterval(KdenliveSettings::captureinterval() * 1000); }