]> git.sesse.net Git - kdenlive/blobdiff - src/mainwindow.cpp
Double click on monitor overlay info to edit a marker
[kdenlive] / src / mainwindow.cpp
index bbfaa6e37c3b3d3444770c012c6301b8d40273c8..5c36eb9ada3da9d9fc16bd7253f33cbc0cbf6e54 100644 (file)
@@ -156,6 +156,7 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString &
     if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
     setFont(KGlobalSettings::toolBarFont());
     parseProfiles(MltPath);
+    KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
     m_commandStack = new QUndoGroup;
     setDockNestingEnabled(true);
     m_timelineArea = new KTabWidget(this);
@@ -373,7 +374,6 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString &
     setCentralWidget(m_timelineArea);
 
 
-    KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
     m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
     readOptions();
     m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
@@ -617,13 +617,6 @@ MainWindow::~MainWindow()
     Mlt::Factory::close();
 }
 
-void MainWindow::queryQuit()
-{
-    if (queryClose()) {
-        close();
-    }
-}
-
 //virtual
 bool MainWindow::queryClose()
 {
@@ -867,6 +860,7 @@ void MainWindow::slotConnectMonitors()
     connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool, bool)), m_projectList, SLOT(slotReplyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool, bool)));
 
     connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
+    connect(m_projectMonitor->render, SIGNAL(removeInvalidProxy(const QString &)), m_projectList, SLOT(slotRemoveInvalidProxy(const QString &)));
 
     connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &, bool)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &, bool)));
 
@@ -1428,6 +1422,7 @@ void MainWindow::setupActions()
     connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
 
     KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
+    editClipMarker->setData(QString("edit_marker"));
     collection.addAction("edit_clip_marker", editClipMarker);
     connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
 
@@ -1526,7 +1521,7 @@ void MainWindow::setupActions()
     connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
 
     m_closeAction = KStandardAction::close(this,  SLOT(closeCurrentDocument()),   collection);
-    KStandardAction::quit(this,                   SLOT(queryQuit()),              collection);
+    KStandardAction::quit(this,                   SLOT(close()),              collection);
     KStandardAction::open(this,                   SLOT(openFile()),               collection);
     m_saveAction = KStandardAction::save(this,    SLOT(saveFile()),               collection);
     KStandardAction::saveAs(this,                 SLOT(saveFileAs()),             collection);
@@ -1802,8 +1797,17 @@ void MainWindow::newFile(bool showProjectSettings, bool force)
     m_fileRevert->setEnabled(false);
     QString profileName = KdenliveSettings::default_profile();
     KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
+    QMap <QString, QString> documentProperties;
     QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
     if (!showProjectSettings) {
+        // set up default properties
+        documentProperties.insert("enableproxy", QString::number((int) KdenliveSettings::enableproxy()));
+        documentProperties.insert("generateproxy", QString::number((int) KdenliveSettings::generateproxy()));
+        documentProperties.insert("proxyminsize", QString::number(KdenliveSettings::proxyminsize()));
+        documentProperties.insert("proxyparams", KdenliveSettings::proxyparams());
+        documentProperties.insert("proxyextension", KdenliveSettings::proxyextension());
+        documentProperties.insert("generateimageproxy", QString::number((int) KdenliveSettings::generateimageproxy()));
+        documentProperties.insert("proxyimageminsize", QString::number(KdenliveSettings::proxyimageminsize()));
         if (!KdenliveSettings::activatetabs())
             if (!closeCurrentDocument())
                 return;
@@ -1821,11 +1825,19 @@ void MainWindow::newFile(bool showProjectSettings, bool force)
         profileName = w->selectedProfile();
         projectFolder = w->selectedFolder();
         projectTracks = w->tracks();
+        documentProperties.insert("enableproxy", QString::number((int) w->useProxy()));
+        documentProperties.insert("generateproxy", QString::number((int) w->generateProxy()));
+        documentProperties.insert("proxyminsize", QString::number(w->proxyMinSize()));
+        documentProperties.insert("proxyparams", w->proxyParams());
+        documentProperties.insert("proxyextension", w->proxyExtension());
+        documentProperties.insert("generateimageproxy", QString::number((int) w->generateImageProxy()));
+        documentProperties.insert("proxyimageminsize", QString::number(w->proxyImageMinSize()));
         delete w;
     }
     m_timelineArea->setEnabled(true);
     m_projectList->setEnabled(true);
-    KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, m_notesWidget, this);
+    
+    KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, documentProperties, projectTracks, m_projectMonitor->render, m_notesWidget, this);
     doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
     bool ok;
     TrackView *trackView = new TrackView(doc, &ok, this);
@@ -2038,7 +2050,7 @@ void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
     progressDialog.progressBar()->setValue(0);
     qApp->processEvents();
 
-    KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, m_notesWidget, this, &progressDialog);
+    KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QMap <QString, QString> (), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, m_notesWidget, this, &progressDialog);
 
     progressDialog.progressBar()->setValue(1);
     progressDialog.progressBar()->setMaximum(4);
@@ -2219,6 +2231,39 @@ void MainWindow::slotEditProjectSettings()
         if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
         if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
         if (m_activeDocument->profilePath() != profile) slotUpdateProjectProfile(profile);
