aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Mardelle <[email protected]>2015-01-01 21:31:36 +0100
committerJean-Baptiste Mardelle <[email protected]>2015-01-01 21:31:36 +0100
commitba65793f4ef68b624fe17bbefa29a3201a0595d9 (patch)
tree3100ed508b843196e4d9f3dd547122dab36b4517
parent4df5f2d7b9b4a83032055383ce6d886396166207 (diff)
cleanup
-rw-r--r--src/bin/bin.cpp33
-rw-r--r--src/bin/bin.h4
-rw-r--r--src/bin/projectclip.cpp4
-rw-r--r--src/bin/projectfolder.cpp2
-rw-r--r--src/mainwindow.cpp2
-rw-r--r--src/mltcontroller/clipcontroller.cpp14
-rw-r--r--src/mltcontroller/clipcontroller.h3
-rw-r--r--src/monitor/monitor.cpp21
-rw-r--r--src/monitor/monitor.h5
-rw-r--r--src/timeline/customtrackview.cpp4
-rw-r--r--src/timeline/customtrackview.h2
11 files changed, 64 insertions, 30 deletions
diff --git a/src/bin/bin.cpp b/src/bin/bin.cpp
index 96d81f8..c6349a0 100644
--- a/src/bin/bin.cpp
+++ b/src/bin/bin.cpp
@@ -228,14 +228,14 @@ void Bin::slotAddClip()
void Bin::deleteClip(const QString &id)
{
+ if (m_monitor->activeClipId() == id) {
+ m_monitor->openClip(NULL);
+ }
ProjectClip *clip = m_rootFolder->clip(id);
if (!clip) return;
m_jobManager->discardJobs(id);
m_rootFolder->removeChild(clip);
delete clip;
- if (m_openedProducer == id) {
- m_openedProducer.clear();
- }
}
void Bin::slotDeleteClip()
@@ -296,7 +296,7 @@ int Bin::lastClipId() const
void Bin::setDocument(KdenliveDoc* project)
{
// Remove clip from Bin's monitor
- m_monitor->open(NULL);
+ m_monitor->openClip(NULL);
closeEditing();
setEnabled(false);
delete m_rootFolder;
@@ -306,7 +306,6 @@ void Bin::setDocument(KdenliveDoc* project)
m_clipCounter = 1;
m_folderCounter = 1;
m_doc = project;
- m_openedProducer.clear();
int iconHeight = style()->pixelMetric(QStyle::PM_ToolBarIconSize) * 2;
m_iconSize = QSize(iconHeight * m_doc->dar(), iconHeight);
m_itemModel->setIconSize(m_iconSize);
@@ -417,7 +416,6 @@ void Bin::selectProxyModel(const QModelIndex &id)
currentItem->setCurrent(true);
if (!currentItem->isFolder()) {
m_editAction->setEnabled(true);
- m_openedProducer = currentItem->clipId();
if (m_propertiesPanel->width() > 0) {
// if info panel is displayed, update info
if (!currentItem->isFolder()) showClipProperties(currentItem);
@@ -425,7 +423,6 @@ void Bin::selectProxyModel(const QModelIndex &id)
} else {
// A folder was selected, disable editing clip
m_editAction->setEnabled(false);
- m_openedProducer.clear();
}
m_deleteAction->setEnabled(true);
} else {
@@ -693,8 +690,21 @@ void Bin::slotProducerReady(requestClipInfo info, ClipController *controller)
if (clip) {
clip->setProducer(controller, info.replaceProducer);
emit producerReady(info.clipId);
- if (m_openedProducer == info.clipId) {
- m_monitor->open(clip->producer());
+ QString currentClip = m_monitor->activeClipId();
+ if (currentClip.isEmpty()) {
+ //No clip displayed in monitor, check if item is selected
+ QModelIndexList indexes = m_proxyModel->selectionModel()->selectedIndexes();
+ foreach (const QModelIndex &ix, indexes) {
+ ProjectClip *currentItem = static_cast<ProjectClip *>(m_proxyModel->mapToSource(ix).internalPointer());
+ if (currentItem->clipId() == info.clipId) {
+ // Item was selected, show it in monitor
+ m_monitor->openClip(controller);
+ break;
+ }
+ }
+ }
+ else if (currentClip == info.clipId) {
+ m_monitor->openClip(controller);
}
}
else {
@@ -716,10 +726,9 @@ void Bin::slotProducerReady(requestClipInfo info, ClipController *controller)
}
}
-void Bin::openProducer(const QString &id, Mlt::Producer *producer)
+void Bin::openProducer(ClipController *controller)
{
- m_openedProducer = id;
- m_monitor->open(producer);
+ m_monitor->openClip(controller);
}
void Bin::emitItemUpdated(AbstractProjectItem* item)
diff --git a/src/bin/bin.h b/src/bin/bin.h
index 929e77d..cc3e933 100644
--- a/src/bin/bin.h
+++ b/src/bin/bin.h
@@ -226,7 +226,7 @@ public:
Monitor *monitor();
/** @brief Open a producer in the clip monitor */
- void openProducer(const QString &id, Mlt::Producer *producer);
+ void openProducer(ClipController *controller);
/** @brief Trigger deletion of an item */
void deleteClip(const QString &id);
@@ -354,8 +354,6 @@ private:
QAction *m_proxyAction;
QAction *m_editAction;
QAction *m_deleteAction;
- /** @brief Keeps the id of the clip currently displayed in monitor. */
- QString m_openedProducer;
void showClipProperties(ProjectClip *clip);
void selectModel(const QModelIndex &id);
diff --git a/src/bin/projectclip.cpp b/src/bin/projectclip.cpp
index 1f58bd8..24bbf82 100644
--- a/src/bin/projectclip.cpp
+++ b/src/bin/projectclip.cpp
@@ -148,8 +148,8 @@ void ProjectClip::reloadProducer()
void ProjectClip::setCurrent(bool current, bool notify)
{
AbstractProjectItem::setCurrent(current, notify);
- if (current && m_controller) {
- bin()->openProducer(m_id, m_controller->masterProducer());
+ if (current) {
+ bin()->openProducer(m_controller);
}
}
diff --git a/src/bin/projectfolder.cpp b/src/bin/projectfolder.cpp
index ce15210..9252e2b 100644
--- a/src/bin/projectfolder.cpp
+++ b/src/bin/projectfolder.cpp
@@ -54,7 +54,7 @@ void ProjectFolder::setCurrent(bool current, bool notify)
{
AbstractProjectItem::setCurrent(current, notify);
if (current) {
- bin()->openProducer(QString(), NULL);
+ bin()->openProducer(NULL);
}
}
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index b0c6507..df3cccc 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -3017,7 +3017,7 @@ void MainWindow::slotInsertZoneToTimeline()
{
if (pCore->projectManager()->currentTrackView() == NULL || m_clipMonitor->activeClip() == NULL) return;
QStringList info = m_clipMonitor->getZoneInfo();
- pCore->projectManager()->currentTrackView()->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
+ pCore->projectManager()->currentTrackView()->projectView()->insertClipCut(m_clipMonitor->activeClipId(), info.at(1).toInt(), info.at(2).toInt());
}
diff --git a/src/mltcontroller/clipcontroller.cpp b/src/mltcontroller/clipcontroller.cpp
index 9dde648..1dfa66a 100644
--- a/src/mltcontroller/clipcontroller.cpp
+++ b/src/mltcontroller/clipcontroller.cpp
@@ -84,6 +84,12 @@ bool ClipController::isValid()
return m_masterProducer->is_valid();
}
+const QString &ClipController::clipId()
+{
+ if (m_masterProducer == NULL) return QString();
+ return property("id");
+}
+
void ClipController::updateProducer(Mlt::Producer* producer)
{
//TODO replace all track producers
@@ -151,7 +157,7 @@ int ClipController::getPlaytime() const
QString ClipController::property(const QString &name)
{
- return QString(m_masterProducer->get(name.toUtf8().constData()));
+ return QString(m_masterProducer->parent().get(name.toUtf8().constData()));
}
QUrl ClipController::clipUrl() const
@@ -172,19 +178,19 @@ QString ClipController::serviceName() const
void ClipController::setProperty(const QString& name, int value)
{
//TODO: also set property on all track producers
- m_masterProducer->set(name.toUtf8().constData(), value);
+ m_masterProducer->parent().set(name.toUtf8().constData(), value);
}
void ClipController::setProperty(const QString& name, double value)
{
//TODO: also set property on all track producers
- m_masterProducer->set(name.toUtf8().constData(), value);
+ m_masterProducer->parent().set(name.toUtf8().constData(), value);
}
void ClipController::setProperty(const QString& name, const QString& value)
{
//TODO: also set property on all track producers
- m_masterProducer->set(name.toUtf8().constData(), value.toUtf8().constData());
+ m_masterProducer->parent().set(name.toUtf8().constData(), value.toUtf8().constData());
}
ClipType ClipController::clipType() const
diff --git a/src/mltcontroller/clipcontroller.h b/src/mltcontroller/clipcontroller.h
index b45c28f..deabd30 100644
--- a/src/mltcontroller/clipcontroller.h
+++ b/src/mltcontroller/clipcontroller.h
@@ -58,6 +58,9 @@ public:
/** @brief Returns a clone of our master producer */
Mlt::Producer *masterProducer();
+ /** @brief Returns the MLT's producer id */
+ const QString &clipId();
+
/** @brief Returns the clip name (usually file name) */
QString clipName() const;
diff --git a/src/monitor/monitor.cpp b/src/monitor/monitor.cpp
index fb94186..afe01ca 100644
--- a/src/monitor/monitor.cpp
+++ b/src/monitor/monitor.cpp
@@ -23,7 +23,7 @@
#include "monitoreditwidget.h"
#include "videosurface.h"
#include "smallruler.h"
-
+#include "mltcontroller/clipcontroller.h"
#include "kdenlivesettings.h"
#include "doc/docclipbase.h"
#include "timeline/abstractclipitem.h"
@@ -52,6 +52,7 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
AbstractMonitor(id, manager, parent)
, render(NULL)
, m_currentClip(NULL)
+ , m_controller(NULL)
, m_overlay(NULL)
, m_length(2)
, m_dragStarted(false)
@@ -880,10 +881,24 @@ void Monitor::updateClipProducer(Mlt::Producer *prod)
render->setProducer(prod, render->seekFramePosition());
}
-void Monitor::open(Mlt::Producer *prod)
+void Monitor::openClip(ClipController *controller)
{
if (render == NULL) return;
- render->setProducer(prod, -1);
+ m_controller = controller;
+ if (controller) {
+ render->setProducer(m_controller->masterProducer(), -1);
+ }
+ else {
+ render->setProducer(NULL, -1);
+ }
+}
+
+const QString &Monitor::activeClipId()
+{
+ if (m_controller) {
+ return m_controller->clipId();
+ }
+ return QString();
}
void Monitor::slotSetClipProducer(DocClipBase *clip, QPoint zone, bool forceUpdate, int position)
diff --git a/src/monitor/monitor.h b/src/monitor/monitor.h
index bffb399..cf1ce98 100644
--- a/src/monitor/monitor.h
+++ b/src/monitor/monitor.h
@@ -38,6 +38,7 @@
class SmallRuler;
class DocClipBase;
+class ClipController;
class AbstractClipItem;
class Transition;
class ClipItem;
@@ -80,6 +81,7 @@ public:
void setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMenu *markerMenu = NULL, QAction *loopClip = NULL);
const QString sceneList();
DocClipBase *activeClip();
+ const QString &activeClipId();
GenTime position();
void checkOverlay();
void updateTimecodeFormat();
@@ -118,6 +120,7 @@ protected:
private:
DocClipBase *m_currentClip;
+ ClipController *m_controller;
SmallRuler *m_ruler;
Overlay *m_overlay;
int m_length;
@@ -174,7 +177,7 @@ public slots:
void slotOpenFile(const QString &);
void slotSetClipProducer(DocClipBase *clip, QPoint zone = QPoint(), bool forceUpdate = false, int position = -1);
void updateClipProducer(Mlt::Producer *prod);
- void open(Mlt::Producer *prod);
+ void openClip(ClipController *controller);
void refreshMonitor(bool visible);
void refreshMonitor();
void slotSeek(int pos);
diff --git a/src/timeline/customtrackview.cpp b/src/timeline/customtrackview.cpp
index abfbf89..eb24ab7 100644
--- a/src/timeline/customtrackview.cpp
+++ b/src/timeline/customtrackview.cpp
@@ -1592,7 +1592,7 @@ void CustomTrackView::activateMonitor()
emit activateDocumentMonitor();
}
-void CustomTrackView::insertClipCut(DocClipBase *clip, int in, int out)
+void CustomTrackView::insertClipCut(const QString &id, int in, int out)
{
resetSelectionGroup();
ItemInfo info;
@@ -1624,7 +1624,7 @@ void CustomTrackView::insertClipCut(DocClipBase *clip, int in, int out)
QUndoCommand *addCommand = new QUndoCommand();
addCommand->setText(i18n("Add timeline clip"));
new RefreshMonitorCommand(this, false, true, addCommand);
- new AddTimelineClipCommand(this, clip->getId(), pasteInfo, EffectsList(), m_scene->editMode() == OverwriteEdit, m_scene->editMode() == InsertEdit, true, false, addCommand);
+ new AddTimelineClipCommand(this, id, pasteInfo, EffectsList(), m_scene->editMode() == OverwriteEdit, m_scene->editMode() == InsertEdit, true, false, addCommand);
new RefreshMonitorCommand(this, true, false, addCommand);
updateTrackDuration(pasteInfo.track, addCommand);
diff --git a/src/timeline/customtrackview.h b/src/timeline/customtrackview.h
index 4059d41..94297d9 100644
--- a/src/timeline/customtrackview.h
+++ b/src/timeline/customtrackview.h
@@ -186,7 +186,7 @@ public:
* @param out The outpoint of the clip (crop from end)
*
* Inserts at the position of timeline cursor and selected track. */
- void insertClipCut(DocClipBase *clip, int in, int out);
+ void insertClipCut(const QString &id, int in, int out);
void clearSelection(bool emitInfo = true);
void editItemDuration();
void buildGuidesMenu(QMenu *goMenu) const;