]> git.sesse.net Git - kdenlive/blobdiff - src/mainwindow.cpp
Fix audio thumbs progress info when window was not focused
[kdenlive] / src / mainwindow.cpp
index 4449df7f08395471e1197ce4e6061d209fd4f27b..8004e65b6584cb73d8b2e961394eb86911624d10 100644 (file)
 
 #include "mainwindow.h"
 #include "kdenlivesettings.h"
-#include "ui_configmisc_ui.h"
-#include "ui_configenv_ui.h"
+#include "kdenlivesettingsdialog.h"
 #include "initeffects.h"
-#include "ui_profiledialog_ui.h"
+#include "profilesdialog.h"
+#include "projectsettings.h"
+#include "events.h"
 
 #define ID_STATUS_MSG 1
 #define ID_EDITMODE_MSG 2
@@ -86,7 +87,7 @@ MainWindow::MainWindow(QWidget *parent)
   
   effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
   effectStackDock->setObjectName("effect_stack");
-  effectStack = new EffectStackView(this);
+  effectStack = new EffectStackView(&m_audioEffects, &m_videoEffects, &m_customEffects,this);
   effectStackDock->setWidget(effectStack);
   addDockWidget(Qt::TopDockWidgetArea, effectStackDock);
   
@@ -136,6 +137,16 @@ MainWindow::MainWindow(QWidget *parent)
   m_timecodeFormat = new KComboBox(this);
   m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
   m_timecodeFormat->addItem(i18n("Frames"));
+
+  statusProgressBar=new QProgressBar(this);
+  statusProgressBar->setMinimum(0);
+  statusProgressBar->setMaximum(100);
+  statusProgressBar->setMaximumWidth(150);
+  statusProgressBar->setVisible(false);
+  statusLabel=new QLabel(this);        
+
+  statusBar()->insertPermanentWidget(0,statusProgressBar,1);
+  statusBar()->insertPermanentWidget(1,statusLabel,1);
   statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
   statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat); 
 
@@ -145,7 +156,7 @@ MainWindow::MainWindow(QWidget *parent)
   connect(clipMonitorDock, SIGNAL(visibilityChanged (bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
   connect(m_monitorManager, SIGNAL(connectMonitors ()), this, SLOT(slotConnectMonitors()));
   connect(m_monitorManager, SIGNAL(raiseClipMonitor (bool)), this, SLOT(slotRaiseMonitor(bool)));
-  connect(m_effectList, SIGNAL(addEffect(int, const QString&)), this, SLOT(slotAddEffect(int, const QString &)));
+  connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
   m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
        
   setAutoSaveSettings();
@@ -167,18 +178,22 @@ bool MainWindow::queryClose()
   }
 }
 
-void MainWindow::slotAddEffect(int effectType, const QString &effectName)
+void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track)
 {
   if (!m_activeDocument) return;
-  QMap <QString, QString> filter;
+  /*QMap <QString, QString> filter;
   if (effectType == 0)
     filter = m_videoEffects.effect(effectName);
   else if (effectType == 1)
     filter = m_audioEffects.effect(effectName);
   else 
-    filter = m_customEffects.effect(effectName);
+    filter = m_customEffects.effect(effectName);*/
+  if (effect.isNull()) {
+    kDebug()<<"--- ERROR, TRYING TO APPEND NULL EFFECT";
+    return;
+  }
   TrackView *currentTimeLine = (TrackView *) m_timelineArea->currentWidget();
-  currentTimeLine->projectView()->slotAddEffect(filter);
+  currentTimeLine->projectView()->slotAddEffect(effect, pos, track);
 }
 
 void MainWindow::slotRaiseMonitor(bool clipMonitor)
@@ -225,6 +240,14 @@ void MainWindow::setupActions()
   profilesAction->setIcon(KIcon("document-new"));
   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"));
+  actionCollection()->addAction("project_settings", projectAction);
+  connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
+
+
  
   KStandardAction::quit(kapp, SLOT(quit()),
                         actionCollection());
@@ -253,12 +276,22 @@ void MainWindow::setupActions()
   KStandardAction::redo(this, SLOT(redo()),
                         actionCollection());*/
 
+  connect(actionCollection(), SIGNAL( actionHighlighted( QAction* ) ), 
+    this, SLOT( slotDisplayActionMessage( QAction* ) ) );
+  //connect(actionCollection(), SIGNAL( clearStatusText() ),
+    //statusBar(), SLOT( clear() ) );
+
   readOptions();  
 
   /*m_redo = m_commandStack->createRedoAction(actionCollection());
   m_undo = m_commandStack->createUndoAction(actionCollection());*/
 }
 
