/[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 759 by capela, Sun Aug 28 11:44:10 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            // Notify.that we've just changed one audio route.
91            QObject::connect(AudioRoutingTable, SIGNAL(valueChanged(int,int)),
92                    this, SLOT(changeAudioRouting(int,int)));
93    
94            // Populate Engines list.
95            const char **ppszEngines = ::lscp_list_available_engines(m_pChannel->client());
96            if (ppszEngines) {
97                    EngineNameComboBox->clear();
98                    for (int iEngine = 0; ppszEngines[iEngine]; iEngine++)
99                            EngineNameComboBox->insertItem(ppszEngines[iEngine]);
100            }
101            else m_pChannel->appendMessagesClient("lscp_list_available_engines");
102    
103      // It can be a brand new channel, remember?          // Populate Audio output type list.
104      bool bNew = (m_pChannel->channelID() < 0);          AudioDriverComboBox->clear();
105      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(  
106                  qsamplerDevice::getDrivers(m_pChannel->client(), qsamplerDevice::Audio));                  qsamplerDevice::getDrivers(m_pChannel->client(), qsamplerDevice::Audio));
107    
108      // Populate MIDI input type list.          // Populate MIDI input type list.
109      MidiDriverComboBox->clear();          MidiDriverComboBox->clear();
110      MidiDriverComboBox->insertStringList(          MidiDriverComboBox->insertStringList(
111                  qsamplerDevice::getDrivers(m_pChannel->client(), qsamplerDevice::Midi));                  qsamplerDevice::getDrivers(m_pChannel->client(), qsamplerDevice::Midi));
112    
113      // Read proper channel information,          // Read proper channel information,
114      // and populate the channel form fields.          // and populate the channel form fields.
115    
116      // Engine name...          // Engine name...
117      QString sEngineName = pChannel->engineName();          QString sEngineName = pChannel->engineName();
118      if (sEngineName.isEmpty() || bNew)          if (sEngineName.isEmpty() || bNew)
119          sEngineName = pOptions->sEngineName;                  sEngineName = pOptions->sEngineName;
120      if (sEngineName.isEmpty())          if (sEngineName.isEmpty())
121          sEngineName = qsamplerChannel::noEngineName();                  sEngineName = qsamplerChannel::noEngineName();
122      if (EngineNameComboBox->listBox()->findItem(sEngineName, Qt::ExactMatch) == NULL)          if (EngineNameComboBox->listBox()->findItem(sEngineName,
123          EngineNameComboBox->insertItem(sEngineName);                          Qt::ExactMatch | Qt::CaseSensitive) == NULL) {
124      EngineNameComboBox->setCurrentText(sEngineName);                  EngineNameComboBox->insertItem(sEngineName);
125      // Instrument filename and index...          }
126      QString sInstrumentFile = pChannel->instrumentFile();          EngineNameComboBox->setCurrentText(sEngineName);
127      if (sInstrumentFile.isEmpty())          // Instrument filename and index...
128          sInstrumentFile = qsamplerChannel::noInstrumentName();          QString sInstrumentFile = pChannel->instrumentFile();
129      InstrumentFileComboBox->setCurrentText(sInstrumentFile);          if (sInstrumentFile.isEmpty())
130      InstrumentNrComboBox->clear();                  sInstrumentFile = qsamplerChannel::noInstrumentName();
131      InstrumentNrComboBox->insertStringList(          InstrumentFileComboBox->setCurrentText(sInstrumentFile);
132            InstrumentNrComboBox->clear();
133            InstrumentNrComboBox->insertStringList(
134                  qsamplerChannel::getInstrumentList(sInstrumentFile,                  qsamplerChannel::getInstrumentList(sInstrumentFile,
135                  pOptions->bInstrumentNames));                  pOptions->bInstrumentNames));
136      InstrumentNrComboBox->setCurrentItem(pChannel->instrumentNr());          InstrumentNrComboBox->setCurrentItem(pChannel->instrumentNr());
137        
138          // MIDI input device...          // MIDI input device...
139          qsamplerDevice midiDevice(m_pChannel->mainForm(),          qsamplerDevice midiDevice(m_pChannel->mainForm(),
140                  qsamplerDevice::Midi, m_pChannel->midiDevice());                  qsamplerDevice::Midi, m_pChannel->midiDevice());
141      // MIDI input driver...          // MIDI input driver...
142          QString sMidiDriver = midiDevice.driverName();          QString sMidiDriver = midiDevice.driverName();
143          if (sMidiDriver.isEmpty() || bNew)          if (sMidiDriver.isEmpty() || bNew)
144                  sMidiDriver = pOptions->sMidiDriver;                  sMidiDriver = pOptions->sMidiDriver.upper();
145          if (!sMidiDriver.isEmpty()) {          if (!sMidiDriver.isEmpty()) {
146                  if (MidiDriverComboBox->listBox()->findItem(sMidiDriver, Qt::ExactMatch) == NULL)                  if (MidiDriverComboBox->listBox()->findItem(sMidiDriver,
147                                    Qt::ExactMatch | Qt::CaseSensitive) == NULL) {
148                          MidiDriverComboBox->insertItem(sMidiDriver);                          MidiDriverComboBox->insertItem(sMidiDriver);
149                    }
150                  MidiDriverComboBox->setCurrentText(sMidiDriver);                  MidiDriverComboBox->setCurrentText(sMidiDriver);
151          }          }
152          selectMidiDriver(sMidiDriver);          selectMidiDriverItem(sMidiDriver);
153          if (!bNew)          if (!bNew)
154                  MidiDeviceComboBox->setCurrentText(midiDevice.deviceName());                  MidiDeviceComboBox->setCurrentText(midiDevice.deviceName());
155          selectMidiDevice(MidiDeviceComboBox->currentItem());          selectMidiDeviceItem(MidiDeviceComboBox->currentItem());
156      // MIDI input port...          // MIDI input port...
157      MidiPortSpinBox->setValue(pChannel->midiPort());          MidiPortSpinBox->setValue(pChannel->midiPort());
158      // MIDI input channel...          // MIDI input channel...
159      int iMidiChannel = pChannel->midiChannel();          int iMidiChannel = pChannel->midiChannel();
160      // When new, try to suggest a sensible MIDI channel...          // When new, try to suggest a sensible MIDI channel...
161      if (iMidiChannel < 0)          if (iMidiChannel < 0)
162          iMidiChannel = (::lscp_get_channels(m_pChannel->client()) % 16);                  iMidiChannel = (::lscp_get_channels(m_pChannel->client()) % 16);
163      MidiChannelComboBox->setCurrentItem(iMidiChannel);          MidiChannelComboBox->setCurrentItem(iMidiChannel);
164    
165          // Audio output device...          // Audio output device...
166          qsamplerDevice audioDevice(m_pChannel->mainForm(),          qsamplerDevice audioDevice(m_pChannel->mainForm(),
# Line 154  void qsamplerChannelForm::setup ( qsampl Line 168  void qsamplerChannelForm::setup ( qsampl
168          // Audio output driver...          // Audio output driver...
169          QString sAudioDriver = audioDevice.driverName();          QString sAudioDriver = audioDevice.driverName();
170          if (sAudioDriver.isEmpty() || bNew)          if (sAudioDriver.isEmpty() || bNew)
171                  sAudioDriver = pOptions->sAudioDriver;                  sAudioDriver = pOptions->sAudioDriver.upper();
172          if (!sAudioDriver.isEmpty()) {          if (!sAudioDriver.isEmpty()) {
173                  if (AudioDriverComboBox->listBox()->findItem(sAudioDriver, Qt::ExactMatch) == NULL)                  if (AudioDriverComboBox->listBox()->findItem(sAudioDriver,
174                                    Qt::ExactMatch | Qt::CaseSensitive) == NULL) {
175                          AudioDriverComboBox->insertItem(sAudioDriver);                          AudioDriverComboBox->insertItem(sAudioDriver);
176                    }
177                  AudioDriverComboBox->setCurrentText(sAudioDriver);                  AudioDriverComboBox->setCurrentText(sAudioDriver);
178          }          }
179          selectAudioDriver(sAudioDriver);          selectAudioDriverItem(sAudioDriver);
180          if (!bNew)          if (!bNew)
181                  AudioDeviceComboBox->setCurrentText(audioDevice.deviceName());                  AudioDeviceComboBox->setCurrentText(audioDevice.deviceName());
182          selectAudioDevice(AudioDeviceComboBox->currentItem());          selectAudioDeviceItem(AudioDeviceComboBox->currentItem());
183    
184          // As convenient, make it ready on stabilizeForm() for          // As convenient, make it ready on stabilizeForm() for
185          // prompt acceptance, if we got the minimum required...          // prompt acceptance, if we got the minimum required...
186          if (sEngineName != qsamplerChannel::noEngineName() &&  /*      if (sEngineName != qsamplerChannel::noEngineName() &&
187                  sInstrumentFile != qsamplerChannel::noInstrumentName())                  sInstrumentFile != qsamplerChannel::noInstrumentName())
188                  m_iDirtyCount++;                  m_iDirtyCount++; */
189      // Done.          // Done.
190      m_iDirtySetup--;          m_iDirtySetup--;
191      stabilizeForm();          stabilizeForm();
192  }  }
193    
194    
195  // Accept settings (OK button slot).  // Accept settings (OK button slot).
196  void qsamplerChannelForm::accept (void)  void qsamplerChannelForm::accept (void)
197  {  {
198      if (m_pChannel == NULL)          if (m_pChannel == NULL)
199          return;                  return;
200    
201      qsamplerOptions *pOptions = m_pChannel->options();          qsamplerOptions *pOptions = m_pChannel->options();
202      if (pOptions == NULL)          if (pOptions == NULL)
203          return;                  return;
204    
205      // We'll go for it!          // We'll go for it!
206      if (m_iDirtyCount > 0) {          if (m_iDirtyCount > 0) {
207          int iErrors = 0;                  int iErrors = 0;
208          // Are we a new channel?                  // Are we a new channel?
209          if (!m_pChannel->addChannel())                  if (!m_pChannel->addChannel())
210              iErrors++;                          iErrors++;
211                  // Accept Audio driver or device selection...                  // Accept Audio driver or device selection...
212                  if (m_audioDevices.isEmpty()) {                  if (m_audioDevices.isEmpty()) {
213                          if (!m_pChannel->setAudioDriver(AudioDriverComboBox->currentText()))                          if (!m_pChannel->setAudioDriver(AudioDriverComboBox->currentText()))
# Line 202  void qsamplerChannelForm::accept (void) Line 218  void qsamplerChannelForm::accept (void)
218                                  iErrors++;                                  iErrors++;
219                          else if (!m_pChannel->setAudioDevice(pDevice->deviceID()))                          else if (!m_pChannel->setAudioDevice(pDevice->deviceID()))
220                                  iErrors++;                                  iErrors++;
221                            else if (!m_audioRouting.isEmpty()) {
222                                    // Set the audio route changes...
223                                    qsamplerChannelRoutingMap::ConstIterator iter;
224                                    for (iter = m_audioRouting.begin();
225                                                    iter != m_audioRouting.end(); ++iter) {
226                                            if (!m_pChannel->setAudioChannel(iter.key(), iter.data()))
227                                                    iErrors++;
228                                    }
229                            }
230                  }                  }
231                  // Accept MIDI driver or device selection...                  // Accept MIDI driver or device selection...
232                  if (m_midiDevices.isEmpty()) {                  if (m_midiDevices.isEmpty()) {
# Line 214  void qsamplerChannelForm::accept (void) Line 239  void qsamplerChannelForm::accept (void)
239                          else if (!m_pChannel->setMidiDevice(pDevice->deviceID()))                          else if (!m_pChannel->setMidiDevice(pDevice->deviceID()))
240                                  iErrors++;                                  iErrors++;
241                  }                  }
242          // MIDI input port number...                  // MIDI input port number...
243          if (!m_pChannel->setMidiPort(MidiPortSpinBox->value()))                  if (!m_pChannel->setMidiPort(MidiPortSpinBox->value()))
244              iErrors++;                          iErrors++;
245          // MIDI input channel...                  // MIDI input channel...
246          if (!m_pChannel->setMidiChannel(MidiChannelComboBox->currentItem()))                  if (!m_pChannel->setMidiChannel(MidiChannelComboBox->currentItem()))
247              iErrors++;                          iErrors++;
248          // Engine name...                  // Engine name...
249          if (!m_pChannel->loadEngine(EngineNameComboBox->currentText()))                  if (!m_pChannel->loadEngine(EngineNameComboBox->currentText()))
250              iErrors++;                          iErrors++;
251          // Instrument file and index...                  // Instrument file and index...
252          if (!m_pChannel->loadInstrument(InstrumentFileComboBox->currentText(), InstrumentNrComboBox->currentItem()))                  if (!m_pChannel->loadInstrument(InstrumentFileComboBox->currentText(), InstrumentNrComboBox->currentItem()))
253              iErrors++;                          iErrors++;
254          // Show error messages?                  // Show error messages?
255          if (iErrors > 0)                  if (iErrors > 0)
256              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."));
257      }          }
   
     // 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);  
258    
259      // Just go with dialog acceptance.          // Save default engine name, instrument directory and history...
260      QDialog::accept();          pOptions->sInstrumentDir = QFileInfo(InstrumentFileComboBox->currentText()).dirPath(true);
261            pOptions->sEngineName  = EngineNameComboBox->currentText();
262            pOptions->sAudioDriver = AudioDriverComboBox->currentText();
263            pOptions->sMidiDriver  = MidiDriverComboBox->currentText();
264            pOptions->saveComboBoxHistory(InstrumentFileComboBox);
265    
266            // Just go with dialog acceptance.
267            QDialog::accept();
268  }  }
269    
270    
271  // Reject settings (Cancel button slot).  // Reject settings (Cancel button slot).
272  void qsamplerChannelForm::reject (void)  void qsamplerChannelForm::reject (void)
273  {  {
274      bool bReject = true;          bool bReject = true;
275    
276      // Check if there's any pending changes...          // Check if there's any pending changes...
277      if (m_iDirtyCount > 0 && OkPushButton->isEnabled()) {          if (m_iDirtyCount > 0 && OkPushButton->isEnabled()) {
278          switch (QMessageBox::warning(this, tr("Warning"),                  switch (QMessageBox::warning(this,
279              tr("Some channel settings have been changed.\n\n"                          QSAMPLER_TITLE ": " + tr("Warning"),
280                 "Do you want to apply the changes?"),                          tr("Some channel settings have been changed.\n\n"
281              tr("Apply"), tr("Discard"), tr("Cancel"))) {                          "Do you want to apply the changes?"),
282          case 0:     // Apply...                          tr("Apply"), tr("Discard"), tr("Cancel"))) {
283              accept();                  case 0:     // Apply...
284              return;                          accept();
285          case 1:     // Discard                          return;
286              break;                  case 1:     // Discard
287          default:    // Cancel.                          break;
288              bReject = false;                  default:    // Cancel.
289          }                          bReject = false;
290      }                  }
291            }
292    
293      if (bReject)          if (bReject)
294          QDialog::reject();                  QDialog::reject();
295  }  }
296    
297    
298  // Browse and open an instrument file.  // Browse and open an instrument file.
299  void qsamplerChannelForm::openInstrumentFile (void)  void qsamplerChannelForm::openInstrumentFile (void)
300  {  {
301      qsamplerOptions *pOptions = m_pChannel->options();          qsamplerOptions *pOptions = m_pChannel->options();
302      if (pOptions == NULL)          if (pOptions == NULL)
303          return;                  return;
304    
305      // FIXME: the instrument file filters should be restricted,          // FIXME: the instrument file filters should be restricted,
306      // depending on the current engine.          // depending on the current engine.
307      QString sInstrumentFile = QFileDialog::getOpenFileName(          QString sInstrumentFile = QFileDialog::getOpenFileName(
308              pOptions->sInstrumentDir,                   // Start here.                  pOptions->sInstrumentDir,                   // Start here.
309              tr("Instrument files") + " (*.gig *.dls)",  // Filter (GIG and DLS files)                  tr("Instrument files") + " (*.gig *.dls)",  // Filter (GIG and DLS files)
310              this, 0,                                    // Parent and name (none)                  this, 0,                                    // Parent and name (none)
311              tr("Instrument files")                      // Caption.                  QSAMPLER_TITLE ": " + tr("Instrument files")    // Caption.
312      );          );
313    
314      if (sInstrumentFile.isEmpty())          if (sInstrumentFile.isEmpty())
315          return;                  return;
316    
317      InstrumentFileComboBox->setCurrentText(sInstrumentFile);          InstrumentFileComboBox->setCurrentText(sInstrumentFile);
318            updateInstrumentName();
319  }  }
320    
321    
322  // Refresh the actual instrument name.  // Refresh the actual instrument name.
323  void qsamplerChannelForm::updateInstrumentName (void)  void qsamplerChannelForm::updateInstrumentName (void)
324  {  {
325      qsamplerOptions *pOptions = m_pChannel->options();          qsamplerOptions *pOptions = m_pChannel->options();
326      if (pOptions == NULL)          if (pOptions == NULL)
327          return;                  return;
328    
329      // Finally this better idea would be to use libgig          // Finally this better idea would be to use libgig
330      // to retrieve the REAL instrument names.          // to retrieve the REAL instrument names.
331      InstrumentNrComboBox->clear();          InstrumentNrComboBox->clear();
332      InstrumentNrComboBox->insertStringList(          InstrumentNrComboBox->insertStringList(
333          qsamplerChannel::getInstrumentList(                  qsamplerChannel::getInstrumentList(
334                          InstrumentFileComboBox->currentText(),                          InstrumentFileComboBox->currentText(),
335                          pOptions->bInstrumentNames)                          pOptions->bInstrumentNames)
336      );          );
337    
338            optionsChanged();
339    }
340    
341    // Show device options dialog.
342    void qsamplerChannelForm::setupDevice ( qsamplerDevice *pDevice,
343            qsamplerDevice::qsamplerDeviceType deviceTypeMode,
344            const QString& sDriverName )
345    {
346            // Create the device form if not already...
347            if (m_pDeviceForm == NULL) {
348                    m_pDeviceForm = new qsamplerDeviceForm(this, 0,
349                            WType_Dialog | WShowModal);
350                    m_pDeviceForm->setMainForm(m_pChannel->mainForm());
351                    QObject::connect(m_pDeviceForm, SIGNAL(devicesChanged()),
352                            this, SLOT(updateDevices()));
353            }
354    
355      optionsChanged();          // Refresh the device form with selected data.
356            if (m_pDeviceForm) {
357                    m_pDeviceForm->setDeviceTypeMode(deviceTypeMode);
358                    m_pDeviceForm->setClient(m_pChannel->client()); // -> refreshDevices();
359                    m_pDeviceForm->setDevice(pDevice);
360                    m_pDeviceForm->setDriverName(sDriverName);
361                    m_pDeviceForm->show();
362            }
363  }  }
364    
365    
366  // Refresh MIDI device options.  // Refresh MIDI driver item devices.
367  void qsamplerChannelForm::selectMidiDriver ( const QString& sMidiDriver )  void qsamplerChannelForm::selectMidiDriverItem ( const QString& sMidiDriver )
368  {  {
369          const QString sDriverName = sMidiDriver.upper();          const QString sDriverName = sMidiDriver.upper();
370            
371            // Save current device id.
372            int iDeviceID = 0;
373            qsamplerDevice *pDevice = m_midiDevices.at(MidiDeviceComboBox->currentItem());
374            if (pDevice)
375                    iDeviceID = pDevice->deviceID();
376    
377            // Clean maplist.
378          MidiDeviceComboBox->clear();          MidiDeviceComboBox->clear();
379          m_audioDevices.clear();          m_midiDevices.clear();
380    
381            // Populate with the current ones...
382          const QPixmap& midiPixmap = QPixmap::fromMimeSource("midi2.png");          const QPixmap& midiPixmap = QPixmap::fromMimeSource("midi2.png");
383          int *piDeviceIDs = qsamplerDevice::getDevices(m_pChannel->client(),          int *piDeviceIDs = qsamplerDevice::getDevices(m_pChannel->client(),
384                  qsamplerDevice::Midi);                  qsamplerDevice::Midi);
385          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {
386                  qsamplerDevice *pDevice = new qsamplerDevice(m_pChannel->mainForm(),                  pDevice = new qsamplerDevice(m_pChannel->mainForm(),
387                          qsamplerDevice::Midi, piDeviceIDs[i]);                          qsamplerDevice::Midi, piDeviceIDs[i]);
388                  if (pDevice->driverName().upper() == sDriverName) {                  if (pDevice->driverName().upper() == sDriverName) {
389                          MidiDeviceComboBox->insertItem(midiPixmap, pDevice->deviceName());                          MidiDeviceComboBox->insertItem(midiPixmap, pDevice->deviceName());
# Line 334  void qsamplerChannelForm::selectMidiDriv Line 393  void qsamplerChannelForm::selectMidiDriv
393                  }                  }
394          }          }
395    
396            // Do proper enabling...
397          bool bEnabled = !m_midiDevices.isEmpty();          bool bEnabled = !m_midiDevices.isEmpty();
398          if (!bEnabled)          if (bEnabled) {
399                  MidiDeviceComboBox->insertItem(tr("(New MIDI device)"));                  // Select the previous current device...
400                    int iMidiItem = 0;
401                    for (pDevice = m_midiDevices.first();
402                                    pDevice;
403                                            pDevice = m_midiDevices.next()) {
404                            if (pDevice->deviceID() == iDeviceID) {
405                                    MidiDeviceComboBox->setCurrentItem(iMidiItem);
406                                    selectMidiDeviceItem(iMidiItem);
407                                    break;
408                            }
409                            iMidiItem++;
410                    }
411            } else {
412                    MidiDeviceComboBox->insertItem(
413                            tr("(New MIDI %1 device)").arg(sMidiDriver));
414            }
415          MidiDeviceTextLabel->setEnabled(bEnabled);          MidiDeviceTextLabel->setEnabled(bEnabled);
416          MidiDeviceComboBox->setEnabled(bEnabled);          MidiDeviceComboBox->setEnabled(bEnabled);
417    }
418    
419    
420    // Refresh MIDI device options slot.
421    void qsamplerChannelForm::selectMidiDriver ( const QString& sMidiDriver )
422    {
423            if (m_iDirtySetup > 0)
424                    return;
425    
426            selectMidiDriverItem(sMidiDriver);
427          optionsChanged();          optionsChanged();
428  }  }
429    
430    
431  // Select MIDI device options.  // Select MIDI device item.
432  void qsamplerChannelForm::selectMidiDevice ( int iMidiItem )  void qsamplerChannelForm::selectMidiDeviceItem ( int iMidiItem )
433  {  {
434          qsamplerDevice *pDevice = m_midiDevices.at(iMidiItem);          qsamplerDevice *pDevice = m_midiDevices.at(iMidiItem);
435          if (pDevice) {          if (pDevice) {
# Line 355  void qsamplerChannelForm::selectMidiDevi Line 440  void qsamplerChannelForm::selectMidiDevi
440                  if (iPorts > 0)                  if (iPorts > 0)
441                          MidiPortSpinBox->setMaxValue(iPorts - 1);                          MidiPortSpinBox->setMaxValue(iPorts - 1);
442          }          }
443    }
444    
445    
446    // Select MIDI device options slot.
447    void qsamplerChannelForm::selectMidiDevice ( int iMidiItem )
448    {
449            if (m_iDirtySetup > 0)
450                    return;
451    
452            selectMidiDeviceItem(iMidiItem);
453          optionsChanged();          optionsChanged();
454  }  }
455    
456    
457  // Refresh Audio device options.  // MIDI device options.
458  void qsamplerChannelForm::selectAudioDriver ( const QString& sAudioDriver )  void qsamplerChannelForm::setupMidiDevice (void)
459    {
460            setupDevice(m_midiDevices.at(MidiDeviceComboBox->currentItem()),
461                    qsamplerDevice::Midi, MidiDriverComboBox->currentText());
462    }
463    
464    
465    // Refresh Audio driver item devices.
466    void qsamplerChannelForm::selectAudioDriverItem ( const QString& sAudioDriver )
467  {  {
468          const QString sDriverName = sAudioDriver.upper();          const QString sDriverName = sAudioDriver.upper();
469    
470            // Save current device id.
471            int iDeviceID = 0;
472            qsamplerDevice *pDevice = m_audioDevices.at(AudioDeviceComboBox->currentItem());
473            if (pDevice)
474                    iDeviceID = pDevice->deviceID();
475    
476            // Clean maplist.
477          AudioDeviceComboBox->clear();          AudioDeviceComboBox->clear();
478          m_audioDevices.clear();          m_audioDevices.clear();
479    
480            // Populate with the current ones...
481          const QPixmap& audioPixmap = QPixmap::fromMimeSource("audio2.png");          const QPixmap& audioPixmap = QPixmap::fromMimeSource("audio2.png");
482          int *piDeviceIDs = qsamplerDevice::getDevices(m_pChannel->client(),          int *piDeviceIDs = qsamplerDevice::getDevices(m_pChannel->client(),
483                  qsamplerDevice::Audio);                  qsamplerDevice::Audio);
484          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {
485                  qsamplerDevice *pDevice = new qsamplerDevice(m_pChannel->mainForm(),                  pDevice = new qsamplerDevice(m_pChannel->mainForm(),
486                          qsamplerDevice::Audio, piDeviceIDs[i]);                          qsamplerDevice::Audio, piDeviceIDs[i]);
487                  if (pDevice->driverName().upper() == sDriverName) {                  if (pDevice->driverName().upper() == sDriverName) {
488                          AudioDeviceComboBox->insertItem(audioPixmap, pDevice->deviceName());                          AudioDeviceComboBox->insertItem(audioPixmap, pDevice->deviceName());
# Line 381  void qsamplerChannelForm::selectAudioDri Line 492  void qsamplerChannelForm::selectAudioDri
492                  }                  }
493          }          }
494    
495            // Do proper enabling...
496          bool bEnabled = !m_audioDevices.isEmpty();          bool bEnabled = !m_audioDevices.isEmpty();
497          if (!bEnabled)          if (bEnabled) {
498                  AudioDeviceComboBox->insertItem(tr("(New Audio device)"));                  // Select the previous current device...
499                    int iAudioItem = 0;
500                    for (pDevice = m_audioDevices.first();
501                                    pDevice;
502                                            pDevice = m_audioDevices.next()) {
503                            if (pDevice->deviceID() == iDeviceID) {
504                                    AudioDeviceComboBox->setCurrentItem(iAudioItem);
505                                    selectAudioDeviceItem(iAudioItem);
506                                    break;
507                            }
508                            iAudioItem++;
509                    }
510            } else {
511                    AudioDeviceComboBox->insertItem(
512                            tr("(New Audio %1 device)").arg(sAudioDriver));
513                    AudioRoutingTable->setNumRows(0);
514            }
515          AudioDeviceTextLabel->setEnabled(bEnabled);          AudioDeviceTextLabel->setEnabled(bEnabled);
516          AudioDeviceComboBox->setEnabled(bEnabled);          AudioDeviceComboBox->setEnabled(bEnabled);
517            AudioRoutingTable->setEnabled(bEnabled);
518    }
519    
520    
521    // Refresh Audio device options slot.
522    void qsamplerChannelForm::selectAudioDriver ( const QString& sAudioDriver )
523    {
524            if (m_iDirtySetup > 0)
525                    return;
526    
527            selectAudioDriverItem(sAudioDriver);
528          optionsChanged();          optionsChanged();
529  }  }
530    
531    
532  // Select Audio device options.  // Select Audio device item.
533  void qsamplerChannelForm::selectAudioDevice ( int iAudioItem )  void qsamplerChannelForm::selectAudioDeviceItem ( int iAudioItem )
534  {  {
535          qsamplerDevice *pDevice = m_audioDevices.at(iAudioItem);          qsamplerDevice *pDevice = m_audioDevices.at(iAudioItem);
536          if (pDevice) {          if (pDevice) {
537                  // Is there anything to do here?                  // Refresh the audio routing table.
538                    AudioRoutingTable->refresh(pDevice, m_pChannel->audioRouting());
539                    // Reset routing change map.
540                    m_audioRouting.clear();
541          }          }
542    }
543    
544    
545    // Select Audio device options slot.
546    void qsamplerChannelForm::selectAudioDevice ( int iAudioItem )
547    {
548            if (m_iDirtySetup > 0)
549                    return;
550    
551            selectAudioDeviceItem(iAudioItem);
552            optionsChanged();
553    }
554    
555    
556    // Audio device options.
557    void qsamplerChannelForm::setupAudioDevice (void)
558    {
559            setupDevice(m_audioDevices.at(AudioDeviceComboBox->currentItem()),
560                    qsamplerDevice::Audio, AudioDriverComboBox->currentText());
561    }
562    
563    
564    // Audio routing change slot.
565    void qsamplerChannelForm::changeAudioRouting ( int iRow, int iCol )
566    {
567            if (m_iDirtySetup > 0)
568                    return;
569            if (iRow < 0 || iCol < 0)
570                    return;
571    
572            // Verify that this is a QComboTableItem (magic rtti == 1)
573            QTableItem *pItem = AudioRoutingTable->item(iRow, iCol);
574            if (pItem == NULL)
575                    return;
576            qsamplerChannelRoutingComboBox *pComboItem =
577                    static_cast<qsamplerChannelRoutingComboBox*> (pItem);
578            // FIXME: Its not garanteed that we must have
579            // iAudioOut == iRow on all times forth!
580            m_audioRouting[iRow] = pComboItem->currentItem();
581    
582            // And let's get dirty...
583            optionsChanged();
584    }
585    
586    
587    // UPdate all device lists slot.
588    void qsamplerChannelForm::updateDevices (void)
589    {
590            if (m_iDirtySetup > 0)
591                    return;
592    
593            selectMidiDriverItem(MidiDriverComboBox->currentText());
594            selectAudioDriverItem(AudioDriverComboBox->currentText());
595          optionsChanged();          optionsChanged();
596  }  }
597    
# Line 404  void qsamplerChannelForm::selectAudioDev Line 599  void qsamplerChannelForm::selectAudioDev
599  // Dirty up settings.  // Dirty up settings.
600  void qsamplerChannelForm::optionsChanged (void)  void qsamplerChannelForm::optionsChanged (void)
601  {  {
602      if (m_iDirtySetup > 0)          if (m_iDirtySetup > 0)
603          return;                  return;
604    
605      m_iDirtyCount++;          m_iDirtyCount++;
606      stabilizeForm();          stabilizeForm();
607  }  }
608    
609    
610  // Stabilize current form state.  // Stabilize current form state.
611  void qsamplerChannelForm::stabilizeForm (void)  void qsamplerChannelForm::stabilizeForm (void)
612  {  {
613      const QString& sFilename = InstrumentFileComboBox->currentText();          const QString& sFilename = InstrumentFileComboBox->currentText();
614      OkPushButton->setEnabled(m_iDirtyCount > 0 && !sFilename.isEmpty() && QFileInfo(sFilename).exists());          OkPushButton->setEnabled(m_iDirtyCount > 0 && !sFilename.isEmpty() && QFileInfo(sFilename).exists());
615  }  }
616    
617    
618  // end of qsamplerChannelForm.ui.h  // end of qsamplerChannelForm.ui.h
   

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

  ViewVC Help
Powered by ViewVC