Merge pull request #1545 from DanWin/channel
Add "Remove unused channels" option to FX-Mixer
This commit is contained in:
@@ -73,6 +73,7 @@ private:
|
||||
private slots:
|
||||
void renameChannel();
|
||||
void removeChannel();
|
||||
void removeUnusedChannels();
|
||||
void moveChannelLeft();
|
||||
void moveChannelRight();
|
||||
void displayHelp();
|
||||
|
||||
@@ -92,6 +92,9 @@ public:
|
||||
// notify the view that an fx channel was deleted
|
||||
void deleteChannel(int index);
|
||||
|
||||
// delete all unused channels
|
||||
void deleteUnusedChannels();
|
||||
|
||||
// move the channel to the left or right
|
||||
void moveChannelLeft(int index);
|
||||
void moveChannelRight(int index);
|
||||
|
||||
@@ -395,6 +395,40 @@ void FxMixerView::deleteChannel(int index)
|
||||
|
||||
|
||||
|
||||
void FxMixerView::deleteUnusedChannels()
|
||||
{
|
||||
TrackContainer::TrackList tracks;
|
||||
tracks += Engine::getSong()->tracks();
|
||||
tracks += Engine::getBBTrackContainer()->tracks();
|
||||
|
||||
// go through all FX Channels
|
||||
for(int i = m_fxChannelViews.size()-1; i > 0; --i)
|
||||
{
|
||||
// check if an instrument references to the current channel
|
||||
bool empty=true;
|
||||
foreach( Track* t, tracks )
|
||||
{
|
||||
if( t->type() == Track::InstrumentTrack )
|
||||
{
|
||||
InstrumentTrack* inst = dynamic_cast<InstrumentTrack *>( t );
|
||||
if( i == inst->effectChannelModel()->value(0) )
|
||||
{
|
||||
empty=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
FxChannel * ch = Engine::fxMixer()->effectChannel( i );
|
||||
// delete channel if no references found
|
||||
if( empty && ch->m_receives.isEmpty() )
|
||||
{
|
||||
deleteChannel( i );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FxMixerView::moveChannelLeft(int index)
|
||||
{
|
||||
// can't move master or first channel left or last channel right
|
||||
|
||||
@@ -192,14 +192,18 @@ void FxLine::contextMenuEvent( QContextMenuEvent * )
|
||||
}
|
||||
contextMenu->addAction( tr( "Rename &channel" ), this, SLOT( renameChannel() ) );
|
||||
contextMenu->addSeparator();
|
||||
|
||||
|
||||
if( m_channelIndex != 0 ) // no remove-option in master
|
||||
{
|
||||
contextMenu->addAction( embed::getIconPixmap( "cancel" ), tr( "R&emove channel" ),
|
||||
this, SLOT( removeChannel() ) );
|
||||
contextMenu->addSeparator();
|
||||
}
|
||||
|
||||
|
||||
contextMenu->addAction( embed::getIconPixmap( "cancel" ), tr( "Remove &unused channels" ),
|
||||
this, SLOT( removeUnusedChannels() ) );
|
||||
contextMenu->addSeparator();
|
||||
|
||||
contextMenu->addHelpAction();
|
||||
contextMenu->exec( QCursor::pos() );
|
||||
delete contextMenu;
|
||||
@@ -230,6 +234,13 @@ void FxLine::removeChannel()
|
||||
}
|
||||
|
||||
|
||||
void FxLine::removeUnusedChannels()
|
||||
{
|
||||
FxMixerView * mix = Engine::fxMixerView();
|
||||
mix->deleteUnusedChannels();
|
||||
}
|
||||
|
||||
|
||||
void FxLine::moveChannelLeft()
|
||||
{
|
||||
FxMixerView * mix = Engine::fxMixerView();
|
||||
|
||||
Reference in New Issue
Block a user