1 |
// qsamplerChannelForm.cpp |
// qsamplerChannelForm.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2010, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007, Christian Schoenebeck |
Copyright (C) 2007, 2008 Christian Schoenebeck |
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
8 |
modify it under the terms of the GNU General Public License |
modify it under the terms of the GNU General Public License |
107 |
QObject::connect(m_ui.AudioDeviceComboBox, |
QObject::connect(m_ui.AudioDeviceComboBox, |
108 |
SIGNAL(activated(int)), |
SIGNAL(activated(int)), |
109 |
SLOT(selectAudioDevice(int))); |
SLOT(selectAudioDevice(int))); |
110 |
QObject::connect(m_ui.OkPushButton, |
QObject::connect(m_ui.DialogButtonBox, |
111 |
SIGNAL(clicked()), |
SIGNAL(accepted()), |
112 |
SLOT(accept())); |
SLOT(accept())); |
113 |
QObject::connect(m_ui.CancelPushButton, |
QObject::connect(m_ui.DialogButtonBox, |
114 |
SIGNAL(clicked()), |
SIGNAL(rejected()), |
115 |
SLOT(reject())); |
SLOT(reject())); |
116 |
QObject::connect(m_ui.MidiDeviceToolButton, |
QObject::connect(m_ui.MidiDeviceToolButton, |
117 |
SIGNAL(clicked()), |
SIGNAL(clicked()), |
156 |
return; |
return; |
157 |
|
|
158 |
// It can be a brand new channel, remember? |
// It can be a brand new channel, remember? |
159 |
bool bNew = (m_pChannel->channelID() < 0); |
const bool bNew = (m_pChannel->channelID() < 0); |
160 |
setWindowTitle(QSAMPLER_TITLE ": " + m_pChannel->channelName()); |
setWindowTitle(QSAMPLER_TITLE ": " + m_pChannel->channelName()); |
161 |
|
|
162 |
// Check if we're up and connected. |
// Check if we're up and connected. |
242 |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
243 |
m_ui.MidiDriverComboBox->insertItem(0, sMidiDriver); |
m_ui.MidiDriverComboBox->insertItem(0, sMidiDriver); |
244 |
} |
} |
245 |
m_ui.MidiDriverComboBox->setItemText( |
m_ui.MidiDriverComboBox->setCurrentIndex( |
246 |
m_ui.MidiDriverComboBox->currentIndex(), |
m_ui.MidiDriverComboBox->findText(sMidiDriver, |
247 |
sMidiDriver); |
Qt::MatchExactly | Qt::MatchCaseSensitive) |
248 |
|
); |
249 |
} |
} |
250 |
selectMidiDriverItem(sMidiDriver); |
selectMidiDriverItem(sMidiDriver); |
251 |
if (!bNew) { |
if (!bNew) { |
289 |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
290 |
m_ui.AudioDriverComboBox->insertItem(0, sAudioDriver); |
m_ui.AudioDriverComboBox->insertItem(0, sAudioDriver); |
291 |
} |
} |
292 |
m_ui.AudioDriverComboBox->setItemText( |
m_ui.AudioDriverComboBox->setCurrentIndex( |
293 |
m_ui.AudioDriverComboBox->currentIndex(), |
m_ui.AudioDriverComboBox->findText(sAudioDriver, |
294 |
sAudioDriver); |
Qt::MatchExactly | Qt::MatchCaseSensitive) |
295 |
|
); |
296 |
} |
} |
297 |
selectAudioDriverItem(sAudioDriver); |
selectAudioDriverItem(sAudioDriver); |
298 |
if (!bNew) { |
if (!bNew) { |
434 |
bool bReject = true; |
bool bReject = true; |
435 |
|
|
436 |
// Check if there's any pending changes... |
// Check if there's any pending changes... |
437 |
if (m_iDirtyCount > 0 && m_ui.OkPushButton->isEnabled()) { |
if (m_iDirtyCount > 0) { |
438 |
switch (QMessageBox::warning(this, |
switch (QMessageBox::warning(this, |
439 |
QSAMPLER_TITLE ": " + tr("Warning"), |
QSAMPLER_TITLE ": " + tr("Warning"), |
440 |
tr("Some channel settings have been changed.\n\n" |
tr("Some channel settings have been changed.\n\n" |
441 |
"Do you want to apply the changes?"), |
"Do you want to apply the changes?"), |
442 |
tr("Apply"), tr("Discard"), tr("Cancel"))) { |
QMessageBox::Apply | |
443 |
case 0: // Apply... |
QMessageBox::Discard | |
444 |
|
QMessageBox::Cancel)) { |
445 |
|
case QMessageBox::Apply: |
446 |
accept(); |
accept(); |
447 |
return; |
return; |
448 |
case 1: // Discard |
case QMessageBox::Discard: |
449 |
break; |
break; |
450 |
default: // Cancel. |
default: // Cancel. |
451 |
bReject = false; |
bReject = false; |
473 |
|
|
474 |
// FIXME: the instrument file filters should be restricted, |
// FIXME: the instrument file filters should be restricted, |
475 |
// depending on the current engine. |
// depending on the current engine. |
476 |
|
QStringList filters; |
477 |
|
filters << tr("GIG Instrument files") + " (*.gig *.dls)"; |
478 |
|
filters << tr("SFZ Instrument files") + " (*.sfz)"; |
479 |
|
// filters << tr("SF2 Instrument files") + " (*.sf2)"; |
480 |
|
filters << tr("All files") + " (*.*)"; |
481 |
|
const QString& filter = filters.join(";;"); |
482 |
|
|
483 |
QString sInstrumentFile = QFileDialog::getOpenFileName(this, |
QString sInstrumentFile = QFileDialog::getOpenFileName(this, |
484 |
QSAMPLER_TITLE ": " + tr("Instrument files"), // Caption. |
QSAMPLER_TITLE ": " + tr("Instrument files"), // Caption. |
485 |
pOptions->sInstrumentDir, // Start here. |
pOptions->sInstrumentDir, // Start here. |
486 |
tr("Instrument files") + " (*.gig *.dls)" // Filter (GIG and DLS files) |
filter // File filter. |
487 |
); |
); |
488 |
|
|
489 |
if (sInstrumentFile.isEmpty()) |
if (sInstrumentFile.isEmpty()) |
577 |
m_midiDevices.clear(); |
m_midiDevices.clear(); |
578 |
|
|
579 |
// Populate with the current ones... |
// Populate with the current ones... |
580 |
const QPixmap midiPixmap(":/icons/midi2.png"); |
const QPixmap midiPixmap(":/images/midi2.png"); |
581 |
int *piDeviceIDs = Device::getDevices(pMainForm->client(), |
int *piDeviceIDs = Device::getDevices(pMainForm->client(), |
582 |
Device::Midi); |
Device::Midi); |
583 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
692 |
m_audioDevices.clear(); |
m_audioDevices.clear(); |
693 |
|
|
694 |
// Populate with the current ones... |
// Populate with the current ones... |
695 |
const QPixmap audioPixmap(":/icons/audio2.png"); |
const QPixmap audioPixmap(":/images/audio2.png"); |
696 |
int *piDeviceIDs = Device::getDevices(pMainForm->client(), |
int *piDeviceIDs = Device::getDevices(pMainForm->client(), |
697 |
Device::Audio); |
Device::Audio); |
698 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
814 |
const QString& sPath = InstrumentFileComboBox->currentText(); |
const QString& sPath = InstrumentFileComboBox->currentText(); |
815 |
bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists(); |
bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists(); |
816 |
#endif |
#endif |
817 |
m_ui.OkPushButton->setEnabled(m_iDirtyCount > 0 && bValid); |
m_ui.DialogButtonBox->button( |
818 |
|
QDialogButtonBox::Ok)->setEnabled(m_iDirtyCount > 0 && bValid); |
819 |
} |
} |
820 |
|
|
821 |
|
|