Commit 28d99da0 authored by Ludovic Fauvet's avatar Ludovic Fauvet

Print the type of the tracks on each side of the separator.

parent 10b904b2
......@@ -25,6 +25,7 @@
#include <QGraphicsWidget>
#include <QPainter>
#include <QDebug>
class GraphicsTrack : public QGraphicsWidget
{
......@@ -70,18 +71,31 @@ public:
protected:
virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem*, QWidget* = 0 )
{
Q_UNUSED( painter );
/*
Debugging of tracks.
Do not remove this block.
if ( m_type == Video )
painter->setBrush( Qt::green );
else
painter->setBrush( Qt::blue );
painter->setPen( Qt::transparent );
painter->drawRect( rect() );
*/
painter->setMatrixEnabled( false );
if ( m_trackNumber == 0 )
{
QString text;
switch ( m_type )
{
case Video:
text = tr( "Video" );
break;
case Audio:
text = tr( "Audio" );
break;
}
QRectF mapped = mapRectToScene( boundingRect() ).adjusted( 10, 1, 0, 0 );
QFont textFont;
textFont.setItalic( true );
textFont.setBold( true );
textFont.setPixelSize( mapped.height() + 12 );
painter->setPen( QPen( palette().window().color().lighter( 125 ) ) );
painter->setFont( textFont );
painter->drawText( mapped, Qt::AlignVCenter, text );
}
}
private:
......
......@@ -96,6 +96,11 @@ void TracksView::createLayout()
addAudioTrack();
m_scene->addItem( container );
// Hack: make sure the tracks type appears correctly
m_layout->setMinimumWidth( 2000 );
m_layout->setMaximumWidth( 2000 );
setSceneRect( m_layout->contentsRect() );
}
void TracksView::addVideoTrack()
......@@ -455,15 +460,18 @@ void TracksView::drawBackground( QPainter* painter, const QRectF& rect )
{
// Draw the tracks separators
painter->setPen( QPen( QColor( 72, 72, 72 ) ) );
QList<QGraphicsItem*> gi = items( 0, 0, 1, sceneRect().height() );
for ( int i = 0; i < gi.count(); ++i )
for ( int i = 0; i < m_layout->count(); ++i )
{
GraphicsTrack* track = qgraphicsitem_cast<GraphicsTrack*>( gi.at( i ) );
QGraphicsItem* gi = m_layout->itemAt( i )->graphicsItem();
if ( !gi ) continue;
GraphicsTrack* track = qgraphicsitem_cast<GraphicsTrack*>( gi );
if ( !track ) continue;
if ( track->trackNumber() == 0 ) continue;
QRectF trackRect = track->mapRectToScene( track->boundingRect() );
painter->drawLine( trackRect.left(), trackRect.bottom(), rect.right(), trackRect.bottom() );
if ( track->type() == GraphicsTrack::Video )
painter->drawLine( trackRect.left(), trackRect.top(), rect.right(), trackRect.top() );
else
painter->drawLine( trackRect.left(), trackRect.bottom(), rect.right(), trackRect.bottom() );
}
// Audio/Video separator
......@@ -671,6 +679,9 @@ void TracksView::updateDuration()
m_projectDuration = projectDuration;
// Hack: make sure the tracks type appears correctly
m_projectDuration = qMax( m_projectDuration, 2000 );
// PreferredWidth not working ?
m_layout->setMinimumWidth( m_projectDuration );
m_layout->setMaximumWidth( m_projectDuration );
......
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