]> git.sesse.net Git - kdenlive/commitdiff
Keyboard shortcuts for stop motion capture
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 25 Oct 2010 20:50:32 +0000 (20:50 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 25 Oct 2010 20:50:32 +0000 (20:50 +0000)
svn path=/trunk/kdenlive/; revision=5051

src/mainwindow.cpp
src/mainwindow.h
src/stopmotion/stopmotion.cpp
src/stopmotion/stopmotion.h

index b8ec9ec53f3791274b7bbcdff697942acde67869..1dfe6e491841317e3c664b8bc591f72cb25b0394 100644 (file)
@@ -341,6 +341,20 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString &
         layoutActions->addAction("save_layout" + QString::number(i), save);
     }
 
+    KAction *action;
+    // Stop motion actions. Beware of the order, we MUST use the same order in stopmotion/stopmotion.cpp
+    m_stopmotion_actions = new KActionCategory(i18n("Stop Motion"), actionCollection());
+    action = new KAction(KIcon("media-record"), i18n("Capture frame"), this);
+    action->setShortcut(Qt::Key_Space);
+    //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
+    m_stopmotion_actions->addAction("stopmotion_capture", action);
+    action = new KAction(i18n("Switch live / captured frame"), this);
+    //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
+    m_stopmotion_actions->addAction("stopmotion_switch", action);
+    action = new KAction(KIcon("edit-paste"), i18n("Show last frame over video"), this);
+    action->setCheckable(true);
+    action->setChecked(false);
+    m_stopmotion_actions->addAction("stopmotion_overlay", action);
     setupGUI();
 
 
@@ -379,7 +393,6 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString &
                                       static_cast<QMenu*>(factory()->container("transcoders", this)),
                                       clipInTimeline);
 
-    KAction *action;
     // build themes menus
     QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
     QActionGroup *themegroup = new QActionGroup(this);
@@ -559,7 +572,7 @@ MainWindow::~MainWindow()
 void MainWindow::queryQuit()
 {
     if (queryClose()) {
-        kapp->quit();
+        close();
     }
 }
 
@@ -1969,8 +1982,8 @@ void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
 
     // Recreate stopmotion widget on document change
     if (m_stopmotion) {
-       delete m_stopmotion;
-       m_stopmotion = NULL;
+        delete m_stopmotion;
+        m_stopmotion = NULL;
     }
 
     KProgressDialog progressDialog(this, i18n("Loading project"), i18n("Loading project"));
@@ -2171,8 +2184,8 @@ void MainWindow::slotUpdateProjectProfile(const QString &profile)
 
     // Recreate the stopmotion widget if profile changes
     if (m_stopmotion) {
-       delete m_stopmotion;
-       m_stopmotion = NULL;
+        delete m_stopmotion;
+        m_stopmotion = NULL;
     }
 
     // Deselect current effect / transition
@@ -3996,7 +4009,7 @@ void MainWindow::slotUpdateColorScopes()
 void MainWindow::slotOpenStopmotion()
 {
     if (m_stopmotion == NULL) {
-        m_stopmotion = new StopmotionWidget(m_activeDocument->projectFolder(), this);
+        m_stopmotion = new StopmotionWidget(m_activeDocument->projectFolder(), m_stopmotion_actions->actions(), this);
         connect(m_stopmotion, SIGNAL(addOrUpdateSequence(const QString)), m_projectList, SLOT(slotAddOrUpdateSequence(const QString)));
     }
     m_stopmotion->show();
index a637c40b07c001ae14e5eec3ef5991a634da6c98..27365b4b777c8bfec17b32424a5513d952366edb 100644 (file)
@@ -37,6 +37,7 @@
 #include <KRecentFilesAction>
 #include <KComboBox>
 #include <kautosavefile.h>
+#include <KActionCategory>
 
 #include "effectslist.h"
 #include "gentime.h"
@@ -194,6 +195,9 @@ private:
     QMenu *m_timelineContextTransitionMenu;
     KUrl m_startUrl;
 
+    /** Actions used in the stopmotion widget */
+    KActionCategory *m_stopmotion_actions;
+
     /** @brief Shortcut to remove the focus from any element.
      *
      * It allows to get out of e.g. text input fields and to press another
@@ -374,7 +378,7 @@ private slots:
     void slotEditClipMarker();
 
     /** @brief Adds marker or auide at the current position without showing the marker dialog.
-     * 
+     *
      * Adds a marker if clip monitor is active, otherwise a guide.
      * The comment is set to the current position (therefore not dialog).
      * This can be useful to mark something during playback. */
index 40372969d94991eec4348dbe7c7491428d5aae45..a3c2413331d55e13a348da30d464482732a857e4 100644 (file)
@@ -83,7 +83,7 @@ void MyLabel::paintEvent(QPaintEvent * event)
 }
 
 
