Improve clip monitor

svn path=/branches/KDE4/; revision=1781
parent f697b9fd
......@@ -212,6 +212,7 @@ void MainWindow::connectDocument(KdenliveDoc *doc) //changed
{
if (m_activeDocument) m_activeDocument->setProducers(m_projectList->producersList());
m_projectList->setDocument(doc);
m_monitorManager->setTimecode(doc->timecode());
m_activeDocument = doc;
}
......
......@@ -18,10 +18,19 @@ Monitor::Monitor(QString name, MonitorManager *manager, QWidget *parent)
layout->addWidget( m_ruler);
ui.ruler_frame->setLayout( layout );
//m_ruler->setPixelPerMark(3);
m_playIcon = KIcon("media-playback-start");
m_pauseIcon = KIcon("media-playback-pause");
ui.button_play->setIcon(m_playIcon);
ui.button_rew1->setIcon(KIcon("media-skip-backward"));
ui.button_rew->setIcon(KIcon("media-seek-backward"));
ui.button_fwd1->setIcon(KIcon("media-skip-forward"));
ui.button_fwd->setIcon(KIcon("media-seek-forward"));
connect(m_ruler, SIGNAL(seekRenderer(int)), this, SLOT(slotSeek(int)));
connect(ui.button_play, SIGNAL(clicked()), this, SLOT(slotOpen()));
connect(ui.button_rew, SIGNAL(clicked()), this, SLOT(slotRewind()));
connect(ui.button_play_2, SIGNAL(clicked()), this, SLOT(slotPlay()));
connect(ui.button_rew1, SIGNAL(clicked()), this, SLOT(slotRewindOneFrame()));
connect(ui.button_fwd, SIGNAL(clicked()), this, SLOT(slotForward()));
connect(ui.button_fwd1, SIGNAL(clicked()), this, SLOT(slotForwardOneFrame()));
connect(ui.button_play, SIGNAL(clicked()), this, SLOT(slotPlay()));
}
// virtual
......@@ -33,10 +42,8 @@ void Monitor::mousePressEvent ( QMouseEvent * event )
// virtual
void Monitor::wheelEvent ( QWheelEvent * event )
{
render->play(0);
if (event->delta() > 0) m_position++;
else m_position--;
render->seekToFrame(m_position);
if (event->delta() > 0) slotForwardOneFrame();
else slotRewindOneFrame();
}
void Monitor::slotSeek(int pos)
......@@ -44,13 +51,49 @@ void Monitor::slotSeek(int pos)
if ( render == NULL ) return;
int realPos = ((double) pos) / m_scale;
render->seekToFrame(realPos);
m_position = realPos;
ui.monitor_time->setText(m_monitorManager->timecode().getTimecodeFromFrames(m_position));
}
void Monitor::slotRewind()
{
double speed = render->playSpeed();
if ( speed >= 0 ) render->play(-2);
else render->play(speed * 2);
ui.button_play->setChecked(true);
ui.button_play->setIcon(m_pauseIcon);
}
void Monitor::slotForward()
{
double speed = render->playSpeed();
if ( speed <= 1 ) render->play(2);
else render->play(speed * 2);
ui.button_play->setChecked(true);
ui.button_play->setIcon(m_pauseIcon);
}
void Monitor::slotRewindOneFrame()
{
render->play(0);
m_position--;
render->seekToFrame(m_position);
ui.monitor_time->setText(m_monitorManager->timecode().getTimecodeFromFrames(m_position));
}
void Monitor::slotForwardOneFrame()
{
render->play(0);
m_position++;
render->seekToFrame(m_position);
ui.monitor_time->setText(m_monitorManager->timecode().getTimecodeFromFrames(m_position));
}
void Monitor::seekCursor(int pos)
{
int rulerPos = (int) (pos * m_scale);
m_position = pos;
ui.monitor_time->setText(m_monitorManager->timecode().getTimecodeFromFrames(pos));
//kDebug()<<"seek: "<<pos<<", scale: "<<m_scale<<
m_ruler->slotNewValue(rulerPos);
}
......@@ -59,7 +102,8 @@ void Monitor::rendererStopped(int pos)
{
int rulerPos = (int) (pos * m_scale);
m_ruler->slotNewValue(rulerPos);
ui.button_play_2->setChecked(false);
ui.button_play->setChecked(false);
ui.button_play->setIcon(m_playIcon);
}
void Monitor::initMonitor()
......@@ -118,19 +162,13 @@ void Monitor::slotOpen()
render->mltInsertClip(2, GenTime(0, 25), QString("<westley><producer mlt_service=\"avformat\" resource=\"/home/one/.vids/clip3e.mpg\" in=\"1\" out=\"300\" /></westley>"));
}
void Monitor::slotRewind()
{
if ( render == NULL ) return;
m_monitorManager->activateMonitor(m_name);
render->seek(GenTime(0));
}
void Monitor::slotPlay()
{
if ( render == NULL ) return;
m_monitorManager->activateMonitor(m_name);
render->switchPlay();
ui.button_play_2->setChecked(true);
ui.button_play->setChecked(true);
ui.button_play->setIcon(m_pauseIcon);
}
void Monitor::slotSetXml(const QDomElement &e)
......@@ -143,6 +181,7 @@ void Monitor::slotSetXml(const QDomElement &e)
westley.appendChild(e);
render->setSceneList(doc, 0);
m_ruler->slotNewValue(0);
ui.monitor_time->setText("00:00:00:00");
m_position = 0;
}
......
#ifndef MONITOR_H
#define MONITOR_H
#include <KIcon>
#include "ui_monitor_ui.h"
#include "renderer.h"
#include "monitormanager.h"
......@@ -28,15 +30,20 @@ class Monitor : public QWidget
int m_length;
int m_position;
SmallRuler *m_ruler;
KIcon m_playIcon;
KIcon m_pauseIcon;
private slots:
void slotPlay();
void slotOpen();
void slotRewind();
void adjustRulerSize(int length);
void seekCursor(int pos);
void rendererStopped(int pos);
void slotSeek(int pos);
void slotRewindOneFrame();
void slotForwardOneFrame();
void slotForward();
void slotRewind();
public slots:
void slotOpenFile(const QString &);
......
......@@ -10,6 +10,16 @@ MonitorManager::MonitorManager(QWidget *parent)
}
void MonitorManager::setTimecode(Timecode tc)
{
m_timecode = tc;
}
Timecode MonitorManager::timecode()
{
return m_timecode;
}
void MonitorManager::initMonitors(Monitor *clipMonitor, Monitor *projectMonitor)
{
m_clipMonitor = clipMonitor;
......
......@@ -2,6 +2,7 @@
#define MONITORMANAGER_H
#include "monitor.h"
#include "timecode.h"
class Monitor;
......@@ -14,11 +15,14 @@ class MonitorManager : public QObject
void initMonitors(Monitor *clipMonitor, Monitor *projectMonitor);
void activateMonitor(QString name);
Timecode timecode();
void setTimecode(Timecode tc);
private:
Monitor *m_clipMonitor;
Monitor *m_projectMonitor;
QString m_activeMonitor;
Timecode m_timecode;
private slots:
void initProjectMonitor();
......
......@@ -105,6 +105,8 @@ ProjectList::ProjectList(QWidget *parent)
searchView->setTreeWidget(listView);
listView->setColumnCount(3);
listView->setDragEnabled(true);
listView->setDragDropMode(QAbstractItemView::DragOnly);
QStringList headers;
headers<<i18n("Thumbnail")<<i18n("Filename")<<i18n("Description");
listView->setHeaderLabels(headers);
......
......@@ -53,6 +53,15 @@ void SmallRuler::mousePressEvent ( QMouseEvent * event )
kDebug()<<pos;
}
// virtual
void SmallRuler::mouseMoveEvent ( QMouseEvent * event )
{
int pos = event->x();
//slotNewValue( pos );
emit seekRenderer(pos);
kDebug()<<pos;
}
void SmallRuler::slotNewValue ( int _value )
{
m_cursorPosition = _value / pixelPerMark();
......
......@@ -10,7 +10,7 @@ class SmallRuler : public KRuler
public:
SmallRuler(QWidget *parent=0);
virtual void mousePressEvent ( QMouseEvent * event );
virtual void mouseMoveEvent ( QMouseEvent * event );
void setPixelPerMark ( double rate );
protected:
......
......@@ -5,14 +5,17 @@
<rect>
<x>0</x>
<y>0</y>
<width>365</width>
<height>249</height>
<width>320</width>
<height>238</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QGridLayout" >
<property name="verticalSpacing" >
<number>0</number>
</property>
<item row="0" column="0" colspan="2" >
<widget class="QFrame" name="video_frame" >
<property name="frameShape" >
......@@ -45,7 +48,7 @@
<number>0</number>
</property>
<item>
<widget class="KPushButton" name="button_play" >
<widget class="KPushButton" name="button_rew" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
......@@ -64,7 +67,7 @@
</widget>
</item>
<item>
<widget class="KPushButton" name="button_rew" >
<widget class="KPushButton" name="button_rew1" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
......@@ -83,7 +86,7 @@
</widget>
</item>
<item>
<widget class="KPushButton" name="button_play_2" >
<widget class="KPushButton" name="button_play" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
......@@ -102,13 +105,10 @@
<property name="checked" >
<bool>false</bool>
</property>
<property name="flat" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="KPushButton" name="kpushbutton_18" >
<widget class="KPushButton" name="button_fwd1" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
......@@ -127,7 +127,7 @@
</widget>
</item>
<item>
<widget class="KPushButton" name="kpushbutton_19" >
<widget class="KPushButton" name="button_fwd" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
......@@ -288,7 +288,7 @@
</layout>
</item>
<item row="3" column="1" >
<widget class="KRestrictedLine" name="krestrictedline" >
<widget class="KRestrictedLine" name="monitor_time" >
<property name="inputMask" >
<string>99:99:99:99; </string>
</property>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment