aboutsummaryrefslogtreecommitdiff
path: root/qmidiplayer-desktop/qmppresetselect.cpp
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2016-12-11 20:22:06 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2016-12-11 20:22:06 +0800
commit717067493346bd51dc6f13a6f1ea307ca35bcc2c (patch)
tree849f82f41261a4906fb8644254719218272d34d5 /qmidiplayer-desktop/qmppresetselect.cpp
parentec415e53bbe042df084bdb93117b2aef7cb779cd (diff)
downloadQMidiPlayer-717067493346bd51dc6f13a6f1ea307ca35bcc2c.tar.xz
Update the preset selection dialog to improve support for external MIDI devices.
Diffstat (limited to 'qmidiplayer-desktop/qmppresetselect.cpp')
-rw-r--r--qmidiplayer-desktop/qmppresetselect.cpp69
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();
+}