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 <kuiserverjobtracker.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 fileName(QString()), 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::slotAddEffect(QDomElement effect, GenTime pos, int track) {
206 if (!m_activeDocument) return;
207 if (effect.isNull()) {
208 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
211 TrackView *currentTimeLine = (TrackView *) m_timelineArea->currentWidget();
212 currentTimeLine->projectView()->slotAddEffect(effect, pos, track);
215 void MainWindow::slotRaiseMonitor(bool clipMonitor) {
216 if (clipMonitor) clipMonitorDock->raise();
217 else projectMonitorDock->raise();
220 void MainWindow::slotSetClipDuration(int id, int duration) {
221 if (!m_activeDocument) return;
222 m_activeDocument->setProducerDuration(id, duration);
225 void MainWindow::slotConnectMonitors() {
227 m_projectList->setRenderer(m_clipMonitor->render);
228 connect(m_projectList, SIGNAL(clipSelected(const QDomElement &)), m_clipMonitor, SLOT(slotSetXml(const QDomElement &)));
229 connect(m_projectList, SIGNAL(receivedClipDuration(int, int)), this, SLOT(slotSetClipDuration(int, int)));
230 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, int)), m_clipMonitor->render, SLOT(getFileProperties(const QDomElement &, int)));
231 connect(m_clipMonitor->render, SIGNAL(replyGetImage(int, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(int, int, const QPixmap &, int, int)));
232 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 > &)));
235 void MainWindow::setupActions() {
236 KAction* clearAction = new KAction(this);
237 clearAction->setText(i18n("Clear"));
238 clearAction->setIcon(KIcon("document-new"));
239 clearAction->setShortcut(Qt::CTRL + Qt::Key_W);
240 actionCollection()->addAction("clear", clearAction);
241 /*connect(clearAction, SIGNAL(triggered(bool)),
242 textArea, SLOT(clear()));*/
244 KAction* profilesAction = new KAction(this);
245 profilesAction->setText(i18n("Manage Profiles"));
246 profilesAction->setIcon(KIcon("document-new"));
247 actionCollection()->addAction("manage_profiles", profilesAction);
248 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
250 KAction* projectAction = new KAction(this);
251 projectAction->setText(i18n("Project Settings"));
252 projectAction->setIcon(KIcon("document-new"));
253 actionCollection()->addAction("project_settings", projectAction);
254 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
256 KAction* projectRender = new KAction(this);
257 projectRender->setText(i18n("Render Project"));
258 projectRender->setIcon(KIcon("document-new"));
259 actionCollection()->addAction("project_render", projectRender);
260 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
262 KAction* monitorPlay = new KAction(this);
263 monitorPlay->setText(i18n("Play"));
264 monitorPlay->setIcon(KIcon("media-playback-start"));
265 monitorPlay->setShortcut(Qt::Key_Space);
266 actionCollection()->addAction("monitor_play", monitorPlay);
267 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
269 KStandardAction::quit(kapp, SLOT(quit()),
272 KStandardAction::open(this, SLOT(openFile()),
275 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
278 KStandardAction::save(this, SLOT(saveFile()),
281 KStandardAction::saveAs(this, SLOT(saveFileAs()),
284 KStandardAction::openNew(this, SLOT(newFile()),
287 KStandardAction::preferences(this, SLOT(slotPreferences()),
290 KStandardAction::undo(this, SLOT(undo()),
293 KStandardAction::redo(this, SLOT(redo()),
296 connect(actionCollection(), SIGNAL(actionHighlighted(QAction*)),
297 this, SLOT(slotDisplayActionMessage(QAction*)));
298 //connect(actionCollection(), SIGNAL( clearStatusText() ),
299 //statusBar(), SLOT( clear() ) );
304 void MainWindow::undo() {
305 m_commandStack->undo();
308 void MainWindow::redo() {
309 m_commandStack->redo();
312 void MainWindow::slotDisplayActionMessage(QAction *a) {
313 statusBar()->showMessage(a->data().toString(), 3000);
316 void MainWindow::saveOptions() {
317 KSharedConfigPtr config = KGlobal::config();
318 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
322 void MainWindow::readOptions() {
323 KSharedConfigPtr config = KGlobal::config();
324 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
327 void MainWindow::newFile() {
329 if (m_timelineArea->count() == 0) profileName = KdenliveSettings::default_profile();
331 ProjectSettings *w = new ProjectSettings;
333 profileName = w->selectedProfile();
336 MltVideoProfile prof = ProfilesDialog::getVideoProfile(profileName);
337 if (prof.width == 0) prof = ProfilesDialog::getVideoProfile("dv_pal");
338 KdenliveDoc *doc = new KdenliveDoc(KUrl(), prof, m_commandStack);
339 TrackView *trackView = new TrackView(doc);
340 m_timelineArea->addTab(trackView, KIcon("kdenlive"), i18n("Untitled") + " / " + prof.description);
341 if (m_timelineArea->count() == 1)
342 connectDocument(trackView, doc);
343 else m_timelineArea->setTabBarHidden(false);
346 void MainWindow::activateDocument() {
347 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
348 KdenliveDoc *currentDoc = currentTab->document();
349 connectDocument(currentTab, currentDoc);
352 void MainWindow::closeDocument(QWidget *w) {
353 if (w == m_timelineArea->currentWidget()) {
354 // closing current document
355 int ix = m_timelineArea->currentIndex() + 1;
356 if (ix == m_timelineArea->count()) ix = 0;
357 m_timelineArea->setCurrentIndex(ix);
360 TrackView *tabToClose = (TrackView *) w;
361 KdenliveDoc *docToClose = tabToClose->document();
362 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
367 void MainWindow::saveFileAs(const QString &outputFileName) {
368 KSaveFile file(outputFileName);
371 QByteArray outputByteArray;
372 //outputByteArray.append(textArea->toPlainText());
373 file.write(outputByteArray);
377 fileName = outputFileName;
380 void MainWindow::saveFileAs() {
381 saveFileAs(KFileDialog::getSaveFileName());
384 void MainWindow::saveFile() {
385 if (!fileName.isEmpty()) {
386 saveFileAs(fileName);
392 void MainWindow::openFile() { //changed
393 KUrl url = KFileDialog::getOpenUrl(KUrl(), "application/vnd.kde.kdenlive;*.kdenlive");
394 if (url.isEmpty()) return;
395 m_fileOpenRecent->addUrl(url);
399 void MainWindow::openFile(const KUrl &url) { //new
400 //TODO: get video profile from url before opening it
401 MltVideoProfile prof = ProfilesDialog::getVideoProfile(KdenliveSettings::default_profile());
402 if (prof.width == 0) prof = ProfilesDialog::getVideoProfile("dv_pal");
403 KdenliveDoc *doc = new KdenliveDoc(url, prof, m_commandStack);
404 TrackView *trackView = new TrackView(doc);
405 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
406 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
407 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
408 //connectDocument(trackView, doc);
412 void MainWindow::parseProfiles() {
413 //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
414 if (KdenliveSettings::mltpath().isEmpty()) {
415 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
417 if (KdenliveSettings::rendererpath().isEmpty()) {
418 KdenliveSettings::setRendererpath(KStandardDirs::findExe("inigo"));
420 QStringList profilesFilter;
421 profilesFilter << "*";
422 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
424 if (profilesList.isEmpty()) {
425 // Cannot find MLT path, try finding inigo
426 QString profilePath = KdenliveSettings::rendererpath();
427 if (!profilePath.isEmpty()) {
428 profilePath = profilePath.section('/', 0, -3);
429 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
430 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
433 if (profilesList.isEmpty()) {
434 // Cannot find the MLT profiles, ask for location
435 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
436 getUrl->fileDialog()->setMode(KFile::Directory);
438 KUrl mltPath = getUrl->selectedUrl();
440 if (mltPath.isEmpty()) exit(1);
441 KdenliveSettings::setMltpath(mltPath.path());
442 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
446 if (KdenliveSettings::rendererpath().isEmpty()) {
447 // Cannot find the MLT inigo renderer, ask for location
448 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
450 KUrl rendererPath = getUrl->selectedUrl();
452 if (rendererPath.isEmpty()) exit(1);
453 KdenliveSettings::setRendererpath(rendererPath.path());
456 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
458 // Parse MLT profiles to build a list of available video formats
459 if (profilesList.isEmpty()) parseProfiles();
463 void MainWindow::slotEditProfiles() {
464 ProfilesDialog *w = new ProfilesDialog;
469 void MainWindow::slotEditProjectSettings() {
470 ProjectSettings *w = new ProjectSettings;
475 void MainWindow::slotRenderProject() {
476 if (!m_renderWidget) {
477 m_renderWidget = new RenderWidget(this);
478 connect(m_renderWidget, SIGNAL(doRender(const QString&, const QStringList &, bool, bool)), this, SLOT(slotDoRender(const QString&, const QStringList &, bool, bool)));
480 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
481 if (currentTab) m_renderWidget->setTimeline(currentTab);
482 m_renderWidget->setDocument(m_activeDocument);*/
483 m_renderWidget->show();
486 void MainWindow::slotDoRender(const QString &dest, const QStringList &args, bool zoneOnly, bool playAfter) {
487 if (dest.isEmpty()) return;
490 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
491 if (currentTab && zoneOnly) {
492 in = currentTab->inPoint();
493 out = currentTab->outPoint();
496 temp.setAutoRemove(false);
497 temp.setSuffix(".westley");
499 m_projectMonitor->saveSceneList(temp.fileName());
502 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
503 QString videoPlayer = "-";
504 if (playAfter) videoPlayer = "kmplayer";
505 args << "inigo" << videoPlayer << temp.fileName() << dest;
506 QProcess::startDetached("kdenlive_render", args);
510 void MainWindow::slotUpdateMousePosition(int pos) {
511 if (m_activeDocument)
512 switch (m_timecodeFormat->currentIndex()) {
514 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
517 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
521 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //changed
522 //m_projectMonitor->stop();
523 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
524 if (m_activeDocument) {
525 if (m_activeDocument == doc) return;
526 m_activeDocument->backupMltPlaylist();
527 if (m_activeTimeline) {
528 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
529 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline->projectView(), SLOT(setDuration(int)));
530 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
531 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(int)), m_projectList, SLOT(slotDeleteClip(int)));
532 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(int)), m_projectList, SLOT(slotUpdateClip(int)));
533 disconnect(m_activeDocument, SIGNAL(deletTimelineClip(int)), m_activeTimeline, SLOT(slotDeleteClip(int)));
534 disconnect(m_activeDocument, SIGNAL(thumbsProgress(KUrl, int)), this, SLOT(slotGotProgressInfo(KUrl, int)));
535 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
536 disconnect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement)));
537 disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
538 disconnect(effectStack, SIGNAL(changeEffectState(ClipItem*, QDomElement, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, QDomElement, bool)));
539 disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
541 m_activeDocument->setRenderer(NULL);
542 disconnect(m_projectList, SIGNAL(clipSelected(const QDomElement &)), m_clipMonitor, SLOT(slotSetXml(const QDomElement &)));
543 m_clipMonitor->stop();
545 m_monitorManager->resetProfiles(doc->profilePath());
546 m_projectList->setDocument(doc);
547 connect(m_projectList, SIGNAL(clipSelected(const QDomElement &)), m_clipMonitor, SLOT(slotSetXml(const QDomElement &)));
548 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
549 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
550 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
551 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView->projectView(), SLOT(setDuration(int)));
552 connect(doc, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
553 connect(doc, SIGNAL(signalDeleteProjectClip(int)), m_projectList, SLOT(slotDeleteClip(int)));
554 connect(doc, SIGNAL(updateClipDisplay(int)), m_projectList, SLOT(slotUpdateClip(int)));
555 connect(doc, SIGNAL(deletTimelineClip(int)), trackView, SLOT(slotDeleteClip(int)));
556 connect(doc, SIGNAL(thumbsProgress(KUrl, int)), this, SLOT(slotGotProgressInfo(KUrl, int)));
558 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
559 connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement)));
560 connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
561 connect(effectStack, SIGNAL(changeEffectState(ClipItem*, QDomElement, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, QDomElement, bool)));
562 connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
563 m_activeTimeline = trackView;
565 m_monitorManager->setTimecode(doc->timecode());
566 doc->setRenderer(m_projectMonitor->render);
567 m_commandStack->setActiveStack(doc->commandStack());
569 m_overView->setScene(trackView->projectScene());
570 m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
571 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
573 setCaption(doc->description());
574 m_activeDocument = doc;
577 void MainWindow::slotPreferences() {
578 //An instance of your dialog could be already created and could be
579 // cached, in which case you want to display the cached dialog
580 // instead of creating another one
581 if (KConfigDialog::showDialog("settings"))
584 // KConfigDialog didn't find an instance of this dialog, so lets
586 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
587 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
591 void MainWindow::updateConfiguration() {
592 //TODO: we should apply settings to all projects, not only the current one
593 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
595 currentTab->refresh();
596 currentTab->projectView()->checkAutoScroll();
597 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
599 timeline_buttons_ui.buttonAudio->setDown(KdenliveSettings::audiothumbnails());
600 timeline_buttons_ui.buttonVideo->setDown(KdenliveSettings::videothumbnails());
603 void MainWindow::slotSwitchVideoThumbs() {
604 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
605 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
607 currentTab->refresh();
609 timeline_buttons_ui.buttonVideo->setDown(KdenliveSettings::videothumbnails());
612 void MainWindow::slotSwitchAudioThumbs() {
613 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
614 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
616 currentTab->refresh();
617 currentTab->projectView()->checkAutoScroll();
618 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
620 timeline_buttons_ui.buttonAudio->setDown(KdenliveSettings::audiothumbnails());
623 void MainWindow::slotGotProgressInfo(KUrl url, int progress) {
624 statusProgressBar->setValue(progress);
626 statusLabel->setText(tr("Creating Audio Thumbs"));
627 statusProgressBar->setVisible(true);
629 statusLabel->setText("");
630 statusProgressBar->setVisible(false);
634 #include "mainwindow.moc"