Hi,
While using hydrogen i find it nice to add and remove instruments using the
keyboard.
I did this patch which i'd like to be discussed. I don't know the hydrogen
internal well, so probably this a bit of code duplication but i hope it can be
a start for hydrogen developers to create a better patch. I tested it with
delete and add but rename i didnt' so i guess it will not works.
What do you think about the feature?
Ciao,
Sal
Index: gui/src/MainForm.cpp
===================================================================
--- gui/src/MainForm.cpp (revision 1563)
+++ gui/src/MainForm.cpp (working copy)
@@ -262,11 +262,13 @@
// INSTRUMENTS MENU
QMenu *m_pInstrumentsMenu = m_pMenubar->addMenu( trUtf8( "I&nstruments" ) );
- m_pInstrumentsMenu->addAction( trUtf8( "&Add instrument" ), this, SLOT( action_instruments_addInstrument() ), QKeySequence( "" ) );
- m_pInstrumentsMenu->addAction( trUtf8( "&Clear all" ), this, SLOT( action_instruments_clearAll() ), QKeySequence( "" ) );
- m_pInstrumentsMenu->addAction( trUtf8( "&Save library" ), this, SLOT( action_instruments_saveLibrary() ), QKeySequence( "" ) );
- m_pInstrumentsMenu->addAction( trUtf8( "&Export library" ), this, SLOT( action_instruments_exportLibrary() ), QKeySequence( "" ) );
- m_pInstrumentsMenu->addAction( trUtf8( "&Import library" ), this, SLOT( action_instruments_importLibrary() ), QKeySequence( "" ) );
+ m_pInstrumentsMenu->addAction( trUtf8( "&Add instrument" ), this, SLOT( action_instruments_addInstrument() ), QKeySequence( "Ctrl+I" ) );
+ m_pInstrumentsMenu->addAction( trUtf8( "&Delete instrument" ), this, SLOT( action_instruments_deleteInstrument() ), QKeySequence( "Ctrl+W" ) );
+ m_pInstrumentsMenu->addAction( trUtf8( "&Rename instrument" ), this, SLOT( action_instruments_renameInstrument() ), QKeySequence( "F2" ) );
+ m_pInstrumentsMenu->addAction( trUtf8( "&Clear all" ), this, SLOT( action_instruments_clearAll() ), QKeySequence( "Ctrl+A" ) );
+ m_pInstrumentsMenu->addAction( trUtf8( "&Save library" ), this, SLOT( action_instruments_saveLibrary() ), QKeySequence( "Ctrl+L" ) );
+ m_pInstrumentsMenu->addAction( trUtf8( "&Export library" ), this, SLOT( action_instruments_exportLibrary() ), QKeySequence( "Ctrl+X" ) );
+ m_pInstrumentsMenu->addAction( trUtf8( "&Import library" ), this, SLOT( action_instruments_importLibrary() ), QKeySequence( "Ctrl+Y" ) );
@@ -813,8 +815,40 @@
//EventQueue::get_instance()->pushEvent( EVENT_SELECTED_PATTERN_CHANGED, -1 );
}
+void MainForm::action_instruments_deleteInstrument()
+{
+ Hydrogen *pEngine = Hydrogen::get_instance();
+ pEngine->removeInstrument( pEngine->getSelectedInstrumentNumber(), false );
+
+ AudioEngine::get_instance()->lock( RIGHT_HERE );
+#ifdef JACK_SUPPORT
+ pEngine->renameJackPorts();
+#endif
+ AudioEngine::get_instance()->unlock();
+}
+void MainForm::action_instruments_renameInstrument()
+{
+ Hydrogen *pEngine = Hydrogen::get_instance();
+ Instrument *m_pInstrument = H2Core::Instrument::get_instance();
+ if (m_pInstrument) {
+ QString sOldName = m_pInstrument->get_name();
+ bool bIsOkPressed;
+ QString sNewName = QInputDialog::getText( this, "Hydrogen", trUtf8( "New instrument name" ), QLineEdit::Normal, sOldName, &bIsOkPressed );
+ if ( bIsOkPressed ) {
+ m_pInstrument->set_name( sNewName );
+ selectedInstrumentChangedEvent();
+ // this will force an update...
+ EventQueue::get_instance()->push_event( EVENT_SELECTED_INSTRUMENT_CHANGED, -1 );
+
+ }
+ else {
+ // user entered nothing or pressed Cancel
+ }
+ }
+}
+
void MainForm::action_instruments_clearAll()
{
switch(
Index: gui/src/MainForm.h
===================================================================
--- gui/src/MainForm.h (revision 1563)
+++ gui/src/MainForm.h (working copy)
@@ -74,6 +74,7 @@
void action_help_about();
void action_instruments_addInstrument();
+ void action_instruments_deleteInstrument();
void action_instruments_clearAll();
void action_instruments_saveLibrary();
void action_instruments_exportLibrary();
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Hydrogen-devel mailing list
Hydrogen-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hydrogen-devel