From 20fe95369f5f762ac93693bbcfcf5be6803a60f6 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Sun, 9 Jan 2011 13:08:38 +0000 Subject: [PATCH] Stop motion widget: notify a few seconds before capturing frame in interval mode so that user can get ready before frame capture svn path=/trunk/kdenlive/; revision=5312 --- src/kdenlive.notifyrc | 5 ++++ src/kdenlivesettings.kcfg | 12 +++++++- src/stopmotion/stopmotion.cpp | 56 +++++++++++++++++++++++++---------- src/stopmotion/stopmotion.h | 15 ++++++---- src/widgets/smconfig_ui.ui | 20 +++++++++++-- src/widgets/stopmotion_ui.ui | 49 +++++++++++++++++------------- 6 files changed, 110 insertions(+), 47 deletions(-) diff --git a/src/kdenlive.notifyrc b/src/kdenlive.notifyrc index 8ddc7f7a..da5679c4 100644 --- a/src/kdenlive.notifyrc +++ b/src/kdenlive.notifyrc @@ -43,6 +43,11 @@ Name[ru]=Кадр снят Comment=A frame was captured to disk Comment[es]=Se ha capturado un fotograma al disco Comment[ru]=Кадр снят и сохранён на диск +Sound=KDE-Sys-App-Message.ogg +Action=Sound + +[Event/ReadyToCapture] +Name=Ready to capture Sound=KDE-Sys-App-Positive.ogg Action=Sound diff --git a/src/kdenlivesettings.kcfg b/src/kdenlivesettings.kcfg index 648e8f12..f5d83b06 100644 --- a/src/kdenlivesettings.kcfg +++ b/src/kdenlivesettings.kcfg @@ -657,7 +657,17 @@ 5 - + + + + + 3 + + + + + false + diff --git a/src/stopmotion/stopmotion.cpp b/src/stopmotion/stopmotion.cpp index e927d3ea..96526070 100644 --- a/src/stopmotion/stopmotion.cpp +++ b/src/stopmotion/stopmotion.cpp @@ -113,12 +113,21 @@ StopmotionWidget::StopmotionWidget(KUrl projectFolder, QList< QAction* > actions 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; @@ -180,15 +189,6 @@ StopmotionWidget::StopmotionWidget(KUrl projectFolder, QList< QAction* > actions config_button->setIcon(KIcon("configure")); config_button->setMenu(confMenu); - // Build capture menu - QMenu* capMenu = new QMenu; - m_intervalCapture = new QAction(KIcon("edit-redo"), i18n("Interval capture"), this); - m_intervalCapture->setCheckable(true); - m_intervalCapture->setChecked(false); - connect(m_intervalCapture, SIGNAL(triggered(bool)), this, SLOT(slotIntervalCapture(bool))); - capMenu->addAction(m_intervalCapture); - capture_button->setMenu(capMenu); - connect(sequence_name, SIGNAL(textChanged(const QString&)), this, SLOT(sequenceNameChanged(const QString&))); connect(sequence_name, SIGNAL(currentIndexChanged(int)), live_button, SLOT(setFocus())); @@ -251,6 +251,9 @@ StopmotionWidget::StopmotionWidget(KUrl projectFolder, QList< QAction* > actions 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); } StopmotionWidget::~StopmotionWidget() @@ -281,12 +284,21 @@ void StopmotionWidget::slotConfigure() ui.setupUi(&d); d.setWindowTitle(i18n("Configure Stop Motion")); ui.sm_interval->setValue(KdenliveSettings::captureinterval()); + ui.sm_interval->setSuffix(ki18np(" second", " seconds")); + ui.sm_notifytime->setSuffix(ki18np(" second", " seconds")); + ui.sm_notifytime->setValue(KdenliveSettings::sm_notifytime()); + connect(ui.sm_prenotify, SIGNAL(checked(bool)), ui.sm_notifytime, SLOT(setEnabled(bool))); + ui.sm_prenotify->setChecked(KdenliveSettings::sm_prenotify()); ui.sm_loop->setChecked(KdenliveSettings::sm_loop()); ui.sm_framesplayback->setValue(KdenliveSettings::sm_framesplayback()); + if (d.exec() == QDialog::Accepted) { KdenliveSettings::setSm_loop(ui.sm_loop->isChecked()); KdenliveSettings::setCaptureinterval(ui.sm_interval->value()); KdenliveSettings::setSm_framesplayback(ui.sm_framesplayback->value()); + KdenliveSettings::setSm_notifytime(ui.sm_notifytime->value()); + KdenliveSettings::setSm_prenotify(ui.sm_prenotify->isChecked()); + m_intervalTimer.setInterval(KdenliveSettings::captureinterval() * 1000); } } @@ -303,11 +315,6 @@ void StopmotionWidget::slotShowThumbs(bool show) frame_list->setHidden(!show); } -void StopmotionWidget::slotIntervalCapture(bool capture) -{ - if (capture) slotCaptureFrame(); -} - void StopmotionWidget::slotUpdateHandler() { @@ -463,7 +470,10 @@ void StopmotionWidget::slotCaptureFrame() if (m_bmCapture == NULL) return; if (sequence_name->currentText().isEmpty()) { QString seqName = QInputDialog::getText(this, i18n("Create New Sequence"), i18n("Enter sequence name")); - if (seqName.isEmpty()) return; + if (seqName.isEmpty()) { + m_captureAction->setChecked(false); + return; + } sequence_name->blockSignals(true); sequence_name->setItemText(sequence_name->currentIndex(), seqName); sequence_name->blockSignals(false); @@ -473,12 +483,26 @@ void StopmotionWidget::slotCaptureFrame() m_sequenceFrame = 0; } //capture_button->setEnabled(false); + if (m_intervalTimer.isActive()) { + // stop interval capture + m_intervalTimer.stop(); + return; + } QString currentPath = getPathForFrame(m_sequenceFrame); m_bmCapture->captureFrame(currentPath); KNotification::event("FrameCaptured", i18n("Frame Captured"), QPixmap(), this); m_sequenceFrame++; button_addsequence->setEnabled(true); - if (m_intervalCapture->isChecked()) QTimer::singleShot(KdenliveSettings::captureinterval() * 1000, this, SLOT(slotCaptureFrame())); + if (capture_interval->isChecked()) { + if (KdenliveSettings::sm_prenotify()) QTimer::singleShot((KdenliveSettings::captureinterval() - KdenliveSettings::sm_notifytime()) * 1000, this, SLOT(slotPreNotify())); + m_intervalTimer.start(); + } + else m_captureAction->setChecked(false); +} + +void StopmotionWidget::slotPreNotify() +{ + if (m_captureAction->isChecked()) KNotification::event("ReadyToCapture", i18n("Going to Capture Frame"), QPixmap(), this); } diff --git a/src/stopmotion/stopmotion.h b/src/stopmotion/stopmotion.h index c76f634c..9e82f28f 100644 --- a/src/stopmotion/stopmotion.h +++ b/src/stopmotion/stopmotion.h @@ -25,6 +25,7 @@ #include #include #include +#include class MyLabel : public QLabel { @@ -106,9 +107,6 @@ private: /** @brief Get the frame number ix. */ QListWidgetItem* getFrameFromIndex(int ix); - /** @brief The action triggering interval capture. */ - QAction* m_intervalCapture; - /** @brief The action triggering display of last frame over current live video feed. */ QAction* m_showOverlay; @@ -117,6 +115,9 @@ private: /** @brief Tells if we are in animation (playback) mode. */ bool m_animate; + + /** @brief Timer for interval capture. */ + QTimer m_intervalTimer; #ifdef QIMAGEBLITZ @@ -182,9 +183,6 @@ private slots: /** @brief Show / hide sequence thumbnails. */ void slotShowThumbs(bool show); - /** @brief Capture one frame every interval time. */ - void slotIntervalCapture(bool capture); - /** @brief Show the config dialog */ void slotConfigure(); @@ -199,8 +197,13 @@ private slots: /** @brief Delete current frame from disk. */ void slotRemoveFrame(); + /** @brief Enable / disable frame analysis (in color scopes). */ void slotSwitchAnalyse(bool isOn); + + /** @brief Send a notification a few seconds before capturing. */ + void slotPreNotify(); + signals: /** @brief Ask to add sequence to current project. */ void addOrUpdateSequence(const QString); diff --git a/src/widgets/smconfig_ui.ui b/src/widgets/smconfig_ui.ui index 145a87bc..9daa2801 100644 --- a/src/widgets/smconfig_ui.ui +++ b/src/widgets/smconfig_ui.ui @@ -7,7 +7,7 @@ 0 0 338 - 190 + 217 @@ -70,13 +70,13 @@ - Capture + Interval Capture - Capture interval (seconds) + Capture delay @@ -90,6 +90,20 @@ + + + + Notify before capture + + + + + + + 1 + + + diff --git a/src/widgets/stopmotion_ui.ui b/src/widgets/stopmotion_ui.ui index ff07fa06..0d7d35cc 100644 --- a/src/widgets/stopmotion_ui.ui +++ b/src/widgets/stopmotion_ui.ui @@ -14,7 +14,7 @@ Dialog - + Qt::Vertical @@ -67,7 +67,7 @@ - + Sequence name @@ -77,7 +77,7 @@ - + Capture device @@ -87,7 +87,7 @@ - + @@ -103,14 +103,14 @@ - + Add to project - + Preview sequence @@ -158,31 +158,38 @@ - - - - Capture frame - - - + + + + Sequence name + + + + ... - - QToolButton::MenuButtonPopup - - - + + + + Interval capture + - Sequence name + ... + + + true - - + + + + Capture frame + ... -- 2.39.2