/[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 484 by capela, Tue Mar 22 12:55:29 2005 UTC revision 757 by capela, Fri Aug 26 23:04:32 2005 UTC
# Line 20  Line 20 
20    
21  *****************************************************************************/  *****************************************************************************/
22    
23    #include "qsamplerAbout.h"
24    #include "qsamplerDeviceForm.h"
25    
26  #include <qvalidator.h>  #include <qvalidator.h>
27  #include <qmessagebox.h>  #include <qmessagebox.h>
28  #include <qfiledialog.h>  #include <qfiledialog.h>
29  #include <qfileinfo.h>  #include <qfileinfo.h>
30  #include <qlistbox.h>  #include <qlistbox.h>
31    
 #include "config.h"  
   
32    
33  // Kind of constructor.  // Kind of constructor.
34  void qsamplerChannelForm::init (void)  void qsamplerChannelForm::init (void)
35  {  {
36      // Initialize locals.          // Initialize locals.
37      m_pChannel = NULL;          m_pChannel = NULL;
38    
39      m_iDirtySetup = 0;          m_iDirtySetup = 0;
40      m_iDirtyCount = 0;          m_iDirtyCount = 0;
41    
42          m_midiDevices.setAutoDelete(true);          m_midiDevices.setAutoDelete(true);
43          m_audioDevices.setAutoDelete(true);          m_audioDevices.setAutoDelete(true);
44    
45      // Try to restore normal window positioning.          m_pDeviceForm = NULL;
46      adjustSize();  
47            // Try to restore normal window positioning.
48            adjustSize();
49  }  }
50    
51    
52  // Kind of destructor.  // Kind of destructor.
53  void qsamplerChannelForm::destroy (void)  void qsamplerChannelForm::destroy (void)
54  {  {
55            if (m_pDeviceForm)
56                    delete m_pDeviceForm;
57            m_pDeviceForm = NULL;
58  }  }
59    
60    
61  // Channel dialog setup formal initializer.  // Channel dialog setup formal initializer.
62  void qsamplerChannelForm::setup ( qsamplerChannel *pChannel )  void qsamplerChannelForm::setup ( qsamplerChannel *pChannel )
63  {  {
64      m_pChannel = pChannel;          m_pChannel = pChannel;
65    
66      m_iDirtySetup = 0;          m_iDirtySetup = 0;
67      m_iDirtyCount = 0;          m_iDirtyCount = 0;
68    
69      if (m_pChannel == NULL)          if (m_pChannel == NULL)
70          return;                  return;
71    
72            // It can be a brand new channel, remember?
73            bool bNew = (m_pChannel->channelID() < 0);
74            setCaption(QSAMPLER_TITLE ": " + m_pChannel->channelName());
75    
76            // Check if we're up and connected.
77            if (m_pChannel->client() == NULL)
78                    return;
79    
80            qsamplerOptions *pOptions = m_pChannel->options();
81            if (pOptions == NULL)
82                    return;
83    
84            // Avoid nested changes.
85            m_iDirtySetup++;
86    
87            // Load combo box history...
88            pOptions->loadComboBoxHistory(InstrumentFileComboBox);
89    
90            // Populate Engines list.
91            const char **ppszEngines = ::lscp_list_available_engines(m_pChannel->client());
92            if (ppszEngines) {
93                    EngineNameComboBox->clear();
94                    for (int iEngine = 0; ppszEngines[iEngine]; iEngine++)
95                            EngineNameComboBox->insertItem(ppszEngines[iEngine]);
96            }
97            else m_pChannel->appendMessagesClient("lscp_list_available_engines");
98    
99      // It can be a brand new channel, remember?          // Populate Audio output type list.
100      bool bNew = (m_pChannel->channelID() < 0);          AudioDriverComboBox->clear();
101      setCaption(m_pChannel->channelName());          AudioDriverComboBox->insertStringList(
   
     // Check if we're up and connected.  
     if (m_pChannel->client() == NULL)  
         return;  
   
     qsamplerOptions *pOptions = m_pChannel->options();  
     if (pOptions == NULL)  
         return;  
   
     // Avoid nested changes.  
     m_iDirtySetup++;  
   
     // Load combo box history...  
     pOptions->loadComboBoxHistory(InstrumentFileComboBox);  
   
     // Populate Engines list.  
     const char **ppszEngines = ::lscp_get_available_engines(m_pChannel->client());  
     if (ppszEngines) {  
         EngineNameComboBox->clear();  
         for (int iEngine = 0; ppszEngines[iEngine]; iEngine++)  
             EngineNameComboBox->insertItem(ppszEngines[iEngine]);  
     }  
     else m_pChannel->appendMessagesClient("lscp_get_available_engines");  
   
     // Populate Audio output type list.  
     AudioDriverComboBox->clear();  
     AudioDriverComboBox->insertStringList(  
102                  qsamplerDevice::getDrivers(m_pChannel->client(), qsamplerDevice::Audio));                  qsamplerDevice::getDrivers(m_pChannel->client(), qsamplerDevice::Audio));
103    
104      // Populate MIDI input type list.          // Populate MIDI input type list.
105      MidiDriverComboBox->clear();          MidiDriverComboBox->clear();
106      MidiDriverComboBox->insertStringList(          MidiDriverComboBox->insertStringList(
107                  qsamplerDevice::getDrivers(m_pChannel->client(), qsamplerDevice::Midi));                  qsamplerDevice::getDrivers(m_pChannel->client(), qsamplerDevice::Midi));
108    
109      // Read proper channel information,          // Read proper channel information,
110      // and populate the channel form fields.          // and populate the channel form fields.
111    
112      // Engine name...          // Engine name...
113      QString sEngineName = pChannel->engineName();          QString sEngineName = pChannel->engineName();
114      if (sEngineName.isEmpty() || bNew)          if (sEngineName.isEmpty() || bNew)
115          sEngineName = pOptions->sEngineName;                  sEngineName = pOptions->sEngineName;
116      if (sEngineName.isEmpty())          if (sEngineName.isEmpty())
117          sEngineName = qsamplerChannel::noEngineName();                  sEngineName = qsamplerChannel::noEngineName();
118      if (EngineNameComboBox->listBox()->findItem(sEngineName, Qt::ExactMatch) == NULL)          if (EngineNameComboBox->listBox()->findItem(sEngineName,
119          EngineNameComboBox->insertItem(sEngineName);                          Qt::ExactMatch | Qt::CaseSensitive) == NULL) {
120      EngineNameComboBox->setCurrentText(sEngineName);                  EngineNameComboBox->insertItem(sEngineName);
121      // Instrument filename and index...          }
122      QString sInstrumentFile = pChannel->instrumentFile();          EngineNameComboBox->setCurrentText(sEngineName);
123      if (sInstrumentFile.isEmpty())          // Instrument filename and index...
124          sInstrumentFile = qsamplerChannel::noInstrumentName();          QString sInstrumentFile = pChannel->instrumentFile();
125      InstrumentFileComboBox->setCurrentText(sInstrumentFile);          if (sInstrumentFile.isEmpty())
126      InstrumentNrComboBox->clear();                  sInstrumentFile = qsamplerChannel::noInstrumentName();
127      InstrumentNrComboBox->insertStringList(          InstrumentFileComboBox->setCurrentText(sInstrumentFile);
128            InstrumentNrComboBox->clear();
129            InstrumentNrComboBox->insertStringList(
130                  qsamplerChannel::getInstrumentList(sInstrumentFile,                  qsamplerChannel::getInstrumentList(sInstrumentFile,
131                  pOptions->bInstrumentNames));                  pOptions->bInstrumentNames));
132      InstrumentNrComboBox->setCurrentItem(pChannel->instrumentNr());          InstrumentNrComboBox->setCurrentItem(pChannel->instrumentNr());
133        
134          // MIDI input device...          // MIDI input device...
135          qsamplerDevice midiDevice(m_pChannel->mainForm(),          qsamplerDevice midiDevice(m_pChannel->mainForm(),
136                  qsamplerDevice::Midi, m_pChannel->midiDevice());                  qsamplerDevice::Midi, m_pChannel->midiDevice());
137      // MIDI input driver...          // MIDI input driver...
138          QString sMidiDriver = midiDevice.driverName();          QString sMidiDriver = midiDevice.driverName();
139          if (sMidiDriver.isEmpty() || bNew)          if (sMidiDriver.isEmpty() || bNew)
140                  sMidiDriver = pOptions->sMidiDriver;                  sMidiDriver = pOptions->sMidiDriver.upper();
141          if (!sMidiDriver.isEmpty()) {          if (!sMidiDriver.isEmpty()) {
142                  if (MidiDriverComboBox->listBox()->findItem(sMidiDriver, Qt::ExactMatch) == NULL)                  if (MidiDriverComboBox->listBox()->findItem(sMidiDriver,
143                                    Qt::ExactMatch | Qt::CaseSensitive) == NULL) {
144                          MidiDriverComboBox->insertItem(sMidiDriver);                          MidiDriverComboBox->insertItem(sMidiDriver);
145                    }
146                  MidiDriverComboBox->setCurrentText(sMidiDriver);                  MidiDriverComboBox->setCurrentText(sMidiDriver);
147          }          }
148          selectMidiDriver(sMidiDriver);          selectMidiDriverItem(sMidiDriver);
149          if (!bNew)          if (!bNew)
150                  MidiDeviceComboBox->setCurrentText(midiDevice.deviceName());                  MidiDeviceComboBox->setCurrentText(midiDevice.deviceName());
151          selectMidiDevice(MidiDeviceComboBox->currentItem());          selectMidiDeviceItem(MidiDeviceComboBox->currentItem());
152      // MIDI input port...          // MIDI input port...
153      MidiPortSpinBox->setValue(pChannel->midiPort());          MidiPortSpinBox->setValue(pChannel->midiPort());
154      // MIDI input channel...          // MIDI input channel...
155      int iMidiChannel = pChannel->midiChannel();          int iMidiChannel = pChannel->midiChannel();
156      // When new, try to suggest a sensible MIDI channel...          // When new, try to suggest a sensible MIDI channel...
157      if (iMidiChannel < 0)          if (iMidiChannel < 0)
158          iMidiChannel = (::lscp_get_channels(m_pChannel->client()) % 16);                  iMidiChannel = (::lscp_get_channels(m_pChannel->client()) % 16);
159      MidiChannelComboBox->setCurrentItem(iMidiChannel);          MidiChannelComboBox->setCurrentItem(iMidiChannel);
160    
161          // Audio output device...          // Audio output device...
162          qsamplerDevice audioDevice(m_pChannel->mainForm(),          qsamplerDevice audioDevice(m_pChannel->mainForm(),
# Line 154  void qsamplerChannelForm::setup ( qsampl Line 164  void qsamplerChannelForm::setup ( qsampl
164          // Audio output driver...          // Audio output driver...
165          QString sAudioDriver = audioDevice.driverName();          QString sAudioDriver = audioDevice.driverName();
166          if (sAudioDriver.isEmpty() || bNew)          if (sAudioDriver.isEmpty() || bNew)
167                  sAudioDriver = pOptions->sAudioDriver;                  sAudioDriver = pOptions->sAudioDriver.upper();
168          if (!sAudioDriver.isEmpty()) {          if (!sAudioDriver.isEmpty()) {
169                  if (AudioDriverComboBox->listBox()->findItem(sAudioDriver, Qt::ExactMatch) == NULL)                  if (AudioDriverComboBox->listBox()->findItem(sAudioDriver,
170                                    Qt::ExactMatch | Qt::CaseSensitive) == NULL) {
171                          AudioDriverComboBox->insertItem(sAudioDriver);                          AudioDriverComboBox->insertItem(sAudioDriver);
172                    }
173                  AudioDriverComboBox->setCurrentText(sAudioDriver);                  AudioDriverComboBox->setCurrentText(sAudioDriver);
174          }          }
175          selectAudioDriver(sAudioDriver);          selectAudioDriverItem(sAudioDriver);
176          if (!bNew)          if (!bNew)
177                  AudioDeviceComboBox->setCurrentText(audioDevice.deviceName());                  AudioDeviceComboBox->setCurrentText(audioDevice.deviceName());
178          selectAudioDevice(AudioDeviceComboBox->currentItem());          selectAudioDeviceItem(AudioDeviceComboBox->currentItem());
179    
180          // As convenient, make it ready on stabilizeForm() for          // As convenient, make it ready on stabilizeForm() for
181          // prompt acceptance, if we got the minimum required...          // prompt acceptance, if we got the minimum required...
182          if (sEngineName != qsamplerChannel::noEngineName() &&          if (sEngineName != qsamplerChannel::noEngineName() &&
183                  sInstrumentFile != qsamplerChannel::noInstrumentName())                  sInstrumentFile != qsamplerChannel::noInstrumentName())
184                  m_iDirtyCount++;                  m_iDirtyCount++;
185      // Done.          // Done.
186      m_iDirtySetup--;          m_iDirtySetup--;
187      stabilizeForm();          stabilizeForm();
188  }  }
189    
190    
191  // Accept settings (OK button slot).  // Accept settings (OK button slot).
192  void qsamplerChannelForm::accept (void)  void qsamplerChannelForm::accept (void)
193  {  {
194      if (m_pChannel == NULL)          if (m_pChannel == NULL)
195          return;                  return;
196    
197      qsamplerOptions *pOptions = m_pChannel->options();          qsamplerOptions *pOptions = m_pChannel->options();
198      if (pOptions == NULL)          if (pOptions == NULL)
199          return;                  return;
200    
201      // We'll go for it!          // We'll go for it!
202      if (m_iDirtyCount > 0) {          if (m_iDirtyCount > 0) {
203          int iErrors = 0;                  int iErrors = 0;
204          // Are we a new channel?                  // Are we a new channel?
205          if (!m_pChannel->addChannel())                  if (!m_pChannel->addChannel())
206              iErrors++;                          iErrors++;
207                  // Accept Audio driver or device selection...                  // Accept Audio driver or device selection...
208                  if (m_audioDevices.isEmpty()) {                  if (m_audioDevices.isEmpty()) {
209                          if (!m_pChannel->setAudioDriver(AudioDriverComboBox->currentText()))                          if (!m_pChannel->setAudioDriver(AudioDriverComboBox->currentText()))
# Line 214  void qsamplerChannelForm::accept (void) Line 226  void qsamplerChannelForm::accept (void)
226                          else if (!m_pChannel->setMidiDevice(pDevice->deviceID()))                          else if (!m_pChannel->setMidiDevice(pDevice->deviceID()))
227                                  iErrors++;                                  iErrors++;
228                  }                  }
229          // MIDI input port number...                  // MIDI input port number...
230          if (!m_pChannel->setMidiPort(MidiPortSpinBox->value()))                  if (!m_pChannel->setMidiPort(MidiPortSpinBox->value()))
231              iErrors++;                          iErrors++;
232          // MIDI input channel...                  // MIDI input channel...
233          if (!m_pChannel->setMidiChannel(MidiChannelComboBox->currentItem()))                  if (!m_pChannel->setMidiChannel(MidiChannelComboBox->currentItem()))
234              iErrors++;                          iErrors++;
235          // Engine name...                  // Engine name...
236          if (!m_pChannel->loadEngine(EngineNameComboBox->currentText()))                  if (!m_pChannel->loadEngine(EngineNameComboBox->currentText()))
237              iErrors++;                          iErrors++;
238          // Instrument file and index...                  // Instrument file and index...
239          if (!m_pChannel->loadInstrument(InstrumentFileComboBox->currentText(), InstrumentNrComboBox->currentItem()))                  if (!m_pChannel->loadInstrument(InstrumentFileComboBox->currentText(), InstrumentNrComboBox->currentItem()))
240              iErrors++;                          iErrors++;
241          // Show error messages?                  // Show error messages?
242          if (iErrors > 0)                  if (iErrors > 0)
243              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."));
244      }          }
245    
246      // Save default engine name, instrument directory and history...          // Save default engine name, instrument directory and history...
247      pOptions->sInstrumentDir = QFileInfo(InstrumentFileComboBox->currentText()).dirPath(true);          pOptions->sInstrumentDir = QFileInfo(InstrumentFileComboBox->currentText()).dirPath(true);
248      pOptions->sEngineName  = EngineNameComboBox->currentText();          pOptions->sEngineName  = EngineNameComboBox->currentText();
249      pOptions->sAudioDriver = AudioDriverComboBox->currentText();          pOptions->sAudioDriver = AudioDriverComboBox->currentText();
250      pOptions->sMidiDriver  = MidiDriverComboBox->currentText();          pOptions->sMidiDriver  = MidiDriverComboBox->currentText();
251      pOptions->saveComboBoxHistory(InstrumentFileComboBox);          pOptions->saveComboBoxHistory(InstrumentFileComboBox);
252    
253      // Just go with dialog acceptance.          // Just go with dialog acceptance.
254      QDialog::accept();          QDialog::accept();
255  }  }
256    
257    
258  // Reject settings (Cancel button slot).  // Reject settings (Cancel button slot).
259  void qsamplerChannelForm::reject (void)  void qsamplerChannelForm::reject (void)
260  {  {
261      bool bReject = true;          bool bReject = true;
262    
263      // Check if there's any pending changes...          // Check if there's any pending changes...
264      if (m_iDirtyCount > 0 && OkPushButton->isEnabled()) {          if (m_iDirtyCount > 0 && OkPushButton->isEnabled()) {
265          switch (QMessageBox::warning(this, tr("Warning"),                  switch (QMessageBox::warning(this,
266              tr("Some channel settings have been changed.\n\n"                          QSAMPLER_TITLE ": " + tr("Warning"),
267                 "Do you want to apply the changes?"),                          tr("Some channel settings have been changed.\n\n"
268              tr("Apply"), tr("Discard"), tr("Cancel"))) {                          "Do you want to apply the changes?"),
269          case 0:     // Apply...                          tr("Apply"), tr("Discard"), tr("Cancel"))) {
270              accept();                  case 0:     // Apply...
271              return;                          accept();
272          case 1:     // Discard                          return;
273              break;                  case 1:     // Discard
274          default:    // Cancel.                          break;
275              bReject = false;                  default:    // Cancel.
276          }                          bReject = false;
277      }                  }
278            }
279    
280      if (bReject)          if (bReject)
281          QDialog::reject();                  QDialog::reject();
282  }  }
283    
284    
285  // Browse and open an instrument file.  // Browse and open an instrument file.
286  void qsamplerChannelForm::openInstrumentFile (void)  void qsamplerChannelForm::openInstrumentFile (void)
287  {  {
288      qsamplerOptions *pOptions = m_pChannel->options();          qsamplerOptions *pOptions = m_pChannel->options();
289      if (pOptions == NULL)          if (pOptions == NULL)
290          return;                  return;
291    
292      // FIXME: the instrument file filters should be restricted,          // FIXME: the instrument file filters should be restricted,
293      // depending on the current engine.          // depending on the current engine.
294      QString sInstrumentFile = QFileDialog::getOpenFileName(          QString sInstrumentFile = QFileDialog::getOpenFileName(
295              pOptions->sInstrumentDir,                   // Start here.                  pOptions->sInstrumentDir,                   // Start here.
296              tr("Instrument files") + " (*.gig *.dls)",  // Filter (GIG and DLS files)                  tr("Instrument files") + " (*.gig *.dls)",  // Filter (GIG and DLS files)
297              this, 0,                                    // Parent and name (none)                  this, 0,                                    // Parent and name (none)
298              tr("Instrument files")                      // Caption.                  QSAMPLER_TITLE ": " + tr("Instrument files")    // Caption.
299      );          );
300    
301      if (sInstrumentFile.isEmpty())          if (sInstrumentFile.isEmpty())
302          return;                  return;
303    
304      InstrumentFileComboBox->setCurrentText(sInstrumentFile);          InstrumentFileComboBox->setCurrentText(sInstrumentFile);
305            updateInstrumentName();
306  }  }
307    
308    
309  // Refresh the actual instrument name.  // Refresh the actual instrument name.
310  void qsamplerChannelForm::updateInstrumentName (void)  void qsamplerChannelForm::updateInstrumentName (void)
311  {  {
312      qsamplerOptions *pOptions = m_pChannel->options();          qsamplerOptions *pOptions = m_pChannel->options();
313      if (pOptions == NULL)          if (pOptions == NULL)
314          return;                  return;
315    
316      // Finally this better idea would be to use libgig          // Finally this better idea would be to use libgig
317      // to retrieve the REAL instrument names.          // to retrieve the REAL instrument names.
318      InstrumentNrComboBox->clear();          InstrumentNrComboBox->clear();
319      InstrumentNrComboBox->insertStringList(          InstrumentNrComboBox->insertStringList(
320          qsamplerChannel::getInstrumentList(                  qsamplerChannel::getInstrumentList(
321                          InstrumentFileComboBox->currentText(),                          InstrumentFileComboBox->currentText(),
322                          pOptions->bInstrumentNames)                          pOptions->bInstrumentNames)
323      );          );
324    
325      optionsChanged();          optionsChanged();
326  }  }
327    
328    // Show device options dialog.
329    void qsamplerChannelForm::setupDevice ( qsamplerDevice *pDevice,
330            qsamplerDevice::qsamplerDeviceType deviceTypeMode,
331            const QString& sDriverName )
332    {
333            // Create the device form if not already...
334            if (m_pDeviceForm == NULL) {
335                    m_pDeviceForm = new qsamplerDeviceForm(this, 0,
336                            WType_Dialog | WShowModal);
337                    m_pDeviceForm->setMainForm(m_pChannel->mainForm());
338                    QObject::connect(m_pDeviceForm, SIGNAL(devicesChanged()),
339                            this, SLOT(updateDevices()));
340            }
341    
342  // Refresh MIDI device options.          // Refresh the device form with selected data.
343  void qsamplerChannelForm::selectMidiDriver ( const QString& sMidiDriver )          if (m_pDeviceForm) {
344                    m_pDeviceForm->setDeviceTypeMode(deviceTypeMode);
345                    m_pDeviceForm->setClient(m_pChannel->client()); // -> refreshDevices();
346                    m_pDeviceForm->setDevice(pDevice);
347                    m_pDeviceForm->setDriverName(sDriverName);
348                    m_pDeviceForm->show();
349            }
350    }
351    
352    
353    // Refresh MIDI driver item devices.
354    void qsamplerChannelForm::selectMidiDriverItem ( const QString& sMidiDriver )
355  {  {
356          const QString sDriverName = sMidiDriver.upper();          const QString sDriverName = sMidiDriver.upper();
357            
358            // Save current device id.
359            int iDeviceID = -1;
360            qsamplerDevice *pDevice = m_midiDevices.at(MidiDeviceComboBox->currentItem());
361            if (pDevice)
362                    iDeviceID = pDevice->deviceID();
363    
364            // Clean maplist.
365          MidiDeviceComboBox->clear();          MidiDeviceComboBox->clear();
366          m_audioDevices.clear();          m_midiDevices.clear();
367    
368            // Populate with the current ones...
369          const QPixmap& midiPixmap = QPixmap::fromMimeSource("midi2.png");          const QPixmap& midiPixmap = QPixmap::fromMimeSource("midi2.png");
370          int *piDeviceIDs = qsamplerDevice::getDevices(m_pChannel->client(),          int *piDeviceIDs = qsamplerDevice::getDevices(m_pChannel->client(),
371                  qsamplerDevice::Midi);                  qsamplerDevice::Midi);
372          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {
373                  qsamplerDevice *pDevice = new qsamplerDevice(m_pChannel->mainForm(),                  pDevice = new qsamplerDevice(m_pChannel->mainForm(),
374                          qsamplerDevice::Midi, piDeviceIDs[i]);                          qsamplerDevice::Midi, piDeviceIDs[i]);
375                  if (pDevice->driverName().upper() == sDriverName) {                  if (pDevice->driverName().upper() == sDriverName) {
376                          MidiDeviceComboBox->insertItem(midiPixmap, pDevice->deviceName());                          MidiDeviceComboBox->insertItem(midiPixmap, pDevice->deviceName());
# Line 334  void qsamplerChannelForm::selectMidiDriv Line 380  void qsamplerChannelForm::selectMidiDriv
380                  }                  }
381          }          }
382    
383            // Do proper enabling...
384          bool bEnabled = !m_midiDevices.isEmpty();          bool bEnabled = !m_midiDevices.isEmpty();
385          if (!bEnabled)          if (!bEnabled) {
386                  MidiDeviceComboBox->insertItem(tr("(New MIDI device)"));                  MidiDeviceComboBox->insertItem(
387                            tr("(New MIDI %1 device)").arg(sMidiDriver));
388            } else if (iDeviceID >= 0) {
389                    // Select the previous current device...
390                    int iMidiItem = 0;
391                    for (pDevice = m_midiDevices.first();
392                                    pDevice;
393                                            pDevice = m_midiDevices.next()) {
394                            if (pDevice->deviceID() == iDeviceID) {
395                                    MidiDeviceComboBox->setCurrentItem(iMidiItem);
396                            //      selectMidiDeviceItem(iMidiItem);
397                                    break;
398                            }
399                            iMidiItem++;
400                    }
401            }
402          MidiDeviceTextLabel->setEnabled(bEnabled);          MidiDeviceTextLabel->setEnabled(bEnabled);
403          MidiDeviceComboBox->setEnabled(bEnabled);          MidiDeviceComboBox->setEnabled(bEnabled);
404    }
405    
406    
407    // Refresh MIDI device options slot.
408    void qsamplerChannelForm::selectMidiDriver ( const QString& sMidiDriver )
409    {
410            if (m_iDirtySetup > 0)
411                    return;
412    
413            selectMidiDriverItem(sMidiDriver);
414          optionsChanged();          optionsChanged();
415  }  }
416    
417    
418  // Select MIDI device options.  // Select MIDI device item.
419  void qsamplerChannelForm::selectMidiDevice ( int iMidiItem )  void qsamplerChannelForm::selectMidiDeviceItem ( int iMidiItem )
420  {  {
421          qsamplerDevice *pDevice = m_midiDevices.at(iMidiItem);          qsamplerDevice *pDevice = m_midiDevices.at(iMidiItem);
422          if (pDevice) {          if (pDevice) {
# Line 355  void qsamplerChannelForm::selectMidiDevi Line 427  void qsamplerChannelForm::selectMidiDevi
427                  if (iPorts > 0)                  if (iPorts > 0)
428                          MidiPortSpinBox->setMaxValue(iPorts - 1);                          MidiPortSpinBox->setMaxValue(iPorts - 1);
429          }          }
430    }
431    
432    
433    // Select MIDI device options slot.
434    void qsamplerChannelForm::selectMidiDevice ( int iMidiItem )
435    {
436            if (m_iDirtySetup > 0)
437                    return;
438    
439            selectMidiDeviceItem(iMidiItem);
440          optionsChanged();          optionsChanged();
441  }  }
442    
443    
444  // Refresh Audio device options.  // MIDI device options.
445  void qsamplerChannelForm::selectAudioDriver ( const QString& sAudioDriver )  void qsamplerChannelForm::setupMidiDevice (void)
446    {
447            setupDevice(m_midiDevices.at(MidiDeviceComboBox->currentItem()),
448                    qsamplerDevice::Midi, MidiDriverComboBox->currentText());
449    }
450    
451    
452    // Refresh Audio driver item devices.
453    void qsamplerChannelForm::selectAudioDriverItem ( const QString& sAudioDriver )
454  {  {
455          const QString sDriverName = sAudioDriver.upper();          const QString sDriverName = sAudioDriver.upper();
456    
457            // Save current device id.
458            int iDeviceID = -1;
459            qsamplerDevice *pDevice = m_audioDevices.at(AudioDeviceComboBox->currentItem());
460            if (pDevice)
461                    iDeviceID = pDevice->deviceID();
462    
463            // Clean maplist.
464          AudioDeviceComboBox->clear();          AudioDeviceComboBox->clear();
465          m_audioDevices.clear();          m_audioDevices.clear();
466    
467            // Populate with the current ones...
468          const QPixmap& audioPixmap = QPixmap::fromMimeSource("audio2.png");          const QPixmap& audioPixmap = QPixmap::fromMimeSource("audio2.png");
469          int *piDeviceIDs = qsamplerDevice::getDevices(m_pChannel->client(),          int *piDeviceIDs = qsamplerDevice::getDevices(m_pChannel->client(),
470                  qsamplerDevice::Audio);                  qsamplerDevice::Audio);
471          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {
472                  qsamplerDevice *pDevice = new qsamplerDevice(m_pChannel->mainForm(),                  pDevice = new qsamplerDevice(m_pChannel->mainForm(),
473                          qsamplerDevice::Audio, piDeviceIDs[i]);                          qsamplerDevice::Audio, piDeviceIDs[i]);
474                  if (pDevice->driverName().upper() == sDriverName) {                  if (pDevice->driverName().upper() == sDriverName) {
475                          AudioDeviceComboBox->insertItem(audioPixmap, pDevice->deviceName());                          AudioDeviceComboBox->insertItem(audioPixmap, pDevice->deviceName());
# Line 381  void qsamplerChannelForm::selectAudioDri Line 479  void qsamplerChannelForm::selectAudioDri
479                  }                  }
480          }          }
481    
482            // Do proper enabling...
483          bool bEnabled = !m_audioDevices.isEmpty();          bool bEnabled = !m_audioDevices.isEmpty();
484          if (!bEnabled)          if (!bEnabled) {
485                  AudioDeviceComboBox->insertItem(tr("(New Audio device)"));                  AudioDeviceComboBox->insertItem(
486                            tr("(New Audio %1 device)").arg(sAudioDriver));
487            } else if (iDeviceID >= 0) {
488                    // Select the previous current device...
489                    int iAudioItem = 0;
490                    for (pDevice = m_audioDevices.first();
491                                    pDevice;
492                                            pDevice = m_audioDevices.next()) {
493                            if (pDevice->deviceID() == iDeviceID) {
494                                    AudioDeviceComboBox->setCurrentItem(iAudioItem);
495                            //      selectAudioDeviceItem(iAudioItem);
496                                    break;
497                            }
498                            iAudioItem++;
499                    }
500            }
501          AudioDeviceTextLabel->setEnabled(bEnabled);          AudioDeviceTextLabel->setEnabled(bEnabled);
502          AudioDeviceComboBox->setEnabled(bEnabled);          AudioDeviceComboBox->setEnabled(bEnabled);
503    }
504    
505    
506    // Refresh Audio device options slot.
507    void qsamplerChannelForm::selectAudioDriver ( const QString& sAudioDriver )
508    {
509            if (m_iDirtySetup > 0)
510                    return;
511    
512            selectAudioDriverItem(sAudioDriver);
513          optionsChanged();          optionsChanged();
514  }  }
515    
516    
517  // Select Audio device options.  // Select Audio device item.
518  void qsamplerChannelForm::selectAudioDevice ( int iAudioItem )  void qsamplerChannelForm::selectAudioDeviceItem ( int iAudioItem )
519  {  {
520          qsamplerDevice *pDevice = m_audioDevices.at(iAudioItem);          qsamplerDevice *pDevice = m_audioDevices.at(iAudioItem);
521          if (pDevice) {          if (pDevice) {
522                  // Is there anything to do here?                  // Is there anything to do here?
523          }          }
524    }
525    
526    
527    // Select Audio device options slot.
528    void qsamplerChannelForm::selectAudioDevice ( int iAudioItem )
529    {
530            if (m_iDirtySetup > 0)
531                    return;
532    
533            selectAudioDeviceItem(iAudioItem);
534            optionsChanged();
535    }
536    
537    
538    // Audio device options.
539    void qsamplerChannelForm::setupAudioDevice (void)
540    {
541            setupDevice(m_audioDevices.at(AudioDeviceComboBox->currentItem()),
542                    qsamplerDevice::Audio, AudioDriverComboBox->currentText());
543    }
544    
545    
546    // UPdate all device lists slot.
547    void qsamplerChannelForm::updateDevices (void)
548    {
549            if (m_iDirtySetup > 0)
550                    return;
551    
552            selectMidiDriverItem(MidiDriverComboBox->currentText());
553            selectAudioDriverItem(AudioDriverComboBox->currentText());
554          optionsChanged();          optionsChanged();
555  }  }
556    
# Line 404  void qsamplerChannelForm::selectAudioDev Line 558  void qsamplerChannelForm::selectAudioDev
558  // Dirty up settings.  // Dirty up settings.
559  void qsamplerChannelForm::optionsChanged (void)  void qsamplerChannelForm::optionsChanged (void)
560  {  {
561      if (m_iDirtySetup > 0)          if (m_iDirtySetup > 0)
562          return;                  return;
563    
564      m_iDirtyCount++;          m_iDirtyCount++;
565      stabilizeForm();          stabilizeForm();
566  }  }
567    
568    
569  // Stabilize current form state.  // Stabilize current form state.
570  void qsamplerChannelForm::stabilizeForm (void)  void qsamplerChannelForm::stabilizeForm (void)
571  {  {
572      const QString& sFilename = InstrumentFileComboBox->currentText();          const QString& sFilename = InstrumentFileComboBox->currentText();
573      OkPushButton->setEnabled(m_iDirtyCount > 0 && !sFilename.isEmpty() && QFileInfo(sFilename).exists());          OkPushButton->setEnabled(m_iDirtyCount > 0 && !sFilename.isEmpty() && QFileInfo(sFilename).exists());
574  }  }
575    
576    
577  // end of qsamplerChannelForm.ui.h  // end of qsamplerChannelForm.ui.h
   

Legend:
Removed from v.484  
changed lines
  Added in v.757

  ViewVC Help
Powered by ViewVC