/[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 490 by capela, Fri Apr 1 00:34:58 2005 UTC revision 767 by capela, Tue Aug 30 09:52:46 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 "qsamplerDeviceForm.h"  
   
 #include "config.h"  
   
32    
33  // Kind of constructor.  // Kind of constructor.
34  void qsamplerChannelForm::init (void)  void qsamplerChannelForm::init (void)
# Line 72  void qsamplerChannelForm::setup ( qsampl Line 71  void qsamplerChannelForm::setup ( qsampl
71    
72          // It can be a brand new channel, remember?          // It can be a brand new channel, remember?
73          bool bNew = (m_pChannel->channelID() < 0);          bool bNew = (m_pChannel->channelID() < 0);
74          setCaption(m_pChannel->channelName());          setCaption(QSAMPLER_TITLE ": " + m_pChannel->channelName());
75    
76          // Check if we're up and connected.          // Check if we're up and connected.
77          if (m_pChannel->client() == NULL)          if (m_pChannel->client() == NULL)
# Line 88  void qsamplerChannelForm::setup ( qsampl Line 87  void qsamplerChannelForm::setup ( qsampl
87          // Load combo box history...          // Load combo box history...
88          pOptions->loadComboBoxHistory(InstrumentFileComboBox);          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.          // Populate Engines list.
95          const char **ppszEngines = ::lscp_get_available_engines(m_pChannel->client());          const char **ppszEngines = ::lscp_list_available_engines(m_pChannel->client());
96          if (ppszEngines) {          if (ppszEngines) {
97                  EngineNameComboBox->clear();                  EngineNameComboBox->clear();
98                  for (int iEngine = 0; ppszEngines[iEngine]; iEngine++)                  for (int iEngine = 0; ppszEngines[iEngine]; iEngine++)
99                          EngineNameComboBox->insertItem(ppszEngines[iEngine]);                          EngineNameComboBox->insertItem(ppszEngines[iEngine]);
100          }          }
101          else m_pChannel->appendMessagesClient("lscp_get_available_engines");          else m_pChannel->appendMessagesClient("lscp_list_available_engines");
102    
103          // Populate Audio output type list.          // Populate Audio output type list.
104          AudioDriverComboBox->clear();          AudioDriverComboBox->clear();
# Line 180  void qsamplerChannelForm::setup ( qsampl Line 183  void qsamplerChannelForm::setup ( qsampl
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();
# Line 199  void qsamplerChannelForm::accept (void) Line 202  void qsamplerChannelForm::accept (void)
202          if (pOptions == NULL)          if (pOptions == NULL)
203                  return;                  return;
204    
205            // Flush any pending editing...
206            AudioRoutingTable->flush();
207    
208          // We'll go for it!          // We'll go for it!
209          if (m_iDirtyCount > 0) {          if (m_iDirtyCount > 0) {
210                  int iErrors = 0;                  int iErrors = 0;
# Line 215  void qsamplerChannelForm::accept (void) Line 221  void qsamplerChannelForm::accept (void)
221                                  iErrors++;                                  iErrors++;
222                          else if (!m_pChannel->setAudioDevice(pDevice->deviceID()))                          else if (!m_pChannel->setAudioDevice(pDevice->deviceID()))
223                                  iErrors++;                                  iErrors++;
224                            else if (!m_audioRouting.isEmpty()) {
225                                    // Set the audio route changes...
226                                    qsamplerChannelRoutingMap::ConstIterator iter;
227                                    for (iter = m_audioRouting.begin();
228                                                    iter != m_audioRouting.end(); ++iter) {
229                                            if (!m_pChannel->setAudioChannel(iter.key(), iter.data()))
230                                                    iErrors++;
231                                    }
232                            }
233                  }                  }
234                  // Accept MIDI driver or device selection...                  // Accept MIDI driver or device selection...
235                  if (m_midiDevices.isEmpty()) {                  if (m_midiDevices.isEmpty()) {
# Line 263  void qsamplerChannelForm::reject (void) Line 278  void qsamplerChannelForm::reject (void)
278    
279          // Check if there's any pending changes...          // Check if there's any pending changes...
280          if (m_iDirtyCount > 0 && OkPushButton->isEnabled()) {          if (m_iDirtyCount > 0 && OkPushButton->isEnabled()) {
281                  switch (QMessageBox::warning(this, tr("Warning"),                  switch (QMessageBox::warning(this,
282                            QSAMPLER_TITLE ": " + tr("Warning"),
283                          tr("Some channel settings have been changed.\n\n"                          tr("Some channel settings have been changed.\n\n"
284                          "Do you want to apply the changes?"),                          "Do you want to apply the changes?"),
285                          tr("Apply"), tr("Discard"), tr("Cancel"))) {                          tr("Apply"), tr("Discard"), tr("Cancel"))) {
# Line 292  void qsamplerChannelForm::openInstrument Line 308  void qsamplerChannelForm::openInstrument
308          // FIXME: the instrument file filters should be restricted,          // FIXME: the instrument file filters should be restricted,
309          // depending on the current engine.          // depending on the current engine.
310          QString sInstrumentFile = QFileDialog::getOpenFileName(          QString sInstrumentFile = QFileDialog::getOpenFileName(
311                          pOptions->sInstrumentDir,                   // Start here.                  pOptions->sInstrumentDir,                   // Start here.
312                          tr("Instrument files") + " (*.gig *.dls)",  // Filter (GIG and DLS files)                  tr("Instrument files") + " (*.gig *.dls)",  // Filter (GIG and DLS files)
313                          this, 0,                                    // Parent and name (none)                  this, 0,                                    // Parent and name (none)
314                          tr("Instrument files")                      // Caption.                  QSAMPLER_TITLE ": " + tr("Instrument files")    // Caption.
315          );          );
316    
317          if (sInstrumentFile.isEmpty())          if (sInstrumentFile.isEmpty())
318                  return;                  return;
319    
320          InstrumentFileComboBox->setCurrentText(sInstrumentFile);          InstrumentFileComboBox->setCurrentText(sInstrumentFile);
321            updateInstrumentName();
322  }  }
323    
324    
# Line 355  void qsamplerChannelForm::selectMidiDriv Line 372  void qsamplerChannelForm::selectMidiDriv
372          const QString sDriverName = sMidiDriver.upper();          const QString sDriverName = sMidiDriver.upper();
373    
374          // Save current device id.          // Save current device id.
375          int iDeviceID = -1;          int iDeviceID = 0;
376          qsamplerDevice *pDevice = m_midiDevices.at(MidiDeviceComboBox->currentItem());          qsamplerDevice *pDevice = m_midiDevices.at(MidiDeviceComboBox->currentItem());
377          if (pDevice)          if (pDevice)
378                  iDeviceID = pDevice->deviceID();                  iDeviceID = pDevice->deviceID();
# Line 381  void qsamplerChannelForm::selectMidiDriv Line 398  void qsamplerChannelForm::selectMidiDriv
398    
399          // Do proper enabling...          // Do proper enabling...
400          bool bEnabled = !m_midiDevices.isEmpty();          bool bEnabled = !m_midiDevices.isEmpty();
401          if (!bEnabled) {          if (bEnabled) {
                 MidiDeviceComboBox->insertItem(  
                         tr("(New MIDI %1 device)").arg(sMidiDriver));  
         } else if (iDeviceID >= 0) {  
402                  // Select the previous current device...                  // Select the previous current device...
403                  int iMidiItem = 0;                  int iMidiItem = 0;
404                  for (pDevice = m_midiDevices.first();                  for (pDevice = m_midiDevices.first();
# Line 392  void qsamplerChannelForm::selectMidiDriv Line 406  void qsamplerChannelForm::selectMidiDriv
406                                          pDevice = m_midiDevices.next()) {                                          pDevice = m_midiDevices.next()) {
407                          if (pDevice->deviceID() == iDeviceID) {                          if (pDevice->deviceID() == iDeviceID) {
408                                  MidiDeviceComboBox->setCurrentItem(iMidiItem);                                  MidiDeviceComboBox->setCurrentItem(iMidiItem);
409                          //      selectMidiDeviceItem(iMidiItem);                                  selectMidiDeviceItem(iMidiItem);
410                                  break;                                  break;
411                          }                          }
412                          iMidiItem++;                          iMidiItem++;
413                  }                  }
414            } else {
415                    MidiDeviceComboBox->insertItem(
416                            tr("(New MIDI %1 device)").arg(sMidiDriver));
417          }          }
418          MidiDeviceTextLabel->setEnabled(bEnabled);          MidiDeviceTextLabel->setEnabled(bEnabled);
419          MidiDeviceComboBox->setEnabled(bEnabled);          MidiDeviceComboBox->setEnabled(bEnabled);
# Line 454  void qsamplerChannelForm::selectAudioDri Line 471  void qsamplerChannelForm::selectAudioDri
471          const QString sDriverName = sAudioDriver.upper();          const QString sDriverName = sAudioDriver.upper();
472    
473          // Save current device id.          // Save current device id.
474          int iDeviceID = -1;          int iDeviceID = 0;
475          qsamplerDevice *pDevice = m_audioDevices.at(AudioDeviceComboBox->currentItem());          qsamplerDevice *pDevice = m_audioDevices.at(AudioDeviceComboBox->currentItem());
476          if (pDevice)          if (pDevice)
477                  iDeviceID = pDevice->deviceID();                  iDeviceID = pDevice->deviceID();
# Line 480  void qsamplerChannelForm::selectAudioDri Line 497  void qsamplerChannelForm::selectAudioDri
497    
498          // Do proper enabling...          // Do proper enabling...
499          bool bEnabled = !m_audioDevices.isEmpty();          bool bEnabled = !m_audioDevices.isEmpty();
500          if (!bEnabled) {          if (bEnabled) {
                 AudioDeviceComboBox->insertItem(  
                         tr("(New Audio %1 device)").arg(sAudioDriver));  
         } else if (iDeviceID >= 0) {  
501                  // Select the previous current device...                  // Select the previous current device...
502                  int iAudioItem = 0;                  int iAudioItem = 0;
503                  for (pDevice = m_audioDevices.first();                  for (pDevice = m_audioDevices.first();
# Line 491  void qsamplerChannelForm::selectAudioDri Line 505  void qsamplerChannelForm::selectAudioDri
505                                          pDevice = m_audioDevices.next()) {                                          pDevice = m_audioDevices.next()) {
506                          if (pDevice->deviceID() == iDeviceID) {                          if (pDevice->deviceID() == iDeviceID) {
507                                  AudioDeviceComboBox->setCurrentItem(iAudioItem);                                  AudioDeviceComboBox->setCurrentItem(iAudioItem);
508                          //      selectAudioDeviceItem(iAudioItem);                                  selectAudioDeviceItem(iAudioItem);
509                                  break;                                  break;
510                          }                          }
511                          iAudioItem++;                          iAudioItem++;
512                  }                  }
513            } else {
514                    AudioDeviceComboBox->insertItem(
515                            tr("(New Audio %1 device)").arg(sAudioDriver));
516                    AudioRoutingTable->setNumRows(0);
517          }          }
518          AudioDeviceTextLabel->setEnabled(bEnabled);          AudioDeviceTextLabel->setEnabled(bEnabled);
519          AudioDeviceComboBox->setEnabled(bEnabled);          AudioDeviceComboBox->setEnabled(bEnabled);
520            AudioRoutingTable->setEnabled(bEnabled);
521  }  }
522    
523    
# Line 518  void qsamplerChannelForm::selectAudioDev Line 537  void qsamplerChannelForm::selectAudioDev
537  {  {
538          qsamplerDevice *pDevice = m_audioDevices.at(iAudioItem);          qsamplerDevice *pDevice = m_audioDevices.at(iAudioItem);
539          if (pDevice) {          if (pDevice) {
540                  // Is there anything to do here?                  // Refresh the audio routing table.
541                    AudioRoutingTable->refresh(pDevice, m_pChannel->audioRouting());
542                    // Reset routing change map.
543                    m_audioRouting.clear();
544          }          }
545  }  }
546    
# Line 542  void qsamplerChannelForm::setupAudioDevi Line 564  void qsamplerChannelForm::setupAudioDevi
564  }  }
565    
566    
567    // Audio routing change slot.
568    void qsamplerChannelForm::changeAudioRouting ( int iRow, int iCol )
569    {
570            if (m_iDirtySetup > 0)
571                    return;
572            if (iRow < 0 || iCol < 0)
573                    return;
574    
575            // Verify that this is a QComboTableItem (magic rtti == 1)
576            QTableItem *pItem = AudioRoutingTable->item(iRow, iCol);
577            if (pItem == NULL)
578                    return;
579            qsamplerChannelRoutingComboBox *pComboItem =
580                    static_cast<qsamplerChannelRoutingComboBox*> (pItem);
581            // FIXME: Its not garanteed that we must have
582            // iAudioOut == iRow on all times forth!
583            m_audioRouting[iRow] = pComboItem->currentItem();
584    
585            // And let's get dirty...
586            optionsChanged();
587    }
588    
589    
590  // UPdate all device lists slot.  // UPdate all device lists slot.
591  void qsamplerChannelForm::updateDevices (void)  void qsamplerChannelForm::updateDevices (void)
592  {  {

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

  ViewVC Help
Powered by ViewVC