Merge pull request #1627 from badosu/add-assign-to-new-fx-spinner

Add "assign to new fx channel" on FX SpinBox
This commit is contained in:
Tres Finocchiaro
2015-01-30 13:34:05 -05:00
4 changed files with 100 additions and 49 deletions

View File

@@ -306,6 +306,9 @@ public:
static void cleanupWindowCache();
// Create a menu for assigning/creating channels for this track
QMenu * createFxMenu( QString title, QString newFxLabel );
protected:
virtual void dragEnterEvent( QDragEnterEvent * _dee );
@@ -322,6 +325,9 @@ private slots:
void midiConfigChanged();
void muteChanged();
void assignFxLine( int channelIndex );
void createFxLine();
private:
InstrumentTrackWindow * m_window;
@@ -375,6 +381,12 @@ public:
void setInstrumentTrackView( InstrumentTrackView * _tv );
InstrumentTrackView *instrumentTrackView()
{
return m_itv;
}
PianoView * pianoView()
{
return m_pianoView;

View File

@@ -391,8 +391,6 @@ private slots:
void recordingOn();
void recordingOff();
void clearTrack();
void assignFxLine( int channelIndex );
void createFxLine();
private:
static QPixmap * s_grip;

View File

@@ -1711,29 +1711,6 @@ void TrackOperationsWidget::clearTrack()
/*! \brief Create and assign a new FX Channel for this track */
void TrackOperationsWidget::createFxLine()
{
int channelIndex = gui->fxMixerView()->addNewChannel();
Engine::fxMixer()->effectChannel( channelIndex )->m_name = m_trackView->getTrack()->name();
assignFxLine(channelIndex);
}
/*! \brief Assign a specific FX Channel for this track */
void TrackOperationsWidget::assignFxLine(int channelIndex)
{
Track * track = m_trackView->getTrack();
dynamic_cast<InstrumentTrack *>( track )->effectChannelModel()->setValue( channelIndex );
gui->fxMixerView()->setCurrentFxLine( channelIndex );
}
/*! \brief Remove this track from the track list
*
*/
@@ -1770,31 +1747,8 @@ void TrackOperationsWidget::updateMenu()
}
if( InstrumentTrackView * trackView = dynamic_cast<InstrumentTrackView *>( m_trackView ) )
{
int channelIndex = trackView->model()->effectChannelModel()->value();
FxChannel * fxChannel = Engine::fxMixer()->effectChannel( channelIndex );
QMenu * fxMenu = new QMenu( tr( "FX %1: %2" ).arg( channelIndex ).arg( fxChannel->m_name ), to_menu );
QSignalMapper * fxMenuSignalMapper = new QSignalMapper(this);
fxMenu->addAction("Assign to new FX Channel" , this, SLOT( createFxLine() ) );
fxMenu->addSeparator();
for (int i = 0; i < Engine::fxMixer()->fxChannels().size(); ++i)
{
FxChannel * currentChannel = Engine::fxMixer()->fxChannels()[i];
if ( currentChannel != fxChannel )
{
QString label = tr( "FX %1: %2" ).arg( currentChannel->m_channelIndex ).arg( currentChannel->m_name );
QAction * action = fxMenu->addAction( label, fxMenuSignalMapper, SLOT( map() ) );
fxMenuSignalMapper->setMapping(action, currentChannel->m_channelIndex);
}
}
QMenu *fxMenu = trackView->createFxMenu( tr( "FX %1: %2" ), tr( "Assign to new FX Channel" ));
to_menu->addMenu(fxMenu);
connect(fxMenuSignalMapper, SIGNAL(mapped(int)), this, SLOT(assignFxLine(int)));
to_menu->addSeparator();
to_menu->addMenu( trackView->midiMenu() );

View File

@@ -36,12 +36,14 @@
#include <QMessageBox>
#include <QMdiSubWindow>
#include <QPainter>
#include <QWidget>
#include "FileDialog.h"
#include "InstrumentTrack.h"
#include "AudioPort.h"
#include "AutomationPattern.h"
#include "BBTrack.h"
#include "CaptionMenu.h"
#include "ConfigManager.h"
#include "ControllerConnection.h"
#include "debug.h"
@@ -963,6 +965,30 @@ InstrumentTrackWindow * InstrumentTrackView::topLevelInstrumentTrackWindow()
/*! \brief Create and assign a new FX Channel for this track */
void InstrumentTrackView::createFxLine()
{
int channelIndex = gui->fxMixerView()->addNewChannel();
Engine::fxMixer()->effectChannel( channelIndex )->m_name = getTrack()->name();
assignFxLine(channelIndex);
}
/*! \brief Assign a specific FX Channel for this track */
void InstrumentTrackView::assignFxLine(int channelIndex)
{
model()->effectChannelModel()->setValue( channelIndex );
gui->fxMixerView()->setCurrentFxLine( channelIndex );
}
// TODO: Add windows to free list on freeInstrumentTrackWindow.
// But, don't NULL m_window or disconnect signals. This will allow windows
// that are being show/hidden frequently to stay connected.
@@ -1147,6 +1173,43 @@ void InstrumentTrackView::muteChanged()
QMenu * InstrumentTrackView::createFxMenu(QString title, QString newFxLabel)
{
int channelIndex = model()->effectChannelModel()->value();
FxChannel *fxChannel = Engine::fxMixer()->effectChannel( channelIndex );
// If title allows interpolation, pass channel index and name
if ( title.contains( "%2" ) )
{
title = title.arg( channelIndex ).arg( fxChannel->m_name );
}
QMenu *fxMenu = new QMenu( title );
QSignalMapper * fxMenuSignalMapper = new QSignalMapper(fxMenu);
fxMenu->addAction( newFxLabel, this, SLOT( createFxLine() ) );
fxMenu->addSeparator();
for (int i = 0; i < Engine::fxMixer()->fxChannels().size(); ++i)
{
FxChannel * currentChannel = Engine::fxMixer()->fxChannels()[i];
if ( currentChannel != fxChannel )
{
QString label = tr( "FX %1: %2" ).arg( currentChannel->m_channelIndex ).arg( currentChannel->m_name );
QAction * action = fxMenu->addAction( label, fxMenuSignalMapper, SLOT( map() ) );
fxMenuSignalMapper->setMapping(action, currentChannel->m_channelIndex);
}
}
connect(fxMenuSignalMapper, SIGNAL(mapped(int)), this, SLOT(assignFxLine(int)));
return fxMenu;
}
class fxLineLcdSpinBox : public LcdSpinBox
@@ -1165,6 +1228,30 @@ class fxLineLcdSpinBox : public LcdSpinBox
gui->fxMixerView()->setFocus();// set focus to fxMixer window
//engine::getFxMixerView()->raise();
}
virtual void contextMenuEvent( QContextMenuEvent* event )
{
// for the case, the user clicked right while pressing left mouse-
// button, the context-menu appears while mouse-cursor is still hidden
// and it isn't shown again until user does something which causes
// an QApplication::restoreOverrideCursor()-call...
mouseReleaseEvent( NULL );
QPointer<CaptionMenu> contextMenu = new CaptionMenu( model()->displayName(), this );
// This condition is here just as a safety check, fxLineLcdSpinBox is aways
// created inside a TabWidget inside an InstrumentTrackWindow
if ( InstrumentTrackWindow* window = dynamic_cast<InstrumentTrackWindow*>( (QWidget *)this->parent()->parent() ) )
{
QMenu *fxMenu = window->instrumentTrackView()->createFxMenu( tr( "Assign to:" ), tr( "New FX Channel" ) );
contextMenu->addMenu( fxMenu );
contextMenu->addSeparator();
}
addDefaultActions( contextMenu );
contextMenu->exec( QCursor::pos() );
}
};