aboutsummaryrefslogtreecommitdiff
path: root/qmppresetselect.cpp
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2015-12-29 23:54:24 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2015-12-29 23:54:24 +0800
commit8dc90ae27c24aec1851215f2cc28ee24eff01ea5 (patch)
tree13a604bf55804960ced6ec7559f626962a1265bd /qmppresetselect.cpp
parent40ea6580aaf3d19aa77f43551185a55013d216d9 (diff)
downloadQMidiPlayer-8dc90ae27c24aec1851215f2cc28ee24eff01ea5.tar.xz
Master Spark. (WTF)
Diffstat (limited to 'qmppresetselect.cpp')
-rw-r--r--qmppresetselect.cpp93
1 files changed, 93 insertions, 0 deletions
diff --git a/qmppresetselect.cpp b/qmppresetselect.cpp
new file mode 100644
index 0000000..f96c99e
--- /dev/null
+++ b/qmppresetselect.cpp
@@ -0,0 +1,93 @@
+#include <cstdio>
+#include "qmppresetselect.hpp"
+#include "ui_qmppresetselect.h"
+#include "qmpmainwindow.hpp"
+
+qmppresetselect::qmppresetselect(QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::qmppresetselect)
+{
+ ui->setupUi(this);
+}
+
+qmppresetselect::~qmppresetselect()
+{
+ delete ui;
+}
+
+void qmppresetselect::showEvent(QShowEvent *e)
+{
+ e->accept();memset(presets,0,sizeof(presets));
+ CMidiPlayer *plyr=((qmpMainWindow*)(this->parent()->parent()))->getPlayer();
+ int sfc=plyr->getSFCount();
+ for(int i=0;i<sfc;++i)
+ {
+ fluid_sfont_t* psf=plyr->getSFPtr(i);
+ fluid_preset_t preset;
+ psf->iteration_start(psf);
+ while(psf->iteration_next(psf,&preset))
+ strcpy(presets[preset.get_banknum(&preset)][preset.get_num(&preset)],preset.get_name(&preset));
+ }
+ ui->lwBankSelect->clear();
+ ui->lwPresetSelect->clear();
+ for(int i=0;i<=128;++i)
+ {
+ int b=0;
+ for(int j=0;j<128;++j)if(strlen(presets[i][j])){b=1;break;}
+ if(b)ui->lwBankSelect->addItem(QString::number(i));
+ }
+}
+void qmppresetselect::setupWindow(int chid)
+{
+ CMidiPlayer *plyr=((qmpMainWindow*)(this->parent()->parent()))->getPlayer();
+ ch=chid;int b,p,r;char name[30];
+ plyr->getChannelPreset(chid,&b,&p,name);
+ for(int i=0;i<ui->lwBankSelect->count();++i)
+ {
+ sscanf(ui->lwBankSelect->item(i)->text().toStdString().c_str(),"%d",&r);
+ if(r==b){ui->lwBankSelect->setCurrentRow(i);break;}
+ }
+ r=0;
+ for(int i=0,cr=0;i<128;++i)
+ if(strlen(presets[b][i]))
+ {
+ sprintf(name,"%d %s",i,presets[b][i]);
+ if(i==p)r=cr;
+ ui->lwPresetSelect->addItem(name);
+ cr++;
+ }
+ ui->lwPresetSelect->setCurrentRow(r);
+}
+
+void qmppresetselect::on_pbCancel_clicked()
+{
+ close();
+}
+
+void qmppresetselect::on_pbOk_clicked()
+{
+ CMidiPlayer *plyr=((qmpMainWindow*)(this->parent()->parent()))->getPlayer();
+ 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();
+}
+
+void qmppresetselect::on_lwPresetSelect_itemDoubleClicked()
+{
+ on_pbOk_clicked();
+}
+
+void qmppresetselect::on_lwBankSelect_currentRowChanged()
+{
+ ui->lwPresetSelect->clear();
+ if(!ui->lwBankSelect->currentItem())return;
+ char name[30];int b;
+ sscanf(ui->lwBankSelect->currentItem()->text().toStdString().c_str(),"%d",&b);
+ for(int i=0;i<128;++i)
+ if(strlen(presets[b][i]))
+ {
+ sprintf(name,"%d %s",i,presets[b][i]);
+ ui->lwPresetSelect->addItem(name);
+ }
+}