Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow renaming of FX mixer channels with the F2 and enter keys. #4348

Merged
merged 4 commits into from
May 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion include/FxLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ class FxLine : public QWidget

static const int FxLineHeight;

void renameChannel();

bool eventFilter (QObject *dist, QEvent *event);

private:
void drawFxLine( QPainter* p, const FxLine *fxLine, bool isActive, bool sendToThis, bool receiveFromThis );
QString elideName( const QString & name );
Expand All @@ -98,7 +102,6 @@ class FxLine : public QWidget
QGraphicsView * m_view;

private slots:
void renameChannel();
void renameFinished();
void removeChannel();
void removeUnusedChannels();
Expand Down
2 changes: 2 additions & 0 deletions include/FxMixerView.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ class EXPORT FxMixerView : public QWidget, public ModelView,
void moveChannelLeft(int index, int focusIndex);
void moveChannelRight(int index);

void renameChannel(int index);

// make sure the display syncs up with the fx mixer.
// useful for loading projects
void refreshDisplay();
Expand Down
11 changes: 11 additions & 0 deletions src/gui/FxMixerView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,12 @@ void FxMixerView::moveChannelRight(int index)
}


void FxMixerView::renameChannel(int index)
{
m_fxChannelViews[index]->m_fxLine->renameChannel();
}



void FxMixerView::keyPressEvent(QKeyEvent * e)
{
Expand Down Expand Up @@ -527,6 +533,11 @@ void FxMixerView::keyPressEvent(QKeyEvent * e)
addNewChannel();
}
break;
case Qt::Key_Enter:
case Qt::Key_Return:
case Qt::Key_F2:
renameChannel( m_currentFxLine->channelIndex() );
break;
}
}

Expand Down
19 changes: 19 additions & 0 deletions src/gui/widgets/FxLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,24 @@
#include "GuiApplication.h"
#include "Song.h"

bool FxLine::eventFilter( QObject *dist, QEvent *event )
{
// If we are in a rename, capture the enter/return events and handle them
if ( event->type() == QEvent::KeyPress )
{
QKeyEvent * keyEvent = static_cast<QKeyEvent*>(event);
if( keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return )
{
if( m_inRename )
{
renameFinished();
event->accept(); // Stop the event from propagating
return true;
}
}
}
return false;
}

const int FxLine::FxLineHeight = 287;
QPixmap * FxLine::s_sendBgArrow = NULL;
Expand Down Expand Up @@ -100,6 +118,7 @@ FxLine::FxLine( QWidget * _parent, FxMixerView * _mv, int _channelIndex ) :
m_renameLineEdit->setFixedWidth( 65 );
m_renameLineEdit->setFont( pointSizeF( font(), 7.5f ) );
m_renameLineEdit->setReadOnly( true );
m_renameLineEdit->installEventFilter( this );

QGraphicsScene * scene = new QGraphicsScene();
scene->setSceneRect( 0, 0, 33, FxLineHeight );
Expand Down