diff options
Diffstat (limited to 'qmidiplayer-desktop/qmpchannelswindow.cpp')
-rw-r--r-- | qmidiplayer-desktop/qmpchannelswindow.cpp | 76 |
1 files changed, 42 insertions, 34 deletions
diff --git a/qmidiplayer-desktop/qmpchannelswindow.cpp b/qmidiplayer-desktop/qmpchannelswindow.cpp index 41f545e..0854e4c 100644 --- a/qmidiplayer-desktop/qmpchannelswindow.cpp +++ b/qmidiplayer-desktop/qmpchannelswindow.cpp @@ -236,8 +236,9 @@ qmpChannelsWindow::qmpChannelsWindow(QWidget *parent) : ui(new Ui::qmpChannelsWindow) { ui->setupUi(this); + mainwindow=qmpMainWindow::getInstance(); ui->tvChannels->setHorizontalHeader(new QHeaderView(Qt::Orientation::Horizontal)); - ui->tvChannels->setModel(chmodel=new qmpChannelsModel); + ui->tvChannels->setModel(chmodel=new qmpChannelsModel(ui->tvChannels)); ui->tvChannels->setItemDelegateForColumn(3,new qmpDeviceItemDelegate(false,ui->tvChannels)); ui->tvChannels->setAlternatingRowColors(true); ui->tvChannels->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection); @@ -268,25 +269,6 @@ qmpChannelsWindow::qmpChannelsWindow(QWidget *parent) : emit this->noteOn(); } ,nullptr,false); - std::vector<std::string> devs=qmpMainWindow::getInstance()->getPlayer()->getMidiOutDevices(); - size_t devc=devs.size(); - std::set<std::string> devset; - for(auto dev:devs)devset.insert(dev); - std::string selecteddev; - for(auto setdev:qmpSettingsWindow::getSettingsIntf()->value("Midi/DevicePriority",QList<QVariant>{"Internal FluidSynth"}).toList()) - if(devset.find(setdev.toString().toStdString())!=devset.end()) - { - selecteddev=setdev.toString().toStdString(); - break; - } - for(int ch=0;ch<16;++ch) - { - for(size_t j=0;j<devc;++j) - { - if(selecteddev==devs[j]) - qmpMainWindow::getInstance()->getPlayer()->setChannelOutput(ch,j); - } - } qmpMainWindow::getInstance()->registerFunctionality( chnlf=new qmpChannelFunc(this), std::string("Channel"), @@ -295,42 +277,68 @@ qmpChannelsWindow::qmpChannelsWindow(QWidget *parent) : 0, true ); - if(qmpSettingsWindow::getSettingsIntf()->value("DialogStatus/ChnlW",QRect(-999,-999,999,999)).toRect()!=QRect(-999,-999,999,999)) - setGeometry(qmpSettingsWindow::getSettingsIntf()->value("DialogStatus/ChnlW",QRect(-999,-999,999,999)).toRect()); - if(qmpSettingsWindow::getSettingsIntf()->value("DialogStatus/ChnlWShown",0).toInt()) + if(mainwindow->getSettings()->getOptionRaw("DialogStatus/ChnlW",QRect(-999,-999,999,999)).toRect()!=QRect(-999,-999,999,999)) + setGeometry(mainwindow->getSettings()->getOptionRaw("DialogStatus/ChnlW",QRect(-999,-999,999,999)).toRect()); + if(mainwindow->getSettings()->getOptionRaw("DialogStatus/ChnlWShown",0).toInt()) {show();qmpMainWindow::getInstance()->setFuncState("Channel",true);} } void qmpChannelsWindow::showEvent(QShowEvent *event) { - if(qmpSettingsWindow::getSettingsIntf()->value("Behavior/DialogStatus","").toInt()) + if(mainwindow->getSettings()->getOptionBool("Behavior/DialogStatus")) { - qmpSettingsWindow::getSettingsIntf()->setValue("DialogStatus/ChnlWShown",1); + mainwindow->getSettings()->setOptionRaw("DialogStatus/ChnlWShown",1); } - if(qmpSettingsWindow::getSettingsIntf()->value("DialogStatus/ChnlW",QRect(-999,-999,999,999)).toRect()!=QRect(-999,-999,999,999)) - setGeometry(qmpSettingsWindow::getSettingsIntf()->value("DialogStatus/ChnlW",QRect(-999,-999,999,999)).toRect()); + if(mainwindow->getSettings()->getOptionRaw("DialogStatus/ChnlW",QRect(-999,-999,999,999)).toRect()!=QRect(-999,-999,999,999)) + setGeometry(mainwindow->getSettings()->getOptionRaw("DialogStatus/ChnlW",QRect(-999,-999,999,999)).toRect()); event->accept(); } void qmpChannelsWindow::closeEvent(QCloseEvent *event) { - if(qmpSettingsWindow::getSettingsIntf()->value("Behavior/DialogStatus","").toInt()) + if(mainwindow->getSettings()->getOptionBool("Behavior/DialogStatus")) { - qmpSettingsWindow::getSettingsIntf()->setValue("DialogStatus/ChnlW",geometry()); + mainwindow->getSettings()->setOptionRaw("DialogStatus/ChnlW",geometry()); } setVisible(false); - if(!qmpMainWindow::getInstance()->isFinalizing()&&qmpSettingsWindow::getSettingsIntf()->value("Behavior/DialogStatus","").toInt()) + if(!qmpMainWindow::getInstance()->isFinalizing()&&mainwindow->getSettings()->getOptionBool("Behavior/DialogStatus")) { - qmpSettingsWindow::getSettingsIntf()->setValue("DialogStatus/ChnlWShown",0); + mainwindow->getSettings()->setOptionRaw("DialogStatus/ChnlWShown",0); } - qmpMainWindow::getInstance()->setFuncState("Channel",false); + mainwindow->setFuncState("Channel",false); event->accept(); } +void qmpChannelsWindow::selectDefaultDevice() +{ + std::string selecteddev; + std::vector<std::string> devs=mainwindow->getPlayer()->getMidiOutDevices(); + size_t devc=devs.size(); + std::set<std::string> devset; + for(auto dev:devs)devset.insert(dev); + QVariant *devpriov=static_cast<QVariant*>(qmpMainWindow::getInstance()->getSettings()->getOptionCustom("Midi/DevicePriority")); + QList<QVariant> devprio=devpriov->toList(); + delete devpriov; + for(auto &setdev:devprio) + if(devset.find(setdev.toString().toStdString())!=devset.end()) + { + selecteddev=setdev.toString().toStdString(); + break; + } + for(int ch=0;ch<16;++ch) + { + for(size_t j=0;j<devc;++j) + { + if(selecteddev==devs[j]) + mainwindow->getPlayer()->setChannelOutput(ch,j); + } + } +} + qmpChannelsWindow::~qmpChannelsWindow() { - qmpMainWindow::getInstance()->unregisterFunctionality("Channel"); - qmpMainWindow::getInstance()->getPlayer()->unregisterEventHandler(eh); + mainwindow->unregisterFunctionality("Channel"); + mainwindow->getPlayer()->unregisterEventHandler(eh); delete chnlf; delete chi;delete cha; delete ui; |