+        if (m_activeDocument->getDocumentProperty("proxyparams") != w->proxyParams()) {
+            m_activeDocument->setModified();
+            m_activeDocument->setDocumentProperty("proxyparams", w->proxyParams());
+            if (m_activeDocument->clipManager()->clipsCount() > 0 && KMessageBox::questionYesNo(this, i18n("You have changed the proxy parameters. Do you want to recreate all proxy clips for this project?")) == KMessageBox::Yes) {
+                //TODO: rebuild all proxies
+                //m_activeDocument->rebuildAllProxies();
+            }
+        }
+        if (m_activeDocument->getDocumentProperty("proxyextension") != w->proxyExtension()) {
+            m_activeDocument->setModified();
+            m_activeDocument->setDocumentProperty("proxyextension", w->proxyExtension());
+        }
+        if (m_activeDocument->getDocumentProperty("generateproxy") != QString::number((int) w->generateProxy())) {
+            m_activeDocument->setModified();
+            m_activeDocument->setDocumentProperty("generateproxy", QString::number((int) w->generateProxy()));
+        }
+        if (m_activeDocument->getDocumentProperty("proxyminsize") != QString::number(w->proxyMinSize())) {
+            m_activeDocument->setModified();
+            m_activeDocument->setDocumentProperty("proxyminsize", QString::number(w->proxyMinSize()));
+        }
+        if (m_activeDocument->getDocumentProperty("generateimageproxy") != QString::number((int) w->generateImageProxy())) {
+            m_activeDocument->setModified();
+            m_activeDocument->setDocumentProperty("generateimageproxy", QString::number((int) w->generateImageProxy()));
+        }
+        if (m_activeDocument->getDocumentProperty("proxyimageminsize") != QString::number(w->proxyImageMinSize())) {
+            m_activeDocument->setModified();
+            m_activeDocument->setDocumentProperty("proxyimageminsize", QString::number(w->proxyImageMinSize()));
+        }
+        if (QString::number((int) w->useProxy()) != m_activeDocument->getDocumentProperty("enableproxy")) {
+            m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) w->useProxy()));
+            m_activeDocument->setModified();
+            slotUpdateProxySettings();
+        }
     }
     delete w;
 }
@@ -2265,7 +2310,7 @@ void MainWindow::slotRenderProject()
 {
     if (!m_renderWidget) {
         QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
-        m_renderWidget = new RenderWidget(projectfolder, this);
+        m_renderWidget = new RenderWidget(projectfolder, m_projectList->useProxy(), this);
         connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
         connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
         connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
@@ -2573,7 +2618,6 @@ void MainWindow::slotPreferences(int page, int option)
     
     KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(actions, this);
     connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
-    connect(dialog, SIGNAL(updateProxySettings()), this, SLOT(slotUpdateProxySettings()));
     connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
 #ifndef Q_WS_MAC
     connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
@@ -3135,6 +3179,10 @@ void MainWindow::slotShowClipProperties(DocClipBase *clip)
             if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
                 // duration changed, we need to update duration
                 newprops.insert("out", QString::number(dia_ui->outPoint()));
+                int currentLength = QString(clip->producerProperty("length")).toInt();
+                if (currentLength <= dia_ui->outPoint())
+                        newprops.insert("length", QString::number(dia_ui->outPoint() + 1));
+                else newprops.insert("length", clip->producerProperty("length"));
             }
             if (!path.isEmpty()) {
                 // we are editing an external file, asked if we want to detach from that file or save the result to that title file.
@@ -3182,9 +3230,17 @@ void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QSt
     if (dia.exec() == QDialog::Accepted) {
         QUndoCommand *command = new QUndoCommand();
         command->setText(i18n("Edit clips"));
+        QMap <QString, QString> newImageProps = dia.properties();
+        // Transparency setting applies only for images
+        QMap <QString, QString> newProps = newImageProps;
+        newProps.remove("transparency");
+
         for (int i = 0; i < cliplist.count(); i++) {
             DocClipBase *clip = cliplist.at(i);
-            new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true, command);
+            if (clip->clipType() == IMAGE)
+                new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newImageProps, true, command);
+            else 
+                new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newProps, true, command);
         }
         m_activeDocument->commandStack()->push(command);
         for (int i = 0; i < cliplist.count(); i++)
@@ -3805,7 +3861,7 @@ void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QS
     } else exportAudio = m_renderWidget->selectedAudioExport();
     
     // Do we want proxy rendering
-    if (KdenliveSettings::enableproxy() && !m_renderWidget->proxyRendering()) {
+    if (m_projectList->useProxy() && !m_renderWidget->proxyRendering()) {
         // replace proxy clips with originals
         QMap <QString, QString> proxies = m_projectList->getProxies();
         QMapIterator<QString, QString> i(proxies);
@@ -4139,7 +4195,7 @@ void MainWindow::slotDeleteClip(const QString &id)
 
 void MainWindow::slotUpdateProxySettings()
 {
-    if (m_renderWidget) m_renderWidget->updateProxyConfig();
+    if (m_renderWidget) m_renderWidget->updateProxyConfig(m_projectList->useProxy());
     if (KdenliveSettings::enableproxy())
         KStandardDirs::makeDir(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "proxy/");
     m_projectList->updateProxyConfig();