--- qsampler/trunk/src/qsamplerChannelForm.ui.h 2004/06/07 21:41:43 115 +++ qsampler/trunk/src/qsamplerChannelForm.ui.h 2004/11/16 15:26:18 295 @@ -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) @@ -87,7 +86,7 @@ EngineNameComboBox->insertItem(ppszEngines[iEngine]); } else m_pChannel->appendMessagesClient("lscp_get_available_engines"); -/* + // Populate Audio output type list. const char **ppszAudioDrivers = ::lscp_get_available_audio_drivers(m_pChannel->client()); if (ppszAudioDrivers) { @@ -105,39 +104,51 @@ MidiDriverComboBox->insertItem(ppszMidiDrivers[iMidiDriver]); } else m_pChannel->appendMessagesClient("lscp_get_available_midi_drivers"); -*/ + // Read proper channel information, // and populate the channel form fields. // Engine name... - const QString& sEngineName = pChannel->engineName(); - if (!sEngineName.isEmpty()) { - if (EngineNameComboBox->listBox()->findItem(sEngineName, Qt::ExactMatch) == NULL) - EngineNameComboBox->insertItem(sEngineName); - EngineNameComboBox->setCurrentText(sEngineName); - } + 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) + EngineNameComboBox->insertItem(sEngineName); + EngineNameComboBox->setCurrentText(sEngineName); // Instrument filename and index... - InstrumentFileComboBox->setCurrentText(pChannel->instrumentFile()); + QString sInstrumentFile = pChannel->instrumentFile(); + if (sInstrumentFile.isEmpty()) + sInstrumentFile = tr("(No instrument)"); + InstrumentFileComboBox->setCurrentText(sInstrumentFile); InstrumentNrSpinBox->setValue(pChannel->instrumentNr()); - // MIDI input... - const QString& sMidiDriver = pChannel->midiDriver(); + // 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(); @@ -157,6 +168,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++; @@ -167,7 +181,7 @@ 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())) @@ -180,8 +194,11 @@ 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. @@ -195,7 +212,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?"), @@ -265,7 +282,7 @@ // Stabilize current form state. void qsamplerChannelForm::stabilizeForm (void) { - const QString sFilename = InstrumentFileComboBox->currentText(); + const QString& sFilename = InstrumentFileComboBox->currentText(); OkPushButton->setEnabled(m_iDirtyCount > 0 && !sFilename.isEmpty() && QFileInfo(sFilename).exists()); }