diff options
author | Chris Xiong <chirs241097@gmail.com> | 2016-04-08 23:49:24 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2016-04-08 23:49:24 +0800 |
commit | 2b46ba471830d4e6e22be5afc720adc2489efcfe (patch) | |
tree | 8445440ba0204a67d1cb49185297a49e326dc9ab /qmidiplayer-desktop/qmpchannelswindow.cpp | |
parent | 8f8782f43bd838e825f3792b611d27fffa90399b (diff) | |
download | QMidiPlayer-2b46ba471830d4e6e22be5afc720adc2489efcfe.tar.xz |
the Awakening of the Evil.
Diffstat (limited to 'qmidiplayer-desktop/qmpchannelswindow.cpp')
-rw-r--r-- | qmidiplayer-desktop/qmpchannelswindow.cpp | 58 |
1 files changed, 39 insertions, 19 deletions
diff --git a/qmidiplayer-desktop/qmpchannelswindow.cpp b/qmidiplayer-desktop/qmpchannelswindow.cpp index 4d5f6ab..3e43c3d 100644 --- a/qmidiplayer-desktop/qmpchannelswindow.cpp +++ b/qmidiplayer-desktop/qmpchannelswindow.cpp @@ -14,30 +14,38 @@ qmpChannelsWindow::qmpChannelsWindow(QWidget *parent) : ceditw=new qmpChannelEditor(this); connect(this,SIGNAL(dialogClosing()),parent,SLOT(dialogClosed())); mapper=qmpMainWindow::getInstance()->getPlayer()->getMidiMapper(); + cha=new QPixmap(":/img/ledon.png");chi=new QPixmap(":/img/ledoff.png"); + cb=new qmpCWNoteOnCB(); + qmpMainWindow::getInstance()->getPlayer()->setNoteOnCallBack(cb,NULL); + connect(cb,SIGNAL(onNoteOn()),this,SLOT(updateChannelActivity())); int devc=mapper->enumDevices(); for(int i=0;i<16;++i) { - ui->twChannels->setCellWidget(i,0,new QCheckBox("")); - connect(ui->twChannels->cellWidget(i,0),SIGNAL(stateChanged(int)),this,SLOT(channelMSChanged())); + ui->twChannels->setItem(i,0,new QTableWidgetItem()); + ui->twChannels->item(i,0)->setIcon(*chi); + ui->twChannels->item(i,0)->setFlags(ui->twChannels->item(i,0)->flags()^Qt::ItemIsEditable); ui->twChannels->setCellWidget(i,1,new QCheckBox("")); connect(ui->twChannels->cellWidget(i,1),SIGNAL(stateChanged(int)),this,SLOT(channelMSChanged())); - ui->twChannels->setCellWidget(i,2,new QDCComboBox()); - QDCComboBox *cb=(QDCComboBox*)ui->twChannels->cellWidget(i,2); + ui->twChannels->setCellWidget(i,2,new QCheckBox("")); + connect(ui->twChannels->cellWidget(i,2),SIGNAL(stateChanged(int)),this,SLOT(channelMSChanged())); + ui->twChannels->setCellWidget(i,3,new QDCComboBox()); + QDCComboBox *cb=(QDCComboBox*)ui->twChannels->cellWidget(i,3); cb->addItem("Internal FluidSynth");cb->setID(i); for(int j=0;j<devc;++j)cb->addItem(mapper->deviceName(j).c_str()); connect(cb,SIGNAL(onChange(int,int)),this,SLOT(changeMidiMapping(int,int))); - ui->twChannels->setCellWidget(i,3,new QDCLabel("")); - ((QDCLabel*)ui->twChannels->cellWidget(i,3))->setID(i); - connect(ui->twChannels->cellWidget(i,3),SIGNAL(onDoubleClick(int)),this,SLOT(showPresetWindow(int))); - ui->twChannels->setCellWidget(i,4,new QDCPushButton("...")); + ui->twChannels->setCellWidget(i,4,new QDCLabel("")); ((QDCLabel*)ui->twChannels->cellWidget(i,4))->setID(i); - connect(ui->twChannels->cellWidget(i,4),SIGNAL(onClick(int)),this,SLOT(showChannelEditorWindow(int))); + connect(ui->twChannels->cellWidget(i,4),SIGNAL(onDoubleClick(int)),this,SLOT(showPresetWindow(int))); + ui->twChannels->setCellWidget(i,5,new QDCPushButton("...")); + ((QDCLabel*)ui->twChannels->cellWidget(i,5))->setID(i); + connect(ui->twChannels->cellWidget(i,5),SIGNAL(onClick(int)),this,SLOT(showChannelEditorWindow(int))); } - ui->twChannels->setColumnWidth(0,32); + ui->twChannels->setColumnWidth(0,24); ui->twChannels->setColumnWidth(1,32); - ui->twChannels->setColumnWidth(2,192); + ui->twChannels->setColumnWidth(2,32); ui->twChannels->setColumnWidth(3,192); - ui->twChannels->setColumnWidth(4,32); + ui->twChannels->setColumnWidth(4,192); + ui->twChannels->setColumnWidth(5,32); } void qmpChannelsWindow::showEvent(QShowEvent *event) @@ -68,12 +76,19 @@ void qmpChannelsWindow::moveEvent(QMoveEvent *event) } } +void qmpChannelsWindow::updateChannelActivity() +{ + for(int i=0;i<16;++i) + ui->twChannels->item(i,0)->setIcon( + qmpMainWindow::getInstance()->getPlayer()->getChstates()[i]?*cha:*chi); +} + void qmpChannelsWindow::channelWindowsUpdate() { if(qmpMainWindow::getInstance()->getPlayer()->isFinished()) { for(int i=0;i<16;++i) - ((QLabel*)ui->twChannels->cellWidget(i,3))->setText(""); + ((QLabel*)ui->twChannels->cellWidget(i,4))->setText(""); return; } for(int i=0;i<16;++i) @@ -82,7 +97,11 @@ void qmpChannelsWindow::channelWindowsUpdate() int b,p; qmpMainWindow::getInstance()->getPlayer()->getChannelPreset(i,&b,&p,nm); sprintf(data,"%d:%d %s",b,p,nm); - ((QLabel*)ui->twChannels->cellWidget(i,3))->setText(data); + ((QLabel*)ui->twChannels->cellWidget(i,4))->setText(data); + ui->twChannels->item(i,0)->setIcon( + qmpMainWindow::getInstance()->getPlayer()->getChstates()[i]?*cha:*chi); + if(qmpMainWindow::getInstance()->getPlayer()->getChstates()[i]) + qmpMainWindow::getInstance()->getPlayer()->getChstates()[i]=0; } } @@ -91,8 +110,8 @@ void qmpChannelsWindow::channelMSChanged() for(int i=0;i<16;++i) { QCheckBox *m,*s; - m=(QCheckBox*)ui->twChannels->cellWidget(i,0); - s=(QCheckBox*)ui->twChannels->cellWidget(i,1); + m=(QCheckBox*)ui->twChannels->cellWidget(i,1); + s=(QCheckBox*)ui->twChannels->cellWidget(i,2); if(m->isChecked()&&s->isChecked())s->setChecked(false); qmpMainWindow::getInstance()->getPlayer()->setMute(i,m->isChecked()); qmpMainWindow::getInstance()->getPlayer()->setSolo(i,s->isChecked()); @@ -101,14 +120,15 @@ void qmpChannelsWindow::channelMSChanged() qmpChannelsWindow::~qmpChannelsWindow() { - delete ui; + delete chi;delete cha; + delete cb;delete ui; } void qmpChannelsWindow::on_pbUnmute_clicked() { for(int i=0;i<16;++i) { - ((QCheckBox*)ui->twChannels->cellWidget(i,0))->setChecked(false); + ((QCheckBox*)ui->twChannels->cellWidget(i,1))->setChecked(false); qmpMainWindow::getInstance()->getPlayer()->setMute(i,false); } } @@ -117,7 +137,7 @@ void qmpChannelsWindow::on_pbUnsolo_clicked() { for(int i=0;i<16;++i) { - ((QCheckBox*)ui->twChannels->cellWidget(i,1))->setChecked(false); + ((QCheckBox*)ui->twChannels->cellWidget(i,2))->setChecked(false); qmpMainWindow::getInstance()->getPlayer()->setSolo(i,false); } } |