From 38369a0585dfe9982ef4776a2c9db1acb8fc955b Mon Sep 17 00:00:00 2001 From: Joshua Wade Date: Wed, 9 May 2018 22:37:32 -0400 Subject: [PATCH 1/4] Add f2 as a FX mixer rename shortcut. Enter doesn't work yet. --- include/FxLine.h | 3 ++- include/FxMixerView.h | 3 +++ src/gui/FxMixerView.cpp | 10 ++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/FxLine.h b/include/FxLine.h index 46490044f07..5dffbd8e0f8 100644 --- a/include/FxLine.h +++ b/include/FxLine.h @@ -79,6 +79,8 @@ class FxLine : public QWidget static const int FxLineHeight; + void renameChannel(); + private: void drawFxLine( QPainter* p, const FxLine *fxLine, bool isActive, bool sendToThis, bool receiveFromThis ); QString elideName( const QString & name ); @@ -98,7 +100,6 @@ class FxLine : public QWidget QGraphicsView * m_view; private slots: - void renameChannel(); void renameFinished(); void removeChannel(); void removeUnusedChannels(); diff --git a/include/FxMixerView.h b/include/FxMixerView.h index 973195bb38d..2366851569b 100644 --- a/include/FxMixerView.h +++ b/include/FxMixerView.h @@ -100,6 +100,9 @@ class EXPORT FxMixerView : public QWidget, public ModelView, void moveChannelLeft(int index, int focusIndex); void moveChannelRight(int index); + // rename the channel + void renameChannel(int index); + // make sure the display syncs up with the fx mixer. // useful for loading projects void refreshDisplay(); diff --git a/src/gui/FxMixerView.cpp b/src/gui/FxMixerView.cpp index 8da1cb4e0a5..d9edf851b77 100644 --- a/src/gui/FxMixerView.cpp +++ b/src/gui/FxMixerView.cpp @@ -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) { @@ -527,6 +533,10 @@ void FxMixerView::keyPressEvent(QKeyEvent * e) addNewChannel(); } break; + case Qt::Key_F2: + renameChannel( m_currentFxLine->channelIndex() ); + case Qt::Key_Enter: + renameChannel( m_currentFxLine->channelIndex() ); } } From e8cf859c9bdc112c34f4b83f64b5db82159ee1b8 Mon Sep 17 00:00:00 2001 From: Joshua Wade Date: Thu, 10 May 2018 00:43:40 -0400 Subject: [PATCH 2/4] Add both enter keys, remove code duplication --- src/gui/FxMixerView.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/FxMixerView.cpp b/src/gui/FxMixerView.cpp index d9edf851b77..5a394117e55 100644 --- a/src/gui/FxMixerView.cpp +++ b/src/gui/FxMixerView.cpp @@ -534,9 +534,10 @@ void FxMixerView::keyPressEvent(QKeyEvent * e) } break; case Qt::Key_F2: - renameChannel( m_currentFxLine->channelIndex() ); case Qt::Key_Enter: + case Qt::Key_Return: renameChannel( m_currentFxLine->channelIndex() ); + break; } } From e42646fb31c6a26dbdd209ed295d3223850d8fcc Mon Sep 17 00:00:00 2001 From: Joshua Wade Date: Fri, 11 May 2018 12:08:33 -0400 Subject: [PATCH 3/4] Fix renaming with enter/return --- include/FxLine.h | 2 ++ include/FxMixerView.h | 1 - src/gui/FxMixerView.cpp | 7 ++++++- src/gui/widgets/FxLine.cpp | 19 +++++++++++++++++++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/include/FxLine.h b/include/FxLine.h index 5dffbd8e0f8..5bb04da2f2d 100644 --- a/include/FxLine.h +++ b/include/FxLine.h @@ -81,6 +81,8 @@ class FxLine : public QWidget 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 ); diff --git a/include/FxMixerView.h b/include/FxMixerView.h index 2366851569b..30c75983885 100644 --- a/include/FxMixerView.h +++ b/include/FxMixerView.h @@ -100,7 +100,6 @@ class EXPORT FxMixerView : public QWidget, public ModelView, void moveChannelLeft(int index, int focusIndex); void moveChannelRight(int index); - // rename the channel void renameChannel(int index); // make sure the display syncs up with the fx mixer. diff --git a/src/gui/FxMixerView.cpp b/src/gui/FxMixerView.cpp index 5a394117e55..f1814f310cc 100644 --- a/src/gui/FxMixerView.cpp +++ b/src/gui/FxMixerView.cpp @@ -533,9 +533,14 @@ void FxMixerView::keyPressEvent(QKeyEvent * e) addNewChannel(); } break; - case Qt::Key_F2: case Qt::Key_Enter: case Qt::Key_Return: + { + /*bool accepted = e->isAccepted(); + if ( e->isAccepted() ) + break;*/ + } + case Qt::Key_F2: renameChannel( m_currentFxLine->channelIndex() ); break; } diff --git a/src/gui/widgets/FxLine.cpp b/src/gui/widgets/FxLine.cpp index c6e6fd9aef8..309ef6a1c7c 100644 --- a/src/gui/widgets/FxLine.cpp +++ b/src/gui/widgets/FxLine.cpp @@ -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(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; @@ -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 ); From c68692605870a8b06eb555d2bfedfe7acf77811b Mon Sep 17 00:00:00 2001 From: Joshua Wade Date: Fri, 11 May 2018 12:26:13 -0400 Subject: [PATCH 4/4] Clean up --- src/gui/FxMixerView.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/gui/FxMixerView.cpp b/src/gui/FxMixerView.cpp index f1814f310cc..cbcfd0a47eb 100644 --- a/src/gui/FxMixerView.cpp +++ b/src/gui/FxMixerView.cpp @@ -535,11 +535,6 @@ void FxMixerView::keyPressEvent(QKeyEvent * e) break; case Qt::Key_Enter: case Qt::Key_Return: - { - /*bool accepted = e->isAccepted(); - if ( e->isAccepted() ) - break;*/ - } case Qt::Key_F2: renameChannel( m_currentFxLine->channelIndex() ); break;