1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
22 #include <QTextStream>
28 #include <KApplication>
31 #include <KActionCollection>
32 #include <KStandardAction>
33 #include <KFileDialog>
34 #include <KMessageBox>
36 #include <KIO/NetAccess>
39 #include <KConfigDialog>
40 #include <KXMLGUIFactory>
42 #include <kstandarddirs.h>
43 #include <KUrlRequesterDialog>
44 #include <KTemporaryFile>
45 #include <ktogglefullscreenaction.h>
47 #include <mlt++/Mlt.h>
49 #include "mainwindow.h"
50 #include "kdenlivesettings.h"
51 #include "kdenlivesettingsdialog.h"
52 #include "initeffects.h"
53 #include "profilesdialog.h"
54 #include "projectsettings.h"
56 #include "renderjob.h"
58 #define ID_STATUS_MSG 1
59 #define ID_EDITMODE_MSG 2
60 #define ID_TIMELINE_MSG 3
61 #define ID_TIMELINE_BUTTONS 5
62 #define ID_TIMELINE_POS 6
63 #define ID_TIMELINE_FORMAT 7
65 MainWindow::MainWindow(QWidget *parent)
66 : KXmlGuiWindow(parent),
67 m_activeDocument(NULL), m_activeTimeline(NULL), m_renderWidget(NULL) {
70 m_commandStack = new QUndoGroup;
71 m_timelineArea = new KTabWidget(this);
72 m_timelineArea->setHoverCloseButton(true);
73 m_timelineArea->setTabReorderingEnabled(true);
74 m_timelineArea->setTabBarHidden(true);
75 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
76 connect(m_timelineArea, SIGNAL(closeRequest(QWidget *)), this, SLOT(closeDocument(QWidget *)));
79 initEffects::parseEffectFiles(&m_audioEffects, &m_videoEffects);
80 m_monitorManager = new MonitorManager();
82 projectListDock = new QDockWidget(i18n("Project Tree"), this);
83 projectListDock->setObjectName("project_tree");
84 m_projectList = new ProjectList(this);
85 projectListDock->setWidget(m_projectList);
86 addDockWidget(Qt::TopDockWidgetArea, projectListDock);
88 effectListDock = new QDockWidget(i18n("Effect List"), this);
89 effectListDock->setObjectName("effect_list");
90 m_effectList = new EffectsListView(&m_audioEffects, &m_videoEffects, &m_customEffects);
92 //m_effectList = new KListWidget(this);
93 effectListDock->setWidget(m_effectList);
94 addDockWidget(Qt::TopDockWidgetArea, effectListDock);
96 effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
97 effectStackDock->setObjectName("effect_stack");
98 effectStack = new EffectStackView(&m_audioEffects, &m_videoEffects, &m_customEffects, this);
99 effectStackDock->setWidget(effectStack);
100 addDockWidget(Qt::TopDockWidgetArea, effectStackDock);
102 transitionConfigDock = new QDockWidget(i18n("Transition"), this);
103 transitionConfigDock->setObjectName("transition");
104 transitionConfig = new KListWidget(this);
105 transitionConfigDock->setWidget(transitionConfig);
106 addDockWidget(Qt::TopDockWidgetArea, transitionConfigDock);
109 clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
110 clipMonitorDock->setObjectName("clip_monitor");
111 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
112 clipMonitorDock->setWidget(m_clipMonitor);
113 addDockWidget(Qt::TopDockWidgetArea, clipMonitorDock);
114 //m_clipMonitor->stop();
116 projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
117 projectMonitorDock->setObjectName("project_monitor");
118 m_projectMonitor = new Monitor("project", m_monitorManager, this);
119 projectMonitorDock->setWidget(m_projectMonitor);
120 addDockWidget(Qt::TopDockWidgetArea, projectMonitorDock);
122 undoViewDock = new QDockWidget(i18n("Undo History"), this);
123 undoViewDock->setObjectName("undo_history");
124 m_undoView = new QUndoView(this);
125 m_undoView->setCleanIcon(KIcon("edit-clear"));
126 m_undoView->setEmptyLabel(i18n("Clean"));
127 undoViewDock->setWidget(m_undoView);
128 m_undoView->setGroup(m_commandStack);
129 addDockWidget(Qt::TopDockWidgetArea, undoViewDock);
131 overviewDock = new QDockWidget(i18n("Project Overview"), this);
132 overviewDock->setObjectName("project_overview");
133 m_overView = new CustomTrackView(NULL, NULL, this);
134 overviewDock->setWidget(m_overView);
135 addDockWidget(Qt::TopDockWidgetArea, overviewDock);
138 tabifyDockWidget(projectListDock, effectListDock);
139 tabifyDockWidget(projectListDock, effectStackDock);
140 tabifyDockWidget(projectListDock, transitionConfigDock);
141 tabifyDockWidget(projectListDock, undoViewDock);
142 projectListDock->raise();
144 tabifyDockWidget(clipMonitorDock, projectMonitorDock);
145 setCentralWidget(m_timelineArea);
147 m_timecodeFormat = new KComboBox(this);
148 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
149 m_timecodeFormat->addItem(i18n("Frames"));
151 statusProgressBar = new QProgressBar(this);
152 statusProgressBar->setMinimum(0);
153 statusProgressBar->setMaximum(100);
154 statusProgressBar->setMaximumWidth(150);
155 statusProgressBar->setVisible(false);
156 statusLabel = new QLabel(this);
158 QWidget *w = new QWidget;
159 timeline_buttons_ui.setupUi(w);
160 timeline_buttons_ui.buttonVideo->setDown(KdenliveSettings::videothumbnails());
161 timeline_buttons_ui.buttonAudio->setDown(KdenliveSettings::audiothumbnails());
162 connect(timeline_buttons_ui.buttonVideo, SIGNAL(clicked()), this, SLOT(slotSwitchVideoThumbs()));
163 connect(timeline_buttons_ui.buttonAudio, SIGNAL(clicked()), this, SLOT(slotSwitchAudioThumbs()));
165 statusBar()->insertPermanentWidget(0, statusProgressBar, 1);
166 statusBar()->insertPermanentWidget(1, statusLabel, 1);
167 statusBar()->insertPermanentWidget(ID_TIMELINE_BUTTONS, w);
168 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
169 statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat);
170 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
172 timeline_buttons_ui.buttonVideo->setIcon(KIcon("display-video"));
173 timeline_buttons_ui.buttonVideo->setToolTip(i18n("Show video thumbnails"));
174 timeline_buttons_ui.buttonAudio->setIcon(KIcon("display-audio"));
175 timeline_buttons_ui.buttonAudio->setToolTip(i18n("Show audio thumbnails"));
177 setupGUI(Default, "kdenliveui.rc");
179 connect(projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
180 connect(clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
181 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
182 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
183 connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
184 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
185 slotConnectMonitors();
187 setAutoSaveSettings();
192 bool MainWindow::queryClose() {
194 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
195 case KMessageBox::Yes :
196 // save document here. If saving fails, return false;
198 case KMessageBox::No :
205 void MainWindow::slotFullScreen() {
206 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
209 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track) {
210 if (!m_activeDocument) return;
211 if (effect.isNull()) {
212 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
215 TrackView *currentTimeLine = (TrackView *) m_timelineArea->currentWidget();
216 currentTimeLine->projectView()->slotAddEffect(effect, pos, track);
219 void MainWindow::slotRaiseMonitor(bool clipMonitor) {
220 if (clipMonitor) clipMonitorDock->raise();
221 else projectMonitorDock->raise();
224 void MainWindow::slotSetClipDuration(int id, int duration) {
225 if (!m_activeDocument) return;
226 m_activeDocument->setProducerDuration(id, duration);
229 void MainWindow::slotConnectMonitors() {
231 m_projectList->setRenderer(m_clipMonitor->render);
232 connect(m_projectList, SIGNAL(clipSelected(const QDomElement &)), m_clipMonitor, SLOT(slotSetXml(const QDomElement &)));
233 connect(m_projectList, SIGNAL(receivedClipDuration(int, int)), this, SLOT(slotSetClipDuration(int, int)));
234 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, int)), m_clipMonitor->render, SLOT(getFileProperties(const QDomElement &, int)));
235 connect(m_clipMonitor->render, SIGNAL(replyGetImage(int, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(int, int, const QPixmap &, int, int)));
236 connect(m_clipMonitor->render, SIGNAL(replyGetFileProperties(int, const QMap < QString, QString > &, const QMap < QString, QString > &)), m_projectList, SLOT(slotReplyGetFileProperties(int, const QMap < QString, QString > &, const QMap < QString, QString > &)));
239 void MainWindow::setupActions() {
240 KAction* clearAction = new KAction(this);
241 clearAction->setText(i18n("Clear"));
242 clearAction->setIcon(KIcon("document-new"));
243 clearAction->setShortcut(Qt::CTRL + Qt::Key_W);
244 actionCollection()->addAction("clear", clearAction);
245 /*connect(clearAction, SIGNAL(triggered(bool)),
246 textArea, SLOT(clear()));*/
248 KAction* profilesAction = new KAction(this);
249 profilesAction->setText(i18n("Manage Profiles"));
250 profilesAction->setIcon(KIcon("document-new"));
251 actionCollection()->addAction("manage_profiles", profilesAction);
252 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
254 KAction* projectAction = new KAction(this);
255 projectAction->setText(i18n("Project Settings"));
256 projectAction->setIcon(KIcon("document-new"));
257 actionCollection()->addAction("project_settings", projectAction);
258 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
260 KAction* projectRender = new KAction(this);
261 projectRender->setText(i18n("Render Project"));
262 projectRender->setIcon(KIcon("document-new"));
263 actionCollection()->addAction("project_render", projectRender);
264 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
266 KAction* monitorPlay = new KAction(this);
267 monitorPlay->setText(i18n("Play"));
268 monitorPlay->setIcon(KIcon("media-playback-start"));
269 monitorPlay->setShortcut(Qt::Key_Space);
270 actionCollection()->addAction("monitor_play", monitorPlay);
271 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
273 KStandardAction::quit(kapp, SLOT(quit()),
276 KStandardAction::open(this, SLOT(openFile()),
279 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
282 KStandardAction::save(this, SLOT(saveFile()),
285 KStandardAction::saveAs(this, SLOT(saveFileAs()),
288 KStandardAction::openNew(this, SLOT(newFile()),
291 KStandardAction::preferences(this, SLOT(slotPreferences()),
294 KStandardAction::undo(this, SLOT(undo()),
297 KStandardAction::redo(this, SLOT(redo()),
300 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, actionCollection());
302 connect(actionCollection(), SIGNAL(actionHovered(QAction*)),
303 this, SLOT(slotDisplayActionMessage(QAction*)));
304 //connect(actionCollection(), SIGNAL( clearStatusText() ),
305 //statusBar(), SLOT( clear() ) );
310 void MainWindow::undo() {
311 m_commandStack->undo();
314 void MainWindow::redo() {
315 m_commandStack->redo();
318 void MainWindow::slotDisplayActionMessage(QAction *a) {
319 statusBar()->showMessage(a->data().toString(), 3000);
322 void MainWindow::saveOptions() {
323 KSharedConfigPtr config = KGlobal::config();
324 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
328 void MainWindow::readOptions() {
329 KSharedConfigPtr config = KGlobal::config();
330 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
333 void MainWindow::newFile() {
335 if (m_timelineArea->count() == 0) profileName = KdenliveSettings::default_profile();
337 ProjectSettings *w = new ProjectSettings;
339 profileName = w->selectedProfile();
342 MltVideoProfile prof = ProfilesDialog::getVideoProfile(profileName);
343 if (prof.width == 0) prof = ProfilesDialog::getVideoProfile("dv_pal");
344 KdenliveDoc *doc = new KdenliveDoc(KUrl(), prof, m_commandStack);
345 TrackView *trackView = new TrackView(doc);
346 m_timelineArea->addTab(trackView, KIcon("kdenlive"), i18n("Untitled") + " / " + prof.description);
347 if (m_timelineArea->count() == 1)
348 connectDocument(trackView, doc);
349 else m_timelineArea->setTabBarHidden(false);
352 void MainWindow::activateDocument() {
353 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
354 KdenliveDoc *currentDoc = currentTab->document();
355 connectDocument(currentTab, currentDoc);
358 void MainWindow::closeDocument(QWidget *w) {
359 if (w == m_timelineArea->currentWidget()) {
360 // closing current document
361 int ix = m_timelineArea->currentIndex() + 1;
362 if (ix == m_timelineArea->count()) ix = 0;
363 m_timelineArea->setCurrentIndex(ix);
366 TrackView *tabToClose = (TrackView *) w;
367 KdenliveDoc *docToClose = tabToClose->document();
368 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
373 void MainWindow::saveFileAs(const QString &outputFileName) {
374 m_projectMonitor->saveSceneList(outputFileName, m_activeDocument->documentInfoXml());
375 m_activeDocument->setUrl(KUrl(outputFileName));
376 setCaption(m_activeDocument->description());
377 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
378 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
381 void MainWindow::saveFileAs() {
382 QString outputFile = KFileDialog::getSaveFileName();
383 if (QFile::exists(outputFile)) {
384 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) == KMessageBox::No) return;
386 saveFileAs(outputFile);
389 void MainWindow::saveFile() {
390 if (!m_activeDocument) return;
391 if (m_activeDocument->url().isEmpty()) {
394 saveFileAs(m_activeDocument->url().path());
398 void MainWindow::openFile() { //changed
399 KUrl url = KFileDialog::getOpenUrl(KUrl(), "application/vnd.kde.kdenlive;*.kdenlive");
400 if (url.isEmpty()) return;
401 m_fileOpenRecent->addUrl(url);
405 void MainWindow::openFile(const KUrl &url) { //new
406 //TODO: get video profile from url before opening it
407 MltVideoProfile prof = ProfilesDialog::getVideoProfile(KdenliveSettings::default_profile());
408 if (prof.width == 0) prof = ProfilesDialog::getVideoProfile("dv_pal");
409 KdenliveDoc *doc = new KdenliveDoc(url, prof, m_commandStack);
410 TrackView *trackView = new TrackView(doc);
411 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
412 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
413 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
414 //connectDocument(trackView, doc);
418 void MainWindow::parseProfiles() {
419 //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
420 if (KdenliveSettings::mltpath().isEmpty()) {
421 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
423 if (KdenliveSettings::rendererpath().isEmpty()) {
424 KdenliveSettings::setRendererpath(KStandardDirs::findExe("inigo"));
426 QStringList profilesFilter;
427 profilesFilter << "*";
428 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
430 if (profilesList.isEmpty()) {
431 // Cannot find MLT path, try finding inigo
432 QString profilePath = KdenliveSettings::rendererpath();
433 if (!profilePath.isEmpty()) {
434 profilePath = profilePath.section('/', 0, -3);
435 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
436 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
439 if (profilesList.isEmpty()) {
440 // Cannot find the MLT profiles, ask for location
441 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
442 getUrl->fileDialog()->setMode(KFile::Directory);
444 KUrl mltPath = getUrl->selectedUrl();
446 if (mltPath.isEmpty()) exit(1);
447 KdenliveSettings::setMltpath(mltPath.path());
448 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
452 if (KdenliveSettings::rendererpath().isEmpty()) {
453 // Cannot find the MLT inigo renderer, ask for location
454 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
456 KUrl rendererPath = getUrl->selectedUrl();
458 if (rendererPath.isEmpty()) exit(1);
459 KdenliveSettings::setRendererpath(rendererPath.path());
462 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
464 // Parse MLT profiles to build a list of available video formats
465 if (profilesList.isEmpty()) parseProfiles();
469 void MainWindow::slotEditProfiles() {
470 ProfilesDialog *w = new ProfilesDialog;
475 void MainWindow::slotEditProjectSettings() {
476 ProjectSettings *w = new ProjectSettings;
477 if (w->exec() == QDialog::Accepted) {
478 QString profile = w->selectedProfile();
479 m_activeDocument->setProfilePath(profile);
480 m_monitorManager->resetProfiles(profile);
481 setCaption(m_activeDocument->description());
482 KdenliveSettings::setCurrent_profile(m_activeDocument->profilePath());
483 if (m_renderWidget) m_renderWidget->setDocumentStandard(m_activeDocument->getDocumentStandard());
484 m_monitorManager->setTimecode(m_activeDocument->timecode());
485 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
487 // We need to desactivate & reactivate monitors to get a refresh
488 m_monitorManager->switchMonitors();
493 void MainWindow::slotRenderProject() {
494 if (!m_renderWidget) {
495 m_renderWidget = new RenderWidget(this);
496 connect(m_renderWidget, SIGNAL(doRender(const QString&, const QString&, const QStringList &, bool, bool)), this, SLOT(slotDoRender(const QString&, const QString&, const QStringList &, bool, bool)));
498 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
499 if (currentTab) m_renderWidget->setTimeline(currentTab);
500 m_renderWidget->setDocument(m_activeDocument);*/
501 m_renderWidget->show();
504 void MainWindow::slotDoRender(const QString &dest, const QString &render, const QStringList &avformat_args, bool zoneOnly, bool playAfter) {
505 if (dest.isEmpty()) return;
508 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
509 if (currentTab && zoneOnly) {
510 in = currentTab->inPoint();
511 out = currentTab->outPoint();
514 temp.setAutoRemove(false);
515 temp.setSuffix(".westley");
517 m_projectMonitor->saveSceneList(temp.fileName());
520 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
521 QString videoPlayer = "-";
522 if (playAfter) videoPlayer = "kmplayer";
523 args << "inigo" << render << videoPlayer << temp.fileName() << dest << avformat_args;
524 QProcess::startDetached("kdenlive_render", args);
528 void MainWindow::slotUpdateMousePosition(int pos) {
529 if (m_activeDocument)
530 switch (m_timecodeFormat->currentIndex()) {
532 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
535 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
539 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //changed
540 //m_projectMonitor->stop();
541 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
542 if (m_activeDocument) {
543 if (m_activeDocument == doc) return;
544 m_activeDocument->backupMltPlaylist();
545 if (m_activeTimeline) {
546 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
547 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline->projectView(), SLOT(setDuration(int)));
548 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
549 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(int)), m_projectList, SLOT(slotDeleteClip(int)));
550 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(int)), m_projectList, SLOT(slotUpdateClip(int)));
551 disconnect(m_activeDocument, SIGNAL(deletTimelineClip(int)), m_activeTimeline, SLOT(slotDeleteClip(int)));
552 disconnect(m_activeDocument, SIGNAL(thumbsProgress(KUrl, int)), this, SLOT(slotGotProgressInfo(KUrl, int)));
553 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
554 disconnect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement)));
555 disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
556 disconnect(effectStack, SIGNAL(changeEffectState(ClipItem*, QDomElement, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, QDomElement, bool)));
557 disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
558 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
560 m_activeDocument->setRenderer(NULL);
561 disconnect(m_projectList, SIGNAL(clipSelected(const QDomElement &)), m_clipMonitor, SLOT(slotSetXml(const QDomElement &)));
562 m_clipMonitor->stop();
564 m_monitorManager->resetProfiles(doc->profilePath());
565 m_projectList->setDocument(doc);
566 connect(m_projectList, SIGNAL(clipSelected(const QDomElement &)), m_clipMonitor, SLOT(slotSetXml(const QDomElement &)));
567 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
568 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
569 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
570 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView->projectView(), SLOT(setDuration(int)));
571 connect(doc, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
572 connect(doc, SIGNAL(signalDeleteProjectClip(int)), m_projectList, SLOT(slotDeleteClip(int)));
573 connect(doc, SIGNAL(updateClipDisplay(int)), m_projectList, SLOT(slotUpdateClip(int)));
574 connect(doc, SIGNAL(deletTimelineClip(int)), trackView, SLOT(slotDeleteClip(int)));
575 connect(doc, SIGNAL(thumbsProgress(KUrl, int)), this, SLOT(slotGotProgressInfo(KUrl, int)));
577 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
578 connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement)));
579 connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
580 connect(effectStack, SIGNAL(changeEffectState(ClipItem*, QDomElement, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, QDomElement, bool)));
581 connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
582 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
585 m_activeTimeline = trackView;
586 KdenliveSettings::setCurrent_profile(doc->profilePath());
587 if (m_renderWidget) m_renderWidget->setDocumentStandard(doc->getDocumentStandard());
588 m_monitorManager->setTimecode(doc->timecode());
589 doc->setRenderer(m_projectMonitor->render);
590 m_commandStack->setActiveStack(doc->commandStack());
592 m_overView->setScene(trackView->projectScene());
593 m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
594 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
596 setCaption(doc->description());
597 m_activeDocument = doc;
600 void MainWindow::slotPreferences() {
601 //An instance of your dialog could be already created and could be
602 // cached, in which case you want to display the cached dialog
603 // instead of creating another one
604 if (KConfigDialog::showDialog("settings"))
607 // KConfigDialog didn't find an instance of this dialog, so lets
609 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
610 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
614 void MainWindow::updateConfiguration() {
615 //TODO: we should apply settings to all projects, not only the current one
616 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
618 currentTab->refresh();
619 currentTab->projectView()->checkAutoScroll();
620 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
622 timeline_buttons_ui.buttonAudio->setDown(KdenliveSettings::audiothumbnails());
623 timeline_buttons_ui.buttonVideo->setDown(KdenliveSettings::videothumbnails());
626 void MainWindow::slotSwitchVideoThumbs() {
627 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
628 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
630 currentTab->refresh();
632 timeline_buttons_ui.buttonVideo->setDown(KdenliveSettings::videothumbnails());
635 void MainWindow::slotSwitchAudioThumbs() {
636 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
637 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
639 currentTab->refresh();
640 currentTab->projectView()->checkAutoScroll();
641 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
643 timeline_buttons_ui.buttonAudio->setDown(KdenliveSettings::audiothumbnails());
646 void MainWindow::slotGotProgressInfo(KUrl url, int progress) {
647 statusProgressBar->setValue(progress);
649 statusLabel->setText(tr("Creating Audio Thumbs"));
650 statusProgressBar->setVisible(true);
652 statusLabel->setText("");
653 statusProgressBar->setVisible(false);
657 #include "mainwindow.moc"