X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmainwindow.cpp;h=ef4e12afdb21b7f15d51e7e987e1a38b7dfa7c56;hb=7c5f778451bd87db882905afb0dd680aabc36400;hp=1890424587c266ad297c171305f6e34c01360c8f;hpb=218462392c92f8a9e577bd1af25645ad841f8aef;p=kdenlive diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 18904245..ef4e12af 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -60,8 +60,10 @@ MainWindow::MainWindow(QWidget *parent) : KXmlGuiWindow(parent), - fileName(QString()), m_activeDocument(NULL), m_activeTimeline(NULL), m_commandStack(NULL) { + fileName(QString()), m_activeDocument(NULL), m_activeTimeline(NULL) { parseProfiles(); + + m_commandStack = new QUndoGroup; m_timelineArea = new KTabWidget(this); m_timelineArea->setHoverCloseButton(true); m_timelineArea->setTabReorderingEnabled(true); @@ -116,8 +118,10 @@ MainWindow::MainWindow(QWidget *parent) undoViewDock = new QDockWidget(i18n("Undo History"), this); undoViewDock->setObjectName("undo_history"); m_undoView = new QUndoView(this); + m_undoView->setCleanIcon(KIcon("edit-clear")); + m_undoView->setEmptyLabel(i18n("Clean")); undoViewDock->setWidget(m_undoView); - m_undoView->setStack(m_commandStack); + m_undoView->setGroup(m_commandStack); addDockWidget(Qt::TopDockWidgetArea, undoViewDock); overviewDock = new QDockWidget(i18n("Project Overview"), this); @@ -156,10 +160,11 @@ MainWindow::MainWindow(QWidget *parent) connect(projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool))); connect(clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool))); - connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors())); + //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors())); connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool))); connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement))); m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor); + slotConnectMonitors(); setAutoSaveSettings(); newFile(); @@ -202,17 +207,11 @@ void MainWindow::slotSetClipDuration(int id, int duration) { void MainWindow::slotConnectMonitors() { m_projectList->setRenderer(m_clipMonitor->render); - connect(m_projectList, SIGNAL(clipSelected(const QDomElement &)), m_clipMonitor, SLOT(slotSetXml(const QDomElement &))); - connect(m_projectList, SIGNAL(receivedClipDuration(int, int)), this, SLOT(slotSetClipDuration(int, int))); - connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, int)), m_clipMonitor->render, SLOT(getFileProperties(const QDomElement &, int))); - connect(m_clipMonitor->render, SIGNAL(replyGetImage(int, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(int, int, const QPixmap &, int, int))); - 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 > &))); - } void MainWindow::setupActions() { @@ -264,11 +263,11 @@ void MainWindow::setupActions() { KStandardAction::preferences(this, SLOT(slotPreferences()), actionCollection()); - /*KStandardAction::undo(this, SLOT(undo()), + KStandardAction::undo(this, SLOT(undo()), actionCollection()); KStandardAction::redo(this, SLOT(redo()), - actionCollection());*/ + actionCollection()); connect(actionCollection(), SIGNAL(actionHighlighted(QAction*)), this, SLOT(slotDisplayActionMessage(QAction*))); @@ -276,9 +275,14 @@ void MainWindow::setupActions() { //statusBar(), SLOT( clear() ) ); readOptions(); +} + +void MainWindow::undo() { + m_commandStack->undo(); +} - /*m_redo = m_commandStack->createRedoAction(actionCollection()); - m_undo = m_commandStack->createUndoAction(actionCollection());*/ +void MainWindow::redo() { + m_commandStack->redo(); } void MainWindow::slotDisplayActionMessage(QAction *a) { @@ -299,7 +303,7 @@ void MainWindow::readOptions() { void MainWindow::newFile() { MltVideoProfile prof = ProfilesDialog::getVideoProfile(KdenliveSettings::default_profile()); if (prof.width == 0) prof = ProfilesDialog::getVideoProfile("dv_pal"); - KdenliveDoc *doc = new KdenliveDoc(KUrl(), prof); + KdenliveDoc *doc = new KdenliveDoc(KUrl(), prof, m_commandStack); TrackView *trackView = new TrackView(doc); m_timelineArea->addTab(trackView, KIcon("kdenlive"), i18n("Untitled") + " / " + prof.description); if (m_timelineArea->count() == 1) @@ -364,7 +368,7 @@ void MainWindow::openFile(const KUrl &url) { //new //TODO: get video profile from url before opening it MltVideoProfile prof = ProfilesDialog::getVideoProfile(KdenliveSettings::default_profile()); if (prof.width == 0) prof = ProfilesDialog::getVideoProfile("dv_pal"); - KdenliveDoc *doc = new KdenliveDoc(url, prof); + KdenliveDoc *doc = new KdenliveDoc(url, prof, m_commandStack); TrackView *trackView = new TrackView(doc); m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description())); m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path()); @@ -469,10 +473,12 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*))); } m_activeDocument->setRenderer(NULL); + disconnect(m_projectList, SIGNAL(clipSelected(const QDomElement &)), m_clipMonitor, SLOT(slotSetXml(const QDomElement &))); + m_clipMonitor->stop(); } m_monitorManager->resetProfiles(doc->profilePath()); m_projectList->setDocument(doc); - + connect(m_projectList, SIGNAL(clipSelected(const QDomElement &)), m_clipMonitor, SLOT(slotSetXml(const QDomElement &))); connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor())); connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int))); connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int))); @@ -492,28 +498,12 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha m_monitorManager->setTimecode(doc->timecode()); doc->setRenderer(m_projectMonitor->render); - //m_undoView->setStack(0); - m_commandStack = doc->commandStack(); + m_commandStack->setActiveStack(doc->commandStack()); m_overView->setScene(trackView->projectScene()); m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber())); //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio); - QAction *redo = m_commandStack->createRedoAction(actionCollection()); - QAction *undo = m_commandStack->createUndoAction(actionCollection()); - - QWidget* w = factory()->container("mainToolBar", this); - if (w) { - if (actionCollection()->action("undo")) - delete actionCollection()->action("undo"); - if (actionCollection()->action("redo")) - delete actionCollection()->action("redo"); - - actionCollection()->addAction("undo", undo); - actionCollection()->addAction("redo", redo); - w->addAction(undo); - w->addAction(redo); - } - m_undoView->setStack(doc->commandStack()); + setCaption(doc->description()); m_activeDocument = doc; }