aboutsummaryrefslogtreecommitdiff
path: root/qmidiplayer-desktop/qmpchannelswindow.cpp
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2019-10-05 23:04:53 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2019-10-05 23:04:53 +0800
commit8cf35c5ceb10d5c54e933127fb60c5034ef8a149 (patch)
tree21d68963030f0fca87eef2e8503e32c97ceb0553 /qmidiplayer-desktop/qmpchannelswindow.cpp
parent5ad76bb13ecc29aeb5b2b71cb33a00add44c5b35 (diff)
downloadQMidiPlayer-8cf35c5ceb10d5c54e933127fb60c5034ef8a149.tar.xz
Replaced the option "default output device" with a more powerful one.
Old code for default output device completely removed.
Diffstat (limited to 'qmidiplayer-desktop/qmpchannelswindow.cpp')
-rw-r--r--qmidiplayer-desktop/qmpchannelswindow.cpp25
1 files changed, 11 insertions, 14 deletions
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 <cstdio>
#include <functional>
+#include <set>
#include <QCheckBox>
#include <QPushButton>
#include <QComboBox>
@@ -256,27 +257,23 @@ qmpChannelsWindow::qmpChannelsWindow(QWidget *parent) :
,nullptr);
std::vector<std::string> devs=qmpMainWindow::getInstance()->getPlayer()->getMidiOutDevices();
size_t devc=devs.size();
- //We setup default output here...
- //Pretty strange...
- for(size_t i=0;i<devc;++i)
- {
- qmpSettingsWindow::getDefaultOutWidget()->addItem(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<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(!qmpSettingsWindow::getSettingsIntf()->
- 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"),