From 8cf35c5ceb10d5c54e933127fb60c5034ef8a149 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Sat, 5 Oct 2019 23:04:53 +0800 Subject: Replaced the option "default output device" with a more powerful one. Old code for default output device completely removed. --- qmidiplayer-desktop/qmpchannelswindow.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'qmidiplayer-desktop/qmpchannelswindow.cpp') diff --git a/qmidiplayer-desktop/qmpchannelswindow.cpp b/qmidiplayer-desktop/qmpchannelswindow.cpp index 0c34239..029daff 100644 --- a/qmidiplayer-desktop/qmpchannelswindow.cpp +++ b/qmidiplayer-desktop/qmpchannelswindow.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -256,27 +257,23 @@ qmpChannelsWindow::qmpChannelsWindow(QWidget *parent) : ,nullptr); std::vector devs=qmpMainWindow::getInstance()->getPlayer()->getMidiOutDevices(); size_t devc=devs.size(); - //We setup default output here... - //Pretty strange... - for(size_t i=0;iaddItem(devs[i].c_str()); - if(!QString(devs[i].c_str()).compare(qmpSettingsWindow::getSettingsIntf()-> - value("Midi/DefaultOutput","Internal FluidSynth").toString())) - qmpSettingsWindow::getDefaultOutWidget()->setCurrentIndex(i); - } + std::set devset; + for(auto dev:devs)devset.insert(dev); + std::string selecteddev; + for(auto setdev:qmpSettingsWindow::getSettingsIntf()->value("Midi/DevicePriority",QList{"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 - value("Midi/DefaultOutput","Internal FluidSynth").toString().compare( - QString(devs[j].c_str()))) + if(selecteddev==devs[j]) qmpMainWindow::getInstance()->getPlayer()->setChannelOutput(ch,j); } } - qmpSettingsWindow::getSettingsIntf()->setValue("Midi/DefaultOutput", - qmpSettingsWindow::getDefaultOutWidget()->currentText()); qmpMainWindow::getInstance()->registerFunctionality( chnlf=new qmpChannelFunc(this), std::string("Channel"), -- cgit v1.2.3