/[svn]/qsampler/trunk/src/qsamplerChannelForm.ui.h
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerChannelForm.ui.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 115 by capela, Mon Jun 7 21:41:43 2004 UTC revision 341 by capela, Tue Jan 18 11:29:01 2005 UTC
# Line 2  Line 2 
2  //  //
3  // ui.h extension file, included from the uic-generated form implementation.  // ui.h extension file, included from the uic-generated form implementation.
4  /****************************************************************************  /****************************************************************************
5     Copyright (C) 2004, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2005, rncbc aka Rui Nuno Capela. All rights reserved.
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
# Line 26  Line 26 
26  #include <qfileinfo.h>  #include <qfileinfo.h>
27  #include <qlistbox.h>  #include <qlistbox.h>
28    
 #include "qsamplerOptions.h"  
 #include "qsamplerChannelStrip.h"  
   
29  #include "config.h"  #include "config.h"
30    
31    
# Line 53  void qsamplerChannelForm::destroy (void) Line 50  void qsamplerChannelForm::destroy (void)
50    
51    
52  // Channel dialog setup formal initializer.  // Channel dialog setup formal initializer.
53  void qsamplerChannelForm::setup ( qsamplerChannelStrip *pChannel )  void qsamplerChannelForm::setup ( qsamplerChannel *pChannel )
54  {  {
55      m_pChannel = pChannel;      m_pChannel = pChannel;
56    
# Line 63  void qsamplerChannelForm::setup ( qsampl Line 60  void qsamplerChannelForm::setup ( qsampl
60      if (m_pChannel == NULL)      if (m_pChannel == NULL)
61          return;          return;
62    
63      setCaption(m_pChannel->caption());      // It can be a brand new channel, remember?
64        bool bNew = (m_pChannel->channelID() < 0);
65        setCaption(m_pChannel->channelName());
66    
67      // Check if we're up and connected.      // Check if we're up and connected.
68      if (m_pChannel->client() == NULL)      if (m_pChannel->client() == NULL)
# Line 87  void qsamplerChannelForm::setup ( qsampl Line 86  void qsamplerChannelForm::setup ( qsampl
86              EngineNameComboBox->insertItem(ppszEngines[iEngine]);              EngineNameComboBox->insertItem(ppszEngines[iEngine]);
87      }      }
88      else m_pChannel->appendMessagesClient("lscp_get_available_engines");      else m_pChannel->appendMessagesClient("lscp_get_available_engines");
89  /*  
90      // Populate Audio output type list.      // Populate Audio output type list.
91      const char **ppszAudioDrivers = ::lscp_get_available_audio_drivers(m_pChannel->client());      const char **ppszAudioDrivers = ::lscp_get_available_audio_drivers(m_pChannel->client());
92      if (ppszAudioDrivers) {      if (ppszAudioDrivers) {
# Line 105  void qsamplerChannelForm::setup ( qsampl Line 104  void qsamplerChannelForm::setup ( qsampl
104              MidiDriverComboBox->insertItem(ppszMidiDrivers[iMidiDriver]);              MidiDriverComboBox->insertItem(ppszMidiDrivers[iMidiDriver]);
105      }      }
106      else m_pChannel->appendMessagesClient("lscp_get_available_midi_drivers");      else m_pChannel->appendMessagesClient("lscp_get_available_midi_drivers");
107  */  
108      // Read proper channel information,      // Read proper channel information,
109      // and populate the channel form fields.      // and populate the channel form fields.
110    
111      // Engine name...      // Engine name...
112      const QString& sEngineName = pChannel->engineName();      QString sEngineName = pChannel->engineName();
113      if (!sEngineName.isEmpty()) {      if (sEngineName.isEmpty() && bNew)
114          if (EngineNameComboBox->listBox()->findItem(sEngineName, Qt::ExactMatch) == NULL)          sEngineName = pOptions->sEngineName;
115              EngineNameComboBox->insertItem(sEngineName);      if (sEngineName.isEmpty())
116          EngineNameComboBox->setCurrentText(sEngineName);          sEngineName = tr("(No engine)");
117      }      if (EngineNameComboBox->listBox()->findItem(sEngineName, Qt::ExactMatch) == NULL)
118            EngineNameComboBox->insertItem(sEngineName);
119        EngineNameComboBox->setCurrentText(sEngineName);
120      // Instrument filename and index...      // Instrument filename and index...
121      InstrumentFileComboBox->setCurrentText(pChannel->instrumentFile());      QString sInstrumentFile = pChannel->instrumentFile();
122      InstrumentNrSpinBox->setValue(pChannel->instrumentNr());      if (sInstrumentFile.isEmpty())
123      // MIDI input...          sInstrumentFile = tr("(No instrument)");
124      const QString& sMidiDriver = pChannel->midiDriver();      InstrumentFileComboBox->setCurrentText(sInstrumentFile);
125        InstrumentNrComboBox->clear();
126        InstrumentNrComboBox->insertStringList(qsamplerChannel::getInstrumentList(sInstrumentFile));
127        InstrumentNrComboBox->setCurrentItem(pChannel->instrumentNr());
128        // MIDI input driver...
129        QString sMidiDriver = pChannel->midiDriver();
130        if (sMidiDriver.isEmpty() || bNew)
131            sMidiDriver = pOptions->sMidiDriver;
132      if (!sMidiDriver.isEmpty()) {      if (!sMidiDriver.isEmpty()) {
133          if (MidiDriverComboBox->listBox()->findItem(sMidiDriver, Qt::ExactMatch) == NULL)          if (MidiDriverComboBox->listBox()->findItem(sMidiDriver, Qt::ExactMatch) == NULL)
134              MidiDriverComboBox->insertItem(sMidiDriver);              MidiDriverComboBox->insertItem(sMidiDriver);
135          MidiDriverComboBox->setCurrentText(sMidiDriver);          MidiDriverComboBox->setCurrentText(sMidiDriver);
136      }      }
137        // MIDI input port...
138      MidiPortSpinBox->setValue(pChannel->midiPort());      MidiPortSpinBox->setValue(pChannel->midiPort());
139      MidiChannelSpinBox->setValue(pChannel->midiChannel());      // MIDI input channel...
140      // Audio output...      int iMidiChannel = pChannel->midiChannel();
141      const QString& sAudioDriver = pChannel->audioDriver();      // When new, try to suggest a sensible MIDI channel...
142        if (iMidiChannel < 0)
143            iMidiChannel = (::lscp_get_channels(m_pChannel->client()) % 16);
144        MidiChannelComboBox->setCurrentItem(iMidiChannel);
145        // Audio output driver...
146        QString sAudioDriver = pChannel->audioDriver();
147        if (sAudioDriver.isEmpty() || bNew)
148            sAudioDriver = pOptions->sAudioDriver;
149      if (!sAudioDriver.isEmpty()) {      if (!sAudioDriver.isEmpty()) {
150          if (AudioDriverComboBox->listBox()->findItem(sAudioDriver, Qt::ExactMatch) == NULL)          if (AudioDriverComboBox->listBox()->findItem(sAudioDriver, Qt::ExactMatch) == NULL)
151              AudioDriverComboBox->insertItem(sAudioDriver);              AudioDriverComboBox->insertItem(sAudioDriver);
152          AudioDriverComboBox->setCurrentText(sAudioDriver);          AudioDriverComboBox->setCurrentText(sAudioDriver);
153      }      }
     // FIXME: Disable this while we don't know what to do.  
     MidiPortTextLabel->setEnabled(false);  
     MidiPortSpinBox->setEnabled(false);  
