protected:
ItemInfo m_info;
-// int m_track;
/** The position of the current keyframe when it has moved */
int m_editedKeyframe;
/** The position of the current keyframe before it was moved */
#include <QMimeData>
#include <QGraphicsSceneMouseEvent>
+
AbstractGroupItem::AbstractGroupItem(double /* fps */) :
QObject(),
QGraphicsItemGroup()
void AbstractGroupItem::addItem(QGraphicsItem * item)
{
addToGroup(item);
- //fixItemRect();
+ item->setFlag(QGraphicsItem::ItemIsMovable, false);
}
void AbstractGroupItem::fixItemRect()
//kDebug()<<"GRP XPOS:"<<xpos<<", START:"<<start.x()<<",NEW:"<<newPos.x()<<"; SCENE:"<<scenePos().x()<<",POS:"<<pos().x();
newPos.setX((int)(pos().x() + xpos - (int) start.x()));
- //int startTrack = (start.y() + trackHeight / 2) / trackHeight;
-
- int realTrack = (start.y() + newPos.y() - pos().y()) / trackHeight;
- int proposedTrack = newPos.y() / trackHeight;
-
- int correctedTrack = qMin(realTrack, projectScene()->tracksCount() - (int)(boundingRect().height() + 5) / trackHeight);
- correctedTrack = qMax(correctedTrack, 0);
-
- proposedTrack += (correctedTrack - realTrack);
+ int yOffset = property("y_absolute").toInt() + newPos.y();
+ int proposedTrack = yOffset / trackHeight;
// Check if top item is a clip or a transition
int offset = 0;
int topTrack = -1;
QList<QGraphicsItem *> children = childItems();
for (int i = 0; i < children.count(); i++) {
- int currentTrack = (int)(children.at(i)->scenePos().y() / trackHeight);
+ int currentTrack = 0;
+ if (children.at(i)->type() == AVWIDGET || children.at(i)->type() == TRANSITIONWIDGET) currentTrack = static_cast <AbstractClipItem*> (children.at(i))->track();
+ else if (children.at(i)->type() == GROUPWIDGET) currentTrack = static_cast <AbstractGroupItem*> (children.at(i))->track();
+ else continue;
if (children.at(i)->type() == AVWIDGET) {
if (topTrack == -1 || currentTrack <= topTrack) {
offset = 0;
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"
if (event->buttons() != Qt::NoButton) {
bool move = (event->pos() - m_clickEvent).manhattanLength() >= QApplication::startDragDistance();
+ if (m_dragItem && move) m_clipDrag = true;
if (m_dragItem && m_tool == SELECTTOOL) {
- if (m_operationMode == MOVE && move) {
- //m_dragItem->setProperty("y_absolute", event->pos().y());
+ if (m_operationMode == MOVE && m_clipDrag) {
QGraphicsView::mouseMoveEvent(event);
// If mouse is at a border of the view, scroll
if (pos < 5) {
{
setFocus(Qt::MouseFocusReason);
m_menuPosition = QPoint();
+ m_clipDrag = false;
// special cases (middle click button or ctrl / shift click
if (event->button() == Qt::MidButton) {
collisionClip = static_cast <AbstractClipItem *>(collisionList.at(ct));
if (collisionClip->isItemLocked())
break;
- if (collisionClip == m_dragItem)
+ if (collisionClip == m_dragItem) {
collisionClip = NULL;
- else
+ }
+ else {
m_dragItem = collisionClip;
+ }
found = true;
m_dragItem->setProperty("y_absolute", mapToScene(m_clickEvent).y() - m_dragItem->scenePos().y());
m_dragItemInfo = m_dragItem->info();
+ if (m_selectionGroup) m_selectionGroup->setProperty("y_absolute", mapToScene(m_clickEvent).y() - m_dragItem->scenePos().y());
if (m_dragItem->parentItem() && m_dragItem->parentItem()->type() == GROUPWIDGET && m_dragItem->parentItem() != m_selectionGroup) {
- // kDebug()<<"// KLIK FOUND GRP: "<<m_dragItem->sceneBoundingRect();
dragGroup = static_cast <AbstractGroupItem *>(m_dragItem->parentItem());
+ dragGroup->setProperty("y_absolute", mapToScene(m_clickEvent).y() - m_dragItem->scenePos().y());
}
break;
}
if (m_dragItem) emit clipItemSelected(NULL);
m_dragItem = NULL;
}
-#if QT_VERSION >= 0x040600
+#if QT_VERSION >= 0x040800
// Add shadow to dragged item, currently disabled because of painting artifacts
- //TODO: re-enable when fixed
- /*QGraphicsDropShadowEffect *eff = new QGraphicsDropShadowEffect();
- eff->setBlurRadius(5);
- eff->setOffset(3, 3);
- m_dragItem->setGraphicsEffect(eff);*/
+ /*if (m_dragItem) {
+ QGraphicsDropShadowEffect *eff = new QGraphicsDropShadowEffect();
+ eff->setBlurRadius(5);
+ eff->setOffset(3, 3);
+ m_dragItem->setGraphicsEffect(eff);
+ }*/
#endif
if (m_dragItem && m_dragItem->type() == TRANSITIONWIDGET) {
// update transition menu action
if (item->isItemLocked()) continue;
offsetList.append(item->startPos());
offsetList.append(item->endPos());
- m_selectionGroup->addToGroup(selection.at(i));
- selection.at(i)->setFlag(QGraphicsItem::ItemIsMovable, false);
+ m_selectionGroup->addItem(selection.at(i));
} else if (/*selection.at(i)->parentItem() == 0 && */selection.at(i)->type() == GROUPWIDGET) {
if (static_cast<AbstractGroupItem *>(selection.at(i))->isItemLocked()) continue;
QList<QGraphicsItem *> children = selection.at(i)->childItems();
offsetList.append(item->startPos());
offsetList.append(item->endPos());
}
- m_selectionGroup->addToGroup(selection.at(i));
- selection.at(i)->setFlag(QGraphicsItem::ItemIsMovable, false);
+ m_selectionGroup->addItem(selection.at(i));
} else if (selection.at(i)->parentItem() && !selection.contains(selection.at(i)->parentItem())) {
if (static_cast<AbstractGroupItem *>(selection.at(i)->parentItem())->isItemLocked()) continue;
- //AbstractGroupItem *grp = static_cast<AbstractGroupItem *>(selection.at(i)->parentItem());
- m_selectionGroup->addToGroup(selection.at(i)->parentItem());
- selection.at(i)->parentItem()->setFlag(QGraphicsItem::ItemIsMovable, false);
+ m_selectionGroup->addItem(selection.at(i)->parentItem());
}
}
m_spacerOffset = m_selectionGroup->sceneBoundingRect().left() - (int)(mapToScene(m_clickEvent).x());
} else {
seekCursorPos((int)(mapToScene(event->x(), 0).x()));
}
- //QGraphicsView::mousePressEvent(event);
+ QGraphicsView::mousePressEvent(event);
event->ignore();
return;
}
}
bool itemSelected = false;
- if (m_dragItem->isSelected())
+ if (m_dragItem->isSelected()) {
itemSelected = true;
- else if (m_dragItem->parentItem() && m_dragItem->parentItem()->isSelected())
+ }
+ else if (m_dragItem->parentItem() && m_dragItem->parentItem()->isSelected()) {
itemSelected = true;
- else if (dragGroup && dragGroup->isSelected())
+ }
+ else if (dragGroup && dragGroup->isSelected()) {
itemSelected = true;
+ }
if ((event->modifiers() == Qt::ControlModifier) || itemSelected == false) {
if (event->modifiers() != Qt::ControlModifier) {
if (m_dragItem->parentItem() && m_dragItem->parentItem()->type() == GROUPWIDGET) {
dragGroup = static_cast <AbstractGroupItem *>(m_dragItem->parentItem());
}
+
bool selected = !m_dragItem->isSelected();
- /*if (dragGroup)
+ QGraphicsView::mousePressEvent(event);
+
+ if (dragGroup) {
dragGroup->setSelected(selected);
- else*/
+ if (dragGroup->parentItem())
+ dragGroup->parentItem()->setSelected(selected);
+ }
+ else
m_dragItem->setSelected(selected);
if (selected == false) {
m_dragItem = NULL;
}
else updateClipTypeActions(NULL);
}
+ else {
+ QGraphicsView::mousePressEvent(event);
+ if (m_selectionGroup) {
+ QList<QGraphicsItem *> children = m_selectionGroup->childItems();
+ for (int i = 0; i < children.count(); i++) {
+ children.at(i)->setSelected(itemSelected);
+ }
+ m_selectionGroup->setSelected(itemSelected);
+
+ }
+ if (dragGroup)
+ dragGroup->setSelected(itemSelected);
+ m_dragItem->setSelected(itemSelected);
+ }
if (collisionClip != NULL || m_dragItem == NULL) {
if (m_dragItem && m_dragItem->type() == AVWIDGET && !m_dragItem->isItemLocked()) {
// If clicked item is selected, allow move
//if (!(event->modifiers() | Qt::ControlModifier) && m_operationMode == NONE)
- QGraphicsView::mousePressEvent(event);
+ //QGraphicsView::mousePressEvent(event);
if (m_dragItem) {
m_clickPoint = QPoint((int)(mapToScene(event->pos()).x() - m_dragItem->startPos().frames(m_document->fps())), (int)(event->pos().y() - m_dragItem->pos().y()));
}
m_blockRefresh = false;
- //kDebug()<<pos;
- QGraphicsView::mousePressEvent(event);
}
void CustomTrackView::rebuildGroup(int childTrack, GenTime childPos)
void CustomTrackView::rebuildGroup(AbstractGroupItem *group)
{
if (group) {
- resetSelectionGroup(false);
- m_scene->clearSelection();
-
QList <QGraphicsItem *> children = group->childItems();
m_document->clipManager()->removeGroup(group);
- scene()->destroyItemGroup(group);
- for (int i = 0; i < children.count(); i++)
- children.at(i)->setSelected(true);
- groupSelectedItems(false, true);
+ /*for (int i = 0; i < children.count(); i++) {
+ group->removeFromGroup(children.at(i));
+ }*/
+ scene()->destroyItemGroup(group);
+ groupSelectedItems(children, false, true, true);
}
}
QList<QGraphicsItem *> children = m_selectionGroup->childItems();
scene()->destroyItemGroup(m_selectionGroup);
+ m_selectionGroup = NULL;
for (int i = 0; i < children.count(); i++) {
if (children.at(i)->parentItem() == 0 && (children.at(i)->type() == AVWIDGET || children.at(i)->type() == TRANSITIONWIDGET)) {
if (!static_cast <AbstractClipItem *>(children.at(i))->isItemLocked()) {
children.at(i)->setSelected(selectItems);
}
}
-
- m_selectionGroup = NULL;
KdenliveSettings::setSnaptopoints(snap);
}
}
-void CustomTrackView::groupSelectedItems(bool force, bool createNewGroup)
+void CustomTrackView::groupSelectedItems(QList <QGraphicsItem *> selection, bool force, bool createNewGroup, bool selectNewGroup)
{
if (m_selectionGroup) {
kDebug() << "///// ERROR, TRYING TO OVERRIDE EXISTING GROUP";
return;
}
- QList<QGraphicsItem *> selection = m_scene->selectedItems();
- if (m_dragItem && !selection.contains(m_dragItem)) {
- selection << m_dragItem;
+ if (selection.isEmpty()) selection = m_scene->selectedItems();
+ // Split groups and items
+ QSet <QGraphicsItemGroup *> groupsList;
+ QSet <QGraphicsItem *> itemsList;
+
+ for (int i = 0; i < selection.count(); i++) {
+ if (selection.at(i)->type() == GROUPWIDGET) {
+ groupsList.insert(static_cast<AbstractGroupItem*> (selection.at(i)));
+ }
+ }
+ for (int i = 0; i < selection.count(); i++) {
+ if (selection.at(i)->type() == AVWIDGET || selection.at(i)->type() == TRANSITIONWIDGET) {
+ if (selection.at(i)->parentItem() && selection.at(i)->parentItem()->type() == GROUPWIDGET) {
+ groupsList.insert(static_cast <QGraphicsItemGroup *> (selection.at(i)->parentItem()));
+ }
+ else {
+ itemsList.insert(selection.at(i));
+ }
+ }
}
- if (selection.isEmpty()) return;
+ if (itemsList.isEmpty() && groupsList.isEmpty()) return;
+
QRectF rectUnion;
// Find top left position of selection
- for (int i = 0; i < selection.count(); i++) {
- if (selection.at(i)->parentItem() == 0 && (selection.at(i)->type() == AVWIDGET || selection.at(i)->type() == TRANSITIONWIDGET || selection.at(i)->type() == GROUPWIDGET)) {
- rectUnion = rectUnion.united(selection.at(i)->sceneBoundingRect());
- } else if (selection.at(i)->parentItem()) {
- rectUnion = rectUnion.united(selection.at(i)->parentItem()->sceneBoundingRect());
- }
+ foreach (const QGraphicsItemGroup *value, groupsList) {
+ rectUnion = rectUnion.united(value->sceneBoundingRect());
+ }
+ foreach (const QGraphicsItem *value, itemsList) {
+ rectUnion = rectUnion.united(value->sceneBoundingRect());
}
-
if (force || selection.count() > 1) {
bool snap = KdenliveSettings::snaptopoints();
KdenliveSettings::setSnaptopoints(false);
//newGroup->translate((int) -rectUnion.left(), (int) -rectUnion.top() + 1);
scene()->addItem(newGroup);
-
// Check if we are trying to include a group in a group
- QList <AbstractGroupItem *> groups;
- for (int i = 0; i < selection.count(); i++) {
- if (selection.at(i)->type() == GROUPWIDGET && !groups.contains(static_cast<AbstractGroupItem *>(selection.at(i))))
- groups.append(static_cast<AbstractGroupItem *>(selection.at(i)));
- else if (selection.at(i)->parentItem() && !groups.contains(static_cast<AbstractGroupItem *>(selection.at(i)->parentItem())))
- groups.append(static_cast<AbstractGroupItem *>(selection.at(i)->parentItem()));
- }
- if (!groups.isEmpty()) {
- // ungroup previous groups
- while (!groups.isEmpty()) {
- AbstractGroupItem *grp = groups.takeFirst();
- m_document->clipManager()->removeGroup(grp);
- scene()->destroyItemGroup(grp);
- }
- selection = m_scene->selectedItems();
- }
+ foreach (QGraphicsItemGroup *value, groupsList) {
+ QList<QGraphicsItem *> children = value->childItems();
+ for (int i = 0; i < children.count(); i++) {
+ if (children.at(i)->type() == AVWIDGET || children.at(i)->type() == TRANSITIONWIDGET)
+ itemsList.insert(children.at(i));
+ }
+ AbstractGroupItem *grp = static_cast<AbstractGroupItem *>(value);
+ m_document->clipManager()->removeGroup(grp);
+ scene()->destroyItemGroup(grp);
+ }
- for (int i = 0; i < selection.count(); i++) {
- if (selection.at(i)->type() == AVWIDGET || selection.at(i)->type() == TRANSITIONWIDGET) {
- newGroup->addToGroup(selection.at(i));
- selection.at(i)->setFlag(QGraphicsItem::ItemIsMovable, false);
- }
+ foreach (QGraphicsItem *value, itemsList) {
+ newGroup->addItem(value);
}
KdenliveSettings::setSnaptopoints(snap);
+ if (selectNewGroup) newGroup->setSelected(true);
} else {
m_selectionGroup = new AbstractGroupItem(m_document->fps());
m_selectionGroup->setPos(rectUnion.left(), rectUnion.top() - 1);
m_selectionGroup->translate(- diff.x(), -diff.y());
scene()->addItem(m_selectionGroup);
- for (int i = 0; i < selection.count(); i++) {
- if (selection.at(i)->parentItem() == 0 && (selection.at(i)->type() == AVWIDGET || selection.at(i)->type() == TRANSITIONWIDGET || selection.at(i)->type() == GROUPWIDGET)) {
- m_selectionGroup->addToGroup(selection.at(i));
- selection.at(i)->setFlag(QGraphicsItem::ItemIsMovable, false);
- }
+ foreach (QGraphicsItemGroup *value, groupsList) {
+ m_selectionGroup->addItem(value);
+ }
+ foreach (QGraphicsItem *value, itemsList) {
+ m_selectionGroup->addItem(value);
}
KdenliveSettings::setSnaptopoints(snap);
if (m_selectionGroup) {
m_selectionGroupInfo.startPos = GenTime(m_selectionGroup->scenePos().x(), m_document->fps());
m_selectionGroupInfo.track = m_selectionGroup->track();
+ if (selectNewGroup) m_selectionGroup->setSelected(true);
}
}
} else resetSelectionGroup();
}
m_selectionGroup = new AbstractGroupItem(m_document->fps());
ClipItem *item = new ClipItem(clip, info, m_document->fps(), 1.0, 1, getFrameWidth());
- m_selectionGroup->addToGroup(item);
- item->setFlag(QGraphicsItem::ItemIsMovable, false);
+ m_selectionGroup->addItem(item);
QList <GenTime> offsetList;
offsetList.append(info.endPos);
start += info.cropDuration;
offsetList.append(start);
ClipItem *item = new ClipItem(clip, info, m_document->fps(), 1.0, 1, getFrameWidth(), false);
- item->setFlag(QGraphicsItem::ItemIsMovable, false);
- m_selectionGroup->addToGroup(item);
+ m_selectionGroup->addItem(item);
if (!clip->isPlaceHolder()) m_waitingThumbs.append(item);
}
if (m_selectionGroup && m_clipDrag) {
QList<QGraphicsItem *> items = m_selectionGroup->childItems();
resetSelectionGroup();
+ m_dragItem = NULL;
m_scene->clearSelection();
bool hasVideoClip = false;
QUndoCommand *addCommand = new QUndoCommand();
m_pasteEffectsAction->setEnabled(m_copiedItems.count() == 1);
if (items.count() > 1) {
- groupSelectedItems(true);
+ groupSelectedItems(items, true);
} else if (items.count() == 1) {
m_dragItem = static_cast <AbstractClipItem *>(items.at(0));
emit clipItemSelected((ClipItem*) m_dragItem, false);
}
+ m_document->renderer()->refreshIfActive();
event->setDropAction(Qt::MoveAction);
event->accept();
scene()->addItem(m_selectionGroup);
for (int i = 0; i < selection.count(); i++) {
if ((!selection.at(i)->parentItem()) && (selection.at(i)->type() == AVWIDGET || selection.at(i)->type() == TRANSITIONWIDGET || selection.at(i)->type() == GROUPWIDGET)) {
- m_selectionGroup->addToGroup(selection.at(i));
- selection.at(i)->setFlag(QGraphicsItem::ItemIsMovable, false);
+ m_selectionGroup->addItem(selection.at(i));
}
}
// Move graphic items
scene()->addItem(m_selectionGroup);
for (int i = 0; i < selection.count(); i++) {
if ((!selection.at(i)->parentItem()) && (selection.at(i)->type() == AVWIDGET || selection.at(i)->type() == TRANSITIONWIDGET || selection.at(i)->type() == GROUPWIDGET)) {
- m_selectionGroup->addToGroup(selection.at(i));
- selection.at(i)->setFlag(QGraphicsItem::ItemIsMovable, false);
+ m_selectionGroup->addItem(selection.at(i));
}
}
// Move graphic items
clip = getClipItemAtStart(clipsToMove.at(i).startPos + offset, clipsToMove.at(i).track);
if (clip) {
if (clip->parentItem()) {
- m_selectionGroup->addToGroup(clip->parentItem());
- clip->parentItem()->setFlag(QGraphicsItem::ItemIsMovable, false);
+ m_selectionGroup->addItem(clip->parentItem());
} else {
- m_selectionGroup->addToGroup(clip);
- clip->setFlag(QGraphicsItem::ItemIsMovable, false);
+ m_selectionGroup->addItem(clip);
}
if (trackClipStartList.value(m_document->tracksCount() - clipsToMove.at(i).track) == -1 || clipsToMove.at(i).startPos.frames(m_document->fps()) < trackClipStartList.value(m_document->tracksCount() - clipsToMove.at(i).track))
trackClipStartList[m_document->tracksCount() - clipsToMove.at(i).track] = clipsToMove.at(i).startPos.frames(m_document->fps());
transition = getTransitionItemAtStart(transToMove.at(i).startPos + offset, transToMove.at(i).track);
if (transition) {
if (transition->parentItem()) {
- m_selectionGroup->addToGroup(transition->parentItem());
- transition->parentItem()->setFlag(QGraphicsItem::ItemIsMovable, false);
+ m_selectionGroup->addItem(transition->parentItem());
} else {
- m_selectionGroup->addToGroup(transition);
- transition->setFlag(QGraphicsItem::ItemIsMovable, false);
+ m_selectionGroup->addItem(transition);
}
if (trackTransitionStartList.value(m_document->tracksCount() - transToMove.at(i).track) == -1 || transToMove.at(i).startPos.frames(m_document->fps()) < trackTransitionStartList.value(m_document->tracksCount() - transToMove.at(i).track))
trackTransitionStartList[m_document->tracksCount() - transToMove.at(i).track] = transToMove.at(i).startPos.frames(m_document->fps());
delete deleteCommand;
} else {
updateTrackDuration(-1, deleteCommand);
+ new RefreshMonitorCommand(this, false, deleteCommand);
m_commandStack->push(deleteCommand);
}
+ m_document->renderer()->doRefresh();
}
void CustomTrackView::seekCursorPos(int pos)
void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
{
if (m_moveOpMode == SEEK) m_moveOpMode = NONE;
- if (!m_controlModifier) QGraphicsView::mouseReleaseEvent(event);
- setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate);
-#if QT_VERSION >= 0x040600
- if (m_dragItem) m_dragItem->setGraphicsEffect(NULL);
+ if (!m_controlModifier && m_operationMode != RUBBERSELECTION) {
+ //event->accept();
+ if (m_clipDrag) QGraphicsView::mouseReleaseEvent(event);
+ }
+ m_clipDrag = false;
+ //setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate);
+#if QT_VERSION >= 0x040800
+ if (m_dragItem) {
+ m_dragItem->setGraphicsEffect(NULL);
+ }
#endif
if (m_scrollTimer.isActive()) m_scrollTimer.stop();
if (event->button() == Qt::MidButton) {
return;
}
- setDragMode(QGraphicsView::NoDrag);
+
if (m_operationMode == MOVEGUIDE) {
setCursor(Qt::ArrowCursor);
m_operationMode = NONE;
updateTrackDuration(track, command);
m_commandStack->push(command);
if (track != -1) track = m_document->tracksCount() - track;
- kDebug() << "SPACER TRACK:" << track;
m_document->renderer()->mltInsertSpace(trackClipStartList, trackTransitionStartList, track, timeOffset, GenTime());
setDocumentModified();
}
}
- for (int i = 0; i < groups.count(); i++)
+ resetSelectionGroup();
+ for (int i = 0; i < groups.count(); i++) {
rebuildGroup(groups.at(i));
+ }
- resetSelectionGroup();
clearSelection();
m_operationMode = NONE;
} else if (m_operationMode == RUBBERSELECTION) {
+ //event->accept();
+ QGraphicsView::mouseReleaseEvent(event);
+ setDragMode(QGraphicsView::NoDrag);
+ setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate);
+ if (event->modifiers() != Qt::ControlModifier) m_dragItem = NULL;
resetSelectionGroup();
groupSelectedItems();
m_operationMode = NONE;
// Moving several clips. We need to delete them and readd them to new position,
// or they might overlap each other during the move
QGraphicsItemGroup *group;
- if (m_selectionGroup)
+ if (m_selectionGroup) {
group = static_cast <QGraphicsItemGroup *>(m_selectionGroup);
- else
+ }
+ else {
group = static_cast <QGraphicsItemGroup *>(m_dragItem->parentItem());
+ }
QList<QGraphicsItem *> items = group->childItems();
QList<ItemInfo> clipsToMove;
QList<ItemInfo> transitionsToMove;
if (m_selectionGroup) {
m_selectionGroupInfo.startPos = GenTime(m_selectionGroup->scenePos().x(), m_document->fps());
m_selectionGroupInfo.track = m_selectionGroup->track();
-
- QList <AbstractGroupItem*> groupList;
- for (int i = 0; i < items.count(); ++i) {
- if (items.at(i)->type() == GROUPWIDGET) {
- AbstractGroupItem* group = (AbstractGroupItem*)items.at(i);
- if (!groupList.contains(group)) groupList.append(group);
- items.removeAt(i);
- --i;
+ items = m_selectionGroup->childItems();
+ resetSelectionGroup(false);
+
+ QSet <QGraphicsItem*> groupList;
+ QSet <QGraphicsItem*> itemList;
+ while (!items.isEmpty()) {
+ QGraphicsItem *first = items.takeFirst();
+ if (first->type() == GROUPWIDGET) {
+ if (first != m_selectionGroup) {
+ groupList.insert(first);
+ }
}
- }
- for (int i = 0; i < groupList.count(); ++i) {
- rebuildGroup(groupList.at(i));
+ else if (first->type() == AVWIDGET || first->type() == TRANSITIONWIDGET) {
+ if (first->parentItem() && first->parentItem()->type() == GROUPWIDGET) {
+ if (first->parentItem() != m_selectionGroup) {
+ groupList.insert(first->parentItem());
+ }
+ else itemList.insert(first);
+ }
+ else itemList.insert(first);
+ }
}
-
- for (int i = 0; i < items.count(); ++i) {
- if (items.at(i)) {
- items.at(i)->setSelected(true);
- if (items.at(i)->parentItem())
- items.at(i)->parentItem()->setSelected(true);
- }
+ foreach(QGraphicsItem *item, groupList) {
+ itemList.unite(item->childItems().toSet());
+ rebuildGroup(static_cast <AbstractGroupItem*>(item));
+ }
+
+ foreach(QGraphicsItem *item, itemList) {
+ item->setSelected(true);
+ if (item->parentItem())
+ item->parentItem()->setSelected(true);
}
resetSelectionGroup();
- groupSelectedItems();
+ groupSelectedItems(itemList.toList());
} else {
- rebuildGroup((AbstractGroupItem *)group);
+ AbstractGroupItem *grp = static_cast <AbstractGroupItem *>(group);
+ rebuildGroup(grp);
}
setDocumentModified();
}
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();
}
setDocumentModified();
return;
}
-
- QList <QGraphicsItemGroup *> groups;
+ QList <QGraphicsItem *>list;
for (int i = 0; i < clipInfos.count(); i++) {
ClipItem *clip = getClipItemAt(clipInfos.at(i).startPos, clipInfos.at(i).track);
if (clip) {
- clip->setSelected(true);
+ list.append(clip);
+ //clip->setSelected(true);
}
}
for (int i = 0; i < transitionInfos.count(); i++) {
Transition *clip = getTransitionItemAt(transitionInfos.at(i).startPos, transitionInfos.at(i).track);
if (clip) {
- clip->setSelected(true);
+ list.append(clip);
+ //clip->setSelected(true);
}
}
- groupSelectedItems(false, true);
+ groupSelectedItems(list, false, true);
setDocumentModified();
}
if (clip) {
clip->setItemLocked(false);
if (clip->parentItem()) {
- m_selectionGroup->addToGroup(clip->parentItem());
- clip->parentItem()->setFlag(QGraphicsItem::ItemIsMovable, false);
+ m_selectionGroup->addItem(clip->parentItem());
} else {
- m_selectionGroup->addToGroup(clip);
- clip->setFlag(QGraphicsItem::ItemIsMovable, false);
+ m_selectionGroup->addItem(clip);
}
m_document->renderer()->mltRemoveClip(m_document->tracksCount() - startClip.at(i).track, startClip.at(i).startPos);
} else kDebug() << "//MISSING CLIP AT: " << startClip.at(i).startPos.frames(25);
if (tr) {
tr->setItemLocked(false);
if (tr->parentItem()) {
- m_selectionGroup->addToGroup(tr->parentItem());
- tr->parentItem()->setFlag(QGraphicsItem::ItemIsMovable, false);
+ m_selectionGroup->addItem(tr->parentItem());
} else {
- m_selectionGroup->addToGroup(tr);
- tr->setFlag(QGraphicsItem::ItemIsMovable, false);
+ m_selectionGroup->addItem(tr);
}
m_document->renderer()->mltDeleteTransition(tr->transitionTag(), tr->transitionEndTrack(), m_document->tracksCount() - startTransition.at(i).track, startTransition.at(i).startPos, startTransition.at(i).endPos, tr->toXML());
} else kDebug() << "//MISSING TRANSITION AT: " << startTransition.at(i).startPos.frames(25);
}
resetSelectionGroup(false);
- for (int i = 0; i < groupList.count(); i++)
+ for (int i = 0; i < groupList.count(); i++) {
rebuildGroup(groupList.at(i));
+ }
clearSelection();
}
}
updateTrackDuration(-1, pasteClips);
+ new RefreshMonitorCommand(this, false, pasteClips);
m_commandStack->push(pasteClips);
}
for (int i = 0; i < groups.count(); i++) {
QDomNodeList children = groups.at(i).childNodes();
scene()->clearSelection();
+ QList <QGraphicsItem*>list;
for (int nodeindex = 0; nodeindex < children.count(); nodeindex++) {
QDomElement elem = children.item(nodeindex).toElement();
int pos = elem.attribute("position").toInt();
int track = elem.attribute("track").toInt();
if (elem.tagName() == "clipitem") {
ClipItem *clip = getClipItemAt(pos, track); //m_document->tracksCount() - transitiontrack);
- if (clip) clip->setSelected(true);
+ if (clip) list.append(clip);//clip->setSelected(true);
} else {
Transition *clip = getTransitionItemAt(pos, track); //m_document->tracksCount() - transitiontrack);
- if (clip) clip->setSelected(true);
+ if (clip) list.append(clip);//clip->setSelected(true);
}
}
- groupSelectedItems(false, true);
+ groupSelectedItems(list, false, true);
}
}
}
}
}
- kDebug() << "GOT TRK: " << track;
if (freetrack == 0) {
emit displayMessage(i18n("No empty space to put clip audio"), ErrorMessage);
} else {
ItemInfo info = clip->info();
info.track = m_document->tracksCount() - freetrack;
- addClip(clip->xml(), clip->clipProducer(), info, clip->effectList());
- scene()->clearSelection();
+ QDomElement xml = clip->xml();
+ xml.setAttribute("audio_only", 1);
+ scene()->clearSelection();
+ addClip(xml, clip->clipProducer(), info, clip->effectList(), false, false, false);
clip->setSelected(true);
ClipItem *audioClip = getClipItemAt(start, info.track);
if (audioClip) {
+ clip->setVideoOnly(true);
Mlt::Tractor *tractor = m_document->renderer()->lockService();
- clip->setVideoOnly(true);
if (m_document->renderer()->mltUpdateClipProducer(tractor, m_document->tracksCount() - track, start, clip->baseClip()->videoProducer(info.track)) == false) {
emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", start, track), ErrorMessage);
}
- if (m_document->renderer()->mltUpdateClipProducer(tractor, m_document->tracksCount() - info.track, start, clip->baseClip()->audioProducer(info.track)) == false) {
- emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", start, info.track), ErrorMessage);
- }
m_document->renderer()->unlockService(tractor);
audioClip->setSelected(true);
- audioClip->setAudioOnly(true);
// keep video effects, move audio effects to audio clip
int videoIx = 0;
videoIx++;
}
}
-
- groupSelectedItems(false, true);
+ groupSelectedItems(QList <QGraphicsItem*>()<<clip<<audioClip, false, true);
}
}
} else {
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);
m_scene->addItem(grp);
scene()->destroyItemGroup(grp);
scene()->clearSelection();
- for (int j = 0; j < children.count(); j++) {
+ /*for (int j = 0; j < children.count(); j++) {
if (children.at(j)->type() == AVWIDGET || children.at(j)->type() == TRANSITIONWIDGET) {
//children.at(j)->setParentItem(0);
children.at(j)->setSelected(true);
}
- }
- groupSelectedItems(true, true);
+ }*/
+ groupSelectedItems(children, true, true);
} else if (itemList.at(i)->type() == GUIDEITEM) {
Guide *g = static_cast<Guide *>(itemList.at(i));
g->updatePos();
QRectF rect(0, m_selectedTrack * m_tracksHeight + m_tracksHeight / 2, sceneRect().width(), m_tracksHeight / 2 - 1);
QList<QGraphicsItem *> selection = m_scene->items(rect);
m_scene->clearSelection();
+ QList<QGraphicsItem *> list;
for (int i = 0; i < selection.count(); i++) {
if (selection.at(i)->type() == AVWIDGET || selection.at(i)->type() == TRANSITIONWIDGET || selection.at(i)->type() == GROUPWIDGET) {
- selection.at(i)->setSelected(true);
+ list.append(selection.at(i));
}
}
resetSelectionGroup();
- groupSelectedItems();
+ groupSelectedItems(list);
}
void CustomTrackView::slotSelectAllClips()
{
QList<QGraphicsItem *> selection = m_scene->items();
m_scene->clearSelection();
- for (int i = 0; i < selection.count(); i++) {
- if (selection.at(i)->type() == AVWIDGET || selection.at(i)->type() == TRANSITIONWIDGET || selection.at(i)->type() == GROUPWIDGET) {
- selection.at(i)->setSelected(true);
- }
- }
resetSelectionGroup();
- groupSelectedItems();
+ groupSelectedItems(selection);
}
void CustomTrackView::selectClip(bool add, bool group, int track, int pos)
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. */
ClipItem *getClipUnderCursor() const;
AbstractClipItem *getMainActiveClip() const;
void resetSelectionGroup(bool selectItems = true);
- void groupSelectedItems(bool force = false, bool createNewGroup = false);
+ void groupSelectedItems(QList <QGraphicsItem *> selection = QList <QGraphicsItem *>(), bool force = false, bool createNewGroup = false, bool selectNewGroup = false);
/** Get available space for clip move (min and max free positions) */
void getClipAvailableSpace(AbstractClipItem *item, GenTime &minimum, GenTime &maximum);
/** Get available space for transition move (min and max free positions) */
m_paramWidget = new ParameterContainer(d, info, &m_metaInfo, m_baseWidget);
connect (m_paramWidget, SIGNAL(parameterChanged(const QDomElement, const QDomElement, int)), this, SIGNAL(parameterChanged(const QDomElement, const QDomElement, int)));
- connect(m_paramWidget, SIGNAL(startFilterJob(QString,QString,QString,QString,QString,QStringList)), this, SIGNAL(startFilterJob(QString,QString,QString,QString,QString,QStringList)));
+ connect(m_paramWidget, SIGNAL(startFilterJob(QString,QString,QString,QString,const QMap<QString, QString>)), this, SIGNAL(startFilterJob(QString,QString,QString,QString,const QMap<QString, QString>)));
connect (this, SIGNAL(syncEffectsPos(int)), m_paramWidget, SIGNAL(syncEffectsPos(int)));
connect (m_paramWidget, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
void showComments(bool show);
void effectStateChanged(bool enabled);
/** @brief Start an MLT filter job on this clip. */
- void startFilterJob(const QString &filterName, const QString &filterParams, const QString &finalFilterName, const QString &consumer, const QString &consumerParams, const QStringList&extraParams);
+ void startFilterJob(const QString &filterName, const QString &filterParams, const QString &consumer, const QString &consumerParams, const QMap <QString, QString>);
void importClipKeyframes(GRAPHICSRECTITEM = AVWIDGET);
};
#include "monitorscene.h"
#include "monitoreditwidget.h"
#include "onmonitoritems/onmonitorrectitem.h"
+#include "onmonitoritems/onmonitorpathitem.h"
#include "kdenlivesettings.h"
#include "dragvalue.h"
m_outPoint(1),
m_isEffect(isEffect),
m_rect(NULL),
+ m_geomPath(NULL),
m_previous(NULL),
m_geometry(NULL),
m_showScene(true),
delete m_spinHeight;
delete m_opacity;
m_scene->removeItem(m_rect);
+ m_scene->removeItem(m_geomPath);
if (m_rect) delete m_rect;
+ if (m_geomPath) delete m_geomPath;
if (m_previous) delete m_previous;
delete m_geometry;
m_extraGeometryNames.clear();
}
Mlt::GeometryItem item;
-
m_geometry->fetch(&item, 0);
- delete m_rect;
+ if (m_rect) {
+ m_scene->removeItem(m_rect);
+ delete m_rect;
+ }
+ if (m_geomPath) {
+ m_scene->removeItem(m_geomPath);
+ delete m_geomPath;
+ }
m_rect = new OnMonitorRectItem(QRectF(0, 0, item.w(), item.h()), m_monitor->render->dar());
m_rect->setPos(item.x(), item.y());
m_rect->setZValue(0);
m_scene->addItem(m_rect);
connect(m_rect, SIGNAL(changed()), this, SLOT(slotUpdateGeometry()));
+ m_geomPath = new OnMonitorPathItem(m_monitor->render->dar());
+ connect(m_geomPath, SIGNAL(changed()), this, SLOT(slotUpdatePath()));
+ m_geomPath->setPen(QPen(Qt::red));
+ m_scene->addItem(m_geomPath);
+ m_geomPath->setPoints(m_geometry);
m_scene->centerView();
slotPositionChanged(0, false);
}
slotDeleteKeyframe();
}
+void GeometryWidget::slotUpdatePath()
+{
+ if (!m_geomPath) return;
+ QList <QPointF> points = m_geomPath->points();
+ Mlt::GeometryItem item;
+ int pos = 0;
+ int ix = 0;
+ while (ix < points.count() && !m_geometry->next_key(&item, pos)) {
+ QPointF center = points.at(ix);
+ QSizeF size(item.w(), item.h());
+ item.x(center.x() - size.width()/2);
+ item.y(center.y() - size.height()/2);
+ m_geometry->insert(item);
+ pos = item.frame() + 1;
+ ix++;
+ }
+ slotPositionChanged(-1, false);
+ emit parameterChanged();
+}
void GeometryWidget::slotUpdateGeometry()
geom->insert(item2);
}
}
+ if (m_geomPath) m_geomPath->setPoints(m_geometry);
emit parameterChanged();
}
class KeyframeHelper;
class TimecodeDisplay;
class OnMonitorRectItem;
+class OnMonitorPathItem;
class QGraphicsRectItem;
class DragValue;
bool m_isEffect;
MonitorScene *m_scene;
OnMonitorRectItem *m_rect;
+ OnMonitorPathItem *m_geomPath;
QGraphicsRectItem *m_previous;
KeyframeHelper *m_timeline;
/** Stores the different settings in the MLT geometry format. */
/** @brief Adds or deletes a keyframe depending on whether there is already a keyframe at the current position. */
void slotAddDeleteKeyframe();
+ /** @brief Updates the Mlt::Geometry path object. */
+ void slotUpdatePath();
/** @brief Updates the Mlt::Geometry object. */
void slotUpdateGeometry();
/** @brief Updates the spinBoxes according to the rect. */
Name[it]=Kdenlive
Name[ja]=Kdenlive
Name[km]=Kdenlive
+Name[lt]=Kdenlive
Name[nb]=Kdenlive
Name[nds]=Kdenlive
Name[nl]=Kdenlive
GenericName[it]=Editor video
GenericName[ja]=ビデオエディタ
GenericName[km]=កម្មវិធីកែសម្រួលវីដេអូ
+GenericName[lt]=Video redaktorius
GenericName[nb]=Videoredigeringsprogram
GenericName[nl]=Video-bewerker
GenericName[pl]=Edytor wideo
Comment[it]=Editor di video non lineare per KDE
Comment[ja]=KDE 向けノンリニアビデオエディタ
Comment[km]=កម្មវិធីកែសម្រួលវីដេអូមិនលីនេអ៊ែរសម្រាប់ KDE
+Comment[lt]=Nelinijinis veido redaktorius skirtas KDE
Comment[nb]=Videoredigeringsprogram for KDE med dataklipping
Comment[nl]=Niet-lineaire video-bewerker voor KDE
Comment[pl]=Nieliniowy edytor wideo dla KDE
Comment[it]=Kdenlive
Comment[ja]=Kdenlive
Comment[km]=Kdenlive
+Comment[lt]=Kdenlive
Comment[nb]=Kdenlive
Comment[nds]=Kdenlive
Comment[nl]=Kdenlive
Name[it]=Esportazione terminata
Name[ja]=レンダリングが完了しました
Name[km]=បានបញ្ចប់ការបង្ហាញ
+Name[lt]=Atvaizdavimas baigtas
Name[nb]=Opptegning avsluttet
Name[nl]=Weergave uitwerken beëindigd
Name[pl]=Ukończono renderowanie
Comment[it]=L'esportazione è terminata
Comment[ja]=レンダリングが終了しました
Comment[km]=ការបង្ហាញបានចប់
+Comment[lt]=Atvaizdavimas baigtas
Comment[nb]=Ferdig med opptegning
Comment[nl]=Weergave uitwerken is gereed
Comment[pl]=Ukończono zostało zakończone
Name[it]=Esportazione avviata
Name[ja]=レンダリングを開始しました
Name[km]=ការបង្ហាញបានចាប់ផ្ដើម
+Name[lt]=Atvaizdavimas pradėtas
Name[nb]=Opptegning påbegynt
Name[nl]=Weergave uitwerken begonnen
Name[pl]=Rozpoczęto renderowanie
Comment[it]=L'esportazione è stata avviata
Comment[ja]=レンダリングを開始しました
Comment[km]=ការបង្ហាញត្រូវបានចាប់ផ្ដើម
+Comment[lt]=Atvaizdavimas buvo pradėtas
Comment[nb]=Startet opptegning
Comment[nl]=Weergave uitwerken is begonnen
Comment[pl]=Renderowanie zostało rozpoczęte
Name[it]=Fotogramma acquisito
Name[ja]=フレームをキャプチャしました
Name[km]=បានចាប់យកស៊ុម
+Name[lt]=Kadras išsaugotas
Name[nb]=Stillbilde tatt
Name[nl]=Frame opgenomen
Name[pl]=Przechwycono klatkę
Comment[it]=È stato acquisito un fotogramma sul disco
Comment[ja]=フレームをディスクにキャプチャしました
Comment[km]=ស៊ុមត្រូវបានចាប់យកទៅកាន់ថាស
+Comment[lt]=Kadras buvo išsaugotas į diską
Comment[nb]=Et stillbilde ble lagret
Comment[nl]=Een frame is op schijf opgenomen
Comment[pl]=Klatka została przechwycona na dysk
Name[it]=Pronto per la registrazione
Name[ja]=キャプチャ準備完了
Name[km]=រួចរាល់ដើម្បីចាប់យក
+Name[lt]=Pasiruošęs išsaugoti
Name[nb]=Klar til å ta stillbilde
Name[nl]=Gereed om op te nemen
Name[pl]=Gotowy do przechwycenia
Name[it]=Errore
Name[ja]=エラー
Name[km]=កំហុស
+Name[lt]=Klaida
Name[nb]=Feil
Name[nds]=Fehler
Name[nl]=Fout
Comment[it]=Si è verificato un errore in Kdenlive
Comment[ja]=Kdenlive 内でエラーが発生
Comment[km]=មានកំហុសបានកើតឡើងនៅក្នុង Kdenlive
+Comment[lt]=Įvyko Kdenlive klaida
Comment[nb]=En feil oppsto i Kdenlive
Comment[nl]=Er is een fout opgetreden in Kdenlive
Comment[pl]=Wystąpił błąd w Kdenlive
// 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();
#include "monitorscene.h"
#include "kdenlivesettings.h"
+#include "onmonitoritems/onmonitorrectitem.h"
+#include "onmonitoritems/onmonitorpathitem.h"
+
#include <QGraphicsView>
#include <QVBoxLayout>
#include <QAction>
#include <QToolButton>
+#include <QMouseEvent>
#include <KIcon>
+
MonitorEditWidget::MonitorEditWidget(Render* renderer, QWidget* parent) :
QWidget(parent)
{
m_scene = new MonitorScene(renderer);
m_view = new QGraphicsView(m_scene, m_ui.frameVideo);
m_view->setFrameShape(QFrame::NoFrame);
- m_view->setRenderHints(QFlags<QPainter::RenderHint>());
+ //m_view->setRenderHints(QFlags<QPainter::RenderHint>());
m_view->scale(((double) renderer->renderWidth()) / renderer->frameRenderWidth(), 1.0);
m_view->setMouseTracking(true);
m_scene->setUp();
#include "ui_monitoreditwidget_ui.h"
#include <QWidget>
+#include <QGraphicsView>
class QIcon;
class MonitorScene;
class QVBoxLayout;
-
class MonitorEditWidget : public QWidget
{
Q_OBJECT
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();
${kdenlive_SRCS}
onmonitoritems/onmonitorcornersitem.cpp
onmonitoritems/onmonitorrectitem.cpp
+ onmonitoritems/onmonitorpathitem.cpp
PARENT_SCOPE
)
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2010 by Till Theato (root@ttill.de) *
+ * *
+ * 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 "onmonitorpathitem.h"
+#include "kdenlivesettings.h"
+
+#include <QGraphicsSceneMouseEvent>
+#include <QPainter>
+#include <QStyleOptionGraphicsItem>
+#include <QCursor>
+#include <QGraphicsView>
+#include <QApplication>
+
+#include <mlt++/Mlt.h>
+
+OnMonitorPathItem::OnMonitorPathItem(double dar, QGraphicsItem* parent) :
+ QGraphicsPathItem(parent),
+ m_dar(dar),
+ m_modified(false),
+ m_view(NULL),
+ m_activePoint(-1)
+{
+ setFlags(QGraphicsItem::ItemIsMovable);
+
+ QPen framepen(Qt::SolidLine);
+ framepen.setColor(Qt::red);
+ setPen(framepen);
+ setBrush(Qt::transparent);
+ setAcceptHoverEvents(true);
+}
+
+void OnMonitorPathItem::setPoints(Mlt::Geometry *geometry)
+{
+ m_points.clear();
+ QRectF r;
+ int pos = 0;
+ Mlt::GeometryItem item;
+ while (!geometry->next_key(&item, pos)) {
+ r = QRectF(item.x(), item.y(), item.w(), item.h());
+ m_points << r.center();
+ pos = item.frame() + 1;
+ }
+ rebuildShape();
+}
+
+void OnMonitorPathItem::rebuildShape() {
+ if (m_activePoint > m_points.count()) m_activePoint = -1;
+ QPainterPath p;
+ QPainterPath shape;
+
+ if (!m_points.isEmpty()) {
+ QRectF r(0, 0, 20, 20);
+ r.moveCenter(m_points.at(0));
+ shape.addRect(r);
+
+ p.moveTo(m_points.at(0));
+ for (int i = 1; i < m_points.count(); i++) {
+ p.lineTo(m_points.at(i));
+ r.moveCenter(m_points.at(i));
+ shape.addRect(r);
+ }
+ }
+ m_shape = shape;
+ setPath(p);
+}
+
+void OnMonitorPathItem::getMode(QPointF pos)
+{
+ double dist = 8;
+ if (getView()) {
+ dist /= m_view->matrix().m11();
+ }
+ // Item mapped coordinates
+ for (int i = 0; i < m_points.count(); i++) {
+ if ((pos - m_points.at(i)).manhattanLength() <= dist) {
+ m_activePoint = i;
+ return;
+ }
+ }
+ m_activePoint = -1;
+}
+
+void OnMonitorPathItem::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
+{
+ /*if (event->buttons() != Qt::NoButton && (event->screenPos() - m_screenClickPoint).manhattanLength() < QApplication::startDragDistance()) {
+ * event->accept();
+ * return;
+ }*/
+
+ if (m_activePoint >= 0 && event->buttons() & Qt::LeftButton) {
+ QPointF mousePos = event->pos();
+ m_points[m_activePoint] = mousePos;
+ rebuildShape();
+ m_modified = true;
+ update();
+ }
+
+ if (m_modified) {
+ event->accept();
+ if (KdenliveSettings::monitorscene_directupdate()) {
+ emit changed();
+ m_modified = false;
+ }
+ } else {
+ event->ignore();
+ }
+}
+
+QList <QPointF> OnMonitorPathItem::points() const
+{
+ return m_points;
+}
+
+void OnMonitorPathItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
+{
+ if (m_modified) {
+ m_modified = false;
+ emit changed();
+ }
+ event->accept();
+}
+
+QRectF OnMonitorPathItem::boundingRect () const
+{
+ return shape().boundingRect();
+}
+
+QPainterPath OnMonitorPathItem::shape () const
+{
+ return m_shape;
+}
+
+void OnMonitorPathItem::hoverLeaveEvent(QGraphicsSceneHoverEvent* /*event*/)
+{
+ if (m_activePoint != -1) {
+ m_activePoint = -1;
+ update();
+ }
+ unsetCursor();
+}
+
+void OnMonitorPathItem::hoverEnterEvent(QGraphicsSceneHoverEvent* /*event*/)
+{
+ setCursor(QCursor(Qt::PointingHandCursor));
+}
+
+void OnMonitorPathItem::hoverMoveEvent(QGraphicsSceneHoverEvent* event)
+{
+ int currentPoint = m_activePoint;
+ getMode(event->pos());
+ if (currentPoint != m_activePoint) update();
+ setCursor(QCursor(Qt::PointingHandCursor));
+}
+
+void OnMonitorPathItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
+{
+ //Q_UNUSED(widget)
+ QGraphicsPathItem::paint(painter, option, widget);
+
+ double w = 6;
+ double h = 6;
+ if (getView()) {
+ w /= m_view->matrix().m11();
+ h /= m_view->matrix().m22();
+ }
+
+ QRectF handle(0, 0, w, h);
+ for (int i = 0; i < m_points.count(); i++) {
+ handle.moveCenter(m_points.at(i));
+ painter->fillRect(handle, m_activePoint == i ? Qt::blue : pen().color());
+ }
+}
+
+bool OnMonitorPathItem::getView()
+{
+ if (m_view)
+ return true;
+
+ if (scene() && scene()->views().count()) {
+ m_view = scene()->views()[0];
+ return true;
+ } else {
+ return false;
+ }
+}
+
+#include "onmonitorpathitem.moc"
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2010 by Till Theato (root@ttill.de) *
+ * *
+ * 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 ONMONITORPATHITEM_H
+#define ONMONITORPATHITEM_H
+
+
+#include <QtCore>
+#include <QGraphicsPathItem>
+
+class QGraphicsView;
+
+namespace Mlt {
+class Geometry;
+}
+
+
+class OnMonitorPathItem : public QObject, public QGraphicsPathItem
+{
+ Q_OBJECT
+public:
+ OnMonitorPathItem(double dar, QGraphicsItem *parent = 0);
+ void setPoints(Mlt::Geometry *geometry);
+ void getMode(QPointF pos);
+ void rebuildShape();
+ QList <QPointF> points() const;
+ virtual QPainterPath shape () const;
+
+ /** @brief Reimplemented to draw the handles. */
+ virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0 );
+ virtual QRectF boundingRect () const;
+
+protected:
+ //virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
+ virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
+ virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+ virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
+ virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
+ virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
+
+private:
+ double m_dar;
+ QList <QPointF> m_points;
+ QPointF m_lastPoint;
+ bool m_modified;
+ QGraphicsView *m_view;
+ int m_activePoint;
+ QPainterPath m_shape;
+
+ /** @brief Tries to get the view of the scene. */
+ bool getView();
+
+signals:
+ void changed();
+};
+
+#endif
right.lineTo(pol.at(2));
QPainterPath mouseArea;
- qreal size = 8;
- if (getView())
- size /= m_view->matrix().m11();
- mouseArea.addRect(pos.x() - size / 2, pos.y() - size / 2, size, size);
+ qreal xsize = 10;
+ qreal ysize = 10;
+ if (getView()) {
+ xsize /= m_view->matrix().m11();
+ ysize /= m_view->matrix().m22();
+ }
+ mouseArea.addRect(pos.x() - xsize / 2, pos.y() - ysize / 2, xsize, ysize);
// Check for collisions between the mouse and the borders
if (mouseArea.contains(pol.at(0)))
painter->setPen(pen());
painter->drawRect(option->rect);
-
+ const QRectF r = painter->worldTransform().mapRect(option->rect);
+ painter->setWorldMatrixEnabled(false);
if (isEnabled()) {
- double handleSize = 6 / painter->worldTransform().m11();
- double halfHandleSize = handleSize / 2;
- painter->fillRect(-halfHandleSize, -halfHandleSize, handleSize, handleSize, QColor(Qt::yellow));
- painter->fillRect(option->rect.width() - halfHandleSize, -halfHandleSize, handleSize, handleSize, QColor(Qt::yellow));
- painter->fillRect(option->rect.width() - halfHandleSize, option->rect.height() - halfHandleSize, handleSize, handleSize, QColor(Qt::yellow));
- painter->fillRect(-halfHandleSize, option->rect.height() - halfHandleSize, handleSize, handleSize, QColor(Qt::yellow));
+ QRectF handle(0, 0, 6, 6);
+ handle.moveTopLeft(r.topLeft());
+ painter->fillRect(handle, QColor(Qt::yellow));
+ handle.moveTopRight(r.topRight());
+ painter->fillRect(handle, QColor(Qt::yellow));
+ handle.moveBottomLeft(r.bottomLeft());
+ painter->fillRect(handle, QColor(Qt::yellow));
+ handle.moveBottomRight(r.bottomRight());
+ painter->fillRect(handle, QColor(Qt::yellow));
}
+
+ // Draw cross at center
+ QPointF center = r.center();
+ painter->drawLine(center + QPointF(-6, 0), center + QPointF(6, 0));
+ painter->drawLine(center + QPointF(0, 6), center + QPointF(0, -6));
}
bool OnMonitorRectItem::getView()
enum rectActions { Move, ResizeTopLeft, ResizeBottomLeft, ResizeTopRight, ResizeBottomRight, ResizeLeft, ResizeRight, ResizeTop, ResizeBottom, NoAction };
+
class OnMonitorRectItem : public QObject, public QGraphicsRectItem
{
Q_OBJECT
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();
if (!producer || !producer->is_valid()) {
if (producer) delete producer;
producer = m_blackClip->cut(0, 1);
+ producer->set("id", "black");
}
if (!producer || !producer->is_valid()) {
}
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();
Mlt::Tractor *Render::lockService()
{
// we are going to replace some clips, purge consumer
- QMutexLocker locker(&m_mutex);
if (!m_mltProducer) return NULL;
+ QMutexLocker locker(&m_mutex);
if (m_mltConsumer) {
- if (!m_mltConsumer->is_stopped()) m_mltConsumer->stop();
m_mltConsumer->purge();
}
Mlt::Service service(m_mltProducer->parent().get_service());
if (service.type() != tractor_type) {
- kWarning() << "// TRACTOR PROBLEM";
return NULL;
}
service.lock();
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.
bool isMime = m_view.method_mime->isChecked();
QString path = isMime ? m_view.folder_url->url().path() : m_view.pattern_url->url().directory();
QDir dir(path);
- if (path.isEmpty() || !dir.exists()) return;
+ if (path.isEmpty() || !dir.exists()) {
+ m_count = 0;
+ m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
+ m_view.label_info->setText(QString());
+ return;
+ }
KIcon unknownicon("unknown");
QStringList result;
item->setData(Qt::UserRole, dir.filePath(path));
m_view.icon_list->addItem(item);
}
- m_count = result.count();
- if (m_count == 0) m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
- else m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
+ m_count = m_view.icon_list->count();
+ m_view.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(m_count > 0);
m_view.label_info->setText(i18np("1 image found", "%1 images found", m_count));
if (m_view.show_thumbs->isChecked()) slotGenerateThumbs();
m_view.icon_list->setCurrentRow(0);
int precision = fullSize - filter.size();
int firstFrame = firstFrameData.right(precision).toInt();
+ // Workaround bug in MLT image sequence detection
+ if (firstFrame < 3) firstFrame = 0;
+
// Check how many files we have
QDir dir(folder);
QString path;
}
}
if (firstFrame > 0) extension = filter + '%' + QString::number(firstFrame).rightJustified(precision, '0', false) + 'd' + ext;
- else extension = filter + '%' + QString::number(precision) + 'd' + ext;
+ else extension = filter + "%0" + QString::number(precision) + 'd' + ext;
}
kDebug() << "// FOUND " << (*list).count() << " items for " << url.path();
return folder + extension;
Name[it]=Scaletta MLT
Name[ja]=MLT プレイリスト
Name[km]=បញ្ជីចាក់ MLT
+Name[lt]=MTL grojaraštis
Name[nb]=MLT-spilleliste
Name[nl]=MLT-afspeellijst
Name[pl]=Lista odtwarzania MLT