-StopmotionWidget::StopmotionWidget(KUrl projectFolder, QWidget *parent) :
+StopmotionWidget::StopmotionWidget(KUrl projectFolder, const QList< QAction * > actions, QWidget *parent) :
     QDialog(parent)
     , Ui::Stopmotion_UI()
     , m_projectFolder(projectFolder)
@@ -91,24 +91,25 @@ StopmotionWidget::StopmotionWidget(KUrl projectFolder, QWidget *parent) :
     , m_sequenceFrame(0)
     , m_animatedIndex(-1)
 {
+    addActions(actions);
     setupUi(this);
     setWindowTitle(i18n("Stop Motion Capture"));
     setFont(KGlobalSettings::toolBarFont());
 
     live_button->setIcon(KIcon("camera-photo"));
-    m_captureAction = new QAction(KIcon("media-record"), i18n("Capture frame"), this);
-    m_captureAction->setShortcut(QKeySequence(Qt::Key_Space));
+
+    m_captureAction = actions.at(0);
     connect(m_captureAction, SIGNAL(triggered()), this, SLOT(slotCaptureFrame()));
     capture_button->setDefaultAction(m_captureAction);
 
+    connect(actions.at(1), SIGNAL(triggered()), this, SLOT(slotSwitchLive()));
+
     preview_button->setIcon(KIcon("media-playback-start"));
     capture_button->setEnabled(false);
 
     // Build config menu
     QMenu *confMenu = new QMenu;
-    m_showOverlay = new QAction(KIcon("edit-paste"), i18n("Show last frame over video"), this);
-    m_showOverlay->setCheckable(true);
-    m_showOverlay->setChecked(false);
+    m_showOverlay = actions.at(2);
     connect(m_showOverlay, SIGNAL(triggered(bool)), this, SLOT(slotShowOverlay(bool)));
     confMenu->addAction(m_showOverlay);
 
@@ -285,15 +286,29 @@ void StopmotionWidget::parseExistingSequences()
     }
 }
 
+void StopmotionWidget::slotSwitchLive()
+{
+    setUpdatesEnabled(false);
+    if (m_frame_preview->isHidden()) {
+        m_bmCapture->hidePreview(true);
+        m_frame_preview->setHidden(false);
+    } else {
+        m_frame_preview->setHidden(true);
+        m_bmCapture->hidePreview(false);
+    }
+    setUpdatesEnabled(true);
+}
+
 void StopmotionWidget::slotLive(bool isOn)
 {
     if (isOn) {
-        m_frame_preview->setImage(QImage());
+        //m_frame_preview->setImage(QImage());
         m_frame_preview->setHidden(true);
         m_bmCapture->startPreview(KdenliveSettings::hdmi_capturedevice(), KdenliveSettings::hdmi_capturemode());
         capture_button->setEnabled(true);
     } else {
         m_bmCapture->stopPreview();
+        m_frame_preview->setHidden(false);
         capture_button->setEnabled(false);
         live_button->setChecked(false);
     }
@@ -446,7 +461,7 @@ QString StopmotionWidget::getPathForFrame(int ix, QString seqName)
 
 void StopmotionWidget::slotShowFrame(const QString &path)
 {
-    slotLive(false);
+    //slotLive(false);
     QImage img(path);
     capture_button->setEnabled(false);
     if (!img.isNull()) {
index dbefc944734e2c146bccb53a0e528fd9a92292ec..0f3f27bbca4bfbe1d6361cd0304a849eee1c7ddf 100644 (file)
@@ -54,8 +54,9 @@ public:
 
     /** @brief Build the stopmotion dialog.
      * @param projectFolder The current project folder, where captured files will be stored.
+     * @param actions The actions for this widget that can have a keyboard shortcut.
      * @param parent (optional) parent widget */
-    StopmotionWidget(KUrl projectFolder, QWidget *parent = 0);
+    StopmotionWidget(KUrl projectFolder, const QList< QAction * > actions, QWidget *parent = 0);
     virtual ~StopmotionWidget();
 
 protected:
@@ -184,6 +185,8 @@ private slots:
     /** @brief Set the effect to be applied to overlay frame. */
     void slotUpdateOverlayEffect(QAction *act);
 
+    /** @brief Switch between live view / currently selected fram. */
+    void slotSwitchLive();
 signals:
     /** @brief Ask to add sequence to current project. */
     void addOrUpdateSequence(const QString);