From 5f6d0af98dffbbd67f361844b82dc94319308274 Mon Sep 17 00:00:00 2001 From: Paul Giblock Date: Mon, 2 Jun 2008 06:36:43 +0000 Subject: [PATCH] Allow editing of connections though context menu git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1043 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 2 ++ include/controller_connection_dialog.h | 3 +- src/gui/controller_connection_dialog.cpp | 43 +++++++++++++++++++++--- src/gui/widgets/knob.cpp | 4 ++- 4 files changed, 46 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7cbd14ba2..8ff886e48 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,11 +8,13 @@ * include/controller.h: * include/midi_controller.h: * include/controller_connection_dialog.h: + * src/gui/widgets/knob.cpp: * src/gui/controller_connection_dialog.cpp: * src/core/midi/midi_controller.cpp: * src/core/controller.cpp: * Makefile.am: - Add midi-controller support + - Allow editing of connection through context menu - Code clean-up * include/midi.h: diff --git a/include/controller_connection_dialog.h b/include/controller_connection_dialog.h index 1733e6e34..d88d1d2e7 100644 --- a/include/controller_connection_dialog.h +++ b/include/controller_connection_dialog.h @@ -50,7 +50,8 @@ class controllerConnectionDialog : public QDialog { Q_OBJECT public: - controllerConnectionDialog( QWidget * _parent); + controllerConnectionDialog( QWidget * _parent, + controllerConnection * _connection = NULL ); virtual ~controllerConnectionDialog(); controller * chosenController( void ) diff --git a/src/gui/controller_connection_dialog.cpp b/src/gui/controller_connection_dialog.cpp index 96b829a0e..6d412072b 100644 --- a/src/gui/controller_connection_dialog.cpp +++ b/src/gui/controller_connection_dialog.cpp @@ -32,6 +32,7 @@ #include #include "controller_connection_dialog.h" +#include "controller_connection.h" #include "lcd_spinbox.h" #include "led_checkbox.h" #include "combobox.h" @@ -109,7 +110,8 @@ public slots: -controllerConnectionDialog::controllerConnectionDialog( QWidget * _parent +controllerConnectionDialog::controllerConnectionDialog( QWidget * _parent, + controllerConnection * _connection ) : QDialog( _parent ), m_controller( NULL ), @@ -124,6 +126,7 @@ controllerConnectionDialog::controllerConnectionDialog( QWidget * _parent vlayout->setSpacing( 10 ); vlayout->setMargin( 10 ); + // Midi stuff m_midiGroupBox = new groupBox( tr( "MIDI CONTROLLER" ), this ); m_midiGroupBox->setGeometry( 2, 2, 240, 64 ); @@ -158,6 +161,9 @@ controllerConnectionDialog::controllerConnectionDialog( QWidget * _parent connect( m_userGroupBox->model(), SIGNAL( dataChanged() ), this, SLOT( userToggled() ) ); + m_userController = new comboBox( m_userGroupBox, "Controller" ); + m_userController->setGeometry( 10, 20, 200, 22 ); + m_mappingFunction = new QLineEdit( this ); m_mappingFunction->setGeometry( 2, 140, 240, 16 ); m_mappingFunction->setText( "input" ); @@ -167,9 +173,6 @@ controllerConnectionDialog::controllerConnectionDialog( QWidget * _parent resize( 256, 196 ); - m_userController = new comboBox( m_userGroupBox, "Controller" ); - m_userController->setGeometry( 10, 20, 200, 22 ); - for( int i = 0; i < engine::getSong()->controllers().size(); ++i ) { controller * c = engine::getSong()->controllers().at( i ); @@ -202,6 +205,38 @@ controllerConnectionDialog::controllerConnectionDialog( QWidget * _parent btn_layout->addWidget( cancel_btn ); btn_layout->addSpacing( 10 ); + + // TODO, handle by making this a model for the Dialog "view" + if( _connection && _connection->getController()->type() != + controller::DummyController && engine::getSong() ) + { + if ( _connection->getController()->type() == + controller::MidiController ) + { + m_midiGroupBox->model()->setValue( TRUE ); + // ensure controller is created + midiToggled(); + + midiController * cont = + (midiController*)( _connection->getController() ); + m_midiChannelSpinBox->model()->setValue( + cont->midiChannelModel()->value() ); + m_midiControllerSpinBox->model()->setValue( + cont->midiControllerModel()->value() ); + } + else + { + int idx = engine::getSong()->controllers().indexOf( + _connection->getController() ); + + if( idx >= 0 ) + { + m_userGroupBox->model()->setValue( TRUE ); + m_userController->model()->setValue( idx ); + } + } + } + show(); } diff --git a/src/gui/widgets/knob.cpp b/src/gui/widgets/knob.cpp index 396a028df..9e4591a08 100644 --- a/src/gui/widgets/knob.cpp +++ b/src/gui/widgets/knob.cpp @@ -691,7 +691,9 @@ void knob::connectToController( void ) // TODO[pg]: Display a dialog with list of controllers currently in the song // in addition to any system MIDI controllers - controllerConnectionDialog * d = new controllerConnectionDialog( engine::getMainWindow() ); + controllerConnectionDialog * d = new controllerConnectionDialog( + engine::getMainWindow(), + model()->getControllerConnection() ); d->exec();