1 |
// qsamplerChannelForm.cpp |
// qsamplerChannelForm.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2012, 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 |
64 |
|
|
65 |
m_ui.AudioRoutingTable->setModel(&m_routingModel); |
m_ui.AudioRoutingTable->setModel(&m_routingModel); |
66 |
m_ui.AudioRoutingTable->setItemDelegate(&m_routingDelegate); |
m_ui.AudioRoutingTable->setItemDelegate(&m_routingDelegate); |
67 |
|
#if QT_VERSION < 0x050000 |
68 |
m_ui.AudioRoutingTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); |
m_ui.AudioRoutingTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); |
69 |
|
#endif |
70 |
// m_ui.AudioRoutingTable->verticalHeader()->hide(); |
// m_ui.AudioRoutingTable->verticalHeader()->hide(); |
71 |
|
|
72 |
// This goes initially hidden, and will be shown |
// This goes initially hidden, and will be shown |
109 |
QObject::connect(m_ui.AudioDeviceComboBox, |
QObject::connect(m_ui.AudioDeviceComboBox, |
110 |
SIGNAL(activated(int)), |
SIGNAL(activated(int)), |
111 |
SLOT(selectAudioDevice(int))); |
SLOT(selectAudioDevice(int))); |
112 |
QObject::connect(m_ui.OkPushButton, |
QObject::connect(m_ui.DialogButtonBox, |
113 |
SIGNAL(clicked()), |
SIGNAL(accepted()), |
114 |
SLOT(accept())); |
SLOT(accept())); |
115 |
QObject::connect(m_ui.CancelPushButton, |
QObject::connect(m_ui.DialogButtonBox, |
116 |
SIGNAL(clicked()), |
SIGNAL(rejected()), |
117 |
SLOT(reject())); |
SLOT(reject())); |
118 |
QObject::connect(m_ui.MidiDeviceToolButton, |
QObject::connect(m_ui.MidiDeviceToolButton, |
119 |
SIGNAL(clicked()), |
SIGNAL(clicked()), |
158 |
return; |
return; |
159 |
|
|
160 |
// It can be a brand new channel, remember? |
// It can be a brand new channel, remember? |
161 |
bool bNew = (m_pChannel->channelID() < 0); |
const bool bNew = (m_pChannel->channelID() < 0); |
162 |
setWindowTitle(QSAMPLER_TITLE ": " + m_pChannel->channelName()); |
setWindowTitle(QSAMPLER_TITLE ": " + m_pChannel->channelName()); |
163 |
|
|
164 |
// Check if we're up and connected. |
// Check if we're up and connected. |
244 |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
245 |
m_ui.MidiDriverComboBox->insertItem(0, sMidiDriver); |
m_ui.MidiDriverComboBox->insertItem(0, sMidiDriver); |
246 |
} |
} |
247 |
m_ui.MidiDriverComboBox->setItemText( |
m_ui.MidiDriverComboBox->setCurrentIndex( |
248 |
m_ui.MidiDriverComboBox->currentIndex(), |
m_ui.MidiDriverComboBox->findText(sMidiDriver, |
249 |
sMidiDriver); |
Qt::MatchExactly | Qt::MatchCaseSensitive) |
250 |
|
); |
251 |
} |
} |
252 |
selectMidiDriverItem(sMidiDriver); |
selectMidiDriverItem(sMidiDriver); |
253 |
if (!bNew) { |
if (!bNew) { |
291 |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
292 |
m_ui.AudioDriverComboBox->insertItem(0, sAudioDriver); |
m_ui.AudioDriverComboBox->insertItem(0, sAudioDriver); |
293 |
} |
} |
294 |
m_ui.AudioDriverComboBox->setItemText( |
m_ui.AudioDriverComboBox->setCurrentIndex( |
295 |
m_ui.AudioDriverComboBox->currentIndex(), |
m_ui.AudioDriverComboBox->findText(sAudioDriver, |
296 |
sAudioDriver); |
Qt::MatchExactly | Qt::MatchCaseSensitive) |
297 |
|
); |
298 |
} |
} |
299 |
selectAudioDriverItem(sAudioDriver); |
selectAudioDriverItem(sAudioDriver); |
300 |
if (!bNew) { |
if (!bNew) { |
436 |
bool bReject = true; |
bool bReject = true; |
437 |
|
|
438 |
// Check if there's any pending changes... |
// Check if there's any pending changes... |
439 |
if (m_iDirtyCount > 0 && m_ui.OkPushButton->isEnabled()) { |
if (m_iDirtyCount > 0) { |
440 |
switch (QMessageBox::warning(this, |
switch (QMessageBox::warning(this, |
441 |
QSAMPLER_TITLE ": " + tr("Warning"), |
QSAMPLER_TITLE ": " + tr("Warning"), |
442 |
tr("Some channel settings have been changed.\n\n" |
tr("Some channel settings have been changed.\n\n" |
443 |
"Do you want to apply the changes?"), |
"Do you want to apply the changes?"), |
444 |
tr("Apply"), tr("Discard"), tr("Cancel"))) { |
QMessageBox::Apply | |
445 |
case 0: // Apply... |
QMessageBox::Discard | |
446 |
|
QMessageBox::Cancel)) { |
447 |
|
case QMessageBox::Apply: |
448 |
accept(); |
accept(); |
449 |
return; |
return; |
450 |
case 1: // Discard |
case QMessageBox::Discard: |
451 |
break; |
break; |
452 |
default: // Cancel. |
default: // Cancel. |
453 |
bReject = false; |
bReject = false; |
475 |
|
|
476 |
// FIXME: the instrument file filters should be restricted, |
// FIXME: the instrument file filters should be restricted, |
477 |
// depending on the current engine. |
// depending on the current engine. |
478 |
|
QStringList filters; |
479 |
|
const QString& sEngineName = m_ui.EngineNameComboBox->currentText().toUpper(); |
480 |
|
if (sEngineName.contains("GIG")) |
481 |
|
filters << tr("GIG Instrument files") + " (*.gig *.dls)"; |
482 |
|
if (sEngineName.contains("SFZ")) |
483 |
|
filters << tr("SFZ Instrument files") + " (*.sfz)"; |
484 |
|
if (sEngineName.contains("SF2")) |
485 |
|
filters << tr("SF2 Instrument files") + " (*.sf2)"; |
486 |
|
filters << tr("All files") + " (*.*)"; |
487 |
|
const QString& filter = filters.join(";;"); |
488 |
|
|
489 |
QString sInstrumentFile = QFileDialog::getOpenFileName(this, |
QString sInstrumentFile = QFileDialog::getOpenFileName(this, |
490 |
QSAMPLER_TITLE ": " + tr("Instrument files"), // Caption. |
QSAMPLER_TITLE ": " + tr("Instrument files"), // Caption. |
491 |
pOptions->sInstrumentDir, // Start here. |
pOptions->sInstrumentDir, // Start here. |
492 |
tr("Instrument files") + " (*.gig *.dls)" // Filter (GIG and DLS files) |
filter // File filter. |
493 |
); |
); |
494 |
|
|
495 |
if (sInstrumentFile.isEmpty()) |
if (sInstrumentFile.isEmpty()) |
583 |
m_midiDevices.clear(); |
m_midiDevices.clear(); |
584 |
|
|
585 |
// Populate with the current ones... |
// Populate with the current ones... |
586 |
const QPixmap midiPixmap(":/icons/midi2.png"); |
const QPixmap midiPixmap(":/images/midi2.png"); |
587 |
int *piDeviceIDs = Device::getDevices(pMainForm->client(), |
int *piDeviceIDs = Device::getDevices(pMainForm->client(), |
588 |
Device::Midi); |
Device::Midi); |
589 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
698 |
m_audioDevices.clear(); |
m_audioDevices.clear(); |
699 |
|
|
700 |
// Populate with the current ones... |
// Populate with the current ones... |
701 |
const QPixmap audioPixmap(":/icons/audio2.png"); |
const QPixmap audioPixmap(":/images/audio2.png"); |
702 |
int *piDeviceIDs = Device::getDevices(pMainForm->client(), |
int *piDeviceIDs = Device::getDevices(pMainForm->client(), |
703 |
Device::Audio); |
Device::Audio); |
704 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
820 |
const QString& sPath = InstrumentFileComboBox->currentText(); |
const QString& sPath = InstrumentFileComboBox->currentText(); |
821 |
bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists(); |
bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists(); |
822 |
#endif |
#endif |
823 |
m_ui.OkPushButton->setEnabled(m_iDirtyCount > 0 && bValid); |
m_ui.DialogButtonBox->button( |
824 |
|
QDialogButtonBox::Ok)->setEnabled(m_iDirtyCount > 0 && bValid); |
825 |
} |
} |
826 |
|
|
827 |
|
|