From e02ce4625f1ea04e0213e6fadb65f22bd010a69e Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Mon, 25 Oct 2010 20:50:32 +0000 Subject: [PATCH] Keyboard shortcuts for stop motion capture svn path=/trunk/kdenlive/; revision=5051 --- src/mainwindow.cpp | 27 ++++++++++++++++++++------- src/mainwindow.h | 6 +++++- src/stopmotion/stopmotion.cpp | 31 +++++++++++++++++++++++-------- src/stopmotion/stopmotion.h | 5 ++++- 4 files changed, 52 insertions(+), 17 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b8ec9ec5..1dfe6e49 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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(factory()->container("transcoders", this)), clipInTimeline); - KAction *action; // build themes menus QMenu *themesMenu = static_cast(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(); diff --git a/src/mainwindow.h b/src/mainwindow.h index a637c40b..27365b4b 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -37,6 +37,7 @@ #include #include #include +#include #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. */ diff --git a/src/stopmotion/stopmotion.cpp b/src/stopmotion/stopmotion.cpp index 40372969..a3c24133 100644 --- a/src/stopmotion/stopmotion.cpp +++ b/src/stopmotion/stopmotion.cpp @@ -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()) { diff --git a/src/stopmotion/stopmotion.h b/src/stopmotion/stopmotion.h index dbefc944..0f3f27bb 100644 --- a/src/stopmotion/stopmotion.h +++ b/src/stopmotion/stopmotion.h @@ -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); -- 2.39.2