diff --git a/include/TrackLabelButton.h b/include/TrackLabelButton.h index 7af8f495e4c..2d09be21b1f 100644 --- a/include/TrackLabelButton.h +++ b/include/TrackLabelButton.h @@ -27,6 +27,7 @@ #define TRACK_LABEL_BUTTON_H #include +#include class TrackView; @@ -42,6 +43,7 @@ class TrackLabelButton : public QToolButton public slots: void rename(); + void renameFinished(); protected: @@ -55,6 +57,7 @@ public slots: private: TrackView * m_trackView; QString m_iconName; + QLineEdit * m_rename; } ; diff --git a/src/gui/widgets/TrackLabelButton.cpp b/src/gui/widgets/TrackLabelButton.cpp index 150300564c7..de3a6196db6 100644 --- a/src/gui/widgets/TrackLabelButton.cpp +++ b/src/gui/widgets/TrackLabelButton.cpp @@ -25,6 +25,7 @@ #include +#include #include @@ -61,6 +62,13 @@ TrackLabelButton::TrackLabelButton( TrackView * _tv, QWidget * _parent ) : setIconSize( QSize( 24, 24 ) ); setText( " " ); + m_rename = new QLineEdit(this); + m_rename->move( 30, (height() / 2) - ( m_rename->sizeHint().height() / 2 ) ); + m_rename->setFixedWidth( this->width() - 33 ); + m_rename->hide(); + + connect( m_rename, SIGNAL( editingFinished() ), this, SLOT( renameFinished() ) ); + connect( m_trackView->getTrack(), SIGNAL( dataChanged() ), this, SLOT( update() ) ); } @@ -77,18 +85,40 @@ TrackLabelButton::~TrackLabelButton() void TrackLabelButton::rename() { - QString txt = m_trackView->getTrack()->name(); - RenameDialog rename_dlg( txt ); - rename_dlg.exec(); - if( txt != text() ) + if( ConfigManager::inst()->value( "ui", + "compacttrackbuttons" ).toInt() ) + { + QString txt = m_trackView->getTrack()->name(); + RenameDialog rename_dlg( txt ); + rename_dlg.exec(); + if( txt != text() ) + { + m_trackView->getTrack()->setName( txt ); + } + } + else { - m_trackView->getTrack()->setName( txt ); + QString txt = m_trackView->getTrack()->name(); + m_rename->show(); + m_rename->setText( txt ); + m_rename->selectAll(); + m_rename->setFocus(); } } +void TrackLabelButton::renameFinished() +{ + m_rename->hide(); + setText( m_rename->text() ); + m_trackView->getTrack()->setName( m_rename->text() ); +} + + + + void TrackLabelButton::dragEnterEvent( QDragEnterEvent * _dee ) { m_trackView->dragEnterEvent( _dee );