19#include <QDialogButtonBox>
22#include <QNetworkInterface>
24#include <QStandardPaths>
28#include "ui_macsynthsettingsdialog.h"
40MacSynthSettingsDialog::MacSynthSettingsDialog(QWidget *parent) :
42 ui(new Ui::MacSynthSettingsDialog)
45 connect(ui->buttonBox->button(QDialogButtonBox::RestoreDefaults), &QPushButton::pressed,
46 this, &MacSynthSettingsDialog::restoreDefaults);
47 connect(ui->btn_soundfont, &QToolButton::pressed,
this, &MacSynthSettingsDialog::showFileDialog);
49 SettingsFactory settings;
52 if (m_driver !=
nullptr) {
53 checkDriver(settings.getQSettings());
57MacSynthSettingsDialog::~MacSynthSettingsDialog()
59 if (m_driver !=
nullptr) {
65void MacSynthSettingsDialog::accept()
68 if (m_driver !=
nullptr) {
70 QVariant varStatus = m_driver->property(
"status");
71 if (varStatus.isValid()) {
72 title = varStatus.toBool() ? tr(
"DLS Synth Initialized") : tr(
"DLS Synth Initialization Failed");
73 QVariant varDiag = m_driver->property(
"diagnostics");
74 if (varDiag.isValid()) {
75 QString text = varDiag.toStringList().join(QChar::LineFeed).trimmed();
76 if (varStatus.toBool()) {
77 if (!text.isEmpty()) {
78 QMessageBox::information(
this, title, text);
81 QMessageBox::critical(
this, title, text);
90void MacSynthSettingsDialog::showEvent(QShowEvent *event)
96void MacSynthSettingsDialog::readSettings()
99 SettingsFactory settings;
100 settings->beginGroup(
"DLS Synth");
101 bool reverb = settings->value(
"reverb_dls",
true).toBool();
102 bool def = settings->value(
"default_dls",
true).toBool();
103 QString soundfont = settings->value(
"soundfont_dls").toString();
104 settings->endGroup();
106 ui->reverb_dls->setChecked(reverb);
107 ui->default_dls->setChecked(def);
108 ui->soundfont_dls->setText(soundfont);
111void drumstick::widgets::MacSynthSettingsDialog::checkDriver(
QSettings* settings)
113 if (m_driver !=
nullptr) {
115 m_driver->initialize(settings);
117 m_driver->open(conn);
119 QVariant varStatus = m_driver->property(
"status");
120 if (varStatus.isValid()) {
121 ui->lblStatusText->clear();
122 ui->lblStatusText->setText(varStatus.toBool() ? tr(
"Ready") : tr(
"Failed") );
123 ui->lblStatusIcon->setPixmap(varStatus.toBool() ? QPixmap(
":/checked.png") : QPixmap(
":/error.png") );
128void MacSynthSettingsDialog::writeSettings()
130 SettingsFactory settings;
132 QString soundfont = ui->soundfont_dls->text();
133 bool reverb = ui->reverb_dls->isChecked();
134 bool def = ui->default_dls->isChecked();
136 settings->beginGroup(
"DLS Synth");
137 settings->setValue(
"soundfont_dls", soundfont);
138 settings->setValue(
"reverb_dls", reverb);
139 settings->setValue(
"default_dls", def);
140 settings->endGroup();
143 checkDriver(settings.getQSettings());
146void MacSynthSettingsDialog::restoreDefaults()
148 ui->reverb_dls->setChecked(
false);
149 ui->default_dls->setChecked(
true);
150 ui->soundfont_dls->clear();
153void MacSynthSettingsDialog::changeSoundFont(
const QString& fileName)
156 ui->soundfont_dls->setText(fileName);
160void MacSynthSettingsDialog::showFileDialog()
162 QDir dir = (QDir::homePath() +
"/Library/Audio/Sounds/Banks/");
163 QString fileName = QFileDialog::getOpenFileName(
this, tr(
"Select SoundFont"), dir.absolutePath(), tr(
"SoundFont Files (*.sf2 *.dls)"));
164 if (!fileName.isEmpty()) {
165 ui->soundfont_dls->setText(fileName);
BackendManager class declaration.
The QSettings class provides persistent platform-independent application settings.
The BackendManager class manages lists of dynamic and static backends for applications based on drums...
MIDIOutput * outputBackendByName(const QString name)
outputBackendByName
QPair< QString, QVariant > MIDIConnection
MIDIConnection represents a connection identifier.
Declaration of the Mac Synth configuration dialog.
SettingsFactory class declaration.