return m_monitorManager->isActive(m_id);
}
-bool AbstractMonitor::slotActivateMonitor()
+bool AbstractMonitor::slotActivateMonitor(bool forceRefresh)
{
- return m_monitorManager->activateMonitor(m_id);
+ return m_monitorManager->activateMonitor(m_id, forceRefresh);
}
VideoContainer::VideoContainer(AbstractMonitor* monitor, QWidget *parent) :
virtual void start() = 0;
virtual void slotPlay() = 0;
virtual void slotMouseSeek(int eventDelta, bool fast) = 0;
- bool slotActivateMonitor();
+ bool slotActivateMonitor(bool forceRefresh = false);
virtual void slotSwitchFullScreen() = 0;
protected:
commands/razorclipcommand.cpp
commands/razorgroupcommand.cpp
commands/rebuildgroupcommand.cpp
+ commands/refreshmonitorcommand.cpp
commands/resizeclipcommand.cpp
commands/splitaudiocommand.cpp
PARENT_SCOPE
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2012 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+
+
+#include "refreshmonitorcommand.h"
+#include "customtrackview.h"
+
+
+RefreshMonitorCommand::RefreshMonitorCommand(CustomTrackView *view, bool execute, QUndoCommand * parent) :
+ QUndoCommand(parent),
+ m_view(view),
+ m_exec(execute)
+{
+}
+
+
+// virtual
+void RefreshMonitorCommand::undo()
+{
+ m_view->monitorRefresh();
+}
+// virtual
+void RefreshMonitorCommand::redo()
+{
+ if (m_exec)
+ m_view->monitorRefresh();
+ m_exec = true;
+}
+
+
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2012 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+
+
+#ifndef REFRESHMONITORCOMMAND_H
+#define REFRESHMONITORCOMMAND_H
+
+#include <QUndoCommand>
+
+class CustomTrackView;
+
+class RefreshMonitorCommand : public QUndoCommand
+{
+public:
+ RefreshMonitorCommand(CustomTrackView *view, bool execute, QUndoCommand * parent = 0);
+ virtual void undo();
+ virtual void redo();
+
+private:
+ CustomTrackView *m_view;
+ bool m_exec;
+};
+
+#endif
+
#include "commands/configtrackscommand.h"
#include "commands/rebuildgroupcommand.h"
#include "commands/razorgroupcommand.h"
+#include "commands/refreshmonitorcommand.h"
#include "profilesdialog.h"
#include "lib/audio/audioEnvelope.h"
m_dragItem = static_cast <AbstractClipItem *>(items.at(0));
emit clipItemSelected((ClipItem*) m_dragItem, false);
}
- m_document->renderer()->doRefresh();
+ m_document->renderer()->refreshIfActive();
event->setDropAction(Qt::MoveAction);
event->accept();
delete deleteCommand;
} else {
updateTrackDuration(-1, deleteCommand);
+ new RefreshMonitorCommand(this, false, deleteCommand);
m_commandStack->push(deleteCommand);
}
+ m_document->renderer()->doRefresh();
}
void CustomTrackView::seekCursorPos(int pos)
deleteSelected->setText(i18np("Delete selected transition", "Delete selected transitions", transitionCount));
else deleteSelected->setText(i18n("Delete selected items"));
updateTrackDuration(-1, deleteSelected);
+ new RefreshMonitorCommand(this, false, deleteSelected);
m_commandStack->push(deleteSelected);
+ m_document->renderer()->doRefresh();
}
}
}
updateTrackDuration(-1, pasteClips);
+ new RefreshMonitorCommand(this, false, pasteClips);
m_commandStack->push(pasteClips);
}
m_commandStack->push(videoCommand);
}
+void CustomTrackView::monitorRefresh()
+{
+ m_document->renderer()->doRefresh();
+}
+
void CustomTrackView::doChangeClipType(const GenTime &pos, int track, bool videoOnly, bool audioOnly)
{
ClipItem *clip = getClipItemAt(pos, track);
int getFrameWidth();
/** @brief Returns last requested seeking pos (or SEEK_INACTIVE if no seek). */
int seekPosition() const;
+
+ /** @brief Trigger a monitor refresh. */
+ void monitorRefresh();
public slots:
/** @brief Send seek request to MLT. */
// Connect the project list
connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint, bool)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, bool)));
- connect(m_projectList, SIGNAL(raiseClipMonitor()), m_clipMonitor, SLOT(slotActivateMonitor()));
+ connect(m_projectList, SIGNAL(raiseClipMonitor(bool)), m_clipMonitor, SLOT(slotActivateMonitor(bool)));
connect(m_projectList, SIGNAL(loadingIsOver()), this, SLOT(slotElapsedTime()));
connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
void Monitor::start()
{
if (!isVisible() || !isActive()) return;
- if (render) render->doRefresh();// start();
+ if (render) render->startConsumer();
}
void Monitor::refreshMonitor(bool visible)
if (m_currentClip) m_currentClip->lastSeekPosition = render->seekFramePosition();
m_currentClip = clip;
if (position == -1) position = clip->lastSeekPosition;
- if (m_currentClip) slotActivateMonitor();
updateMarkers(clip);
Mlt::Producer *prod = NULL;
if (clip) prod = clip->getCloneProducer();
return monitor;
}
-bool MonitorManager::activateMonitor(Kdenlive::MONITORID name)
+bool MonitorManager::activateMonitor(Kdenlive::MONITORID name, bool forceRefresh)
{
if (m_clipMonitor == NULL || m_projectMonitor == NULL)
return false;
- if (m_activeMonitor && m_activeMonitor->id() == name)
+ if (m_activeMonitor && m_activeMonitor->id() == name) {
+ if (forceRefresh) m_activeMonitor->start();
return false;
+ }
m_activeMonitor = NULL;
for (int i = 0; i < m_monitorsList.count(); i++) {
if (m_monitorsList.at(i)->id() == name) {
/** @brief Activates a monitor.
* @param name name of the monitor to activate */
- bool activateMonitor(Kdenlive::MONITORID);
+ bool activateMonitor(Kdenlive::MONITORID, bool forceRefresh = false);
bool isActive(Kdenlive::MONITORID id) const;
void slotPlay();
void slotPause();
connect(this, SIGNAL(processNextThumbnail()), this, SLOT(slotProcessNextThumbnail()));
connect(m_listView, SIGNAL(projectModified()), this, SIGNAL(projectModified()));
connect(m_listView, SIGNAL(itemSelectionChanged()), this, SLOT(slotClipSelected()));
- connect(m_listView, SIGNAL(focusMonitor()), this, SIGNAL(raiseClipMonitor()));
+ connect(m_listView, SIGNAL(focusMonitor(bool)), this, SIGNAL(raiseClipMonitor(bool)));
connect(m_listView, SIGNAL(pauseMonitor()), this, SIGNAL(pauseMonitor()));
connect(m_listView, SIGNAL(requestMenu(const QPoint &, QTreeWidgetItem *)), this, SLOT(slotContextMenu(const QPoint &, QTreeWidgetItem *)));
connect(m_listView, SIGNAL(addClip()), this, SIGNAL(pauseMonitor()));
void updateProfile(const QString &);
void processNextThumbnail();
/** @brief Activate the clip monitor. */
- void raiseClipMonitor();
+ void raiseClipMonitor(bool forceRefresh);
/** @brief Set number of running jobs. */
void jobCount(int);
void cancelRunningJob(const QString, stringMap);
{
QTreeWidget::mouseReleaseEvent(event);
QTreeWidgetItem *underMouse = itemAt(event->pos());
- if (underMouse) emit focusMonitor();
+ if (underMouse) emit focusMonitor(true);
}
// virtual
void addClip();
void addClip(const QList <QUrl>, const QString &, const QString &);
void showProperties(DocClipBase *);
- void focusMonitor();
+ void focusMonitor(bool forceRefresh);
void pauseMonitor();
void addClipCut(const QString&, int, int);
void projectModified();
if (producer) delete producer;
return -1;
}
+ bool monitorIsActive = false;
m_mltConsumer->set("refresh", 0);
if (!m_mltConsumer->is_stopped()) {
+ monitorIsActive = true;
m_mltConsumer->stop();
}
m_mltConsumer->purge();
}
m_mltProducer = producer;
m_mltProducer->set_speed(0);
+ if (monitorIsActive) startConsumer();
emit durationChanged(m_mltProducer->get_playtime());
- if (m_mltConsumer->start() == -1) {
+ position = m_mltProducer->position();
+ emit rendererPosition(position);
+ return 0;
+}
+
+void Render::startConsumer() {
+ if (m_mltConsumer->is_stopped() && m_mltConsumer->start() == -1) {
// ARGH CONSUMER BROKEN!!!!
KMessageBox::error(qApp->activeWindow(), i18n("Could not create the video preview window.\nThere is something wrong with your Kdenlive install or your driver settings, please fix it."));
if (m_showFrameEvent) delete m_showFrameEvent;
m_pauseEvent = NULL;
delete m_mltConsumer;
m_mltConsumer = NULL;
- return -1;
+ return;
}
-
- position = m_mltProducer->position();
m_mltConsumer->set("refresh", 1);
// Make sure the first frame is displayed, otherwise if we change producer too fast
// We can crash the avformat producer
Mlt::Event *ev = m_mltConsumer->setup_wait_for("consumer-frame-show");
m_mltConsumer->wait_for(ev);
delete ev;
- emit rendererPosition(position);
- return 0;
}
int Render::setSceneList(QDomDocument list, int position)
else seek(requestedSeekPosition + diff);
}
+void Render::refreshIfActive()
+{
+ if (!m_mltConsumer->is_stopped() && m_mltProducer && m_mltProducer->get_speed() == 0) m_refreshTimer.start();
+}
+
void Render::doRefresh()
{
if (m_mltProducer && m_mltProducer->get_speed() == 0) m_refreshTimer.start();
double dar() const;
/** @brief Returns sample aspect ratio. */
double sar() const;
+ /** @brief If monitor is active, refresh it. */
+ void refreshIfActive();
+ /** @brief Start the MLT monitor consumer. */
+ void startConsumer();
/*
* Playlist manipulation.