diff options
Diffstat (limited to 'qmidiplayer-desktop/qmppresetselect.cpp')
-rw-r--r-- | qmidiplayer-desktop/qmppresetselect.cpp | 69 |
1 files changed, 51 insertions, 18 deletions
diff --git a/qmidiplayer-desktop/qmppresetselect.cpp b/qmidiplayer-desktop/qmppresetselect.cpp index 4c9148c..c5132b3 100644 --- a/qmidiplayer-desktop/qmppresetselect.cpp +++ b/qmidiplayer-desktop/qmppresetselect.cpp @@ -49,22 +49,38 @@ void qmpPresetSelector::setupWindow(int chid) sprintf(name,"Preset Selection - Channel #%d",ch+1); setWindowTitle(name); plyr->getChannelPreset(chid,&b,&p,name); - for(int i=0;i<ui->lwBankSelect->count();++i) - { - sscanf(ui->lwBankSelect->item(i)->text().toStdString().c_str(),"%3d",&r); - if(r==b){ui->lwBankSelect->setCurrentRow(i);break;} + if(plyr->getChannelOutput(chid)){ + ui->lwPresetSelect->setEnabled(false); + ui->lwBankSelect->setEnabled(false); + ui->spCustomLSB->setEnabled(true); + ui->spCustomMSB->setEnabled(true); + ui->spCustomPC->setEnabled(true); + ui->spCustomMSB->setValue(plyr->getCC(chid,0)); + ui->spCustomLSB->setValue(plyr->getCC(chid,32)); + ui->spCustomPC->setValue(p); } - r=0; - ui->lwPresetSelect->clear(); - for(int i=0,cr=0;i<128;++i) - if(strlen(presets[b][i])) - { - sprintf(name,"%03d %s",i,presets[b][i]); - if(i==p)r=cr; - ui->lwPresetSelect->addItem(name); - cr++; + else{ + ui->lwPresetSelect->setEnabled(true); + ui->lwBankSelect->setEnabled(true); + ui->spCustomLSB->setEnabled(false); + ui->spCustomMSB->setEnabled(false); + ui->spCustomPC->setEnabled(false); + for(int i=0;i<ui->lwBankSelect->count();++i){ + sscanf(ui->lwBankSelect->item(i)->text().toStdString().c_str(),"%3d",&r); + if(r==b){ui->lwBankSelect->setCurrentRow(i);break;} + } + r=0; + ui->lwPresetSelect->clear(); + for(int i=0,cr=0;i<128;++i) + if(strlen(presets[b][i])) + { + sprintf(name,"%03d %s",i,presets[b][i]); + if(i==p)r=cr; + ui->lwPresetSelect->addItem(name); + cr++; + } + ui->lwPresetSelect->setCurrentRow(r); } - ui->lwPresetSelect->setCurrentRow(r); } void qmpPresetSelector::on_pbCancel_clicked() @@ -75,10 +91,17 @@ void qmpPresetSelector::on_pbCancel_clicked() void qmpPresetSelector::on_pbOk_clicked() { CMidiPlayer *plyr=qmpMainWindow::getInstance()->getPlayer(); - if(!ui->lwBankSelect->currentItem()||!ui->lwPresetSelect->currentItem())return (void)close(); - int b,p;sscanf(ui->lwBankSelect->currentItem()->text().toStdString().c_str(),"%d",&b); - sscanf(ui->lwPresetSelect->currentItem()->text().toStdString().c_str(),"%d",&p); - plyr->setChannelPreset(ch,b,p); + if(plyr->getChannelOutput(ch)){ + plyr->setChannelPreset(ch,(ui->spCustomMSB->value()<<7)|ui->spCustomLSB->value(),ui->spCustomPC->value()); + //plyr->setCC(ch,0,ui->spCustomMSB->value()); + //plyr->setCC(ch,32,ui->spCustomLSB->value()); + } + else{ + if(!ui->lwBankSelect->currentItem()||!ui->lwPresetSelect->currentItem())return (void)close(); + int b,p;sscanf(ui->lwBankSelect->currentItem()->text().toStdString().c_str(),"%d",&b); + sscanf(ui->lwPresetSelect->currentItem()->text().toStdString().c_str(),"%d",&p); + plyr->setChannelPreset(ch,b,p); + } close(); } @@ -100,3 +123,13 @@ void qmpPresetSelector::on_lwBankSelect_currentRowChanged() ui->lwPresetSelect->addItem(name); } } + +void qmpPresetSelector::on_buttonBox_accepted() +{ + on_pbOk_clicked(); +} + +void qmpPresetSelector::on_buttonBox_rejected() +{ + on_pbCancel_clicked(); +} |