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>
45 #include <mlt++/Mlt.h>
47 #include "mainwindow.h"
48 #include "kdenlivesettings.h"
49 #include "kdenlivesettingsdialog.h"
50 #include "initeffects.h"
51 #include "profilesdialog.h"
52 #include "projectsettings.h"
55 #define ID_STATUS_MSG 1
56 #define ID_EDITMODE_MSG 2
57 #define ID_TIMELINE_MSG 3
58 #define ID_TIMELINE_BUTTONS 4
59 #define ID_TIMELINE_POS 5
60 #define ID_TIMELINE_FORMAT 6
62 MainWindow::MainWindow(QWidget *parent)
63 : KXmlGuiWindow(parent),
64 fileName(QString()), m_activeDocument(NULL), m_activeTimeline(NULL) {
67 m_commandStack = new QUndoGroup;
68 m_timelineArea = new KTabWidget(this);
69 m_timelineArea->setHoverCloseButton(true);
70 m_timelineArea->setTabReorderingEnabled(true);
71 m_timelineArea->setTabBarHidden(true);
72 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
73 connect(m_timelineArea, SIGNAL(closeRequest(QWidget *)), this, SLOT(closeDocument(QWidget *)));
76 initEffects::parseEffectFiles(&m_audioEffects, &m_videoEffects);
77 m_monitorManager = new MonitorManager();
79 projectListDock = new QDockWidget(i18n("Project Tree"), this);
80 projectListDock->setObjectName("project_tree");
81 m_projectList = new ProjectList(this);
82 projectListDock->setWidget(m_projectList);
83 addDockWidget(Qt::TopDockWidgetArea, projectListDock);
85 effectListDock = new QDockWidget(i18n("Effect List"), this);
86 effectListDock->setObjectName("effect_list");
87 m_effectList = new EffectsListView(&m_audioEffects, &m_videoEffects, &m_customEffects);
89 //m_effectList = new KListWidget(this);
90 effectListDock->setWidget(m_effectList);
91 addDockWidget(Qt::TopDockWidgetArea, effectListDock);
93 effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
94 effectStackDock->setObjectName("effect_stack");
95 effectStack = new EffectStackView(&m_audioEffects, &m_videoEffects, &m_customEffects, this);
96 effectStackDock->setWidget(effectStack);
97 addDockWidget(Qt::TopDockWidgetArea, effectStackDock);
99 transitionConfigDock = new QDockWidget(i18n("Transition"), this);
100 transitionConfigDock->setObjectName("transition");
101 transitionConfig = new KListWidget(this);
102 transitionConfigDock->setWidget(transitionConfig);
103 addDockWidget(Qt::TopDockWidgetArea, transitionConfigDock);
106 clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
107 clipMonitorDock->setObjectName("clip_monitor");
108 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
109 clipMonitorDock->setWidget(m_clipMonitor);
110 addDockWidget(Qt::TopDockWidgetArea, clipMonitorDock);
111 //m_clipMonitor->stop();
113 projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
114 projectMonitorDock->setObjectName("project_monitor");
115 m_projectMonitor = new Monitor("project", m_monitorManager, this);
116 projectMonitorDock->setWidget(m_projectMonitor);
117 addDockWidget(Qt::TopDockWidgetArea, projectMonitorDock);
119 undoViewDock = new QDockWidget(i18n("Undo History"), this);
120 undoViewDock->setObjectName("undo_history");
121 m_undoView = new QUndoView(this);
122 m_undoView->setCleanIcon(KIcon("edit-clear"));
123 m_undoView->setEmptyLabel(i18n("Clean"));
124 undoViewDock->setWidget(m_undoView);
125 m_undoView->setGroup(m_commandStack);
126 addDockWidget(Qt::TopDockWidgetArea, undoViewDock);
128 overviewDock = new QDockWidget(i18n("Project Overview"), this);
129 overviewDock->setObjectName("project_overview");
130 m_overView = new CustomTrackView(NULL, NULL, this);
131 overviewDock->setWidget(m_overView);
132 addDockWidget(Qt::TopDockWidgetArea, overviewDock);
135 tabifyDockWidget(projectListDock, effectListDock);
136 tabifyDockWidget(projectListDock, effectStackDock);
137 tabifyDockWidget(projectListDock, transitionConfigDock);
138 tabifyDockWidget(projectListDock, undoViewDock);
139 projectListDock->raise();
141 tabifyDockWidget(clipMonitorDock, projectMonitorDock);
142 setCentralWidget(m_timelineArea);
144 m_timecodeFormat = new KComboBox(this);
145 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
146 m_timecodeFormat->addItem(i18n("Frames"));
148 statusProgressBar = new QProgressBar(this);
149 statusProgressBar->setMinimum(0);
150 statusProgressBar->setMaximum(100);
151 statusProgressBar->setMaximumWidth(150);
152 statusProgressBar->setVisible(false);
153 statusLabel = new QLabel(this);
155 QWidget *w = new QWidget;
156 timeline_buttons_ui.setupUi(w);
157 timeline_buttons_ui.buttonVideo->setDown(KdenliveSettings::videothumbnails());
158 timeline_buttons_ui.buttonAudio->setDown(KdenliveSettings::audiothumbnails());
159 connect(timeline_buttons_ui.buttonVideo, SIGNAL(clicked()), this, SLOT(slotSwitchVideoThumbs()));
160 connect(timeline_buttons_ui.buttonAudio, SIGNAL(clicked()), this, SLOT(slotSwitchAudioThumbs()));
162 statusBar()->insertPermanentWidget(0, statusProgressBar, 1);
163 statusBar()->insertPermanentWidget(1, statusLabel, 1);
164 statusBar()->insertPermanentWidget(ID_TIMELINE_BUTTONS, w);
165 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
166 statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat);
167 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
169 timeline_buttons_ui.buttonVideo->setIcon(KIcon("display-video"));
170 timeline_buttons_ui.buttonVideo->setToolTip(i18n("Show video thumbnails"));
171 timeline_buttons_ui.buttonAudio->setIcon(KIcon("display-audio"));
172 timeline_buttons_ui.buttonAudio->setToolTip(i18n("Show audio thumbnails"));
174 setupGUI(Default, "kdenliveui.rc");
176 connect(projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
177 connect(clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
178 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
179 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
180 connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
181 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
182 slotConnectMonitors();
184 setAutoSaveSettings();
189 bool MainWindow::queryClose() {
191 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
192 case KMessageBox::Yes :
193 // save document here. If saving fails, return false;
195 case KMessageBox::No :
202 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track) {
203 if (!m_activeDocument) return;
204 if (effect.isNull()) {
205 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
208 TrackView *currentTimeLine = (TrackView *) m_timelineArea->currentWidget();
209 currentTimeLine->projectView()->slotAddEffect(effect, pos, track);
212 void MainWindow::slotRaiseMonitor(bool clipMonitor) {
213 if (clipMonitor) clipMonitorDock->raise();
214 else projectMonitorDock->raise();
217 void MainWindow::slotSetClipDuration(int id, int duration) {
218 if (!m_activeDocument) return;
219 m_activeDocument->setProducerDuration(id, duration);
222 void MainWindow::slotConnectMonitors() {
224 m_projectList->setRenderer(m_clipMonitor->render);
225 connect(m_projectList, SIGNAL(clipSelected(const QDomElement &)), m_clipMonitor, SLOT(slotSetXml(const QDomElement &)));
226 connect(m_projectList, SIGNAL(receivedClipDuration(int, int)), this, SLOT(slotSetClipDuration(int, int)));
227 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, int)), m_clipMonitor->render, SLOT(getFileProperties(const QDomElement &, int)));
228 connect(m_clipMonitor->render, SIGNAL(replyGetImage(int, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(int, int, const QPixmap &, int, int)));
229 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 > &)));
232 void MainWindow::setupActions() {
233 KAction* clearAction = new KAction(this);
234 clearAction->setText(i18n("Clear"));
235 clearAction->setIcon(KIcon("document-new"));
236 clearAction->setShortcut(Qt::CTRL + Qt::Key_W);
237 actionCollection()->addAction("clear", clearAction);
238 /*connect(clearAction, SIGNAL(triggered(bool)),
239 textArea, SLOT(clear()));*/
241 KAction* profilesAction = new KAction(this);
242 profilesAction->setText(i18n("Manage Profiles"));
243 profilesAction->setIcon(KIcon("document-new"));
244 actionCollection()->addAction("manage_profiles", profilesAction);
245 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
247 KAction* projectAction = new KAction(this);
248 projectAction->setText(i18n("Project Settings"));
249 projectAction->setIcon(KIcon("document-new"));
250 actionCollection()->addAction("project_settings", projectAction);
251 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
253 KAction* monitorPlay = new KAction(this);
254 monitorPlay->setText(i18n("Play"));
255 monitorPlay->setIcon(KIcon("media-playback-start"));
256 monitorPlay->setShortcut(Qt::Key_Space);
257 actionCollection()->addAction("monitor_play", monitorPlay);
258 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
260 KStandardAction::quit(kapp, SLOT(quit()),
263 KStandardAction::open(this, SLOT(openFile()),
266 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
269 KStandardAction::save(this, SLOT(saveFile()),
272 KStandardAction::saveAs(this, SLOT(saveFileAs()),
275 KStandardAction::openNew(this, SLOT(newFile()),
278 KStandardAction::preferences(this, SLOT(slotPreferences()),
281 KStandardAction::undo(this, SLOT(undo()),
284 KStandardAction::redo(this, SLOT(redo()),
287 connect(actionCollection(), SIGNAL(actionHighlighted(QAction*)),
288 this, SLOT(slotDisplayActionMessage(QAction*)));
289 //connect(actionCollection(), SIGNAL( clearStatusText() ),
290 //statusBar(), SLOT( clear() ) );
295 void MainWindow::undo() {
296 m_commandStack->undo();
299 void MainWindow::redo() {
300 m_commandStack->redo();
303 void MainWindow::slotDisplayActionMessage(QAction *a) {
304 statusBar()->showMessage(a->data().toString(), 3000);
307 void MainWindow::saveOptions() {
308 KSharedConfigPtr config = KGlobal::config();
309 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
313 void MainWindow::readOptions() {
314 KSharedConfigPtr config = KGlobal::config();
315 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
318 void MainWindow::newFile() {
320 if (m_timelineArea->count() == 0) profileName = KdenliveSettings::default_profile();
322 ProjectSettings *w = new ProjectSettings;
324 profileName = w->selectedProfile();
327 MltVideoProfile prof = ProfilesDialog::getVideoProfile(profileName);
328 if (prof.width == 0) prof = ProfilesDialog::getVideoProfile("dv_pal");
329 KdenliveDoc *doc = new KdenliveDoc(KUrl(), prof, m_commandStack);
330 TrackView *trackView = new TrackView(doc);
331 m_timelineArea->addTab(trackView, KIcon("kdenlive"), i18n("Untitled") + " / " + prof.description);
332 if (m_timelineArea->count() == 1)
333 connectDocument(trackView, doc);
334 else m_timelineArea->setTabBarHidden(false);
337 void MainWindow::activateDocument() {
338 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
339 KdenliveDoc *currentDoc = currentTab->document();
340 connectDocument(currentTab, currentDoc);
343 void MainWindow::closeDocument(QWidget *w) {
344 if (w == m_timelineArea->currentWidget()) {
345 // closing current document
346 int ix = m_timelineArea->currentIndex() + 1;
347 if (ix == m_timelineArea->count()) ix = 0;
348 m_timelineArea->setCurrentIndex(ix);
351 TrackView *tabToClose = (TrackView *) w;
352 KdenliveDoc *docToClose = tabToClose->document();
353 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
358 void MainWindow::saveFileAs(const QString &outputFileName) {
359 KSaveFile file(outputFileName);
362 QByteArray outputByteArray;
363 //outputByteArray.append(textArea->toPlainText());
364 file.write(outputByteArray);
368 fileName = outputFileName;
371 void MainWindow::saveFileAs() {
372 saveFileAs(KFileDialog::getSaveFileName());
375 void MainWindow::saveFile() {
376 if (!fileName.isEmpty()) {
377 saveFileAs(fileName);
383 void MainWindow::openFile() { //changed
384 KUrl url = KFileDialog::getOpenUrl(KUrl(), "application/vnd.kde.kdenlive;*.kdenlive");
385 if (url.isEmpty()) return;
386 m_fileOpenRecent->addUrl(url);
390 void MainWindow::openFile(const KUrl &url) { //new
391 //TODO: get video profile from url before opening it
392 MltVideoProfile prof = ProfilesDialog::getVideoProfile(KdenliveSettings::default_profile());
393 if (prof.width == 0) prof = ProfilesDialog::getVideoProfile("dv_pal");
394 KdenliveDoc *doc = new KdenliveDoc(url, prof, m_commandStack);
395 TrackView *trackView = new TrackView(doc);
396 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
397 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
398 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
399 //connectDocument(trackView, doc);
403 void MainWindow::parseProfiles() {
404 //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
405 if (KdenliveSettings::mltpath().isEmpty()) {
406 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
408 if (KdenliveSettings::rendererpath().isEmpty()) {
409 KdenliveSettings::setRendererpath(KStandardDirs::findExe("inigo"));
411 QStringList profilesFilter;
412 profilesFilter << "*";
413 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
415 if (profilesList.isEmpty()) {
416 // Cannot find MLT path, try finding inigo
417 QString profilePath = KdenliveSettings::rendererpath();
418 if (!profilePath.isEmpty()) {
419 profilePath = profilePath.section('/', 0, -3);
420 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
421 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
424 if (profilesList.isEmpty()) {
425 // Cannot find the MLT profiles, ask for location
426 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
427 getUrl->fileDialog()->setMode(KFile::Directory);
429 KUrl mltPath = getUrl->selectedUrl();
431 if (mltPath.isEmpty()) exit(1);
432 KdenliveSettings::setMltpath(mltPath.path());
433 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
437 if (KdenliveSettings::rendererpath().isEmpty()) {
438 // Cannot find the MLT inigo renderer, ask for location
439 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
441 KUrl rendererPath = getUrl->selectedUrl();
443 if (rendererPath.isEmpty()) exit(1);
444 KdenliveSettings::setRendererpath(rendererPath.path());
447 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
449 // Parse MLT profiles to build a list of available video formats
450 if (profilesList.isEmpty()) parseProfiles();
454 void MainWindow::slotEditProfiles() {
455 ProfilesDialog *w = new ProfilesDialog;
460 void MainWindow::slotEditProjectSettings() {
461 ProjectSettings *w = new ProjectSettings;
467 void MainWindow::slotUpdateMousePosition(int pos) {
468 if (m_activeDocument)
469 switch (m_timecodeFormat->currentIndex()) {
471 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
474 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
478 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //changed
479 //m_projectMonitor->stop();
480 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
481 if (m_activeDocument) {
482 if (m_activeDocument == doc) return;
483 m_activeDocument->backupMltPlaylist();
484 if (m_activeTimeline) {
485 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
486 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline->projectView(), SLOT(setDuration(int)));
487 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
488 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(int)), m_projectList, SLOT(slotDeleteClip(int)));
489 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(int)), m_projectList, SLOT(slotUpdateClip(int)));
490 disconnect(m_activeDocument, SIGNAL(deletTimelineClip(int)), m_activeTimeline, SLOT(slotDeleteClip(int)));
491 disconnect(m_activeDocument, SIGNAL(thumbsProgress(KUrl, int)), this, SLOT(slotGotProgressInfo(KUrl, int)));
492 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
493 disconnect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement)));
494 disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
495 disconnect(effectStack, SIGNAL(changeEffectState(ClipItem*, QDomElement, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, QDomElement, bool)));
496 disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
498 m_activeDocument->setRenderer(NULL);
499 disconnect(m_projectList, SIGNAL(clipSelected(const QDomElement &)), m_clipMonitor, SLOT(slotSetXml(const QDomElement &)));
500 m_clipMonitor->stop();
502 m_monitorManager->resetProfiles(doc->profilePath());
503 m_projectList->setDocument(doc);
504 connect(m_projectList, SIGNAL(clipSelected(const QDomElement &)), m_clipMonitor, SLOT(slotSetXml(const QDomElement &)));
505 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
506 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
507 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
508 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView->projectView(), SLOT(setDuration(int)));
509 connect(doc, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
510 connect(doc, SIGNAL(signalDeleteProjectClip(int)), m_projectList, SLOT(slotDeleteClip(int)));
511 connect(doc, SIGNAL(updateClipDisplay(int)), m_projectList, SLOT(slotUpdateClip(int)));
512 connect(doc, SIGNAL(deletTimelineClip(int)), trackView, SLOT(slotDeleteClip(int)));
513 connect(doc, SIGNAL(thumbsProgress(KUrl, int)), this, SLOT(slotGotProgressInfo(KUrl, int)));
515 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
516 connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement)));
517 connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
518 connect(effectStack, SIGNAL(changeEffectState(ClipItem*, QDomElement, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, QDomElement, bool)));
519 connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
520 m_activeTimeline = trackView;
522 m_monitorManager->setTimecode(doc->timecode());
523 doc->setRenderer(m_projectMonitor->render);
524 m_commandStack->setActiveStack(doc->commandStack());
526 m_overView->setScene(trackView->projectScene());
527 m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
528 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
530 setCaption(doc->description());
531 m_activeDocument = doc;
534 void MainWindow::slotPreferences() {
535 //An instance of your dialog could be already created and could be
536 // cached, in which case you want to display the cached dialog
537 // instead of creating another one
538 if (KConfigDialog::showDialog("settings"))
541 // KConfigDialog didn't find an instance of this dialog, so lets
543 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
544 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
548 void MainWindow::updateConfiguration() {
549 //TODO: we should apply settings to all projects, not only the current one
550 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
552 currentTab->refresh();
553 currentTab->projectView()->checkAutoScroll();
554 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
556 timeline_buttons_ui.buttonAudio->setDown(KdenliveSettings::audiothumbnails());
557 timeline_buttons_ui.buttonVideo->setDown(KdenliveSettings::videothumbnails());
560 void MainWindow::slotSwitchVideoThumbs() {
561 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
562 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
564 currentTab->refresh();
566 timeline_buttons_ui.buttonVideo->setDown(KdenliveSettings::videothumbnails());
569 void MainWindow::slotSwitchAudioThumbs() {
570 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
571 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
573 currentTab->refresh();
574 currentTab->projectView()->checkAutoScroll();
575 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
577 timeline_buttons_ui.buttonAudio->setDown(KdenliveSettings::audiothumbnails());
580 void MainWindow::slotGotProgressInfo(KUrl url, int progress) {
581 statusProgressBar->setValue(progress);
583 statusLabel->setText(tr("Creating Audio Thumbs"));
584 statusProgressBar->setVisible(true);
586 statusLabel->setText("");
587 statusProgressBar->setVisible(false);
591 #include "mainwindow.moc"