+void MainWindow::slotDisplayActionMessage( QAction *a)
+{
+  statusBar()->showMessage(a->data().toString(), 3000);
+}
+
 void MainWindow::saveOptions()
 {
   KSharedConfigPtr config = KGlobal::config ();
@@ -387,31 +420,21 @@ void MainWindow::parseProfiles()
 
        // Parse MLT profiles to build a list of available video formats
        if (profilesList.isEmpty()) parseProfiles();
-/*
-       uint i = 0;
-       for (; i < profilesList.count(); i++) { 
-           KConfig confFile(profilePath + *profilesList.at(i), true);
-           QString name = confFile.readEntry("description");
-           int width = confFile.readNumEntry("width");
-           int height = confFile.readNumEntry("height");
-           int aspect_num = confFile.readNumEntry("sample_aspect_num");
-           int aspect_den = confFile.readNumEntry("sample_aspect_den");
-           int display_num = confFile.readNumEntry("display_aspect_num");
-           int display_den = confFile.readNumEntry("display_aspect_den");
-           int fps_num = confFile.readNumEntry("frame_rate_num");
-           int fps_den = confFile.readNumEntry("frame_rate_den");
-           int progressive = confFile.readNumEntry("progressive");
-           if (!name.isEmpty()) m_projectTemplates[name] = formatTemplate(width, height, fps_num, fps_den, aspect_num, aspect_den, display_num, display_den, progressive, *profilesList.at(i));
-       }*/
     }
 
 
 void MainWindow::slotEditProfiles()
 {
-  QDialog *w = new QDialog;
-  Ui::ProfilesDialog_UI profilesDialog;
-  profilesDialog.setupUi(w);
+  ProfilesDialog *w = new ProfilesDialog;
   w->exec();
+  delete w;
+}
+
+void MainWindow::slotEditProjectSettings()
+{
+  ProjectSettings *w = new ProjectSettings;
+  w->exec();
+  delete w;
 }
 
 
@@ -439,11 +462,19 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //chang
   connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
   connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
   connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
+  connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView->projectView(), SLOT(setDuration(int)));
   connect(doc, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
   connect(doc, SIGNAL(signalDeleteProjectClip(int)), m_projectList, SLOT(slotDeleteClip(int)));
   connect(doc, SIGNAL(updateClipDisplay(int)), m_projectList, SLOT(slotUpdateClip(int)));
   connect(doc, SIGNAL(deletTimelineClip(int)), trackView, SLOT(slotDeleteClip(int)));
-       connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
+  connect(doc, SIGNAL(thumbsProgress(KUrl, int)), this, SLOT(slotGotProgressInfo(KUrl, int)));
+
+  connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
+  connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement)));
+  connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
+  connect(effectStack, SIGNAL(changeEffectState(ClipItem*, QDomElement, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, QDomElement, bool)));
+  connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
+
   m_projectList->setDocument(doc);
   m_monitorManager->setTimecode(doc->timecode());
   doc->setRenderer(m_projectMonitor->render);
@@ -482,28 +513,21 @@ void MainWindow::slotPreferences()
 
   // KConfigDialog didn't find an instance of this dialog, so lets
   // create it :
-  KConfigDialog* dialog = new KConfigDialog(this, "settings",
-                                          KdenliveSettings::self());
-
-  QWidget *page1 = new QWidget;
-  Ui::ConfigMisc_UI* confWdg = new Ui::ConfigMisc_UI( );
-  confWdg->setupUi(page1);
-  dialog->addPage( page1, i18n("Misc"), "misc" );
-
-  QWidget *page2 = new QWidget;
-  Ui::ConfigEnv_UI* confWdg2 = new Ui::ConfigEnv_UI( );
-  confWdg2->setupUi(page2);
-  confWdg2->kcfg_mltpath->setMode(KFile::Directory);
-
-  //WARNING: the 2 lines below should not be necessary, but does not work without it...
-  confWdg2->kcfg_mltpath->setPath(KdenliveSettings::mltpath());
-  confWdg2->kcfg_rendererpath->setPath(KdenliveSettings::rendererpath());
-  dialog->addPage( page2, i18n("Environnment"), "env" );
-  //User edited the configuration - update your local copies of the
-  //configuration data
-  connect( dialog, SIGNAL(settingsChanged()), this, SLOT(updateConfiguration()) );
-
+  KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
+  //connect( dialog, SIGNAL(settingsChanged()), this, SLOT(updateConfiguration()) );
   dialog->show();
 }
 
+void MainWindow::slotGotProgressInfo( KUrl url, int progress) {
+  statusProgressBar->setValue(progress);
+  if (progress>0) {
+    statusLabel->setText(tr("Creating Audio Thumbs"));
+    statusProgressBar->setVisible(true);
+  }
+  else {
+    statusLabel->setText("");
+    statusProgressBar->setVisible(false);
+  }
+}
+
 #include "mainwindow.moc"