Commit ab02e700 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

TrackControl: Allow a track to be renamed.

parent 58f10ba0
......@@ -20,18 +20,25 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <QIcon>
#include "GraphicsTrack.h"
#include "TrackControls.h"
#include "ui_TrackControls.h"
#include <QIcon>
#include <QInputDialog>
TrackControls::TrackControls( GraphicsTrack* track, QWidget *parent ) :
QWidget( parent ), m_ui( new Ui::TrackControls ), m_track( track )
QWidget( parent ),
m_ui( new Ui::TrackControls ),
m_track( track )
{
m_ui->setupUi( this );
setTrackDisabled( !m_track->isEnabled() );
connect( m_ui->disableButton, SIGNAL( clicked(bool) ),
this, SLOT( setTrackDisabled(bool) ) );
connect( m_ui->trackLabel, SIGNAL( doubleClicked() ),
this, SLOT( trackNameDoubleClicked() ) );
updateTextLabels();
}
......@@ -40,7 +47,8 @@ TrackControls::~TrackControls()
delete m_ui;
}
void TrackControls::updateTextLabels()
void
TrackControls::updateTextLabels()
{
if ( m_track->mediaType() == Workflow::VideoTrack )
m_ui->trackLabel->setText( tr( "Video #%1" ).arg( QString::number( m_track->trackNumber() + 1 ) ) );
......@@ -48,7 +56,8 @@ void TrackControls::updateTextLabels()
m_ui->trackLabel->setText( tr( "Audio #%1" ).arg( QString::number( m_track->trackNumber() + 1 ) ) );
}
void TrackControls::changeEvent( QEvent *e )
void
TrackControls::changeEvent( QEvent *e )
{
QWidget::changeEvent( e );
switch ( e->type() ) {
......@@ -61,7 +70,8 @@ void TrackControls::changeEvent( QEvent *e )
}
}
void TrackControls::setTrackDisabled( bool disable )
void
TrackControls::setTrackDisabled( bool disable )
{
m_track->setTrackEnabled( !disable );
if ( !disable )
......@@ -79,3 +89,12 @@ void TrackControls::setTrackDisabled( bool disable )
m_ui->disableButton->setIcon( QIcon( ":/images/hpoff" ) );
}
}
void
TrackControls::trackNameDoubleClicked()
{
QString name = QInputDialog::getText( NULL, tr( "Rename track" ),
tr( "Enter the track new name") );
if ( name.isEmpty() == false )
m_ui->trackLabel->setText( name );
}
......@@ -42,7 +42,8 @@ protected:
void changeEvent( QEvent *e );
private slots:
void setTrackDisabled( bool disable );
void setTrackDisabled( bool disable );
void trackNameDoubleClicked();
private:
void updateTextLabels();
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>104</width>
<height>19</height>
<height>22</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -52,7 +52,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="trackLabel">
<widget class="ExtendedLabel" name="trackLabel">
<property name="text">
<string>TextLabel</string>
</property>
......@@ -60,6 +60,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>ExtendedLabel</class>
<extends>QLabel</extends>
<header>ExtendedLabel.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
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