/[svn]/qsampler/trunk/src/qsamplerChannelForm.cpp
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerChannelForm.cpp

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

revision 1519 by capela, Sat Nov 24 13:06:19 2007 UTC revision 3385 by capela, Fri Dec 1 19:23:47 2017 UTC
# Line 1  Line 1 
1  // qsamplerChannelForm.cpp  // qsamplerChannelForm.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2016, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007, Christian Schoenebeck     Copyright (C) 2007, 2008 Christian Schoenebeck
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 38  Line 38 
38    
39  namespace QSampler {  namespace QSampler {
40    
41    //-------------------------------------------------------------------------
42    // QSampler::Channelform -- Channel form implementation.
43    //
44    
45  ChannelForm::ChannelForm ( QWidget* pParent )  ChannelForm::ChannelForm ( QWidget* pParent )
46          : QDialog(pParent)          : QDialog(pParent)
47  {  {
# Line 54  ChannelForm::ChannelForm ( QWidget* pPar Line 58  ChannelForm::ChannelForm ( QWidget* pPar
58    
59          m_pDeviceForm = NULL;          m_pDeviceForm = NULL;
60    
61          int iRowHeight = m_ui.AudioRoutingTable->fontMetrics().height() + 4;          const int iRowHeight = m_ui.AudioRoutingTable->fontMetrics().height() + 4;
62          m_ui.AudioRoutingTable->verticalHeader()->setDefaultSectionSize(iRowHeight);          m_ui.AudioRoutingTable->verticalHeader()->setDefaultSectionSize(iRowHeight);
63          m_ui.AudioRoutingTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);          m_ui.AudioRoutingTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
64    
65          m_ui.AudioRoutingTable->setModel(&m_routingModel);          m_ui.AudioRoutingTable->setModel(&m_routingModel);
66          m_ui.AudioRoutingTable->setItemDelegate(&m_routingDelegate);          m_ui.AudioRoutingTable->setItemDelegate(&m_routingDelegate);
67    #if QT_VERSION >= 0x050000
68            m_ui.AudioRoutingTable->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
69    #else
70          m_ui.AudioRoutingTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);          m_ui.AudioRoutingTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
71    #endif
72  //      m_ui.AudioRoutingTable->verticalHeader()->hide();  //      m_ui.AudioRoutingTable->verticalHeader()->hide();
73    
74          // This goes initially hidden, and will be shown          // This goes initially hidden, and will be shown
# Line 74  ChannelForm::ChannelForm ( QWidget* pPar Line 82  ChannelForm::ChannelForm ( QWidget* pPar
82                  SIGNAL(activated(int)),                  SIGNAL(activated(int)),
83                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
84          QObject::connect(m_ui.InstrumentFileComboBox,          QObject::connect(m_ui.InstrumentFileComboBox,
85                    SIGNAL(editTextChanged(const QString&)),
86                    SLOT(updateInstrumentName()));
87            QObject::connect(m_ui.InstrumentFileComboBox,
88                  SIGNAL(activated(const QString&)),                  SIGNAL(activated(const QString&)),
89                  SLOT(updateInstrumentName()));                  SLOT(updateInstrumentName()));
90          QObject::connect(m_ui.InstrumentFileToolButton,          QObject::connect(m_ui.InstrumentFileToolButton,
# Line 103  ChannelForm::ChannelForm ( QWidget* pPar Line 114  ChannelForm::ChannelForm ( QWidget* pPar
114          QObject::connect(m_ui.AudioDeviceComboBox,          QObject::connect(m_ui.AudioDeviceComboBox,
115                  SIGNAL(activated(int)),                  SIGNAL(activated(int)),
116                  SLOT(selectAudioDevice(int)));                  SLOT(selectAudioDevice(int)));
117          QObject::connect(m_ui.OkPushButton,          QObject::connect(m_ui.DialogButtonBox,
118                  SIGNAL(clicked()),                  SIGNAL(accepted()),
119                  SLOT(accept()));                  SLOT(accept()));
120          QObject::connect(m_ui.CancelPushButton,          QObject::connect(m_ui.DialogButtonBox,
121                  SIGNAL(clicked()),                  SIGNAL(rejected()),
122                  SLOT(reject()));                  SLOT(reject()));
123          QObject::connect(m_ui.MidiDeviceToolButton,          QObject::connect(m_ui.MidiDeviceToolButton,
124                  SIGNAL(clicked()),                  SIGNAL(clicked()),
# Line 115  ChannelForm::ChannelForm ( QWidget* pPar Line 126  ChannelForm::ChannelForm ( QWidget* pPar
126          QObject::connect(m_ui.AudioDeviceToolButton,          QObject::connect(m_ui.AudioDeviceToolButton,
127                  SIGNAL(clicked()),                  SIGNAL(clicked()),
128                  SLOT(setupAudioDevice()));                  SLOT(setupAudioDevice()));
129    
130          QObject::connect(&m_routingModel,          QObject::connect(&m_routingModel,
131                  SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),                  SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),
132                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
# Line 141  ChannelForm::~ChannelForm() Line 153  ChannelForm::~ChannelForm()
153    
154    
155  // Channel dialog setup formal initializer.  // Channel dialog setup formal initializer.
156  void ChannelForm::setup ( qsamplerChannel *pChannel )  void ChannelForm::setup ( Channel *pChannel )
157  {  {
158          m_pChannel = pChannel;          m_pChannel = pChannel;
159    
# Line 152  void ChannelForm::setup ( qsamplerChanne Line 164  void ChannelForm::setup ( qsamplerChanne
164                  return;                  return;
165    
166          // It can be a brand new channel, remember?          // It can be a brand new channel, remember?
167          bool bNew = (m_pChannel->channelID() < 0);          const bool bNew = (m_pChannel->channelID() < 0);
168          setWindowTitle(QSAMPLER_TITLE ": " + m_pChannel->channelName());          setWindowTitle(QSAMPLER_TITLE ": " + m_pChannel->channelName());
169    
170          // Check if we're up and connected.          // Check if we're up and connected.
# Line 162  void ChannelForm::setup ( qsamplerChanne Line 174  void ChannelForm::setup ( qsamplerChanne
174          if (pMainForm->client() == NULL)          if (pMainForm->client() == NULL)
175                  return;                  return;
176    
177          qsamplerOptions *pOptions = pMainForm->options();          Options *pOptions = pMainForm->options();
178          if (pOptions == NULL)          if (pOptions == NULL)
179                  return;                  return;
180    
# Line 171  void ChannelForm::setup ( qsamplerChanne Line 183  void ChannelForm::setup ( qsamplerChanne
183    
184          // Load combo box history...          // Load combo box history...
185          pOptions->loadComboBoxHistory(m_ui.InstrumentFileComboBox);          pOptions->loadComboBoxHistory(m_ui.InstrumentFileComboBox);
186            // Remove non-existant instrument file-paths...
187            int i = m_ui.InstrumentFileComboBox->count() - 1;
188            while (i >= 0) {
189                    const QString& sInstrumentFile
190                            = m_ui.InstrumentFileComboBox->itemText(i);
191                    if (sInstrumentFile.isEmpty()
192                            || !QFileInfo(sInstrumentFile).exists())
193                            m_ui.InstrumentFileComboBox->removeItem(i);
194                    --i;
195            }
196    
197          // Populate Engines list.          // Populate Engines list.
198          const char **ppszEngines = ::lscp_list_available_engines(pMainForm->client());          const char **ppszEngines = ::lscp_list_available_engines(pMainForm->client());
# Line 184  void ChannelForm::setup ( qsamplerChanne Line 206  void ChannelForm::setup ( qsamplerChanne
206          // Populate Audio output type list.          // Populate Audio output type list.
207          m_ui.AudioDriverComboBox->clear();          m_ui.AudioDriverComboBox->clear();
208          m_ui.AudioDriverComboBox->insertItems(0,          m_ui.AudioDriverComboBox->insertItems(0,
209                  qsamplerDevice::getDrivers(pMainForm->client(), qsamplerDevice::Audio));                  Device::getDrivers(pMainForm->client(), Device::Audio));
210    
211          // Populate MIDI input type list.          // Populate MIDI input type list.
212          m_ui.MidiDriverComboBox->clear();          m_ui.MidiDriverComboBox->clear();
213          m_ui.MidiDriverComboBox->insertItems(0,          m_ui.MidiDriverComboBox->insertItems(0,
214                  qsamplerDevice::getDrivers(pMainForm->client(), qsamplerDevice::Midi));                  Device::getDrivers(pMainForm->client(), Device::Midi));
215    
216          // Populate Maps list.          // Populate Maps list.
217          m_ui.MidiMapComboBox->clear();          m_ui.MidiMapComboBox->clear();
218          m_ui.MidiMapComboBox->insertItems(0,          m_ui.MidiMapComboBox->insertItems(0,
219                  qsamplerInstrument::getMapNames());                  Instrument::getMapNames());
220    
221          // Read proper channel information,          // Read proper channel information,
222          // and populate the channel form fields.          // and populate the channel form fields.
# Line 204  void ChannelForm::setup ( qsamplerChanne Line 226  void ChannelForm::setup ( qsamplerChanne
226          if (sEngineName.isEmpty() || bNew)          if (sEngineName.isEmpty() || bNew)
227                  sEngineName = pOptions->sEngineName;                  sEngineName = pOptions->sEngineName;
228          if (sEngineName.isEmpty())          if (sEngineName.isEmpty())
229                  sEngineName = qsamplerChannel::noEngineName();                  sEngineName = Channel::noEngineName();
230          if (m_ui.EngineNameComboBox->findText(sEngineName,          if (m_ui.EngineNameComboBox->findText(sEngineName,
231                          Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {                          Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {
232                  m_ui.EngineNameComboBox->addItem(sEngineName);                  m_ui.EngineNameComboBox->addItem(sEngineName);
# Line 216  void ChannelForm::setup ( qsamplerChanne Line 238  void ChannelForm::setup ( qsamplerChanne
238          // Instrument filename and index...          // Instrument filename and index...
239          QString sInstrumentFile = pChannel->instrumentFile();          QString sInstrumentFile = pChannel->instrumentFile();
240          if (sInstrumentFile.isEmpty())          if (sInstrumentFile.isEmpty())
241                  sInstrumentFile = qsamplerChannel::noInstrumentName();                  sInstrumentFile = Channel::noInstrumentName();
242          m_ui.InstrumentFileComboBox->setEditText(sInstrumentFile);          m_ui.InstrumentFileComboBox->setEditText(sInstrumentFile);
243          m_ui.InstrumentNrComboBox->clear();          m_ui.InstrumentNrComboBox->clear();
244          m_ui.InstrumentNrComboBox->insertItems(0,          m_ui.InstrumentNrComboBox->insertItems(0,
245                  qsamplerChannel::getInstrumentList(sInstrumentFile,                  Channel::getInstrumentList(sInstrumentFile,
246                  pOptions->bInstrumentNames));                  pOptions->bInstrumentNames));
247          int iInstrumentNr = pChannel->instrumentNr();          int iInstrumentNr = pChannel->instrumentNr();
248          if (iInstrumentNr < 0)          if (iInstrumentNr < 0)
# Line 228  void ChannelForm::setup ( qsamplerChanne Line 250  void ChannelForm::setup ( qsamplerChanne
250          m_ui.InstrumentNrComboBox->setCurrentIndex(iInstrumentNr);          m_ui.InstrumentNrComboBox->setCurrentIndex(iInstrumentNr);
251    
252          // MIDI input device...          // MIDI input device...
253          qsamplerDevice midiDevice(qsamplerDevice::Midi, m_pChannel->midiDevice());          const Device midiDevice(Device::Midi, m_pChannel->midiDevice());
254          // MIDI input driver...          // MIDI input driver...
255          QString sMidiDriver = midiDevice.driverName();          QString sMidiDriver = midiDevice.driverName();
256          if (sMidiDriver.isEmpty() || bNew)          if (sMidiDriver.isEmpty() || bNew)
# Line 238  void ChannelForm::setup ( qsamplerChanne Line 260  void ChannelForm::setup ( qsamplerChanne
260                                  Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {                                  Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {
261                          m_ui.MidiDriverComboBox->insertItem(0, sMidiDriver);                          m_ui.MidiDriverComboBox->insertItem(0, sMidiDriver);
262                  }                  }
263                  m_ui.MidiDriverComboBox->setItemText(                  m_ui.MidiDriverComboBox->setCurrentIndex(
264                          m_ui.MidiDriverComboBox->currentIndex(),                          m_ui.MidiDriverComboBox->findText(sMidiDriver,
265                          sMidiDriver);                                  Qt::MatchExactly | Qt::MatchCaseSensitive)
266                    );
267          }          }
268          selectMidiDriverItem(sMidiDriver);          selectMidiDriverItem(sMidiDriver);
269          if (!bNew) {          if (!bNew) {
# Line 262  void ChannelForm::setup ( qsamplerChanne Line 285  void ChannelForm::setup ( qsamplerChanne
285          // When new, try to suggest a sensible MIDI map...          // When new, try to suggest a sensible MIDI map...
286          if (iMidiMap < 0)          if (iMidiMap < 0)
287                  iMidiMap = 0;                  iMidiMap = 0;
288          const QString& sMapName = qsamplerInstrument::getMapName(iMidiMap);          const QString& sMapName = Instrument::getMapName(iMidiMap);
289          if (!sMapName.isEmpty()) {          if (!sMapName.isEmpty()) {
290                  m_ui.MidiMapComboBox->setItemText(                  m_ui.MidiMapComboBox->setItemText(
291                          m_ui.MidiMapComboBox->currentIndex(),                          m_ui.MidiMapComboBox->currentIndex(),
292                          sMapName);                          sMapName);
293          }          }
294          // It might be no maps around...          // It might be no maps around...
295          bool bMidiMapEnabled = (m_ui.MidiMapComboBox->count() > 0);          const bool bMidiMapEnabled = (m_ui.MidiMapComboBox->count() > 0);
296          m_ui.MidiMapTextLabel->setEnabled(bMidiMapEnabled);          m_ui.MidiMapTextLabel->setEnabled(bMidiMapEnabled);
297          m_ui.MidiMapComboBox->setEnabled(bMidiMapEnabled);          m_ui.MidiMapComboBox->setEnabled(bMidiMapEnabled);
298    
299          // Audio output device...          // Audio output device...
300          qsamplerDevice audioDevice(qsamplerDevice::Audio, m_pChannel->audioDevice());          const Device audioDevice(Device::Audio, m_pChannel->audioDevice());
301          // Audio output driver...          // Audio output driver...
302          QString sAudioDriver = audioDevice.driverName();          QString sAudioDriver = audioDevice.driverName();
303          if (sAudioDriver.isEmpty() || bNew)          if (sAudioDriver.isEmpty() || bNew)
# Line 284  void ChannelForm::setup ( qsamplerChanne Line 307  void ChannelForm::setup ( qsamplerChanne
307                                  Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {                                  Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {
308                          m_ui.AudioDriverComboBox->insertItem(0, sAudioDriver);                          m_ui.AudioDriverComboBox->insertItem(0, sAudioDriver);
309                  }                  }
310                  m_ui.AudioDriverComboBox->setItemText(                  m_ui.AudioDriverComboBox->setCurrentIndex(
311                          m_ui.AudioDriverComboBox->currentIndex(),                          m_ui.AudioDriverComboBox->findText(sAudioDriver,
312                          sAudioDriver);                                  Qt::MatchExactly | Qt::MatchCaseSensitive)
313                    );
314          }          }
315          selectAudioDriverItem(sAudioDriver);          selectAudioDriverItem(sAudioDriver);
316          if (!bNew) {          if (!bNew) {
# Line 300  void ChannelForm::setup ( qsamplerChanne Line 324  void ChannelForm::setup ( qsamplerChanne
324          // if we're editing an existing sampler channel...          // if we're editing an existing sampler channel...
325          m_ui.AudioRoutingTable->setVisible(!bNew);          m_ui.AudioRoutingTable->setVisible(!bNew);
326    
327            const QString sInstrumentNrToolTip =
328                    (pOptions->bInstrumentNames) ?
329                            tr("Select an instrument of the file") :
330                            tr("You might want to enable instrument name retrieval in the "
331                            "settings dialog");
332            m_ui.InstrumentNrComboBox->setToolTip(
333                    QObject::tr(sInstrumentNrToolTip.toUtf8().data())
334            );
335    
336    #if 0
337          // As convenient, make it ready on stabilizeForm() for          // As convenient, make it ready on stabilizeForm() for
338          // prompt acceptance, if we got the minimum required...          // prompt acceptance, if we got the minimum required...
339  /*      if (sEngineName != qsamplerChannel::noEngineName() &&          if (sEngineName != Channel::noEngineName() &&
340                  sInstrumentFile != qsamplerChannel::noInstrumentName())                  sInstrumentFile != Channel::noInstrumentName())
341                  m_iDirtyCount++; */                  m_iDirtyCount++;
342    #endif
343    
344          // Done.          // Done.
345          m_iDirtySetup--;          m_iDirtySetup--;
346          stabilizeForm();          stabilizeForm();
# Line 323  void ChannelForm::accept (void) Line 359  void ChannelForm::accept (void)
359          if (pMainForm->client() == NULL)          if (pMainForm->client() == NULL)
360                  return;                  return;
361    
362          qsamplerOptions *pOptions = pMainForm->options();          Options *pOptions = pMainForm->options();
363          if (pOptions == NULL)          if (pOptions == NULL)
364                  return;                  return;
365    
# Line 341  void ChannelForm::accept (void) Line 377  void ChannelForm::accept (void)
377                          if (!m_pChannel->setAudioDriver(m_ui.AudioDriverComboBox->currentText()))                          if (!m_pChannel->setAudioDriver(m_ui.AudioDriverComboBox->currentText()))
378                                  iErrors++;                                  iErrors++;
379                  } else {                  } else {
380                          qsamplerDevice *pDevice = NULL;                          Device *pDevice = NULL;
381                          int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();                          const int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();
382                          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())                          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())
383                                  pDevice = m_audioDevices.at(iAudioItem);                                  pDevice = m_audioDevices.at(iAudioItem);
384                          qsamplerChannelRoutingMap routingMap = m_routingModel.routingMap();                          ChannelRoutingMap routingMap = m_routingModel.routingMap();
385                          if (pDevice == NULL)                          if (pDevice == NULL)
386                                  iErrors++;                                  iErrors++;
387                          else if (!m_pChannel->setAudioDevice(pDevice->deviceID()))                          else if (!m_pChannel->setAudioDevice(pDevice->deviceID()))
388                                  iErrors++;                                  iErrors++;
389                          else if (!routingMap.isEmpty()) {                          else if (!routingMap.isEmpty()) {
390                                  // Set the audio route changes...                                  // Set the audio route changes...
391                                  qsamplerChannelRoutingMap::ConstIterator iter;                                  ChannelRoutingMap::ConstIterator iter;
392                                  for (iter = routingMap.begin();                                  for (iter = routingMap.begin();
393                                                  iter != routingMap.end(); ++iter) {                                                  iter != routingMap.end(); ++iter) {
394                                          if (!m_pChannel->setAudioChannel(iter.key(), iter.value()))                                          if (!m_pChannel->setAudioChannel(iter.key(), iter.value()))
# Line 365  void ChannelForm::accept (void) Line 401  void ChannelForm::accept (void)
401                          if (!m_pChannel->setMidiDriver(m_ui.MidiDriverComboBox->currentText()))                          if (!m_pChannel->setMidiDriver(m_ui.MidiDriverComboBox->currentText()))
402                                  iErrors++;                                  iErrors++;
403                  } else {                  } else {
404                          qsamplerDevice *pDevice = NULL;                          Device *pDevice = NULL;
405                          int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();                          const int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();
406                          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())                          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())
407                                  pDevice = m_midiDevices.at(iMidiItem);                                  pDevice = m_midiDevices.at(iMidiItem);
408                          if (pDevice == NULL)                          if (pDevice == NULL)
# Line 419  void ChannelForm::reject (void) Line 455  void ChannelForm::reject (void)
455          bool bReject = true;          bool bReject = true;
456    
457          // Check if there's any pending changes...          // Check if there's any pending changes...
458          if (m_iDirtyCount > 0 && m_ui.OkPushButton->isEnabled()) {          if (m_iDirtyCount > 0) {
459                  switch (QMessageBox::warning(this,                  switch (QMessageBox::warning(this,
460                          QSAMPLER_TITLE ": " + tr("Warning"),                          QSAMPLER_TITLE ": " + tr("Warning"),
461                          tr("Some channel settings have been changed.\n\n"                          tr("Some channel settings have been changed.\n\n"
462                          "Do you want to apply the changes?"),                          "Do you want to apply the changes?"),
463                          tr("Apply"), tr("Discard"), tr("Cancel"))) {                          QMessageBox::Apply |
464                  case 0:     // Apply...                          QMessageBox::Discard |
465                            QMessageBox::Cancel)) {
466                    case QMessageBox::Apply:
467                          accept();                          accept();
468                          return;                          return;
469                  case 1:     // Discard                  case QMessageBox::Discard:
470                          break;                          break;
471                  default:    // Cancel.                  default:    // Cancel.
472                          bReject = false;                          bReject = false;
# Line 450  void ChannelForm::openInstrumentFile (vo Line 488  void ChannelForm::openInstrumentFile (vo
488          if (pMainForm->client() == NULL)          if (pMainForm->client() == NULL)
489                  return;                  return;
490    
491          qsamplerOptions *pOptions = pMainForm->options();          Options *pOptions = pMainForm->options();
492          if (pOptions == NULL)          if (pOptions == NULL)
493                  return;                  return;
494    
495          // FIXME: the instrument file filters should be restricted,          // FIXME: the instrument file filters should be restricted,
496          // depending on the current engine.          // depending on the current engine.
497            QStringList filters;
498            const QString& sEngineName = m_ui.EngineNameComboBox->currentText().toUpper();
499            if (sEngineName.contains("GIG"))
500                    filters << tr("GIG Instrument files") + " (*.gig *.dls)";
501            if (sEngineName.contains("SFZ"))
502                    filters << tr("SFZ Instrument files") + " (*.sfz)";
503            if (sEngineName.contains("SF2"))
504                    filters << tr("SF2 Instrument files") + " (*.sf2)";
505            filters << tr("All files") + " (*.*)";
506            const QString& filter = filters.join(";;");
507    
508          QString sInstrumentFile = QFileDialog::getOpenFileName(this,          QString sInstrumentFile = QFileDialog::getOpenFileName(this,
509                  QSAMPLER_TITLE ": " + tr("Instrument files"), // Caption.                  QSAMPLER_TITLE ": " + tr("Instrument files"), // Caption.
510                  pOptions->sInstrumentDir,                 // Start here.                  pOptions->sInstrumentDir, // Start here.
511                  tr("Instrument files") + " (*.gig *.dls)" // Filter (GIG and DLS files)                  filter                    // File filter.
512          );          );
513    
514          if (sInstrumentFile.isEmpty())          if (sInstrumentFile.isEmpty())
# Line 479  void ChannelForm::updateInstrumentName ( Line 528  void ChannelForm::updateInstrumentName (
528          if (pMainForm->client() == NULL)          if (pMainForm->client() == NULL)
529                  return;                  return;
530    
531          qsamplerOptions *pOptions = pMainForm->options();          Options *pOptions = pMainForm->options();
532          if (pOptions == NULL)          if (pOptions == NULL)
533                  return;                  return;
534    
# Line 487  void ChannelForm::updateInstrumentName ( Line 536  void ChannelForm::updateInstrumentName (
536          // to retrieve the REAL instrument names.          // to retrieve the REAL instrument names.
537          m_ui.InstrumentNrComboBox->clear();          m_ui.InstrumentNrComboBox->clear();
538          m_ui.InstrumentNrComboBox->insertItems(0,          m_ui.InstrumentNrComboBox->insertItems(0,
539                  qsamplerChannel::getInstrumentList(                  Channel::getInstrumentList(
540                          m_ui.InstrumentFileComboBox->currentText(),                          m_ui.InstrumentFileComboBox->currentText(),
541                          pOptions->bInstrumentNames)                          pOptions->bInstrumentNames)
542          );          );
# Line 497  void ChannelForm::updateInstrumentName ( Line 546  void ChannelForm::updateInstrumentName (
546    
547    
548  // Show device options dialog.  // Show device options dialog.
549  void ChannelForm::setupDevice ( qsamplerDevice *pDevice,  void ChannelForm::setupDevice ( Device *pDevice,
550          qsamplerDevice::DeviceType deviceTypeMode,          Device::DeviceType deviceTypeMode,
551          const QString& sDriverName )          const QString& sDriverName )
552  {  {
         if (pDevice == NULL)  
                 return;  
   
553          MainForm *pMainForm = MainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
554          if (pMainForm == NULL)          if (pMainForm == NULL)
555                  return;                  return;
# Line 541  void ChannelForm::selectMidiDriverItem ( Line 587  void ChannelForm::selectMidiDriverItem (
587          const QString sDriverName = sMidiDriver.toUpper();          const QString sDriverName = sMidiDriver.toUpper();
588    
589          // Save current device id.          // Save current device id.
         // Save current device id.  
590          int iDeviceID = 0;          int iDeviceID = 0;
591          qsamplerDevice *pDevice = NULL;          Device *pDevice = NULL;
592          int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();          int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();
593          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())
594                  pDevice = m_midiDevices.at(iMidiItem);                  pDevice = m_midiDevices.at(iMidiItem);
# Line 556  void ChannelForm::selectMidiDriverItem ( Line 601  void ChannelForm::selectMidiDriverItem (
601          m_midiDevices.clear();          m_midiDevices.clear();
602    
603          // Populate with the current ones...          // Populate with the current ones...
604          const QPixmap midiPixmap(":/icons/midi2.png");          const QPixmap midiPixmap(":/images/midi2.png");
605          int *piDeviceIDs = qsamplerDevice::getDevices(pMainForm->client(),          int *piDeviceIDs = Device::getDevices(pMainForm->client(), Device::Midi);
                 qsamplerDevice::Midi);  
606          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {
607                  pDevice = new qsamplerDevice(qsamplerDevice::Midi, piDeviceIDs[i]);                  pDevice = new Device(Device::Midi, piDeviceIDs[i]);
608                  if (pDevice->driverName().toUpper() == sDriverName) {                  if (pDevice->driverName().toUpper() == sDriverName) {
609                          m_ui.MidiDeviceComboBox->insertItem(0,                          m_ui.MidiDeviceComboBox->insertItem(0,
610                                  midiPixmap, pDevice->deviceName());                                  midiPixmap, pDevice->deviceName());
# Line 571  void ChannelForm::selectMidiDriverItem ( Line 615  void ChannelForm::selectMidiDriverItem (
615          }          }
616    
617          // Do proper enabling...          // Do proper enabling...
618          bool bEnabled = !m_midiDevices.isEmpty();          const bool bEnabled = !m_midiDevices.isEmpty();
619          if (bEnabled) {          if (bEnabled) {
620                  // Select the previous current device...                  // Select the previous current device...
621                  iMidiItem = 0;                  iMidiItem = 0;
622                  QListIterator<qsamplerDevice *> iter(m_midiDevices);                  QListIterator<Device *> iter(m_midiDevices);
623                  while (iter.hasNext()) {                  while (iter.hasNext()) {
624                          pDevice = iter.next();                          pDevice = iter.next();
625                          if (pDevice->deviceID() == iDeviceID) {                          if (pDevice->deviceID() == iDeviceID) {
# Line 608  void ChannelForm::selectMidiDriver ( con Line 652  void ChannelForm::selectMidiDriver ( con
652  // Select MIDI device item.  // Select MIDI device item.
653  void ChannelForm::selectMidiDeviceItem ( int iMidiItem )  void ChannelForm::selectMidiDeviceItem ( int iMidiItem )
654  {  {
655          qsamplerDevice *pDevice = NULL;          Device *pDevice = NULL;
656          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())
657                  pDevice = m_midiDevices.at(iMidiItem);                  pDevice = m_midiDevices.at(iMidiItem);
658          if (pDevice) {          if (pDevice) {
659                  const qsamplerDeviceParamMap& params = pDevice->params();                  const DeviceParamMap& params = pDevice->params();
660                  int iPorts = params["PORTS"].value.toInt();                  const int iPorts = params["PORTS"].value.toInt();
661                  m_ui.MidiPortTextLabel->setEnabled(iPorts > 0);                  m_ui.MidiPortTextLabel->setEnabled(iPorts > 0);
662                  m_ui.MidiPortSpinBox->setEnabled(iPorts > 0);                  m_ui.MidiPortSpinBox->setEnabled(iPorts > 0);
663                  if (iPorts > 0)                  if (iPorts > 0)
# Line 636  void ChannelForm::selectMidiDevice ( int Line 680  void ChannelForm::selectMidiDevice ( int
680  // MIDI device options.  // MIDI device options.
681  void ChannelForm::setupMidiDevice (void)  void ChannelForm::setupMidiDevice (void)
682  {  {
683          qsamplerDevice *pDevice = NULL;          Device *pDevice = NULL;
684          int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();          const int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex();
685          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())          if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count())
686                  pDevice = m_midiDevices.at(iMidiItem);                  pDevice = m_midiDevices.at(iMidiItem);
687          setupDevice(pDevice,          setupDevice(pDevice,
688                  qsamplerDevice::Midi, m_ui.MidiDriverComboBox->currentText());                  Device::Midi, m_ui.MidiDriverComboBox->currentText());
689  }  }
690    
691    
# Line 658  void ChannelForm::selectAudioDriverItem Line 702  void ChannelForm::selectAudioDriverItem
702    
703          // Save current device id.          // Save current device id.
704          int iDeviceID = 0;          int iDeviceID = 0;
705          qsamplerDevice *pDevice = NULL;          Device *pDevice = NULL;
706          int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();          int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();
707          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())
708                  pDevice = m_audioDevices.at(iAudioItem);                  pDevice = m_audioDevices.at(iAudioItem);
# Line 671  void ChannelForm::selectAudioDriverItem Line 715  void ChannelForm::selectAudioDriverItem
715          m_audioDevices.clear();          m_audioDevices.clear();
716    
717          // Populate with the current ones...          // Populate with the current ones...
718          const QPixmap audioPixmap(":/icons/audio2.png");          const QPixmap audioPixmap(":/images/audio2.png");
719          int *piDeviceIDs = qsamplerDevice::getDevices(pMainForm->client(),          int *piDeviceIDs = Device::getDevices(pMainForm->client(),
720                  qsamplerDevice::Audio);                  Device::Audio);
721          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {
722                  pDevice = new qsamplerDevice(qsamplerDevice::Audio, piDeviceIDs[i]);                  pDevice = new Device(Device::Audio, piDeviceIDs[i]);
723                  if (pDevice->driverName().toUpper() == sDriverName) {                  if (pDevice->driverName().toUpper() == sDriverName) {
724                          m_ui.AudioDeviceComboBox->insertItem(0,                          m_ui.AudioDeviceComboBox->insertItem(0,
725                                  audioPixmap, pDevice->deviceName());                                  audioPixmap, pDevice->deviceName());
# Line 686  void ChannelForm::selectAudioDriverItem Line 730  void ChannelForm::selectAudioDriverItem
730          }          }
731    
732          // Do proper enabling...          // Do proper enabling...
733          bool bEnabled = !m_audioDevices.isEmpty();          const bool bEnabled = !m_audioDevices.isEmpty();
734          if (bEnabled) {          if (bEnabled) {
735                  // Select the previous current device...                  // Select the previous current device...
736                  iAudioItem = 0;                  iAudioItem = 0;
737                  QListIterator<qsamplerDevice *> iter(m_audioDevices);                  QListIterator<Device *> iter(m_audioDevices);
738                  while (iter.hasNext()) {                  while (iter.hasNext()) {
739                          pDevice = iter.next();                          pDevice = iter.next();
740                          if (pDevice->deviceID() == iDeviceID) {                          if (pDevice->deviceID() == iDeviceID) {
# Line 725  void ChannelForm::selectAudioDriver ( co Line 769  void ChannelForm::selectAudioDriver ( co
769  // Select Audio device item.  // Select Audio device item.
770  void ChannelForm::selectAudioDeviceItem ( int iAudioItem )  void ChannelForm::selectAudioDeviceItem ( int iAudioItem )
771  {  {
772          qsamplerDevice *pDevice = NULL;          Device *pDevice = NULL;
773          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())
774                  pDevice = m_audioDevices.at(iAudioItem);                  pDevice = m_audioDevices.at(iAudioItem);
775          if (pDevice) {          if (pDevice) {
# Line 751  void ChannelForm::selectAudioDevice ( in Line 795  void ChannelForm::selectAudioDevice ( in
795  // Audio device options.  // Audio device options.
796  void ChannelForm::setupAudioDevice (void)  void ChannelForm::setupAudioDevice (void)
797  {  {
798          qsamplerDevice *pDevice = NULL;          Device *pDevice = NULL;
799          int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();          const int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex();
800          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())          if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count())
801                  pDevice = m_audioDevices.at(iAudioItem);                  pDevice = m_audioDevices.at(iAudioItem);
802          setupDevice(pDevice,          setupDevice(pDevice,
803                  qsamplerDevice::Audio, m_ui.AudioDriverComboBox->currentText());                  Device::Audio, m_ui.AudioDriverComboBox->currentText());
804  }  }
805    
806  // UPdate all device lists slot.  // UPdate all device lists slot.
# Line 785  void ChannelForm::optionsChanged (void) Line 829  void ChannelForm::optionsChanged (void)
829  // Stabilize current form state.  // Stabilize current form state.
830  void ChannelForm::stabilizeForm (void)  void ChannelForm::stabilizeForm (void)
831  {  {
832          const bool bValid =          bool bValid = m_ui.EngineNameComboBox->currentIndex() >= 0 &&
833                  m_ui.EngineNameComboBox->currentIndex() >= 0 &&                  m_ui.EngineNameComboBox->currentText() != Channel::noEngineName();
834                  m_ui.EngineNameComboBox->currentText()  
835                          != qsamplerChannel::noEngineName();          const QString& sPath = m_ui.InstrumentFileComboBox->currentText();
 #if 0  
         const QString& sPath = InstrumentFileComboBox->currentText();  
836          bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists();          bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists();
837  #endif  
838          m_ui.OkPushButton->setEnabled(m_iDirtyCount > 0 && bValid);          m_ui.DialogButtonBox->button(
839                    QDialogButtonBox::Ok)->setEnabled(m_iDirtyCount > 0 && bValid);
840  }  }
841    
842    

Legend:
Removed from v.1519  
changed lines
  Added in v.3385

  ViewVC Help
Powered by ViewVC