diff options
author | Chris Xiong <chirs241097@gmail.com> | 2020-05-12 00:58:40 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2020-05-12 00:58:40 +0800 |
commit | a7407edaf81c685d4a389785a405a53a5de4b148 (patch) | |
tree | e6e4f2d85f2172c94ac83a6e8f01e1e90a78ede9 /simple-visualization/qmpkeyboardwindow.cpp | |
parent | 437b7b16c322a8e53ac55a5f831098494d9a7073 (diff) | |
download | QMidiPlayer-a7407edaf81c685d4a389785a405a53a5de4b148.tar.xz |
Format EVERYTHING.
Hopefully this will make the source code less horrendous and actually
readable.
The command used was:
```
astyle --suffix=none --style=allman --attach-extern-c --attach-closing-while --indent-switches --indent-after-parens --pad-oper --pad-header --unpad-paren --align-pointer=name --recursive './*.cpp,*.hpp'
```
Diffstat (limited to 'simple-visualization/qmpkeyboardwindow.cpp')
-rw-r--r-- | simple-visualization/qmpkeyboardwindow.cpp | 107 |
1 files changed, 55 insertions, 52 deletions
diff --git a/simple-visualization/qmpkeyboardwindow.cpp b/simple-visualization/qmpkeyboardwindow.cpp index 2c5e70a..b33bb4b 100644 --- a/simple-visualization/qmpkeyboardwindow.cpp +++ b/simple-visualization/qmpkeyboardwindow.cpp @@ -6,66 +6,69 @@ #include "qmppianowidget.hpp" #include "qmpkeyboardwindow.hpp" -qmpKeyboardWindow::qmpKeyboardWindow(qmpPluginAPI *_api,QWidget *parent): - QWidget(parent,Qt::Dialog),api(_api) +qmpKeyboardWindow::qmpKeyboardWindow(qmpPluginAPI *_api, QWidget *parent): + QWidget(parent, Qt::Dialog), api(_api) { - setWindowTitle("Keyboard"); - QGridLayout *grid; - setLayout(grid=new QGridLayout()); - for(int ch=0;ch<16;++ch) - { - grid->addWidget(lb[ch]=new QLabel,ch,0); - grid->addWidget(pw[ch]=new qmpPianoWidget(this),ch,1); - lb[ch]->setFont(QFontDatabase::systemFont(QFontDatabase::SystemFont::FixedFont)); - pw[ch]->setSizePolicy(QSizePolicy::Policy::Expanding,QSizePolicy::Policy::Preferred); - QPalette p=palette(); - p.setColor(QPalette::ColorRole::Highlight,api->getOptionUint("Keyboard/acolor"+std::to_string(ch))); - p.setColor(QPalette::ColorRole::Base,api->getOptionUint("Keyboard/bcolor"+std::to_string(ch))); - pw[ch]->setPalette(p); - } - hide(); - eh=api->registerEventHandler( - [this](const void* ee,void*){ - const SEvent *e=(const SEvent*)ee; - int ch=e->type&0xF; - if((e->type&0xF0)==0x80||((e->type&0xF0)==0x90&&e->p2==0)) - emit keystateupdated(ch,e->p1,false); - if((e->type&0xF0)==0x90&&e->p2>0) - emit keystateupdated(ch,e->p1,e->p2>0); - if((e->type&0xF0)==0xB0||(e->type&0xF0)==0xC0) - lb[ch]->setText( - QString::fromStdString(api->getChannelPresetString(ch))+ - QString("\nch:%1 v:0x%2 p:0x%3 e:0x%4") - .arg(ch+1,2,10,QChar('0')) - .arg(api->getChannelCC(ch,0x7),2,16,QChar('0')) - .arg(api->getChannelCC(ch,0xa),2,16,QChar('0')) - .arg(api->getChannelCC(ch,0xb),2,16,QChar('0'))); - } - ,nullptr,true); - connect(this,&qmpKeyboardWindow::keystateupdated,this,&qmpKeyboardWindow::onkeystatesupdate); + setWindowTitle("Keyboard"); + QGridLayout *grid; + setLayout(grid = new QGridLayout()); + for (int ch = 0; ch < 16; ++ch) + { + grid->addWidget(lb[ch] = new QLabel, ch, 0); + grid->addWidget(pw[ch] = new qmpPianoWidget(this), ch, 1); + lb[ch]->setFont(QFontDatabase::systemFont(QFontDatabase::SystemFont::FixedFont)); + pw[ch]->setSizePolicy(QSizePolicy::Policy::Expanding, QSizePolicy::Policy::Preferred); + QPalette p = palette(); + p.setColor(QPalette::ColorRole::Highlight, api->getOptionUint("Keyboard/acolor" + std::to_string(ch))); + p.setColor(QPalette::ColorRole::Base, api->getOptionUint("Keyboard/bcolor" + std::to_string(ch))); + pw[ch]->setPalette(p); + } + hide(); + eh = api->registerEventHandler( + [this](const void *ee, void *) + { + const SEvent *e = (const SEvent *)ee; + int ch = e->type & 0xF; + if ((e->type & 0xF0) == 0x80 || ((e->type & 0xF0) == 0x90 && e->p2 == 0)) + emit keystateupdated(ch, e->p1, false); + if ((e->type & 0xF0) == 0x90 && e->p2 > 0) + emit keystateupdated(ch, e->p1, e->p2 > 0); + if ((e->type & 0xF0) == 0xB0 || (e->type & 0xF0) == 0xC0) + lb[ch]->setText( + QString::fromStdString(api->getChannelPresetString(ch)) + + QString("\nch:%1 v:0x%2 p:0x%3 e:0x%4") + .arg(ch + 1, 2, 10, QChar('0')) + .arg(api->getChannelCC(ch, 0x7), 2, 16, QChar('0')) + .arg(api->getChannelCC(ch, 0xa), 2, 16, QChar('0')) + .arg(api->getChannelCC(ch, 0xb), 2, 16, QChar('0'))); + } + , nullptr, true); + connect(this, &qmpKeyboardWindow::keystateupdated, this, &qmpKeyboardWindow::onkeystatesupdate); } qmpKeyboardWindow::~qmpKeyboardWindow() { - api->unregisterEventHandler(eh); + api->unregisterEventHandler(eh); } void qmpKeyboardWindow::closeEvent(QCloseEvent *event) { - api->setFuncState("Keyboard",false); - event->accept(); + api->setFuncState("Keyboard", false); + event->accept(); +} +void qmpKeyboardWindow::onkeystatesupdate(int ch, int key, bool state) +{ + pw[ch]->setKeyState(key, state); } -void qmpKeyboardWindow::onkeystatesupdate(int ch,int key,bool state) -{pw[ch]->setKeyState(key,state);} void qmpKeyboardWindow::resetAll() { - for(int ch=0;ch<16;++ch) - { - pw[ch]->reset(); - lb[ch]->setText( - QString::fromStdString(api->getChannelPresetString(ch))+ - QString("\nch:%1 v:0x%2 p:0x%3 e:0x%4") - .arg(ch+1,2,10,QChar('0')) - .arg(api->getChannelCC(ch,0x7),2,16,QChar('0')) - .arg(api->getChannelCC(ch,0xa),2,16,QChar('0')) - .arg(api->getChannelCC(ch,0xb),2,16,QChar('0'))); - } + for (int ch = 0; ch < 16; ++ch) + { + pw[ch]->reset(); + lb[ch]->setText( + QString::fromStdString(api->getChannelPresetString(ch)) + + QString("\nch:%1 v:0x%2 p:0x%3 e:0x%4") + .arg(ch + 1, 2, 10, QChar('0')) + .arg(api->getChannelCC(ch, 0x7), 2, 16, QChar('0')) + .arg(api->getChannelCC(ch, 0xa), 2, 16, QChar('0')) + .arg(api->getChannelCC(ch, 0xb), 2, 16, QChar('0'))); + } } |