From: Jean-Baptiste Mardelle Date: Fri, 11 Apr 2008 21:21:18 +0000 (+0000) Subject: Alt + Left / Right to go to previous / next snap point X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=0c3564e5c9a392c23320d169f0aa7ef12c7ab8ba;p=kdenlive Alt + Left / Right to go to previous / next snap point svn path=/branches/KDE4/; revision=2166 --- diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index 25bc0f79..b25d863d 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -1036,6 +1036,33 @@ void CustomTrackView::updateSnapPoints(AbstractClipItem *selected) { // kDebug() << "SNAP POINT: " << m_snapPoints.at(i).frames(25); } +void CustomTrackView::slotSeekToPreviousSnap() { + updateSnapPoints(NULL); + GenTime pos = GenTime(m_cursorPos, m_document->fps()); + GenTime res = GenTime(); + for (int i = 0; i < m_snapPoints.size(); ++i) { + if (m_snapPoints.at(i) >= pos) { + if (i == 0) i = 1; + res = m_snapPoints.at(i - 1); + break; + } + } + setCursorPos((int) res.frames(m_document->fps())); +} + +void CustomTrackView::slotSeekToNextSnap() { + updateSnapPoints(NULL); + GenTime pos = GenTime(m_cursorPos, m_document->fps()); + GenTime res = GenTime(m_projectDuration, m_document->fps()); + for (int i = 0; i < m_snapPoints.size(); ++i) { + if (m_snapPoints.at(i) > pos) { + res = m_snapPoints.at(i); + break; + } + } + setCursorPos((int) res.frames(m_document->fps())); +} + void CustomTrackView::setTool(PROJECTTOOL tool) { m_tool = tool; } diff --git a/src/customtrackview.h b/src/customtrackview.h index 1c9d46f2..09c52724 100644 --- a/src/customtrackview.h +++ b/src/customtrackview.h @@ -71,6 +71,8 @@ public: QList tracksList() const; void setTool(PROJECTTOOL tool); void cutClip(ItemInfo info, GenTime cutTime, bool cut); + void slotSeekToPreviousSnap(); + void slotSeekToNextSnap(); public slots: void setCursorPos(int pos, bool seek = true); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7301920c..34ff83f0 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -408,67 +408,59 @@ void MainWindow::setupActions() { actionCollection()->addAction("select_tool", m_buttonSelectTool); actionCollection()->addAction("razor_tool", m_buttonRazorTool); - KAction* clearAction = new KAction(this); - clearAction->setText(i18n("Clear")); - clearAction->setIcon(KIcon("document-new")); + KAction* clearAction = new KAction(KIcon("document-new"), i18n("Clear"), this); clearAction->setShortcut(Qt::CTRL + Qt::Key_W); actionCollection()->addAction("clear", clearAction); /*connect(clearAction, SIGNAL(triggered(bool)), textArea, SLOT(clear()));*/ - KAction* profilesAction = new KAction(this); - profilesAction->setText(i18n("Manage Profiles")); - profilesAction->setIcon(KIcon("document-new")); + KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Profiles"), this); actionCollection()->addAction("manage_profiles", profilesAction); connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles())); - KAction* projectAction = new KAction(this); - projectAction->setText(i18n("Project Settings")); - projectAction->setIcon(KIcon("document-new")); + KAction* projectAction = new KAction(KIcon("document-new"), i18n("Project Settings"), this); actionCollection()->addAction("project_settings", projectAction); connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings())); - KAction* projectRender = new KAction(this); - projectRender->setText(i18n("Render Project")); - projectRender->setIcon(KIcon("document-new")); + KAction* projectRender = new KAction(KIcon("document-new"), i18n("Render Project"), this); actionCollection()->addAction("project_render", projectRender); connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject())); - KAction* monitorPlay = new KAction(this); - monitorPlay->setText(i18n("Play")); - monitorPlay->setIcon(KIcon("media-playback-start")); + KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this); monitorPlay->setShortcut(Qt::Key_Space); actionCollection()->addAction("monitor_play", monitorPlay); connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay())); - KAction* monitorSeekBackward = new KAction(this); - monitorSeekBackward->setText(i18n("Rewind")); - monitorSeekBackward->setIcon(KIcon("media-seek-backward")); + KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this); monitorSeekBackward->setShortcut(Qt::Key_J); actionCollection()->addAction("monitor_seek_backward", monitorSeekBackward); connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind())); - KAction* monitorSeekBackwardOneFrame = new KAction(this); - monitorSeekBackwardOneFrame->setText(i18n("Rewind 1 Frame")); - monitorSeekBackwardOneFrame->setIcon(KIcon("media-skip-backward")); + KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this); monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left); actionCollection()->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame); connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame())); - KAction* monitorSeekForward = new KAction(this); - monitorSeekForward->setText(i18n("Forward")); - monitorSeekForward->setIcon(KIcon("media-seek-forward")); + KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this); + monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left); + actionCollection()->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward); + connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind())); + + KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this); monitorSeekForward->setShortcut(Qt::Key_L); actionCollection()->addAction("monitor_seek_forward", monitorSeekForward); connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward())); - KAction* monitorSeekForwardOneFrame = new KAction(this); - monitorSeekForwardOneFrame->setText(i18n("Forward 1 Frame")); - monitorSeekForwardOneFrame->setIcon(KIcon("media-skip-forward")); + KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this); monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right); actionCollection()->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame); connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame())); + KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this); + monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right); + actionCollection()->addAction("monitor_seek_snap_forward", monitorSeekSnapForward); + connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward())); + KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this); deleteTimelineClip->setShortcut(Qt::Key_Delete); actionCollection()->addAction("delete_timeline_clip", deleteTimelineClip); @@ -982,6 +974,20 @@ void MainWindow::slotActivateTransitionView() { transitionConfig->raiseWindow(transitionConfigDock); } +void MainWindow::slotSnapRewind() { + if (m_monitorManager->projectMonitorFocused()) { + TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget(); + currentTab->projectView()->slotSeekToPreviousSnap(); + } +} + +void MainWindow::slotSnapForward() { + if (m_monitorManager->projectMonitorFocused()) { + TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget(); + currentTab->projectView()->slotSeekToNextSnap(); + } +} + void MainWindow::slotChangeTool(QAction * action) { if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL); else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL); diff --git a/src/mainwindow.h b/src/mainwindow.h index a5faed00..616d300c 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -178,6 +178,8 @@ private slots: void slotActivateTransitionView(); void slotChangeTool(QAction * action); void slotSetTool(PROJECTTOOL tool); + void slotSnapForward(); + void slotSnapRewind(); }; #endif diff --git a/src/monitormanager.cpp b/src/monitormanager.cpp index 9c163f07..f771fabc 100644 --- a/src/monitormanager.cpp +++ b/src/monitormanager.cpp @@ -26,8 +26,6 @@ MonitorManager::MonitorManager(QWidget *parent) : QObject(parent) { - - } void MonitorManager::setTimecode(Timecode tc) { @@ -43,6 +41,10 @@ void MonitorManager::initMonitors(Monitor *clipMonitor, Monitor *projectMonitor) m_projectMonitor = projectMonitor; } +bool MonitorManager::projectMonitorFocused() { + if (m_activeMonitor != "clip") return true; + return false; +} void MonitorManager::activateMonitor(QString name) { if (m_activeMonitor == name) return; diff --git a/src/monitormanager.h b/src/monitormanager.h index a33af55c..173fbc18 100644 --- a/src/monitormanager.h +++ b/src/monitormanager.h @@ -36,6 +36,7 @@ public: void setTimecode(Timecode tc); void resetProfiles(QString prof); void switchMonitors(); + bool projectMonitorFocused(); public slots: void activateMonitor(QString name = QString::null);