TrackControls.cpp 2.87 KB
Newer Older
1 2 3
/*****************************************************************************
 * TrackControls.cpp: Widget used to configure a track
 *****************************************************************************
Ludovic Fauvet's avatar
Ludovic Fauvet committed
4
 * Copyright (C) 2008-2010 VideoLAN
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 *
 * Authors: Ludovic Fauvet <etix@l0cal.com>
 *
 * 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 <QIcon>
24
#include "GraphicsTrack.h"
25 26 27 28 29 30 31
#include "TrackControls.h"
#include "ui_TrackControls.h"

TrackControls::TrackControls( GraphicsTrack* track, QWidget *parent ) :
    QWidget( parent ), m_ui( new Ui::TrackControls ), m_track( track )
{
    m_ui->setupUi( this );
Ludovic Fauvet's avatar
Ludovic Fauvet committed
32
    setTrackDisabled( !m_track->isEnabled() );
33 34
    connect( m_ui->disableButton, SIGNAL( clicked(bool) ),
             this, SLOT( setTrackDisabled(bool) ) );
35
    updateTextLabels();
36 37 38 39 40 41 42
}

TrackControls::~TrackControls()
{
    delete m_ui;
}

43 44
void TrackControls::updateTextLabels()
{
45
    if ( m_track->mediaType() == Workflow::VideoTrack )
46
        m_ui->trackLabel->setText( tr( "Video #%1" ).arg( QString::number( m_track->trackNumber() + 1 ) ) );
47
    else if ( m_track->mediaType() == Workflow::AudioTrack )
48 49 50
        m_ui->trackLabel->setText( tr( "Audio #%1" ).arg( QString::number( m_track->trackNumber() + 1 ) ) );
}

51 52 53 54 55 56
void TrackControls::changeEvent( QEvent *e )
{
    QWidget::changeEvent( e );
    switch ( e->type() ) {
    case QEvent::LanguageChange:
        m_ui->retranslateUi( this );
57
        updateTextLabels();
58 59 60 61 62 63 64 65 66 67 68
        break;
    default:
        break;
    }
}

void TrackControls::setTrackDisabled( bool disable )
{
    m_track->setTrackEnabled( !disable );
    if ( !disable )
    {
69
        if ( m_track->mediaType() == Workflow::VideoTrack )
70
            m_ui->disableButton->setIcon( QIcon( ":/images/trackon" ) );
71
        else if ( m_track->mediaType() == Workflow::AudioTrack )
72 73 74 75
            m_ui->disableButton->setIcon( QIcon( ":/images/hpon" ) );
    }
    else
    {
76
        if ( m_track->mediaType() == Workflow::VideoTrack )
77
            m_ui->disableButton->setIcon( QIcon( ":/images/trackoff" ) );
78
        else if ( m_track->mediaType() == Workflow::AudioTrack )
79 80 81
            m_ui->disableButton->setIcon( QIcon( ":/images/hpoff" ) );
    }
}