From 0f5f5497b43ead16ca439e7cb275ffc79ef0869d Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Wed, 12 Mar 2008 23:02:03 +0000 Subject: [PATCH] activate monitor when clicking in timeline + small renderer update svn path=/branches/KDE4/; revision=2051 --- renderer/kdenlive_render.cpp | 65 ++++++++++++------------------------ renderer/renderjob.cpp | 4 +-- renderer/renderjob.h | 2 +- src/customruler.cpp | 1 + src/customtrackview.cpp | 13 ++++++++ src/customtrackview.h | 2 ++ src/mainwindow.cpp | 10 ++++-- src/mainwindow.h | 2 +- src/renderwidget.cpp | 4 ++- src/renderwidget.h | 2 +- src/trackview.cpp | 2 +- 11 files changed, 54 insertions(+), 53 deletions(-) diff --git a/renderer/kdenlive_render.cpp b/renderer/kdenlive_render.cpp index a79f030b..27dc63bc 100644 --- a/renderer/kdenlive_render.cpp +++ b/renderer/kdenlive_render.cpp @@ -1,45 +1,21 @@ -/**************************************************************************** -** -** Copyright (C) 2006-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the tools applications of the Qt Toolkit. -** -** This file may be used under the terms of the GNU General Public -** License versions 2.0 or 3.0 as published by the Free Software -** Foundation and appearing in the files LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Alternatively you may (at -** your option) use any later version of the GNU General Public -** License if such license has been publicly approved by Trolltech ASA -** (or its successors, if any) and the KDE Free Qt Foundation. In -** addition, as a special exception, Trolltech gives you certain -** additional rights. These rights are described in the Trolltech GPL -** Exception version 1.2, which can be found at -** http://www.trolltech.com/products/qt/gplexception/ and in the file -** GPL_EXCEPTION.txt in this package. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. If -** you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** In addition, as a special exception, Trolltech, as the sole -** copyright holder for Qt Designer, grants users of the Qt/Eclipse -** Integration plug-in the right for the Qt/Eclipse Integration to -** link to functionality provided by Qt Designer and its related -** libraries. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not expressly -** granted herein. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ +/*************************************************************************** + * Copyright (C) 2008 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 #include @@ -70,13 +46,15 @@ int main(int argc, char **argv) { } QString render = args.at(0); args.takeFirst(); + QString rendermodule = args.at(0); + args.takeFirst(); QString player = args.at(0); args.takeFirst(); QString src = args.at(0); args.takeFirst(); QString dest = args.at(0); args.takeFirst(); - RenderJob *job = new RenderJob(erase, render, player, src, dest, args, in, out); + RenderJob *job = new RenderJob(erase, render, rendermodule, player, src, dest, args, in, out); job->start(); app.exec(); } else { @@ -86,6 +64,7 @@ int main(int argc, char **argv) { " in=pos: start rendering at frame pos\n" " out=pos: end rendering at frame pos\n" " render: path to inigo rendrer\n" + " rendermodule: the MLT consumer used for rendering, usually it is avformat\n" " player: path to video player to play when rendering is over, use '-' to disable playing\n" " src: source file (usually westley playlist)\n" " dest: destination file\n" diff --git a/renderer/renderjob.cpp b/renderer/renderjob.cpp index 792f6da0..ed042f61 100644 --- a/renderer/renderjob.cpp +++ b/renderer/renderjob.cpp @@ -24,7 +24,7 @@ static QDBusConnection connection(QLatin1String("")); -RenderJob::RenderJob(bool erase, QString renderer, QString player, QString scenelist, QString dest, QStringList args, int in, int out) : QObject() { +RenderJob::RenderJob(bool erase, QString renderer, QString rendermodule, QString player, QString scenelist, QString dest, QStringList args, int in, int out) : QObject() { m_scenelist = scenelist; m_dest = dest; m_player = player; @@ -35,7 +35,7 @@ RenderJob::RenderJob(bool erase, QString renderer, QString player, QString scene m_args << scenelist; if (in != -1) m_args << "in=" + QString::number(in); if (out != -1) m_args << "out=" + QString::number(out); - m_args << "-consumer" << "avformat:" + m_dest << "progress=1" << args; + m_args << "-consumer" << rendermodule + ":" + m_dest << "progress=1" << args; connect(m_renderProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotIsOver(int, QProcess::ExitStatus))); connect(m_renderProcess, SIGNAL(readyReadStandardError()), this, SLOT(receivedStderr())); m_renderProcess->setReadChannel(QProcess::StandardError); diff --git a/renderer/renderjob.h b/renderer/renderjob.h index 106a9feb..5068d730 100644 --- a/renderer/renderjob.h +++ b/renderer/renderjob.h @@ -28,7 +28,7 @@ class RenderJob : public QObject { Q_OBJECT public: - RenderJob(bool erase, QString renderer, QString player, QString scenelist, QString dest, QStringList args, int in = -1, int out = -1); + RenderJob(bool erase, QString renderer, QString rendermodule, QString player, QString scenelist, QString dest, QStringList args, int in = -1, int out = -1); ~RenderJob(); void start(); diff --git a/src/customruler.cpp b/src/customruler.cpp index 58f6c3d7..a56f7422 100644 --- a/src/customruler.cpp +++ b/src/customruler.cpp @@ -90,6 +90,7 @@ CustomRuler::CustomRuler(Timecode tc, CustomTrackView *parent) // virtual void CustomRuler::mousePressEvent(QMouseEvent * event) { + m_view->activateMonitor(); int pos = (event->x() + offset()) / pixelPerMark() / FRAME_SIZE; m_moveCursor = RULER_CURSOR; if (event->y() > 10) { diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index e1ef2afe..d89292ba 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -39,6 +39,14 @@ #include "kdenlivesettings.h" #include "transition.h" +//TODO: +// disable animation if user asked it in KDE's global settings +// http://lists.kde.org/?l=kde-commits&m=120398724717624&w=2 +// needs something like below (taken from dolphin) +// #include +// const bool animate = KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects; +// const int duration = animate ? 1500 : 1; + CustomTrackView::CustomTrackView(KdenliveDoc *doc, QGraphicsScene * projectscene, QWidget *parent) : QGraphicsView(projectscene, parent), m_tracksCount(0), m_cursorPos(0), m_dropItem(NULL), m_cursorLine(NULL), m_operationMode(NONE), m_startPos(QPointF()), m_dragItem(NULL), m_visualTip(NULL), m_moveOpMode(NONE), m_animation(NULL), m_projectDuration(0), m_scale(1.0), m_clickPoint(0), m_document(doc), m_autoScroll(KdenliveSettings::autoscroll()) { if (doc) m_commandStack = doc->commandStack(); @@ -311,6 +319,7 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event) { // virtual void CustomTrackView::mousePressEvent(QMouseEvent * event) { + activateMonitor(); int pos = event->x(); if (event->modifiers() == Qt::ControlModifier) { setDragMode(QGraphicsView::ScrollHandDrag); @@ -378,6 +387,10 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event) { //QGraphicsView::mousePressEvent(event); } +void CustomTrackView::activateMonitor() { + emit activateDocumentMonitor(); +} + void CustomTrackView::dragEnterEvent(QDragEnterEvent * event) { if (event->mimeData()->hasFormat("kdenlive/producerslist")) { kDebug() << "/////////////// DRAG ENTERED, TEXT: " << event->mimeData()->data("kdenlive/producerslist"); diff --git a/src/customtrackview.h b/src/customtrackview.h index 6140b048..ce7704ba 100644 --- a/src/customtrackview.h +++ b/src/customtrackview.h @@ -52,6 +52,7 @@ public: void addEffect(int track, GenTime pos, QDomElement effect); void deleteEffect(int track, GenTime pos, QDomElement effect); void updateEffect(int track, GenTime pos, QDomElement effect); + void activateMonitor(); public slots: void setCursorPos(int pos, bool seek = true); @@ -110,6 +111,7 @@ signals: void zoomOut(); void mousePosition(int); void clipItemSelected(ClipItem*); + void activateDocumentMonitor(); }; #endif diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b579101d..8d443e15 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -475,7 +475,7 @@ void MainWindow::slotEditProjectSettings() { void MainWindow::slotRenderProject() { if (!m_renderWidget) { m_renderWidget = new RenderWidget(this); - connect(m_renderWidget, SIGNAL(doRender(const QString&, const QStringList &, bool, bool)), this, SLOT(slotDoRender(const QString&, const QStringList &, bool, bool))); + connect(m_renderWidget, SIGNAL(doRender(const QString&, const QString&, const QStringList &, bool, bool)), this, SLOT(slotDoRender(const QString&, const QString&, const QStringList &, bool, bool))); } /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget(); if (currentTab) m_renderWidget->setTimeline(currentTab); @@ -483,7 +483,7 @@ void MainWindow::slotRenderProject() { m_renderWidget->show(); } -void MainWindow::slotDoRender(const QString &dest, const QStringList &avformat_args, bool zoneOnly, bool playAfter) { +void MainWindow::slotDoRender(const QString &dest, const QString &render, const QStringList &avformat_args, bool zoneOnly, bool playAfter) { if (dest.isEmpty()) return; int in; int out; @@ -502,7 +502,7 @@ void MainWindow::slotDoRender(const QString &dest, const QStringList &avformat_a if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out); QString videoPlayer = "-"; if (playAfter) videoPlayer = "kmplayer"; - args << "inigo" << videoPlayer << temp.fileName() << dest << avformat_args; + args << "inigo" << render << videoPlayer << temp.fileName() << dest << avformat_args; QProcess::startDetached("kdenlive_render", args); } } @@ -537,6 +537,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement))); disconnect(effectStack, SIGNAL(changeEffectState(ClipItem*, QDomElement, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, QDomElement, bool))); disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*))); + disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor())); } m_activeDocument->setRenderer(NULL); disconnect(m_projectList, SIGNAL(clipSelected(const QDomElement &)), m_clipMonitor, SLOT(slotSetXml(const QDomElement &))); @@ -560,6 +561,9 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement))); connect(effectStack, SIGNAL(changeEffectState(ClipItem*, QDomElement, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, QDomElement, bool))); connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*))); + connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor())); + + m_activeTimeline = trackView; if (m_renderWidget) m_renderWidget->setDocumentStandard(doc->getDocumentStandard()); m_monitorManager->setTimecode(doc->timecode()); diff --git a/src/mainwindow.h b/src/mainwindow.h index 4f0cee8c..95dfb2c9 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -134,7 +134,7 @@ private slots: void slotSwitchVideoThumbs(); void slotSwitchAudioThumbs(); void slotRenderProject(); - void slotDoRender(const QString &dest, const QStringList &avformat_args, bool zoneOnly, bool playAfter); + void slotDoRender(const QString &dest, const QString &render, const QStringList &avformat_args, bool zoneOnly, bool playAfter); }; #endif diff --git a/src/renderwidget.cpp b/src/renderwidget.cpp index df3b039e..cabdd388 100644 --- a/src/renderwidget.cpp +++ b/src/renderwidget.cpp @@ -177,12 +177,14 @@ void RenderWidget::slotDeleteProfile() { } void RenderWidget::slotExport() { + QListWidgetItem *item = m_view.size_list->currentItem(); + if (!item) return; QFile f(m_view.out_file->url().path()); if (f.exists()) { if (KMessageBox::warningYesNo(this, i18n("File already exists. Doy you want to overwrite it ?")) != KMessageBox::Yes) return; } - emit doRender(m_view.out_file->url().path(), m_view.advanced_params->text().split(' '), m_view.zone_only->isChecked(), m_view.play_after->isChecked()); + emit doRender(m_view.out_file->url().path(), item->data(RenderRole).toString(), m_view.advanced_params->text().split(' '), m_view.zone_only->isChecked(), m_view.play_after->isChecked()); } void RenderWidget::setDocumentStandard(QString std) { diff --git a/src/renderwidget.h b/src/renderwidget.h index e5fda19e..afc586c1 100644 --- a/src/renderwidget.h +++ b/src/renderwidget.h @@ -48,7 +48,7 @@ private: void parseFile(QString exportFile, bool editable); signals: - void doRender(const QString&, const QStringList &, bool, bool); + void doRender(const QString&, const QString&, const QStringList &, bool, bool); }; diff --git a/src/trackview.cpp b/src/trackview.cpp index 55b6cd40..ee9672c4 100644 --- a/src/trackview.cpp +++ b/src/trackview.cpp @@ -31,7 +31,7 @@ TrackView::TrackView(KdenliveDoc *doc, QWidget *parent) : QWidget(parent), m_doc(doc), m_scale(1.0), m_projectTracks(0), m_projectDuration(0) { - setMouseTracking(true); + view = new Ui::TimeLine_UI(); view->setupUi(this); -- 2.39.2