25 |
#include "qsamplerAbout.h" |
#include "qsamplerAbout.h" |
26 |
#include "qsamplerMainForm.h" |
#include "qsamplerMainForm.h" |
27 |
|
|
28 |
|
#include <QFileDialog> |
29 |
|
#include <QMessageBox> |
30 |
|
|
31 |
// Needed for lroundf() |
// Needed for lroundf() |
32 |
#include <math.h> |
#include <math.h> |
33 |
|
|
34 |
|
|
35 |
namespace QSampler { |
namespace QSampler { |
36 |
|
|
37 |
#ifndef CONFIG_ROUND |
#ifndef CONFIG_ROUND |
137 |
|
|
138 |
// Populate maps list. |
// Populate maps list. |
139 |
ui.MapComboBox->clear(); |
ui.MapComboBox->clear(); |
140 |
ui.MapComboBox->insertStringList(qsamplerInstrument::getMapNames()); |
ui.MapComboBox->insertItems(0, qsamplerInstrument::getMapNames()); |
141 |
|
|
142 |
// Populate Engines list. |
// Populate Engines list. |
143 |
const char **ppszEngines = ::lscp_list_available_engines(pMainForm->client()); |
const char **ppszEngines = ::lscp_list_available_engines(pMainForm->client()); |
144 |
if (ppszEngines) { |
if (ppszEngines) { |
145 |
ui.EngineNameComboBox->clear(); |
ui.EngineNameComboBox->clear(); |
146 |
for (int iEngine = 0; ppszEngines[iEngine]; iEngine++) |
for (int iEngine = 0; ppszEngines[iEngine]; iEngine++) |
147 |
ui.EngineNameComboBox->insertItem(ppszEngines[iEngine]); |
ui.EngineNameComboBox->addItem(ppszEngines[iEngine]); |
148 |
} |
} |
149 |
else pMainForm->appendMessagesClient("lscp_list_available_engines"); |
else pMainForm->appendMessagesClient("lscp_list_available_engines"); |
150 |
|
|
156 |
if (iMap < 0) |
if (iMap < 0) |
157 |
iMap = 0; |
iMap = 0; |
158 |
const QString& sMapName = qsamplerInstrument::getMapName(iMap); |
const QString& sMapName = qsamplerInstrument::getMapName(iMap); |
159 |
if (!sMapName.isEmpty()) |
if (!sMapName.isEmpty()) { |
160 |
ui.MapComboBox->setCurrentText(sMapName); |
ui.MapComboBox->setItemText( |
161 |
|
ui.MapComboBox->currentIndex(), |
162 |
|
sMapName); |
163 |
|
} |
164 |
// It might be no maps around... |
// It might be no maps around... |
165 |
bool bMapEnabled = (ui.MapComboBox->count() > 0); |
bool bMapEnabled = (ui.MapComboBox->count() > 0); |
166 |
ui.MapTextLabel->setEnabled(bMapEnabled); |
ui.MapTextLabel->setEnabled(bMapEnabled); |
187 |
sEngineName = qsamplerChannel::noEngineName(); |
sEngineName = qsamplerChannel::noEngineName(); |
188 |
if (ui.EngineNameComboBox->findText(sEngineName, |
if (ui.EngineNameComboBox->findText(sEngineName, |
189 |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
190 |
ui.EngineNameComboBox->insertItem(sEngineName); |
ui.EngineNameComboBox->addItem(sEngineName); |
191 |
} |
} |
192 |
ui.EngineNameComboBox->setCurrentText(sEngineName); |
ui.EngineNameComboBox->setItemText( |
193 |
|
ui.EngineNameComboBox->currentIndex(), |
194 |
|
sEngineName); |
195 |
// Instrument filename and index... |
// Instrument filename and index... |
196 |
QString sInstrumentFile = m_pInstrument->instrumentFile(); |
QString sInstrumentFile = m_pInstrument->instrumentFile(); |
197 |
if (sInstrumentFile.isEmpty()) |
if (sInstrumentFile.isEmpty()) |
198 |
sInstrumentFile = qsamplerChannel::noInstrumentName(); |
sInstrumentFile = qsamplerChannel::noInstrumentName(); |
199 |
ui.InstrumentFileComboBox->setCurrentText(sInstrumentFile); |
ui.InstrumentFileComboBox->setItemText( |
200 |
|
ui.InstrumentFileComboBox->currentIndex(), |
201 |
|
sInstrumentFile); |
202 |
ui.InstrumentNrComboBox->clear(); |
ui.InstrumentNrComboBox->clear(); |
203 |
ui.InstrumentNrComboBox->insertStringList( |
ui.InstrumentNrComboBox->insertItems(0, |
204 |
qsamplerChannel::getInstrumentList(sInstrumentFile, |
qsamplerChannel::getInstrumentList(sInstrumentFile, |
205 |
pOptions->bInstrumentNames)); |
pOptions->bInstrumentNames)); |
206 |
ui.InstrumentNrComboBox->setCurrentItem(m_pInstrument->instrumentNr()); |
ui.InstrumentNrComboBox->setCurrentIndex(m_pInstrument->instrumentNr()); |
207 |
|
|
208 |
// Instrument volume.... |
// Instrument volume.... |
209 |
int iVolume = (bNew ? pOptions->iVolume : |
int iVolume = (bNew ? pOptions->iVolume : |
213 |
// Instrument load mode... |
// Instrument load mode... |
214 |
int iLoadMode = (bNew ? pOptions->iLoadMode : |
int iLoadMode = (bNew ? pOptions->iLoadMode : |
215 |
m_pInstrument->loadMode()); |
m_pInstrument->loadMode()); |
216 |
ui.LoadModeComboBox->setCurrentItem(iLoadMode); |
ui.LoadModeComboBox->setCurrentIndex(iLoadMode); |
217 |
|
|
218 |
// Done. |
// Done. |
219 |
m_iDirtySetup--; |
m_iDirtySetup--; |
249 |
|
|
250 |
// FIXME: the instrument file filters should be restricted, |
// FIXME: the instrument file filters should be restricted, |
251 |
// depending on the current engine. |
// depending on the current engine. |
252 |
QString sInstrumentFile = QFileDialog::getOpenFileName( |
QString sInstrumentFile = QFileDialog::getOpenFileName(this, |
253 |
pOptions->sInstrumentDir, // Start here. |
QSAMPLER_TITLE ": " + tr("Instrument files"), // Caption. |
254 |
tr("Instrument files") + " (*.gig *.dls)", // Filter (GIG and DLS files) |
pOptions->sInstrumentDir, // Start here. |
255 |
this, 0, // Parent and name (none) |
tr("Instrument files") + " (*.gig *.dls)" // Filter (GIG and DLS files) |
|
QSAMPLER_TITLE ": " + tr("Instrument files")// Caption. |
|
256 |
); |
); |
257 |
|
|
258 |
if (sInstrumentFile.isEmpty()) |
if (sInstrumentFile.isEmpty()) |
259 |
return; |
return; |
260 |
|
|
261 |
ui.InstrumentFileComboBox->setCurrentText(sInstrumentFile); |
ui.InstrumentFileComboBox->setItemText( |
262 |
|
ui.InstrumentFileComboBox->currentIndex(), |
263 |
|
sInstrumentFile); |
264 |
|
|
265 |
updateInstrumentName(); |
updateInstrumentName(); |
266 |
} |
} |
267 |
|
|
280 |
// TODO: this better idea would be to use libgig |
// TODO: this better idea would be to use libgig |
281 |
// to retrieve the REAL instrument names. |
// to retrieve the REAL instrument names. |
282 |
ui.InstrumentNrComboBox->clear(); |
ui.InstrumentNrComboBox->clear(); |
283 |
ui.InstrumentNrComboBox->insertStringList( |
ui.InstrumentNrComboBox->insertItems(0, |
284 |
qsamplerChannel::getInstrumentList( |
qsamplerChannel::getInstrumentList( |
285 |
ui.InstrumentFileComboBox->currentText(), |
ui.InstrumentFileComboBox->currentText(), |
286 |
pOptions->bInstrumentNames) |
pOptions->bInstrumentNames) |
322 |
return; |
return; |
323 |
|
|
324 |
if (m_iDirtyCount > 0) { |
if (m_iDirtyCount > 0) { |
325 |
m_pInstrument->setMap(ui.MapComboBox->currentItem()); |
m_pInstrument->setMap(ui.MapComboBox->currentIndex()); |
326 |
m_pInstrument->setBank(ui.BankSpinBox->value()); |
m_pInstrument->setBank(ui.BankSpinBox->value()); |
327 |
m_pInstrument->setProg(ui.ProgSpinBox->value() - 1); |
m_pInstrument->setProg(ui.ProgSpinBox->value() - 1); |
328 |
m_pInstrument->setName(ui.NameLineEdit->text()); |
m_pInstrument->setName(ui.NameLineEdit->text()); |
329 |
m_pInstrument->setEngineName(ui.EngineNameComboBox->currentText()); |
m_pInstrument->setEngineName(ui.EngineNameComboBox->currentText()); |
330 |
m_pInstrument->setInstrumentFile(ui.InstrumentFileComboBox->currentText()); |
m_pInstrument->setInstrumentFile(ui.InstrumentFileComboBox->currentText()); |
331 |
m_pInstrument->setInstrumentNr(ui.InstrumentNrComboBox->currentItem()); |
m_pInstrument->setInstrumentNr(ui.InstrumentNrComboBox->currentIndex()); |
332 |
m_pInstrument->setVolume(0.01f * float(ui.VolumeSpinBox->value())); |
m_pInstrument->setVolume(0.01f * float(ui.VolumeSpinBox->value())); |
333 |
m_pInstrument->setLoadMode(ui.LoadModeComboBox->currentItem()); |
m_pInstrument->setLoadMode(ui.LoadModeComboBox->currentIndex()); |
334 |
} |
} |
335 |
|
|
336 |
// Save default engine name, instrument directory and history... |
// Save default engine name, instrument directory and history... |
337 |
pOptions->sInstrumentDir = QFileInfo(ui.InstrumentFileComboBox->currentText()).dirPath(true); |
pOptions->sInstrumentDir = QFileInfo( |
338 |
|
ui.InstrumentFileComboBox->currentText()).dir().absolutePath(); |
339 |
pOptions->sEngineName = ui.EngineNameComboBox->currentText(); |
pOptions->sEngineName = ui.EngineNameComboBox->currentText(); |
340 |
pOptions->iMidiMap = ui.MapComboBox->currentItem(); |
pOptions->iMidiMap = ui.MapComboBox->currentIndex(); |
341 |
pOptions->iMidiBank = ui.BankSpinBox->value(); |
pOptions->iMidiBank = ui.BankSpinBox->value(); |
342 |
pOptions->iMidiProg = ui.ProgSpinBox->value(); |
pOptions->iMidiProg = ui.ProgSpinBox->value(); |
343 |
pOptions->iVolume = ui.VolumeSpinBox->value(); |
pOptions->iVolume = ui.VolumeSpinBox->value(); |
344 |
pOptions->iLoadMode = ui.LoadModeComboBox->currentItem(); |
pOptions->iLoadMode = ui.LoadModeComboBox->currentIndex(); |
345 |
pOptions->saveComboBoxHistory(ui.InstrumentFileComboBox); |
pOptions->saveComboBoxHistory(ui.InstrumentFileComboBox); |
346 |
|
|
347 |
// Just go with dialog acceptance. |
// Just go with dialog acceptance. |