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

Legend:
Removed from v.280  
changed lines
  Added in v.490

  ViewVC Help
Powered by ViewVC