--- qsampler/trunk/src/qsamplerChannelForm.ui.h 2004/06/07 21:41:43 115 +++ qsampler/trunk/src/qsamplerChannelForm.ui.h 2004/09/29 13:12:45 264 @@ -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, bool bNew ) { m_pChannel = pChannel; @@ -63,7 +60,7 @@ if (m_pChannel == NULL) return; - setCaption(m_pChannel->caption()); + setCaption(tr("Channel %1").arg(m_pChannel->channelID())); // Check if we're up and connected. if (m_pChannel->client() == NULL) @@ -87,7 +84,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 +102,50 @@ 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(); + if (bNew) + iMidiChannel = (pChannel->channelID() + 1) % 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(); @@ -167,7 +175,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 +188,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 +206,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 +276,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()); }