aboutsummaryrefslogtreecommitdiff
path: root/qmidiplayer-desktop/qmpsettingswindow.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/qmpsettingswindow.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/qmpsettingswindow.cpp')
-rw-r--r--qmidiplayer-desktop/qmpsettingswindow.cpp33
1 files changed, 23 insertions, 10 deletions
diff --git a/qmidiplayer-desktop/qmpsettingswindow.cpp b/qmidiplayer-desktop/qmpsettingswindow.cpp
index bb0ba05..409b087 100644
--- a/qmidiplayer-desktop/qmpsettingswindow.cpp
+++ b/qmidiplayer-desktop/qmpsettingswindow.cpp
@@ -1,3 +1,4 @@
+#include <set>
#include <QLineEdit>
#include <QToolButton>
#include <QFileDialog>
@@ -6,11 +7,11 @@
#include <QDesktopWidget>
#include <QStandardPaths>
#include "qmpsettingswindow.hpp"
+#include "qmpdeviceprioritydialog.hpp"
#include "ui_qmpsettingswindow.h"
#include "qmpmainwindow.hpp"
QSettings* qmpSettingsWindow::settings=nullptr;
-QComboBox* qmpSettingsWindow::outwidget=nullptr;
void qmpFluidForEachOpt(void* data,const char*,const char* option)
{
@@ -25,13 +26,14 @@ qmpSettingsWindow::qmpSettingsWindow(QWidget *parent) :
ui->setupUi(this);customOptions.clear();customOptPages.clear();
connect(this,&qmpSettingsWindow::dialogClosing,(qmpMainWindow*)parent,&qmpMainWindow::dialogClosed);
settings=new QSettings(QStandardPaths::writableLocation(QStandardPaths::StandardLocation::ConfigLocation)+QString("/qmprc"),QSettings::IniFormat);
- settingsInit();outwidget=ui->cbOutputDevice;
+ settingsInit();
ui->pbAdd->setIcon(QIcon(getThemedIcon(":/img/add.svg")));
ui->pbRemove->setIcon(QIcon(getThemedIcon(":/img/remove.svg")));
ui->pbDown->setIcon(QIcon(getThemedIcon(":/img/down.svg")));
ui->pbUp->setIcon(QIcon(getThemedIcon(":/img/up.svg")));
cw=new qmpCustomizeWindow(this);
dps=new qmpDevPropDialog(this);
+ devpriod=new qmpDevicePriorityDialog(this);
}
qmpSettingsWindow::~qmpSettingsWindow()
@@ -56,7 +58,6 @@ void qmpSettingsWindow::hideEvent(QHideEvent *event)
QTableWidget* qmpSettingsWindow::getSFWidget(){return ui->twSoundfont;}
-QComboBox* qmpSettingsWindow::getDefaultOutWidget(){return outwidget;}
void qmpSettingsWindow::on_buttonBox_accepted()
{
@@ -75,8 +76,6 @@ void qmpSettingsWindow::settingsInit()
{
fluid_settings_t *fsettings=new_fluid_settings();
- settings->setValue("Midi/DefaultOutput",settings->value("Midi/DefaultOutput","Internal FluidSynth"));
-
settings->setValue("Midi/DisableMapping",settings->value("Midi/DisableMapping",0));
ui->cbDisableMapping->setChecked(settings->value("Midi/DisableMapping",0).toInt());
@@ -208,8 +207,6 @@ void qmpSettingsWindow::settingsInit()
void qmpSettingsWindow::settingsUpdate()
{
- settings->setValue("Midi/DefaultOutput",ui->cbOutputDevice->currentText());
-
settings->setValue("Midi/DisableMapping",ui->cbDisableMapping->isChecked()?1:0);
settings->setValue("Midi/SendSysEx",ui->cbSendSysx->isChecked()?1:0);
@@ -376,24 +373,35 @@ void qmpSettingsWindow::updatePluginList(qmpPluginManager *pmgr)
ui->twPluginList->setColumnWidth(3,128);
}
-void qmpSettingsWindow::verifySF()
+void qmpSettingsWindow::postInit()
{
int sf=0;
for(int i=0;i<ui->twSoundfont->rowCount();++i)
if(((QCheckBox*)ui->twSoundfont->cellWidget(i,0))->isChecked())++sf;
- if(settings->value("Midi/DefaultOutput","Internal FluidSynth").toString()=="Internal FluidSynth"&&!sf)
+ std::string selecteddev;
+ std::vector<std::string> devs=qmpMainWindow::getInstance()->getPlayer()->getMidiOutDevices();
+ std::set<std::string> devset;
+ for(auto dev:devs)devset.insert(dev);
+ 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;
+ }
+ if(selecteddev=="Internal FluidSynth"&&!sf)
{
// blmark: show dialog at the current screen which user using now.
int curMonitor = QApplication::desktop()->screenNumber(this);
if(QMessageBox::question(QDesktopWidget().screen(curMonitor),//this,
tr("No soundfont loaded"),
- tr("Internal fluidsynth was chosen as the default output but it has no soundfont set. "
+ tr("Internal fluidsynth is the only available MIDI output but it has no soundfont set. "
"Would you like to setup soundfonts now? You may have to reload the internal synth afterwards."))==QMessageBox::Yes)
{
show();
ui->tabWidget->setCurrentWidget(ui->tab_3);
}
}
+ devpriod->setupRegisteredDevices();
}
void qmpSettingsWindow::updateCustomOptions()
@@ -747,3 +755,8 @@ void qmpSettingsWindow::on_pbExtDevSetup_clicked()
{
dps->launch();
}
+
+void qmpSettingsWindow::on_pbDevPrio_clicked()
+{
+ devpriod->show();
+}