--- qsampler/trunk/src/qsamplerChannelForm.ui.h 2004/06/24 18:26:57 145 +++ qsampler/trunk/src/qsamplerChannelForm.ui.h 2005/01/18 13:53:04 344 @@ -2,7 +2,7 @@ // // ui.h extension file, included from the uic-generated form implementation. /**************************************************************************** - Copyright (C) 2004, rncbc aka Rui Nuno Capela. All rights reserved. + Copyright (C) 2004-2005, rncbc aka Rui Nuno Capela. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -26,9 +26,6 @@ #include #include -#include "qsamplerOptions.h" -#include "qsamplerChannelStrip.h" - #include "config.h" @@ -53,7 +50,7 @@ // Channel dialog setup formal initializer. -void qsamplerChannelForm::setup ( qsamplerChannelStrip *pChannel ) +void qsamplerChannelForm::setup ( qsamplerChannel *pChannel ) { m_pChannel = pChannel; @@ -63,7 +60,9 @@ if (m_pChannel == NULL) return; - setCaption(m_pChannel->caption()); + // It can be a brand new channel, remember? + bool bNew = (m_pChannel->channelID() < 0); + setCaption(m_pChannel->channelName()); // Check if we're up and connected. if (m_pChannel->client() == NULL) @@ -111,6 +110,8 @@ // Engine name... QString sEngineName = pChannel->engineName(); + if (sEngineName.isEmpty() && bNew) + sEngineName = pOptions->sEngineName; if (sEngineName.isEmpty()) sEngineName = tr("(No engine)"); if (EngineNameComboBox->listBox()->findItem(sEngineName, Qt::ExactMatch) == NULL) @@ -121,26 +122,37 @@ if (sInstrumentFile.isEmpty()) sInstrumentFile = tr("(No instrument)"); InstrumentFileComboBox->setCurrentText(sInstrumentFile); - InstrumentNrSpinBox->setValue(pChannel->instrumentNr()); - // MIDI input... - const QString& sMidiDriver = pChannel->midiDriver(); + InstrumentNrComboBox->clear(); + InstrumentNrComboBox->insertStringList( + qsamplerChannel::getInstrumentList(sInstrumentFile, + pOptions->bInstrumentNames)); + InstrumentNrComboBox->setCurrentItem(pChannel->instrumentNr()); + // MIDI input driver... + QString sMidiDriver = pChannel->midiDriver(); + if (sMidiDriver.isEmpty() || bNew) + sMidiDriver = pOptions->sMidiDriver; if (!sMidiDriver.isEmpty()) { if (MidiDriverComboBox->listBox()->findItem(sMidiDriver, Qt::ExactMatch) == NULL) MidiDriverComboBox->insertItem(sMidiDriver); MidiDriverComboBox->setCurrentText(sMidiDriver); } + // MIDI input port... MidiPortSpinBox->setValue(pChannel->midiPort()); - MidiChannelSpinBox->setValue(pChannel->midiChannel()); - // Audio output... - const QString& sAudioDriver = pChannel->audioDriver(); + // MIDI input channel... + int iMidiChannel = pChannel->midiChannel(); + // When new, try to suggest a sensible MIDI channel... + if (iMidiChannel < 0) + iMidiChannel = (::lscp_get_channels(m_pChannel->client()) % 16); + MidiChannelComboBox->setCurrentItem(iMidiChannel); + // Audio output driver... + QString sAudioDriver = pChannel->audioDriver(); + if (sAudioDriver.isEmpty() || bNew) + sAudioDriver = pOptions->sAudioDriver; if (!sAudioDriver.isEmpty()) { if (AudioDriverComboBox->listBox()->findItem(sAudioDriver, Qt::ExactMatch) == NULL) AudioDriverComboBox->insertItem(sAudioDriver); AudioDriverComboBox->setCurrentText(sAudioDriver); } - // FIXME: Disable this while we don't know what to do. - MidiPortTextLabel->setEnabled(false); - MidiPortSpinBox->setEnabled(false); // Done. m_iDirtySetup--; stabilizeForm(); @@ -160,6 +172,9 @@ // We'll go for it! if (m_iDirtyCount > 0) { int iErrors = 0; + // Are we a new channel? + if (!m_pChannel->addChannel()) + iErrors++; // Audio output driver type... if (!m_pChannel->setAudioDriver(AudioDriverComboBox->currentText())) iErrors++; @@ -170,21 +185,24 @@ if (!m_pChannel->setMidiPort(MidiPortSpinBox->value())) iErrors++; // MIDI input channel... - if (!m_pChannel->setMidiChannel(MidiChannelSpinBox->value())) + if (!m_pChannel->setMidiChannel(MidiChannelComboBox->currentItem())) iErrors++; // Engine name... if (!m_pChannel->loadEngine(EngineNameComboBox->currentText())) iErrors++; // Instrument file and index... - if (!m_pChannel->loadInstrument(InstrumentFileComboBox->currentText(), InstrumentNrSpinBox->value())) + if (!m_pChannel->loadInstrument(InstrumentFileComboBox->currentText(), InstrumentNrComboBox->currentItem())) iErrors++; // Show error messages? if (iErrors > 0) m_pChannel->appendMessagesError(tr("Some channel settings could not be set.\n\nSorry.")); } - // Save default instrument directory and history... + // Save default engine name, instrument directory and history... pOptions->sInstrumentDir = QFileInfo(InstrumentFileComboBox->currentText()).dirPath(true); + pOptions->sEngineName = EngineNameComboBox->currentText(); + pOptions->sAudioDriver = AudioDriverComboBox->currentText(); + pOptions->sMidiDriver = MidiDriverComboBox->currentText(); pOptions->saveComboBoxHistory(InstrumentFileComboBox); // Just go with dialog acceptance. @@ -198,7 +216,7 @@ bool bReject = true; // Check if there's any pending changes... - if (m_iDirtyCount > 0) { + if (m_iDirtyCount > 0 && OkPushButton->isEnabled()) { switch (QMessageBox::warning(this, tr("Warning"), tr("Some channel settings have been changed.\n\n" "Do you want to apply the changes?"), @@ -244,10 +262,18 @@ // Refresh the actual instrument name. void qsamplerChannelForm::updateInstrumentName (void) { - // FIXME: A better idea would be to use libgig - // to retrieve the REAL instrument name. - InstrumentNameTextLabel->setText(QFileInfo(InstrumentFileComboBox->currentText()).fileName() - + " [" + QString::number(InstrumentNrSpinBox->value()) + "]"); + qsamplerOptions *pOptions = m_pChannel->options(); + if (pOptions == NULL) + return; + + // Finally this better idea would be to use libgig + // to retrieve the REAL instrument names. + InstrumentNrComboBox->clear(); + InstrumentNrComboBox->insertStringList( + qsamplerChannel::getInstrumentList( + InstrumentFileComboBox->currentText(), + pOptions->bInstrumentNames) + ); optionsChanged(); }