Esempio n. 1
0
void StopmotionWidget::slotUpdateDeviceHandler()
{
    slotLive(false);
    delete m_captureDevice;
    /*QString data = capture_device->itemData(capture_device->currentIndex()).toString();
    slotLive(false);
    if (m_bmCapture) {
        delete m_bmCapture;
    }
    m_layout->removeWidget(m_frame_preview);
    if (data == "v4l") {
#ifdef USE_V4L
        m_bmCapture = new V4lCaptureHandler(m_layout);
        m_bmCapture->setDevice(capture_device->itemData(capture_device->currentIndex(), Qt::UserRole + 1).toString(), capture_device->itemData(capture_device->currentIndex(), Qt::UserRole + 2).toString());
#endif
    } else {
        m_bmCapture = new BmdCaptureHandler(m_layout);
        if (m_bmCapture) connect(m_bmCapture, SIGNAL(gotMessage(QString)), this, SLOT(slotGotHDMIMessage(QString)));
    }
    live_button->setEnabled(m_bmCapture != NULL);
    m_layout->addWidget(m_frame_preview);*/
}
Esempio n. 2
0
void StopmotionWidget::closeEvent(QCloseEvent* e)
{
    slotLive(false);
    QDialog::closeEvent(e);
}
Esempio n. 3
0
StopmotionWidget::StopmotionWidget(MonitorManager *manager, KUrl projectFolder, 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* analyse = new QAction(i18n("Send frames to color scopes"), this);
    analyse->setCheckable(true);
    analyse->setChecked(KdenliveSettings::analyse_stopmotion());
    connect(analyse, 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(KGlobalSettings::toolBarFont());

    live_button->setIcon(KIcon("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(KIcon("chronometer"));
    intervalCapture->setCheckable(true);
    intervalCapture->setChecked(false);
    capture_interval->setDefaultAction(intervalCapture);

    preview_button->setIcon(KIcon("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(KIcon("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(KIcon("edit-delete"), i18n("Delete current frame"), this);
    removeCurrent->setShortcut(Qt::Key_Delete);
    connect(removeCurrent, SIGNAL(triggered()), this, SLOT(slotRemoveFrame()));

    QAction* conf = new QAction(KIcon("configure"), i18n("Configure"), this);
    connect(conf, SIGNAL(triggered()), this, SLOT(slotConfigure()));

    confMenu->addAction(showThumbs);
    confMenu->addAction(removeCurrent);
    confMenu->addAction(analyse);
    confMenu->addAction(mirror);
    confMenu->addAction(conf);
    config_button->setIcon(KIcon("configure"));
    config_button->setMenu(confMenu);

    connect(sequence_name, SIGNAL(textChanged(const QString&)), this, SLOT(sequenceNameChanged(const 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);
    m_monitor->videoBox->setLineWidth(4);
    layout->addWidget(m_monitor->videoBox);

    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(const QString &)), this, SLOT(slotNewThumb(const 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);

    //kDebug()<<video_preview->winId();

    QString profilePath;
    // Create MLT producer data
    if (capture_device->itemData(capture_device->currentIndex()) == "v4l") {
        // Capture using a video4linux device
        profilePath = KStandardDirs::locateLocal("appdata", "profiles/video4linux");
    }
    else {
        // Decklink capture
        profilePath = KdenliveSettings::current_profile();
    }

    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(const QString &)), this, SLOT(slotNewThumb(const 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);
}