Add "Assign to new FX Channel" action to FXSpinBox

Fix #604 #921
This commit is contained in:
Amadeus Folego
2015-01-14 16:50:25 -02:00
parent 06cb85b771
commit c99e47f581
3 changed files with 69 additions and 25 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 );
@@ -378,11 +381,12 @@ public:
void setInstrumentTrackView( InstrumentTrackView * _tv );
InstrumentTrackView * instrumentTrackView()
InstrumentTrackView *instrumentTrackView()
{
return m_itv;
}
PianoView * pianoView()
{
return m_pianoView;

View File

@@ -1747,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( tr( "Assign to new FX Channel" ), trackView, 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)), trackView, 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"
@@ -1171,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
@@ -1189,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() );
}
};