154      // Done.      // Done.
155      m_iDirtySetup--;      m_iDirtySetup--;
156      stabilizeForm();      stabilizeForm();
# Line 157  void qsamplerChannelForm::accept (void) Line 170  void qsamplerChannelForm::accept (void)
170      // We'll go for it!      // We'll go for it!
171      if (m_iDirtyCount > 0) {      if (m_iDirtyCount > 0) {
172          int iErrors = 0;          int iErrors = 0;
173            // Are we a new channel?
174            if (!m_pChannel->addChannel())
175                iErrors++;
176          // Audio output driver type...          // Audio output driver type...
177          if (!m_pChannel->setAudioDriver(AudioDriverComboBox->currentText()))          if (!m_pChannel->setAudioDriver(AudioDriverComboBox->currentText()))
178              iErrors++;              iErrors++;
# Line 167  void qsamplerChannelForm::accept (void) Line 183  void qsamplerChannelForm::accept (void)
183          if (!m_pChannel->setMidiPort(MidiPortSpinBox->value()))          if (!m_pChannel->setMidiPort(MidiPortSpinBox->value()))
184              iErrors++;              iErrors++;
185          // MIDI input channel...          // MIDI input channel...
186          if (!m_pChannel->setMidiChannel(MidiChannelSpinBox->value()))          if (!m_pChannel->setMidiChannel(MidiChannelComboBox->currentItem()))
187              iErrors++;              iErrors++;
188          // Engine name...          // Engine name...
189          if (!m_pChannel->loadEngine(EngineNameComboBox->currentText()))          if (!m_pChannel->loadEngine(EngineNameComboBox->currentText()))
190              iErrors++;              iErrors++;
191          // Instrument file and index...          // Instrument file and index...
192          if (!m_pChannel->loadInstrument(InstrumentFileComboBox->currentText(), InstrumentNrSpinBox->value()))          if (!m_pChannel->loadInstrument(InstrumentFileComboBox->currentText(), InstrumentNrComboBox->currentItem()))
193              iErrors++;              iErrors++;
194          // Show error messages?          // Show error messages?
195          if (iErrors > 0)          if (iErrors > 0)
196              m_pChannel->appendMessagesError(tr("Some channel settings could not be set.\n\nSorry."));              m_pChannel->appendMessagesError(tr("Some channel settings could not be set.\n\nSorry."));
197      }      }
198    
199      // Save default instrument directory and history...      // Save default engine name, instrument directory and history...
200      pOptions->sInstrumentDir = QFileInfo(InstrumentFileComboBox->currentText()).dirPath(true);      pOptions->sInstrumentDir = QFileInfo(InstrumentFileComboBox->currentText()).dirPath(true);
201        pOptions->sEngineName  = EngineNameComboBox->currentText();
202        pOptions->sAudioDriver = AudioDriverComboBox->currentText();
203        pOptions->sMidiDriver  = MidiDriverComboBox->currentText();
204      pOptions->saveComboBoxHistory(InstrumentFileComboBox);      pOptions->saveComboBoxHistory(InstrumentFileComboBox);
205    
206      // Just go with dialog acceptance.      // Just go with dialog acceptance.
# Line 195  void qsamplerChannelForm::reject (void) Line 214  void qsamplerChannelForm::reject (void)
214      bool bReject = true;      bool bReject = true;
215    
216      // Check if there's any pending changes...      // Check if there's any pending changes...
217      if (m_iDirtyCount > 0) {      if (m_iDirtyCount > 0 && OkPushButton->isEnabled()) {
218          switch (QMessageBox::warning(this, tr("Warning"),          switch (QMessageBox::warning(this, tr("Warning"),
219              tr("Some channel settings have been changed.\n\n"              tr("Some channel settings have been changed.\n\n"
220                 "Do you want to apply the changes?"),                 "Do you want to apply the changes?"),
# Line 241  void qsamplerChannelForm::openInstrument Line 260  void qsamplerChannelForm::openInstrument
260  // Refresh the actual instrument name.  // Refresh the actual instrument name.
261  void qsamplerChannelForm::updateInstrumentName (void)  void qsamplerChannelForm::updateInstrumentName (void)
262  {  {
263      // FIXME: A better idea would be to use libgig      qsamplerOptions *pOptions = m_pChannel->options();
264      // to retrieve the REAL instrument name.      if (pOptions == NULL)
265      InstrumentNameTextLabel->setText(QFileInfo(InstrumentFileComboBox->currentText()).fileName()          return;
266          + " [" + QString::number(InstrumentNrSpinBox->value()) + "]");  
267        // Finally this better idea would be to use libgig
268        // to retrieve the REAL instrument names.
269        InstrumentNrComboBox->clear();
270        InstrumentNrComboBox->insertStringList(
271            qsamplerChannel::getInstrumentList(InstrumentFileComboBox->currentText())
272        );
273    
274      optionsChanged();      optionsChanged();
275  }  }
# Line 265  void qsamplerChannelForm::optionsChanged Line 290  void qsamplerChannelForm::optionsChanged
290  // Stabilize current form state.  // Stabilize current form state.
291  void qsamplerChannelForm::stabilizeForm (void)  void qsamplerChannelForm::stabilizeForm (void)
292  {  {
293      const QString sFilename = InstrumentFileComboBox->currentText();      const QString& sFilename = InstrumentFileComboBox->currentText();
294      OkPushButton->setEnabled(m_iDirtyCount > 0 && !sFilename.isEmpty() && QFileInfo(sFilename).exists());      OkPushButton->setEnabled(m_iDirtyCount > 0 && !sFilename.isEmpty() && QFileInfo(sFilename).exists());
295  }  }
296    

Legend:
Removed from v.115  
changed lines
  Added in v.341

  ViewVC Help
Powered by ViewVC