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() {
319 MltVideoProfile prof = ProfilesDialog::getVideoProfile(KdenliveSettings::default_profile());
320 if (prof.width == 0) prof = ProfilesDialog::getVideoProfile("dv_pal");
321 KdenliveDoc *doc = new KdenliveDoc(KUrl(), prof, m_commandStack);
322 TrackView *trackView = new TrackView(doc);
323 m_timelineArea->addTab(trackView, KIcon("kdenlive"), i18n("Untitled") + " / " + prof.description);
324 if (m_timelineArea->count() == 1)
325 connectDocument(trackView, doc);
326 else m_timelineArea->setTabBarHidden(false);
329 void MainWindow::activateDocument() {
330 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
331 KdenliveDoc *currentDoc = currentTab->document();
332 connectDocument(currentTab, currentDoc);
335 void MainWindow::closeDocument(QWidget *w) {
336 if (w == m_timelineArea->currentWidget()) {
337 // closing current document
338 int ix = m_timelineArea->currentIndex() + 1;
339 if (ix == m_timelineArea->count()) ix = 0;
340 m_timelineArea->setCurrentIndex(ix);
343 TrackView *tabToClose = (TrackView *) w;
344 KdenliveDoc *docToClose = tabToClose->document();
345 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
350 void MainWindow::saveFileAs(const QString &outputFileName) {
351 KSaveFile file(outputFileName);
354 QByteArray outputByteArray;
355 //outputByteArray.append(textArea->toPlainText());
356 file.write(outputByteArray);
360 fileName = outputFileName;
363 void MainWindow::saveFileAs() {
364 saveFileAs(KFileDialog::getSaveFileName());
367 void MainWindow::saveFile() {
368 if (!fileName.isEmpty()) {
369 saveFileAs(fileName);
375 void MainWindow::openFile() { //changed
376 KUrl url = KFileDialog::getOpenUrl(KUrl(), "application/vnd.kde.kdenlive;*.kdenlive");
377 if (url.isEmpty()) return;
378 m_fileOpenRecent->addUrl(url);
382 void MainWindow::openFile(const KUrl &url) { //new
383 //TODO: get video profile from url before opening it
384 MltVideoProfile prof = ProfilesDialog::getVideoProfile(KdenliveSettings::default_profile());
385 if (prof.width == 0) prof = ProfilesDialog::getVideoProfile("dv_pal");
386 KdenliveDoc *doc = new KdenliveDoc(url, prof, m_commandStack);
387 TrackView *trackView = new TrackView(doc);
388 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
389 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
390 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
391 //connectDocument(trackView, doc);
395 void MainWindow::parseProfiles() {
396 //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
397 if (KdenliveSettings::mltpath().isEmpty()) {
398 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
400 if (KdenliveSettings::rendererpath().isEmpty()) {
401 KdenliveSettings::setRendererpath(KStandardDirs::findExe("inigo"));
403 QStringList profilesFilter;
404 profilesFilter << "*";
405 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
407 if (profilesList.isEmpty()) {
408 // Cannot find MLT path, try finding inigo
409 QString profilePath = KdenliveSettings::rendererpath();
410 if (!profilePath.isEmpty()) {
411 profilePath = profilePath.section('/', 0, -3);
412 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
413 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
416 if (profilesList.isEmpty()) {
417 // Cannot find the MLT profiles, ask for location
418 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
419 getUrl->fileDialog()->setMode(KFile::Directory);
421 KUrl mltPath = getUrl->selectedUrl();
423 if (mltPath.isEmpty()) exit(1);
424 KdenliveSettings::setMltpath(mltPath.path());
425 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
429 if (KdenliveSettings::rendererpath().isEmpty()) {
430 // Cannot find the MLT inigo renderer, ask for location
431 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
433 KUrl rendererPath = getUrl->selectedUrl();
435 if (rendererPath.isEmpty()) exit(1);
436 KdenliveSettings::setRendererpath(rendererPath.path());
439 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
441 // Parse MLT profiles to build a list of available video formats
442 if (profilesList.isEmpty()) parseProfiles();
446 void MainWindow::slotEditProfiles() {
447 ProfilesDialog *w = new ProfilesDialog;
452 void MainWindow::slotEditProjectSettings() {
453 ProjectSettings *w = new ProjectSettings;
459 void MainWindow::slotUpdateMousePosition(int pos) {
460 if (m_activeDocument)
461 switch (m_timecodeFormat->currentIndex()) {
463 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
466 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
470 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //changed
471 //m_projectMonitor->stop();
472 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
473 if (m_activeDocument) {
474 if (m_activeDocument == doc) return;
475 m_activeDocument->backupMltPlaylist();
476 if (m_activeTimeline) {
477 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
478 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline->projectView(), SLOT(setDuration(int)));
479 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
480 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(int)), m_projectList, SLOT(slotDeleteClip(int)));
481 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(int)), m_projectList, SLOT(slotUpdateClip(int)));
482 disconnect(m_activeDocument, SIGNAL(deletTimelineClip(int)), m_activeTimeline, SLOT(slotDeleteClip(int)));
483 disconnect(m_activeDocument, SIGNAL(thumbsProgress(KUrl, int)), this, SLOT(slotGotProgressInfo(KUrl, int)));
484 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
485 disconnect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement)));
486 disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
487 disconnect(effectStack, SIGNAL(changeEffectState(ClipItem*, QDomElement, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, QDomElement, bool)));
488 disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
490 m_activeDocument->setRenderer(NULL);
491 disconnect(m_projectList, SIGNAL(clipSelected(const QDomElement &)), m_clipMonitor, SLOT(slotSetXml(const QDomElement &)));
492 m_clipMonitor->stop();
494 m_monitorManager->resetProfiles(doc->profilePath());
495 m_projectList->setDocument(doc);
496 connect(m_projectList, SIGNAL(clipSelected(const QDomElement &)), m_clipMonitor, SLOT(slotSetXml(const QDomElement &)));
497 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
498 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
499 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
500 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView->projectView(), SLOT(setDuration(int)));
501 connect(doc, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
502 connect(doc, SIGNAL(signalDeleteProjectClip(int)), m_projectList, SLOT(slotDeleteClip(int)));
503 connect(doc, SIGNAL(updateClipDisplay(int)), m_projectList, SLOT(slotUpdateClip(int)));
504 connect(doc, SIGNAL(deletTimelineClip(int)), trackView, SLOT(slotDeleteClip(int)));
505 connect(doc, SIGNAL(thumbsProgress(KUrl, int)), this, SLOT(slotGotProgressInfo(KUrl, int)));
507 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
508 connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement)));
509 connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
510 connect(effectStack, SIGNAL(changeEffectState(ClipItem*, QDomElement, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, QDomElement, bool)));
511 connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
512 m_activeTimeline = trackView;
514 m_monitorManager->setTimecode(doc->timecode());
515 doc->setRenderer(m_projectMonitor->render);
516 m_commandStack->setActiveStack(doc->commandStack());
518 m_overView->setScene(trackView->projectScene());
519 m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
520 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
522 setCaption(doc->description());
523 m_activeDocument = doc;
526 void MainWindow::slotPreferences() {
527 //An instance of your dialog could be already created and could be
528 // cached, in which case you want to display the cached dialog
529 // instead of creating another one
530 if (KConfigDialog::showDialog("settings"))
533 // KConfigDialog didn't find an instance of this dialog, so lets
535 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
536 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
540 void MainWindow::updateConfiguration() {
541 //TODO: we should apply settings to all projects, not only the current one
542 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
544 currentTab->refresh();
545 currentTab->projectView()->checkAutoScroll();
546 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
548 timeline_buttons_ui.buttonAudio->setDown(KdenliveSettings::audiothumbnails());
549 timeline_buttons_ui.buttonVideo->setDown(KdenliveSettings::videothumbnails());
552 void MainWindow::slotSwitchVideoThumbs() {
553 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
554 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
556 currentTab->refresh();
558 timeline_buttons_ui.buttonVideo->setDown(KdenliveSettings::videothumbnails());
561 void MainWindow::slotSwitchAudioThumbs() {
562 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
563 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
565 currentTab->refresh();
566 currentTab->projectView()->checkAutoScroll();
567 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
569 timeline_buttons_ui.buttonAudio->setDown(KdenliveSettings::audiothumbnails());
572 void MainWindow::slotGotProgressInfo(KUrl url, int progress) {
573 statusProgressBar->setValue(progress);
575 statusLabel->setText(tr("Creating Audio Thumbs"));
576 statusProgressBar->setVisible(true);
578 statusLabel->setText("");
579 statusProgressBar->setVisible(false);
583 #include "mainwindow.moc"