]> git.sesse.net Git - kdenlive/blobdiff - src/mainwindow.cpp
Add option to remove unused clips from project tree:
[kdenlive] / src / mainwindow.cpp
index 651a79dbe4c883be88dbc0d554baeeb5559ab05a..a6019f7feb55850242fcf0b28769ecfefdcda1e0 100644 (file)
@@ -81,6 +81,7 @@
 #include <KNotifyConfigWidget>
 #include <knewstuff2/engine.h>
 #include <knewstuff2/ui/knewstuffaction.h>
+#include <KToolBar>
 
 #include <QTextStream>
 #include <QTimer>
@@ -235,7 +236,7 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent
 
 
     setupGUI();
-    
+
     /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
     guiFactory()->addClient(sp);*/
 
@@ -411,7 +412,7 @@ bool MainWindow::queryClose()
     if (m_renderWidget) {
         int waitingJobs = m_renderWidget->waitingJobsCount();
         if (waitingJobs > 0) {
-            switch (KMessageBox::warningYesNoCancel(this, i18n("You have %1 rendering jobs waiting in the queue.\nWhat do you want to do with these jobs?", waitingJobs), QString(), KGuiItem(i18n("Start them now")), KGuiItem(i18n("Delete them")))) {
+            switch (KMessageBox::warningYesNoCancel(this, i18np("You have 1 rendering job waiting in the queue.\nWhat do you want to do with this job?", "You have %1 rendering jobs waiting in the queue.\nWhat do you want to do with these jobs?", waitingJobs), QString(), KGuiItem(i18n("Start them now")), KGuiItem(i18n("Delete them")))) {
             case KMessageBox::Yes :
                 // create script with waiting jobs and start it
                 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
@@ -683,11 +684,11 @@ void MainWindow::setupActions()
     m_statusProgressBar->setMaximumWidth(150);
     m_statusProgressBar->setVisible(false);
 
-    QToolBar *toolbar = new QToolBar("statusToolBar", this);
+    KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
     toolbar->setMovable(false);
     m_toolGroup = new QActionGroup(this);
-
-    QString style1 = "QToolBar {border:0px} QToolButton {background-color: rgba(230, 230, 230, 220); border-style: inset; border:1px solid #999999;border-radius: 3px;margin: 0px 3px;padding: 0px;} QToolButton:checked { background-color: rgba(224, 224, 0, 100); border-style: inset; border:1px solid #cc6666;border-radius: 3px;}";
+    statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
+    QString style1 = "QToolBar { border: 0px } QToolButton {background-color: rgba(230, 230, 230, 220); border-style: inset; border:1px solid #999999;border-radius: 3px;margin: 0px 3px;padding: 0px;} QToolButton:checked { background-color: rgba(224, 224, 0, 100); border-style: inset; border:1px solid #cc6666;border-radius: 3px;}";
 
     m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
     m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
@@ -714,17 +715,18 @@ void MainWindow::setupActions()
     toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
 
     QWidget * actionWidget;
+    int max = toolbar->iconSizeDefault() + 2;
     actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
-    actionWidget->setMaximumWidth(24);
-    actionWidget->setMinimumHeight(18);
+    actionWidget->setMaximumWidth(max);
+    actionWidget->setMaximumHeight(max - 4);
 
     actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
-    actionWidget->setMaximumWidth(24);
-    actionWidget->setMinimumHeight(18);
+    actionWidget->setMaximumWidth(max);
+    actionWidget->setMaximumHeight(max - 4);
 
     actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
-    actionWidget->setMaximumWidth(24);
-    actionWidget->setMinimumHeight(18);
+    actionWidget->setMaximumWidth(max);
+    actionWidget->setMaximumHeight(max - 4);
 
     toolbar->setStyleSheet(style1);
     connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
@@ -736,8 +738,8 @@ void MainWindow::setupActions()
     connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
 
     actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
-    actionWidget->setMaximumWidth(24);
-    actionWidget->setMinimumHeight(18);
+    actionWidget->setMaximumWidth(max);
+    actionWidget->setMaximumHeight(max - 4);
 
     m_zoomSlider = new QSlider(Qt::Horizontal, this);
     m_zoomSlider->setMaximum(13);
@@ -772,20 +774,20 @@ void MainWindow::setupActions()
     connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
 
     actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
-    actionWidget->setMaximumWidth(24);
-    actionWidget->setMinimumHeight(18);
+    actionWidget->setMaximumWidth(max);
+    actionWidget->setMaximumHeight(max - 4);
 
     actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
-    actionWidget->setMaximumWidth(24);
-    actionWidget->setMinimumHeight(18);
+    actionWidget->setMaximumWidth(max);
+    actionWidget->setMaximumHeight(max - 4);
 
     actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
-    actionWidget->setMaximumWidth(24);
-    actionWidget->setMinimumHeight(18);
+    actionWidget->setMaximumWidth(max);
+    actionWidget->setMaximumHeight(max - 4);
 
     actionWidget = toolbar->widgetForAction(m_buttonSnap);
-    actionWidget->setMaximumWidth(24);
-    actionWidget->setMinimumHeight(18);
+    actionWidget->setMaximumWidth(max);
+    actionWidget->setMaximumHeight(max - 4);
 
     m_messageLabel = new StatusBarMessageLabel(this);
     m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
@@ -795,7 +797,7 @@ void MainWindow::setupActions()
     statusBar()->addPermanentWidget(toolbar);
     statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
     statusBar()->addPermanentWidget(m_timecodeFormat);
-    statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
+    //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
 
     collection->addAction("select_tool", m_buttonSelectTool);
     collection->addAction("razor_tool", m_buttonRazorTool);
@@ -851,6 +853,10 @@ void MainWindow::setupActions()
     projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
     connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
 
+    KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
+    collection->addAction("project_clean", projectClean);
+    connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
+    
     KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
     KShortcut playShortcut;
     playShortcut.setPrimary(Qt::Key_Space);
@@ -1253,7 +1259,7 @@ void MainWindow::newFile(bool showProjectSettings)
         profileName = KdenliveSettings::default_profile();
         projectFolder = KdenliveSettings::defaultprojectfolder();
     } else {
-        ProjectSettings *w = new ProjectSettings(projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, this);
+        ProjectSettings *w = new ProjectSettings(projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
         if (w->exec() != QDialog::Accepted) return;
         if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
         KdenliveSettings::setVideothumbnails(w->enableVideoThumbs());
@@ -1611,7 +1617,7 @@ void MainWindow::slotDetectAudioDriver()
 void MainWindow::slotEditProjectSettings()
 {
     QPoint p = m_activeDocument->getTracksCount();
-    ProjectSettings *w = new ProjectSettings(p.x(), p.y(), m_activeDocument->projectFolder().path(), true, this);
+    ProjectSettings *w = new ProjectSettings(p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
 
     if (w->exec() == QDialog::Accepted) {
         QString profile = w->selectedProfile();
@@ -1625,7 +1631,7 @@ void MainWindow::slotEditProjectSettings()
             m_effectStack->slotClipItemSelected(NULL, 0);
             m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
             m_clipMonitor->slotSetXml(NULL, 0);
-            m_activeDocument->setProfilePath(profile);
+            bool updateFps = m_activeDocument->setProfilePath(profile);
             KdenliveSettings::setCurrent_profile(profile);
             KdenliveSettings::setProject_fps(m_activeDocument->fps());
             setCaption(m_activeDocument->description(), m_activeDocument->isModified());
@@ -1639,8 +1645,9 @@ void MainWindow::slotEditProjectSettings()
             m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
             //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
             if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
-            m_activeTimeline->updateProjectFps();
-
+            if (updateFps) m_activeTimeline->updateProjectFps();
+            m_activeDocument->setModified(true);
+            m_commandStack->activeStack()->clear();
             // We need to desactivate & reactivate monitors to get a refresh
             //m_monitorManager->switchMonitors();
         }
@@ -1681,6 +1688,12 @@ void MainWindow::setRenderingFinished(const QString &url, int status, const QStr
     if (m_renderWidget) m_renderWidget->setRenderStatus(url, status, error);
 }
 
+void MainWindow::slotCleanProject()
+{
+    if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
+    m_projectList->cleanup();
+}
+
 void MainWindow::slotUpdateMousePosition(int pos)
 {
     if (m_activeDocument)
@@ -1760,6 +1773,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
             disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
             disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
             disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
+            disconnect(m_projectList, SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
             m_effectStack->clear();
         }
         //m_activeDocument->setRenderer(NULL);
@@ -1825,7 +1839,9 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
     connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
     connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
     connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
+    connect(m_projectList, SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
 
+    
     trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup);
     m_activeTimeline = trackView;
     if (m_renderWidget) {