From: Jean-Baptiste Mardelle Date: Tue, 24 Jun 2008 21:52:46 +0000 (+0000) Subject: new icons, snapping can now be en/disabled X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=c60118aadf194393e71f34229ea38800352d6e66;p=kdenlive new icons, snapping can now be en/disabled svn path=/branches/KDE4/; revision=2272 --- diff --git a/icons/hi16-action-kdenlive-show-audio.png b/icons/hi16-action-kdenlive-show-audio.png index 6247a157..268ecfff 100644 Binary files a/icons/hi16-action-kdenlive-show-audio.png and b/icons/hi16-action-kdenlive-show-audio.png differ diff --git a/icons/hi16-action-kdenlive-show-audiothumb.png b/icons/hi16-action-kdenlive-show-audiothumb.png new file mode 100644 index 00000000..816c54b5 Binary files /dev/null and b/icons/hi16-action-kdenlive-show-audiothumb.png differ diff --git a/icons/hi16-action-kdenlive-show-markers.png b/icons/hi16-action-kdenlive-show-markers.png new file mode 100644 index 00000000..724a5c28 Binary files /dev/null and b/icons/hi16-action-kdenlive-show-markers.png differ diff --git a/icons/hi16-action-kdenlive-show-video.png b/icons/hi16-action-kdenlive-show-video.png index 2639ab87..e61bf432 100644 Binary files a/icons/hi16-action-kdenlive-show-video.png and b/icons/hi16-action-kdenlive-show-video.png differ diff --git a/icons/hi16-action-kdenlive-show-videothumb.png b/icons/hi16-action-kdenlive-show-videothumb.png new file mode 100644 index 00000000..c4e9cbf0 Binary files /dev/null and b/icons/hi16-action-kdenlive-show-videothumb.png differ diff --git a/icons/hi16-action-kdenlive-snap.png b/icons/hi16-action-kdenlive-snap.png new file mode 100644 index 00000000..d13dc300 Binary files /dev/null and b/icons/hi16-action-kdenlive-snap.png differ diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index 93a0a2b4..60af8b52 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -405,6 +405,10 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event) { setCursor(Qt::PointingHandCursor); } } // no clip under mouse + else if (m_tool == RAZORTOOL) { + QGraphicsView::mouseMoveEvent(event); + return; + } else if (opMode == MOVEGUIDE) { m_moveOpMode = opMode; setCursor(Qt::SplitHCursor); @@ -959,9 +963,17 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) { setCursor(Qt::OpenHandCursor); // move clip if (m_dragItem->type() == AVWIDGET && (m_dragItemInfo.startPos != info.startPos || m_dragItemInfo.track != info.track)) { - MoveClipCommand *command = new MoveClipCommand(this, m_dragItemInfo, info, false); - m_commandStack->push(command); - m_document->renderer()->mltMoveClip((int)(m_tracksList.count() - m_dragItemInfo.track), (int)(m_tracksList.count() - m_dragItem->track()), (int) m_dragItemInfo.startPos.frames(m_document->fps()), (int)(m_dragItem->startPos().frames(m_document->fps()))); + bool success = m_document->renderer()->mltMoveClip((int)(m_tracksList.count() - m_dragItemInfo.track), (int)(m_tracksList.count() - m_dragItem->track()), (int) m_dragItemInfo.startPos.frames(m_document->fps()), (int)(m_dragItem->startPos().frames(m_document->fps()))); + if (success) { + MoveClipCommand *command = new MoveClipCommand(this, m_dragItemInfo, info, false); + m_commandStack->push(command); + } + else { + // undo last move and emit error message + MoveClipCommand *command = new MoveClipCommand(this, info, m_dragItemInfo, true); + m_commandStack->push(command); + emit displayMessage(i18n("Cannot move clip to requested position"), ErrorMessage); + } } if (m_dragItem->type() == TRANSITIONWIDGET && (m_dragItemInfo.startPos != info.startPos || m_dragItemInfo.track != info.track)) { MoveTransitionCommand *command = new MoveTransitionCommand(this, m_dragItemInfo, info, false); @@ -1183,8 +1195,15 @@ void CustomTrackView::moveClip(const ItemInfo start, const ItemInfo end) { return; } //kDebug() << "----------------  Move CLIP FROM: " << startPos.x() << ", END:" << endPos.x() << ",TRACKS: " << startPos.y() << " TO " << endPos.y(); - item->moveTo((int) end.startPos.frames(m_document->fps()), m_scale, (int)((end.track - start.track) * m_tracksHeight), end.track); - m_document->renderer()->mltMoveClip((int)(m_tracksList.count() - start.track), (int)(m_tracksList.count() - end.track), (int) start.startPos.frames(m_document->fps()), (int)end.startPos.frames(m_document->fps())); + + bool success = m_document->renderer()->mltMoveClip((int)(m_tracksList.count() - start.track), (int)(m_tracksList.count() - end.track), (int) start.startPos.frames(m_document->fps()), (int)end.startPos.frames(m_document->fps())); + if (success) { + item->moveTo((int) end.startPos.frames(m_document->fps()), m_scale, (int)((end.track - start.track) * m_tracksHeight), end.track); + } + else { + // undo last move and emit error message + emit displayMessage(i18n("Cannot move clip to requested position"), ErrorMessage); + } } void CustomTrackView::moveTransition(const ItemInfo start, const ItemInfo end) { @@ -1279,6 +1298,7 @@ double CustomTrackView::getSnapPointForPos(double pos) { void CustomTrackView::updateSnapPoints(AbstractClipItem *selected) { m_snapPoints.clear(); + if (!KdenliveSettings::snaptopoints()) return; GenTime offset; if (selected) offset = selected->duration(); QList itemList = items(); diff --git a/src/kdenlivesettings.kcfg b/src/kdenlivesettings.kcfg index 8395eb87..dac1dba7 100644 --- a/src/kdenlivesettings.kcfg +++ b/src/kdenlivesettings.kcfg @@ -201,5 +201,10 @@ false + + + true + + \ No newline at end of file diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 22b09371..49885c3e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -376,7 +376,7 @@ void MainWindow::setupActions() { m_toolGroup = new QActionGroup(this); - QString style1 = "QToolButton { background-color: rgba(230, 230, 230, 20); border-style: inset; border:1px solid #666666;border-radius: 3px;margin: 0px 3px} QToolButton:checked { background-color: rgba(224, 0, 0, 100); border-style: inset; border:1px solid #666666;border-radius: 3px;}"; + QString style1 = "QToolButton {background-color: rgba(230, 230, 230, 220); border-style: inset; border:1px solid #999999;border-radius: 3px;margin: 0px 3px;padding: 0px;} QToolButton:checked { background-color: rgba(224, 224, 0, 100); border-style: inset; border:1px solid #cc6666;border-radius: 3px;}"; m_buttonSelectTool = toolbar->addAction(KIcon("kdenlive-select-tool"), i18n("Selection tool")); m_buttonSelectTool->setCheckable(true); @@ -389,6 +389,17 @@ void MainWindow::setupActions() { m_toolGroup->addAction(m_buttonSelectTool); m_toolGroup->addAction(m_buttonRazorTool); m_toolGroup->setExclusive(true); + toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly); + + QWidget * actionWidget; + actionWidget = toolbar->widgetForAction( m_buttonSelectTool ); + actionWidget->setMaximumWidth(24); + actionWidget->setMinimumHeight(18); + + actionWidget = toolbar->widgetForAction( m_buttonRazorTool ); + actionWidget->setMaximumWidth(24); + actionWidget->setMinimumHeight(18); + toolbar->setStyleSheet(style1); connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *))); @@ -415,22 +426,44 @@ void MainWindow::setupActions() { toolbar->addWidget(m_zoomSlider); - m_buttonVideoThumbs = toolbar->addAction(KIcon("video-mpeg"), i18n("Show video thumbnails")); + m_buttonVideoThumbs = toolbar->addAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails")); m_buttonVideoThumbs->setCheckable(true); m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails()); connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs())); - m_buttonAudioThumbs = toolbar->addAction(KIcon("audio-mpeg"), i18n("Show audio thumbnails")); + m_buttonAudioThumbs = toolbar->addAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails")); m_buttonAudioThumbs->setCheckable(true); m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails()); connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs())); - m_buttonShowMarkers = toolbar->addAction(KIcon("audio-mpeg"), i18n("Show markers comments")); + m_buttonShowMarkers = toolbar->addAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments")); m_buttonShowMarkers->setCheckable(true); m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers()); connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments())); + + m_buttonSnap = toolbar->addAction(KIcon("kdenlive-snap"), i18n("Snap")); + m_buttonSnap->setCheckable(true); + m_buttonSnap->setChecked(KdenliveSettings::snaptopoints()); + connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap())); layout->addWidget(toolbar); + + actionWidget = toolbar->widgetForAction( m_buttonVideoThumbs ); + actionWidget->setMaximumWidth(24); + actionWidget->setMinimumHeight(18); + + actionWidget = toolbar->widgetForAction( m_buttonAudioThumbs ); + actionWidget->setMaximumWidth(24); + actionWidget->setMinimumHeight(18); + + actionWidget = toolbar->widgetForAction( m_buttonShowMarkers ); + actionWidget->setMaximumWidth(24); + actionWidget->setMinimumHeight(18); + + actionWidget = toolbar->widgetForAction( m_buttonSnap ); + actionWidget->setMaximumWidth(24); + actionWidget->setMinimumHeight(18); + m_messageLabel = new StatusBarMessageLabel(this); m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding); @@ -958,7 +991,10 @@ void MainWindow::slotSwitchMarkersComments() { m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers()); } - +void MainWindow::slotSwitchSnap() { + KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints()); + m_buttonShowMarkers->setChecked(KdenliveSettings::snaptopoints()); +} void MainWindow::slotDeleteTimelineClip() { diff --git a/src/mainwindow.h b/src/mainwindow.h index 1347b9f0..2a0deea1 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -124,6 +124,7 @@ private: QAction *m_buttonFitZoom; QAction *m_buttonSelectTool; QAction *m_buttonRazorTool; + QAction *m_buttonSnap; QActionGroup *m_toolGroup; QSlider *m_zoomSlider; StatusBarMessageLabel *m_messageLabel; @@ -162,6 +163,7 @@ private slots: void slotSwitchVideoThumbs(); void slotSwitchAudioThumbs(); void slotSwitchMarkersComments(); + void slotSwitchSnap(); void slotRenderProject(); void slotDoRender(const QString &dest, const QString &render, const QStringList &avformat_args, bool zoneOnly, bool playAfter); void slotFullScreen(); diff --git a/src/renderer.cpp b/src/renderer.cpp index 2fd774b6..58749d37 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -808,12 +808,11 @@ void Render::switchPlay() { if (m_mltProducer->get_speed() == 0.0) m_mltProducer->set_speed(1.0); else { m_isBlocked = true; - m_mltProducer->set_speed(0.0); - m_mltConsumer->set("refresh", 0); + m_mltProducer->set_speed(0.0); + //m_mltConsumer->set("refresh", 0); m_mltProducer->seek((int) m_framePosition); m_isBlocked = false; } - /*if (speed == 0.0) { m_mltProducer->seek((int) m_framePosition + 1); m_mltConsumer->purge(); @@ -1444,12 +1443,12 @@ void Render::mltResizeClipStart(int track, GenTime pos, GenTime moveEnd, GenTime m_isBlocked = false; } -void Render::mltMoveClip(int startTrack, int endTrack, GenTime moveStart, GenTime moveEnd) { - mltMoveClip(startTrack, endTrack, (int) moveStart.frames(m_fps), (int) moveEnd.frames(m_fps)); +bool Render::mltMoveClip(int startTrack, int endTrack, GenTime moveStart, GenTime moveEnd) { + return mltMoveClip(startTrack, endTrack, (int) moveStart.frames(m_fps), (int) moveEnd.frames(m_fps)); } -void Render::mltMoveClip(int startTrack, int endTrack, int moveStart, int moveEnd) { +bool Render::mltMoveClip(int startTrack, int endTrack, int moveStart, int moveEnd) { m_isBlocked = true; m_mltConsumer->set("refresh", 0); @@ -1467,27 +1466,39 @@ void Render::mltMoveClip(int startTrack, int endTrack, int moveStart, int moveEn Mlt::Producer clipProducer(trackPlaylist.replace_with_blank(clipIndex)); trackPlaylist.consolidate_blanks(0); if (!trackPlaylist.is_blank_at(moveEnd)) { - kWarning() << "// ERROR, CLIP COLLISION----------"; - int ix = trackPlaylist.get_clip_index_at(moveEnd); - kDebug() << "BAD CLIP STARTS AT: " << trackPlaylist.clip_start(ix) << ", LENGT: " << trackPlaylist.clip_length(ix); + // error, destination is not empty + //int ix = trackPlaylist.get_clip_index_at(moveEnd); + mlt_service_unlock(m_mltConsumer->get_service()); + m_isBlocked = false; + return false; } - trackPlaylist.insert_at(moveEnd, clipProducer, 1); - trackPlaylist.consolidate_blanks(0); + else { + trackPlaylist.insert_at(moveEnd, clipProducer, 1); + trackPlaylist.consolidate_blanks(0); + } //mlt_service_unlock(service.get_service()); } else { - Mlt::Producer clipProducer(trackPlaylist.replace_with_blank(clipIndex)); - trackPlaylist.consolidate_blanks(0); - Mlt::Producer destTrackProducer(tractor.track(endTrack)); Mlt::Playlist destTrackPlaylist((mlt_playlist) destTrackProducer.get_service()); - destTrackPlaylist.consolidate_blanks(1); - destTrackPlaylist.insert_at(moveEnd, clipProducer, 1); - destTrackPlaylist.consolidate_blanks(0); + if (!destTrackPlaylist.is_blank_at(moveEnd)) { + // error, destination is not empty + mlt_service_unlock(m_mltConsumer->get_service()); + m_isBlocked = false; + return false; + } + else { + Mlt::Producer clipProducer(trackPlaylist.replace_with_blank(clipIndex)); + trackPlaylist.consolidate_blanks(0); + destTrackPlaylist.consolidate_blanks(1); + destTrackPlaylist.insert_at(moveEnd, clipProducer, 1); + destTrackPlaylist.consolidate_blanks(0); + } } mltCheckLength(); mlt_service_unlock(m_mltConsumer->get_service()); m_isBlocked = false; m_mltConsumer->set("refresh", 1); + return true; } void Render::mltMoveTransition(QString type, int startTrack, int newTrack, int newTransitionTrack, GenTime oldIn, GenTime oldOut, GenTime newIn, GenTime newOut) { @@ -1603,7 +1614,6 @@ void Render::mltUpdateTransitionParams(QString type, int a_track, int b_track, G } void Render::mltDeleteTransition(QString tag, int a_track, int b_track, GenTime in, GenTime out, QDomElement xml, bool do_refresh) { - Mlt::Service service(m_mltProducer->parent().get_service()); Mlt::Tractor tractor(service); Mlt::Field *field = tractor.field(); @@ -1627,6 +1637,7 @@ void Render::mltDeleteTransition(QString tag, int a_track, int b_track, GenTime if (resource == tag && b_track == currentTrack && currentIn <= old_pos && currentOut >= old_pos) { //kDebug() << " / / / / /DELETE TRANS DOOOMNE"; mlt_field_disconnect_service(field->get_field(), nextservice); + mlt_service_close(nextservice); break; } nextservice = mlt_service_producer(nextservice); @@ -1677,7 +1688,6 @@ QMap Render::mltGetTransitionParamsFromXml(QDomElement xml) { } void Render::mltAddTransition(QString tag, int a_track, int b_track, GenTime in, GenTime out, QDomElement xml, bool do_refresh) { - //kDebug() << "-- ADDING TRANSITION: " << tag << ", ON TRACKS: " << a_track << ", " << b_track; QMap args = mltGetTransitionParamsFromXml(xml); diff --git a/src/renderer.h b/src/renderer.h index 77fbdfaf..54510f12 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -154,8 +154,8 @@ Q_OBJECT public: void mltCutClip(int track, GenTime position); void mltResizeClipEnd(int track, GenTime pos, GenTime in, GenTime out); void mltResizeClipStart(int track, GenTime pos, GenTime moveEnd, GenTime moveStart, GenTime in, GenTime out); - void mltMoveClip(int startTrack, int endTrack, GenTime pos, GenTime moveStart); - void mltMoveClip(int startTrack, int endTrack, int pos, int moveStart); + bool mltMoveClip(int startTrack, int endTrack, GenTime pos, GenTime moveStart); + bool mltMoveClip(int startTrack, int endTrack, int pos, int moveStart); void mltRemoveClip(int track, GenTime position); void mltRemoveEffect(int track, GenTime position, QString index, bool doRefresh = true); void mltAddEffect(int track, GenTime position, QMap args, bool doRefresh = true);