-
Notifications
You must be signed in to change notification settings - Fork 0
/
settingsdialog.cpp
63 lines (57 loc) · 1.67 KB
/
settingsdialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "settingsdialog.h"
#include "decoder_adlmidi.h"
#include <QSettings>
#include <qmmp/qmmp.h>
#include <adlmidi.h>
SettingsDialog::SettingsDialog(QWidget *parent)
: QDialog(parent)
{
m_ui.setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
#ifdef Q_OS_WIN
setFixedHeight(110);
#elif defined Q_OS_UNIX
for(QAbstractButton *button : m_ui.buttonBox->buttons())
{
button->setFocusPolicy(Qt::NoFocus);
}
#endif
const char *const *banks = adl_getBankNames();
if(!banks)
{
return;
}
for(int i = 0; i < adl_getBanksCount(); ++i)
{
m_ui.banksComboBox->addItem(banks[i]);
}
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
QSettings settings;
#else
QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
#endif
settings.beginGroup("Midi");
m_ui.banksComboBox->setCurrentIndex(settings.value("index", -1).toInt());
m_ui.checkBox->setChecked(settings.value("use_wopl", false).toBool());
m_ui.configPathEdit->setText(settings.value("conf_path").toString());
m_ui.configPathEdit->setEnabled(m_ui.checkBox->isChecked());
settings.endGroup();
}
void SettingsDialog::accept()
{
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
QSettings settings;
#else
QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
#endif
settings.beginGroup("Midi");
settings.setValue("index", m_ui.banksComboBox->currentIndex());
settings.setValue("use_wopl", m_ui.checkBox->isChecked());
settings.setValue("conf_path", m_ui.configPathEdit->text());
settings.endGroup();
if(DecoderAdlMidi::instance())
{
DecoderAdlMidi::instance()->readSettings();
}
QDialog::accept();
}