aboutsummaryrefslogtreecommitdiff
path: root/qmidiplayer-desktop/qmpchannelswindow.cpp
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2019-05-26 15:55:28 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2019-05-26 15:55:28 +0800
commit7b03fd544837fbe0bc5a5373b60dfd5de50892e1 (patch)
treea343c4efea96295d60b6e4b7944b8fa23d118db0 /qmidiplayer-desktop/qmpchannelswindow.cpp
parent3f72121ac41741d53e4916f1275cbd4f93259c4d (diff)
downloadQMidiPlayer-7b03fd544837fbe0bc5a5373b60dfd5de50892e1.tar.xz
Major code refactor continued and (mostly) concluded.
Removed all references to ICallback in official plugins. New flag field in SEvent. Further type usage corrections.
Diffstat (limited to 'qmidiplayer-desktop/qmpchannelswindow.cpp')
-rw-r--r--qmidiplayer-desktop/qmpchannelswindow.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/qmidiplayer-desktop/qmpchannelswindow.cpp b/qmidiplayer-desktop/qmpchannelswindow.cpp
index 1800aa5..8968bed 100644
--- a/qmidiplayer-desktop/qmpchannelswindow.cpp
+++ b/qmidiplayer-desktop/qmpchannelswindow.cpp
@@ -14,9 +14,15 @@ qmpChannelsWindow::qmpChannelsWindow(QWidget *parent) :
pselectw=new qmpPresetSelector(this);
ceditw=new qmpChannelEditor(this);
cha=new QIcon(":/img/ledon.svg");chi=new QIcon(":/img/ledoff.svg");
- cb=new qmpCWNoteOnCB();fused=callbacksc=cbcnt=0;
- qmpMainWindow::getInstance()->getPlayer()->setEventHandlerCB(cb,nullptr);
- connect(cb,SIGNAL(onNoteOn()),this,SLOT(updateChannelActivity()));
+ fused=callbacksc=cbcnt=0;
+ eh=qmpMainWindow::getInstance()->getPlayer()->registerEventHandler(
+ [this](const void *ee,void*){
+ const SEvent *e=(const SEvent*)ee;
+ if((e->type&0xF0)==0x90&&e->p2>0&&(e->flags&0x01))
+ emit this->noteOn();
+ }
+ ,nullptr);
+ connect(this,&qmpChannelsWindow::noteOn,this,&qmpChannelsWindow::updateChannelActivity);
std::vector<std::string> devs=qmpMainWindow::getInstance()->getPlayer()->getMidiOutDevices();
size_t devc=devs.size();
//We setup default output here...
@@ -131,7 +137,7 @@ void qmpChannelsWindow::channelWindowsUpdate()
{
for(int i=0;i<16;++i)
ui->twChannels->item(i,4)->setText("");
- connect(cb,SIGNAL(onNoteOn()),this,SLOT(updateChannelActivity()));
+ connect(this,&qmpChannelsWindow::noteOn,this,&qmpChannelsWindow::updateChannelActivity);
fused=0;return;
}
++cbcnt;
@@ -139,7 +145,7 @@ void qmpChannelsWindow::channelWindowsUpdate()
{
if(callbacksc>8192)
{
- disconnect(cb,SIGNAL(onNoteOn()),this,SLOT(updateChannelActivity()));
+ disconnect(this,&qmpChannelsWindow::noteOn,this,&qmpChannelsWindow::updateChannelActivity);
fprintf(stderr,"Fuse!\n");fused=1;
}
cbcnt=0;
@@ -156,7 +162,7 @@ void qmpChannelsWindow::channelWindowsUpdate()
if(strcmp((ui->twChannels->item(i,4))->
text().toStdString().c_str(),data))
{
- connect(cb,SIGNAL(onNoteOn()),this,SLOT(updateChannelActivity()));
+ connect(this,&qmpChannelsWindow::noteOn,this,&qmpChannelsWindow::updateChannelActivity);
fused=0;
}
}
@@ -184,9 +190,10 @@ void qmpChannelsWindow::channelMSChanged()
qmpChannelsWindow::~qmpChannelsWindow()
{
qmpMainWindow::getInstance()->unregisterFunctionality("Channel");
+ qmpMainWindow::getInstance()->getPlayer()->unregisterEventHandler(eh);
delete chnlf;
delete chi;delete cha;
- delete cb;delete ui;
+ delete ui;
}
void qmpChannelsWindow::on_pbUnmute_clicked()