]> git.sesse.net Git - kdenlive/commitdiff
Stop motion widget: notify a few seconds before capturing frame in interval mode...
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 9 Jan 2011 13:08:38 +0000 (13:08 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 9 Jan 2011 13:08:38 +0000 (13:08 +0000)
svn path=/trunk/kdenlive/; revision=5312

src/kdenlive.notifyrc
src/kdenlivesettings.kcfg
src/stopmotion/stopmotion.cpp
src/stopmotion/stopmotion.h
src/widgets/smconfig_ui.ui
src/widgets/stopmotion_ui.ui

index 8ddc7f7ad68bbd513f26c78e9d12ececddb900f6..da5679c409b6bd01d1d0192097a755f2f9a6571b 100644 (file)
@@ -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
 
index 648e8f1282a6ec2bdbd666b25d144471efd81185..f5d83b06fa455b6078d642cd5c67b7d9160fd32f 100644 (file)
     <entry name="captureinterval" type="Int">
       <label>Interval between each capture (in seconds).</label>
       <default>5</default>
-    </entry> 
+    </entry>
+
+    <entry name="sm_notifytime" type="Int">
+      <label>Seconds before triggering a capture notification.</label>
+      <default>3</default>
+    </entry>
+
+    <entry name="sm_prenotify" type="Bool">
+      <label>Send a notification a few seconds before capture.</label>
+      <default>false</default>
+    </entry>
 
     <entry name="sm_loop" type="Bool">
       <label>Should we loop in stop motion playback.</label>
index e927d3ea26853b1e7c82d7d1f1844a9b1f50b897..9652607066fe82604d0b52d366a32517fc3d678f 100644 (file)
@@ -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);
 }
 
 
index c76f634cb98d68ad303897b6a4e10858350c6c43..9e82f28f2401fd20a20c6ae15e805dda7cd82581 100644 (file)
@@ -25,6 +25,7 @@
 #include <QLabel>
 #include <QFuture>
 #include <QVBoxLayout>
+#include <QTimer>
 
 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);
index 145a87bcf6992f2773bd320a4f99717f89dc4909..9daa280136797d61d835e5db74f3445efbbe9532 100644 (file)
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>338</width>
-    <height>190</height>
+    <height>217</height>
    </rect>
   </property>
   <property name="windowTitle">
    <item row="0" column="0" colspan="3">
     <widget class="QGroupBox" name="groupBox_2">
      <property name="title">
-      <string>Capture</string>
+      <string>Interval Capture</string>
      </property>
      <layout class="QGridLayout" name="gridLayout_3">
       <item row="0" column="0">
        <widget class="QLabel" name="label">
         <property name="text">
-         <string>Capture interval (seconds)</string>
+         <string>Capture delay</string>
         </property>
        </widget>
       </item>
         </property>
        </widget>
       </item>
+      <item row="1" column="0">
+       <widget class="QCheckBox" name="sm_prenotify">
+        <property name="text">
+         <string>Notify before capture</string>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="1">
+       <widget class="KIntSpinBox" name="sm_notifytime">
+        <property name="minimum">
+         <number>1</number>
+        </property>
+       </widget>
+      </item>
      </layout>
     </widget>
    </item>
index ff07fa06a0ddc667decf516ab770c0c9a42338de..0d7d35cc214849457c76330e64e7311c0de1c223 100644 (file)
@@ -14,7 +14,7 @@
    <string>Dialog</string>
   </property>
   <layout class="QGridLayout" name="gridLayout">
-   <item row="0" column="0" colspan="14">
+   <item row="0" column="0" colspan="15">
     <widget class="QSplitter" name="splitter">
      <property name="orientation">
       <enum>Qt::Vertical</enum>
@@ -67,7 +67,7 @@
      </widget>
     </widget>
    </item>
-   <item row="1" column="8">
+   <item row="1" column="9">
     <widget class="KComboBox" name="sequence_name">
      <property name="toolTip">
       <string>Sequence name</string>
@@ -77,7 +77,7 @@
      </property>
     </widget>
    </item>
-   <item row="1" column="10">
+   <item row="1" column="11">
     <widget class="KComboBox" name="capture_device">
      <property name="toolTip">
       <string>Capture device</string>
@@ -87,7 +87,7 @@
      </property>
     </widget>
    </item>
-   <item row="1" column="11">
+   <item row="1" column="12">
     <widget class="KComboBox" name="log_box">
      <property name="sizePolicy">
       <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
      </property>
     </widget>
    </item>
-   <item row="1" column="12">
+   <item row="1" column="13">
     <widget class="QPushButton" name="button_addsequence">
      <property name="text">
       <string>Add to project</string>
      </property>
     </widget>
    </item>
-   <item row="1" column="6">
+   <item row="1" column="7">
     <widget class="QToolButton" name="preview_button">
      <property name="toolTip">
       <string>Preview sequence</string>
      </property>
     </widget>
    </item>
-   <item row="1" column="4">
-    <widget class="QToolButton" name="capture_button">
-     <property name="toolTip">
-      <string>Capture frame</string>
-     </property>
-     <property name="whatsThis">
-      <string/>
+   <item row="1" column="8">
+    <widget class="QLabel" name="label">
+     <property name="text">
+      <string>Sequence name</string>
      </property>
+    </widget>
+   </item>
+   <item row="1" column="6">
+    <widget class="QToolButton" name="overlay_button">
      <property name="text">
       <string>...</string>
      </property>
-     <property name="popupMode">
-      <enum>QToolButton::MenuButtonPopup</enum>
-     </property>
     </widget>
    </item>
-   <item row="1" column="7">
-    <widget class="QLabel" name="label">
+   <item row="1" column="5">
+    <widget class="QToolButton" name="capture_interval">
+     <property name="toolTip">
+      <string>Interval capture</string>
+     </property>
      <property name="text">
-      <string>Sequence name</string>
+      <string>...</string>
+     </property>
+     <property name="checkable">
+      <bool>true</bool>
      </property>
     </widget>
    </item>
-   <item row="1" column="5">
-    <widget class="QToolButton" name="overlay_button">
+   <item row="1" column="4">
+    <widget class="QToolButton" name="capture_button">
+     <property name="toolTip">
+      <string>Capture frame</string>
+     </property>
      <property name="text">
       <string>...</string>
      </property>