From 3158e80b92d8e73871fa78b822bf64fea2a2cdca Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Sat, 8 Mar 2008 20:22:35 +0000 Subject: [PATCH] made MIDI-port-menu work again git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@781 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 14 ++++++++ include/instrument_midi_io.h | 19 +++++++---- include/instrument_midi_io_view.h | 3 ++ include/instrument_track.h | 10 ++++++ src/core/instrument_midi_io.cpp | 42 +++++++++++------------ src/widgets/instrument_midi_io_view.cpp | 45 ++++++++++++++++++++++--- 6 files changed, 101 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0afef9b7d..367f43b86 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,19 @@ 2008-03-08 Tobias Doerffel + * src/core/track.cpp: + * include/track.h: + fixed crash when removing TCO via context-menu + + * include/instrument_track.h: + * src/core/file_browser.cpp: + made "Send to active instrument-track" work again + + * include/instrument_midi_io_view.h: + * include/instrument_midi_io.h: + * src/widgets/instrument_midi_io_view.cpp: + * src/core/instrument_midi_io.cpp: + made MIDI-port-menu work again + * plugins/kicker/kicker.cpp: set track for knobs in order to make them automatable diff --git a/include/instrument_midi_io.h b/include/instrument_midi_io.h index 131183ed8..e515fc5ff 100644 --- a/include/instrument_midi_io.h +++ b/include/instrument_midi_io.h @@ -55,17 +55,22 @@ public: } +signals: + void readablePortsChanged( void ); + void writeablePortsChanged( void ); + + public slots: - void midiPortModeChanged( void ); + void updateMidiPortMode( void ); protected slots: - void inputChannelChanged( void ); - void outputChannelChanged( void ); - void defaultVelInChanged( void ); - void defaultVelOutChanged( void ); - void readablePortsChanged( void ); - void writeablePortsChanged( void ); + void updateInputChannel( void ); + void updateOutputChannel( void ); + void updateDefaultVelIn( void ); + void updateDefaultVelOut( void ); + void updateReadablePorts( void ); + void updateWriteablePorts( void ); void activatedReadablePort( const descriptiveMidiPort & _port ); void activatedWriteablePort( const descriptiveMidiPort & _port ); diff --git a/include/instrument_midi_io_view.h b/include/instrument_midi_io_view.h index 9662ebd06..1ef06e8be 100644 --- a/include/instrument_midi_io_view.h +++ b/include/instrument_midi_io_view.h @@ -52,6 +52,9 @@ protected slots: void activatedReadablePort( QAction * _item ); void activatedWriteablePort( QAction * _item ); + void updateReadablePortsMenu( void ); + void updateWriteablePortsMenu( void ); + private: virtual void modelChanged( void ); diff --git a/include/instrument_track.h b/include/instrument_track.h index e8b1c7e3f..2558047f5 100644 --- a/include/instrument_track.h +++ b/include/instrument_track.h @@ -261,6 +261,16 @@ public: return( m_tabWidget ); } + instrumentTrack * model( void ) + { + return( castModel() ); + } + + const instrumentTrack * model( void ) const + { + return( castModel() ); + } + public slots: void textChanged( const QString & _new_name ); diff --git a/src/core/instrument_midi_io.cpp b/src/core/instrument_midi_io.cpp index dc3b852ce..08eb1ff77 100644 --- a/src/core/instrument_midi_io.cpp +++ b/src/core/instrument_midi_io.cpp @@ -61,20 +61,20 @@ instrumentMidiIO::instrumentMidiIO( instrumentTrack * _instrument_track, m_defaultVelocityOutEnabledModel.setTrack( m_instrumentTrack ); connect( &m_inputChannelModel, SIGNAL( dataChanged() ), - this, SLOT( inputChannelChanged() ) ); + this, SLOT( updateInputChannel() ) ); connect( &m_outputChannelModel, SIGNAL( dataChanged() ), - this, SLOT( outputChannelChanged() ) ); + this, SLOT( updateOutputChannel() ) ); connect( &m_receiveEnabledModel, SIGNAL( dataChanged() ), - this, SLOT( midiPortModeChanged() ) ); + this, SLOT( updateMidiPortMode() ) ); connect( &m_defaultVelocityInEnabledModel, SIGNAL( dataChanged() ), - this, SLOT( defaultVelInChanged() ) ); + this, SLOT( updateDefaultVelIn() ) ); connect( &m_sendEnabledModel, SIGNAL( dataChanged() ), - this, SLOT( midiPortModeChanged() ) ); + this, SLOT( updateMidiPortMode() ) ); connect( &m_defaultVelocityOutEnabledModel, SIGNAL( dataChanged() ), - this, SLOT( defaultVelOutChanged() ) ); + this, SLOT( updateDefaultVelOut() ) ); - inputChannelChanged(); - outputChannelChanged(); + updateInputChannel(); + updateOutputChannel(); const midiPort::modes m = m_midiPort->mode(); @@ -88,12 +88,12 @@ instrumentMidiIO::instrumentMidiIO( instrumentTrack * _instrument_track, midiClient * mc = engine::getMixer()->getMIDIClient(); if( mc->isRaw() == FALSE ) { - readablePortsChanged(); - writeablePortsChanged(); + updateReadablePorts(); + updateWriteablePorts(); // we want to get informed about port-changes! - mc->connectRPChanged( this, SLOT( readablePortsChanged() ) ); - mc->connectWPChanged( this, SLOT( writeablePortsChanged() ) ); + mc->connectRPChanged( this, SLOT( updateReadablePorts() ) ); + mc->connectWPChanged( this, SLOT( updateWriteablePorts() ) ); } } @@ -201,7 +201,7 @@ void instrumentMidiIO::loadSettings( const QDomElement & _this ) -void instrumentMidiIO::inputChannelChanged( void ) +void instrumentMidiIO::updateInputChannel( void ) { m_midiPort->setInputChannel( m_inputChannelModel.value() - 1 ); engine::getSong()->setModified(); @@ -210,7 +210,7 @@ void instrumentMidiIO::inputChannelChanged( void ) -void instrumentMidiIO::outputChannelChanged( void ) +void instrumentMidiIO::updateOutputChannel( void ) { m_midiPort->setOutputChannel( m_outputChannelModel.value() - 1 ); engine::getSong()->setModified(); @@ -219,7 +219,7 @@ void instrumentMidiIO::outputChannelChanged( void ) -void instrumentMidiIO::defaultVelInChanged( void ) +void instrumentMidiIO::updateDefaultVelIn( void ) { m_midiPort->enableDefaultVelocityForInEvents( m_defaultVelocityInEnabledModel.value() ); @@ -228,7 +228,7 @@ void instrumentMidiIO::defaultVelInChanged( void ) -void instrumentMidiIO::defaultVelOutChanged( void ) +void instrumentMidiIO::updateDefaultVelOut( void ) { m_midiPort->enableDefaultVelocityForOutEvents( m_defaultVelocityOutEnabledModel.value() ); @@ -237,7 +237,7 @@ void instrumentMidiIO::defaultVelOutChanged( void ) -void instrumentMidiIO::midiPortModeChanged( void ) +void instrumentMidiIO::updateMidiPortMode( void ) { // this small lookup-table makes everything easier static const midiPort::modes modeTable[2][2] = @@ -280,7 +280,7 @@ void instrumentMidiIO::midiPortModeChanged( void ) -void instrumentMidiIO::readablePortsChanged( void ) +void instrumentMidiIO::updateReadablePorts( void ) { // first save all selected ports QStringList selected_ports; @@ -302,13 +302,13 @@ void instrumentMidiIO::readablePortsChanged( void ) m_readablePorts.push_back( qMakePair( *it, selected_ports.indexOf( *it ) != -1 ) ); } - emit dataChanged(); + emit readablePortsChanged(); } -void instrumentMidiIO::writeablePortsChanged( void ) +void instrumentMidiIO::updateWriteablePorts( void ) { // first save all selected ports QStringList selected_ports; @@ -330,7 +330,7 @@ void instrumentMidiIO::writeablePortsChanged( void ) m_writeablePorts.push_back( qMakePair( *it, selected_ports.indexOf( *it ) != -1 ) ); } - emit dataChanged(); + emit writeablePortsChanged(); } diff --git a/src/widgets/instrument_midi_io_view.cpp b/src/widgets/instrument_midi_io_view.cpp index dbddf0904..db44475c6 100644 --- a/src/widgets/instrument_midi_io_view.cpp +++ b/src/widgets/instrument_midi_io_view.cpp @@ -119,10 +119,6 @@ instrumentMidiIOView::instrumentMidiIOView( QWidget * _parent ) : connect( m_writeablePorts, SIGNAL( triggered( QAction * ) ), this, SLOT( activatedWriteablePort( QAction * ) ) ); - // fill menus -/* readablePortsChanged(); - writeablePortsChanged();*/ - QToolButton * rp_btn = new QToolButton( m_setupTabWidget ); rp_btn->setText( tr( "MIDI-devices to receive " "MIDI-events from" ) ); @@ -162,6 +158,12 @@ void instrumentMidiIOView::modelChanged( void ) m_sendCheckBox->setModel( &mio->m_sendEnabledModel ); m_defaultVelocityOutCheckBox->setModel( &mio->m_defaultVelocityOutEnabledModel ); + connect( mio, SIGNAL( readablePortsChanged() ), + this, SLOT( updateReadablePortsMenu() ) ); + connect( mio, SIGNAL( writeablePortsChanged() ), + this, SLOT( updateWriteablePortsMenu() ) ); + updateReadablePortsMenu(); + updateWriteablePortsMenu(); } @@ -200,6 +202,41 @@ void instrumentMidiIOView::activatedWriteablePort( QAction * _item ) + +void instrumentMidiIOView::updateReadablePortsMenu( void ) +{ + instrumentMidiIO * mio = castModel(); + m_readablePorts->clear(); + for( instrumentMidiIO::midiPortMap::const_iterator it = + mio->m_readablePorts.begin(); + it != mio->m_readablePorts.end(); ++it ) + { + QAction * a = m_readablePorts->addAction( it->first ); + a->setCheckable( TRUE ); + a->setChecked( it->second ); + } +} + + + + +void instrumentMidiIOView::updateWriteablePortsMenu( void ) +{ + instrumentMidiIO * mio = castModel(); + m_writeablePorts->clear(); + for( instrumentMidiIO::midiPortMap::const_iterator it = + mio->m_writeablePorts.begin(); + it != mio->m_writeablePorts.end(); ++it ) + { + QAction * a = m_writeablePorts->addAction( it->first ); + a->setCheckable( TRUE ); + a->setChecked( it->second ); + } +} + + + + #include "instrument_midi_io_view.moc"