]> git.sesse.net Git - kdenlive/blobdiff - src/mainwindow.cpp
Fix timeline handling of objects (move them instead of changing their bounding rect
[kdenlive] / src / mainwindow.cpp
index d390f31da6e3692d70cbf6a35083d2f5cdd48dd9..106fb0e092e7e688e33e8c9ff7d494a9361aaaf4 100644 (file)
@@ -164,6 +164,7 @@ MainWindow::MainWindow(QWidget *parent)
     addDockWidget(Qt::TopDockWidgetArea, recMonitorDock);
 
     connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
+    connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
 
     undoViewDock = new QDockWidget(i18n("Undo History"), this);
     undoViewDock->setObjectName("undo_history");
@@ -243,6 +244,7 @@ MainWindow::MainWindow(QWidget *parent)
     m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
 
     m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
+    m_timelineContextClipMenu->addAction(actionCollection()->action("change_clip_speed"));
     m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
     m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
     m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
@@ -314,7 +316,7 @@ void MainWindow::readProperties(KConfig *config) {
 void MainWindow::slotReloadEffects() {
     initEffects::parseCustomEffectsFile();
     m_customEffectsMenu->clear();
-    QStringList effects = customEffects.effectNames();
+    const QStringList effects = customEffects.effectNames();
     QAction *action;
     foreach(const QString &name, effects) {
         action = new QAction(name, this);
@@ -402,6 +404,9 @@ void MainWindow::slotConnectMonitors() {
     connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, int)), m_clipMonitor->render, SLOT(getFileProperties(const QDomElement &, int)));
     connect(m_clipMonitor->render, SIGNAL(replyGetImage(int, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(int, int, const QPixmap &, int, int)));
     connect(m_clipMonitor->render, SIGNAL(replyGetFileProperties(int, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &)), m_projectList, SLOT(slotReplyGetFileProperties(int, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &)));
+
+    connect(m_clipMonitor->render, SIGNAL(removeInvalidClip(int)), m_projectList, SLOT(slotRemoveInvalidClip(int)));
+
     connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(int)), m_projectList, SLOT(slotRefreshClipThumbnail(int)));
 }
 
@@ -623,6 +628,10 @@ void MainWindow::setupActions() {
     actionCollection()->addAction("delete_timeline_clip", deleteTimelineClip);
     connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
 
+    KAction* editTimelineClipSpeed = new KAction(KIcon("edit-delete"), i18n("Change Clip Speed"), this);
+    actionCollection()->addAction("change_clip_speed", editTimelineClipSpeed);
+    connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));
+
     KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
     cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
     actionCollection()->addAction("cut_timeline_clip", cutTimelineClip);
@@ -691,11 +700,15 @@ void MainWindow::setupActions() {
     KStandardAction::paste(this, SLOT(slotPaste()),
                            actionCollection());
 
-    KStandardAction::undo(this, SLOT(undo()),
-                          actionCollection());
+    KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()),
+                                          actionCollection());
+    undo->setEnabled(false);
+    connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
 
-    KStandardAction::redo(this, SLOT(redo()),
-                          actionCollection());
+    KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()),
+                                          actionCollection());
+    redo->setEnabled(false);
+    connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
 
     KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, actionCollection());
 
@@ -707,14 +720,6 @@ void MainWindow::setupActions() {
     readOptions();
 }
 
-void MainWindow::undo() {
-    m_commandStack->undo();
-}
-
-void MainWindow::redo() {
-    m_commandStack->redo();
-}
-
 void MainWindow::slotDisplayActionMessage(QAction *a) {
     statusBar()->showMessage(a->data().toString(), 3000);
 }
@@ -812,8 +817,9 @@ void MainWindow::openFile() {
 
 void MainWindow::openLastFile() {
     KSharedConfigPtr config = KGlobal::config();
-    QString Lastproject = config->group("Recent Files").readPathEntry("File1", QString());
-    openFile(KUrl(Lastproject));
+    KUrl::List urls = m_fileOpenRecent->urls();
+    if (urls.isEmpty()) newFile();
+    else openFile(urls.last());
 }
 
 void MainWindow::openFile(const KUrl &url) {
@@ -1097,18 +1103,22 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha
     m_activeDocument = doc;
 }
 
-void MainWindow::slotPreferences() {
+void MainWindow::slotPreferences(int page, int option) {
     //An instance of your dialog could be already created and could be
     // cached, in which case you want to display the cached dialog
     // instead of creating another one
-    if (KConfigDialog::showDialog("settings"))
+    if (KConfigDialog::showDialog("settings")) {
+        if (page != -1) static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"))->showPage(page, option);
         return;
+    }
 
     // KConfigDialog didn't find an instance of this dialog, so lets
     // create it :
     KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
     connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
+    connect(dialog, SIGNAL(doResetProfile()), this, SLOT(resetProfiles()));
     dialog->show();
+    if (page != -1) dialog->showPage(page, option);
 }
 
 void MainWindow::updateConfiguration() {
@@ -1125,6 +1135,10 @@ void MainWindow::updateConfiguration() {
 
 }
 
+void MainWindow::resetProfiles() {
+    m_monitorManager->resetProfiles(m_activeDocument->profilePath());
+}
+
 void MainWindow::slotSwitchVideoThumbs() {
     KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
     if (m_activeTimeline) {
@@ -1163,6 +1177,12 @@ void MainWindow::slotDeleteTimelineClip() {
     }
 }
 
+void MainWindow::slotChangeClipSpeed() {
+    if (m_activeTimeline) {
+        m_activeTimeline->projectView()->changeClipSpeed();
+    }
+}
+
 void MainWindow::slotAddClipMarker() {
     if (m_activeTimeline) {
         m_activeTimeline->projectView()->slotAddClipMarker();