/[svn]/qsampler/trunk/src/qsamplerChannelForm.ui.h
ViewVC logotype

Annotation of /qsampler/trunk/src/qsamplerChannelForm.ui.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1016 - (hide annotations) (download) (as text)
Mon Jan 8 22:04:33 2007 UTC (17 years, 3 months ago) by capela
File MIME type: text/x-c++hdr
File size: 19736 byte(s)
* MIDI instrument item editing has been fixed (hopefully).

* Sampler channel setup dialog does not mandate for valid nor
  existing instrument file name; dropped MIDI port from sampler
  channel strip display, only MIDI channel is now displayed.

1 capela 104 // qsamplerChannelForm.ui.h
2     //
3     // ui.h extension file, included from the uic-generated form implementation.
4     /****************************************************************************
5 capela 1016 Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved.
6 capela 104
7     This program is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License
9     as published by the Free Software Foundation; either version 2
10     of the License, or (at your option) any later version.
11    
12     This program is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     GNU General Public License for more details.
16    
17 capela 920 You should have received a copy of the GNU General Public License along
18     with this program; if not, write to the Free Software Foundation, Inc.,
19     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 capela 104
21     *****************************************************************************/
22    
23 capela 757 #include "qsamplerAbout.h"
24     #include "qsamplerDeviceForm.h"
25    
26 capela 961 #include "qsamplerMainForm.h"
27 capela 980 #include "qsamplerInstrument.h"
28 capela 961
29 capela 980
30 capela 104 #include <qvalidator.h>
31     #include <qmessagebox.h>
32     #include <qfiledialog.h>
33     #include <qfileinfo.h>
34     #include <qlistbox.h>
35    
36 capela 487
37 capela 104 // Kind of constructor.
38     void qsamplerChannelForm::init (void)
39     {
40 capela 490 // Initialize locals.
41     m_pChannel = NULL;
42 capela 104
43 capela 490 m_iDirtySetup = 0;
44     m_iDirtyCount = 0;
45 capela 104
46 capela 452 m_midiDevices.setAutoDelete(true);
47     m_audioDevices.setAutoDelete(true);
48    
49 capela 487 m_pDeviceForm = NULL;
50 capela 490
51     // Try to restore normal window positioning.
52     adjustSize();
53 capela 104 }
54    
55    
56     // Kind of destructor.
57     void qsamplerChannelForm::destroy (void)
58     {
59 capela 487 if (m_pDeviceForm)
60 capela 490 delete m_pDeviceForm;
61 capela 487 m_pDeviceForm = NULL;
62 capela 104 }
63    
64    
65     // Channel dialog setup formal initializer.
66 capela 295 void qsamplerChannelForm::setup ( qsamplerChannel *pChannel )
67 capela 104 {
68 capela 490 m_pChannel = pChannel;
69 capela 104
70 capela 490 m_iDirtySetup = 0;
71     m_iDirtyCount = 0;
72 capela 104
73 capela 490 if (m_pChannel == NULL)
74     return;
75 capela 104
76 capela 490 // It can be a brand new channel, remember?
77     bool bNew = (m_pChannel->channelID() < 0);
78 capela 757 setCaption(QSAMPLER_TITLE ": " + m_pChannel->channelName());
79 capela 104
80 capela 490 // Check if we're up and connected.
81 capela 961 qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
82     if (pMainForm == NULL)
83 capela 490 return;
84 capela 961 if (pMainForm->client() == NULL)
85     return;
86 capela 104
87 capela 961 qsamplerOptions *pOptions = pMainForm->options();
88 capela 490 if (pOptions == NULL)
89     return;
90 capela 104
91 capela 490 // Avoid nested changes.
92     m_iDirtySetup++;
93 capela 104
94 capela 490 // Load combo box history...
95     pOptions->loadComboBoxHistory(InstrumentFileComboBox);
96 capela 104
97 capela 758 // Notify.that we've just changed one audio route.
98     QObject::connect(AudioRoutingTable, SIGNAL(valueChanged(int,int)),
99     this, SLOT(changeAudioRouting(int,int)));
100    
101 capela 490 // Populate Engines list.
102 capela 961 const char **ppszEngines = ::lscp_list_available_engines(pMainForm->client());
103 capela 490 if (ppszEngines) {
104     EngineNameComboBox->clear();
105     for (int iEngine = 0; ppszEngines[iEngine]; iEngine++)
106     EngineNameComboBox->insertItem(ppszEngines[iEngine]);
107     }
108 capela 525 else m_pChannel->appendMessagesClient("lscp_list_available_engines");
109 capela 145
110 capela 490 // Populate Audio output type list.
111     AudioDriverComboBox->clear();
112     AudioDriverComboBox->insertStringList(
113 capela 961 qsamplerDevice::getDrivers(pMainForm->client(), qsamplerDevice::Audio));
114 capela 104
115 capela 490 // Populate MIDI input type list.
116     MidiDriverComboBox->clear();
117     MidiDriverComboBox->insertStringList(
118 capela 961 qsamplerDevice::getDrivers(pMainForm->client(), qsamplerDevice::Midi));
119 capela 145
120 capela 980 // Populate Maps list.
121     MidiMapComboBox->clear();
122     MidiMapComboBox->insertStringList(qsamplerInstrument::getMapNames());
123    
124 capela 490 // Read proper channel information,
125     // and populate the channel form fields.
126 capela 104
127 capela 490 // Engine name...
128     QString sEngineName = pChannel->engineName();
129     if (sEngineName.isEmpty() || bNew)
130     sEngineName = pOptions->sEngineName;
131     if (sEngineName.isEmpty())
132     sEngineName = qsamplerChannel::noEngineName();
133     if (EngineNameComboBox->listBox()->findItem(sEngineName,
134     Qt::ExactMatch | Qt::CaseSensitive) == NULL) {
135     EngineNameComboBox->insertItem(sEngineName);
136     }
137     EngineNameComboBox->setCurrentText(sEngineName);
138     // Instrument filename and index...
139     QString sInstrumentFile = pChannel->instrumentFile();
140     if (sInstrumentFile.isEmpty())
141     sInstrumentFile = qsamplerChannel::noInstrumentName();
142     InstrumentFileComboBox->setCurrentText(sInstrumentFile);
143     InstrumentNrComboBox->clear();
144     InstrumentNrComboBox->insertStringList(
145 capela 344 qsamplerChannel::getInstrumentList(sInstrumentFile,
146     pOptions->bInstrumentNames));
147 capela 490 InstrumentNrComboBox->setCurrentItem(pChannel->instrumentNr());
148    
149 capela 452 // MIDI input device...
150 capela 961 qsamplerDevice midiDevice(qsamplerDevice::Midi, m_pChannel->midiDevice());
151 capela 490 // MIDI input driver...
152 capela 452 QString sMidiDriver = midiDevice.driverName();
153     if (sMidiDriver.isEmpty() || bNew)
154 capela 490 sMidiDriver = pOptions->sMidiDriver.upper();
155 capela 452 if (!sMidiDriver.isEmpty()) {
156 capela 490 if (MidiDriverComboBox->listBox()->findItem(sMidiDriver,
157     Qt::ExactMatch | Qt::CaseSensitive) == NULL) {
158 capela 452 MidiDriverComboBox->insertItem(sMidiDriver);
159 capela 490 }
160 capela 452 MidiDriverComboBox->setCurrentText(sMidiDriver);
161     }
162 capela 488 selectMidiDriverItem(sMidiDriver);
163 capela 452 if (!bNew)
164     MidiDeviceComboBox->setCurrentText(midiDevice.deviceName());
165 capela 488 selectMidiDeviceItem(MidiDeviceComboBox->currentItem());
166 capela 490 // MIDI input port...
167     MidiPortSpinBox->setValue(pChannel->midiPort());
168     // MIDI input channel...
169     int iMidiChannel = pChannel->midiChannel();
170     // When new, try to suggest a sensible MIDI channel...
171     if (iMidiChannel < 0)
172 capela 961 iMidiChannel = (::lscp_get_channels(pMainForm->client()) % 16);
173 capela 490 MidiChannelComboBox->setCurrentItem(iMidiChannel);
174 capela 980 // MIDI instrument map...
175     int iMidiMap = (bNew ? pOptions->iMidiMap : pChannel->midiMap());
176     // When new, try to suggest a sensible MIDI map...
177     if (iMidiMap < 0)
178     iMidiMap = 0;
179     const QString& sMapName = qsamplerInstrument::getMapName(iMidiMap);
180     if (!sMapName.isEmpty())
181     MidiMapComboBox->setCurrentText(sMapName);
182     // It might be no maps around...
183     bool bMidiMapEnabled = (MidiMapComboBox->count() > 0);
184     MidiMapTextLabel->setEnabled(bMidiMapEnabled);
185     MidiMapComboBox->setEnabled(bMidiMapEnabled);
186 capela 455
187 capela 452 // Audio output device...
188 capela 961 qsamplerDevice audioDevice(qsamplerDevice::Audio, m_pChannel->audioDevice());
189 capela 452 // Audio output driver...
190     QString sAudioDriver = audioDevice.driverName();
191     if (sAudioDriver.isEmpty() || bNew)
192 capela 490 sAudioDriver = pOptions->sAudioDriver.upper();
193 capela 452 if (!sAudioDriver.isEmpty()) {
194 capela 490 if (AudioDriverComboBox->listBox()->findItem(sAudioDriver,
195     Qt::ExactMatch | Qt::CaseSensitive) == NULL) {
196 capela 452 AudioDriverComboBox->insertItem(sAudioDriver);
197 capela 490 }
198 capela 452 AudioDriverComboBox->setCurrentText(sAudioDriver);
199     }
200 capela 488 selectAudioDriverItem(sAudioDriver);
201 capela 452 if (!bNew)
202     AudioDeviceComboBox->setCurrentText(audioDevice.deviceName());
203 capela 488 selectAudioDeviceItem(AudioDeviceComboBox->currentItem());
204 capela 452
205 capela 391 // As convenient, make it ready on stabilizeForm() for
206     // prompt acceptance, if we got the minimum required...
207 capela 759 /* if (sEngineName != qsamplerChannel::noEngineName() &&
208 capela 395 sInstrumentFile != qsamplerChannel::noInstrumentName())
209 capela 759 m_iDirtyCount++; */
210 capela 490 // Done.
211     m_iDirtySetup--;
212     stabilizeForm();
213 capela 104 }
214    
215    
216     // Accept settings (OK button slot).
217     void qsamplerChannelForm::accept (void)
218     {
219 capela 490 if (m_pChannel == NULL)
220     return;
221 capela 104
222 capela 961 qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
223     if (pMainForm == NULL)
224     return;
225     if (pMainForm->client() == NULL)
226     return;
227    
228     qsamplerOptions *pOptions = pMainForm->options();
229 capela 490 if (pOptions == NULL)
230     return;
231 capela 104
232 capela 767 // Flush any pending editing...
233     AudioRoutingTable->flush();
234    
235 capela 490 // We'll go for it!
236     if (m_iDirtyCount > 0) {
237     int iErrors = 0;
238     // Are we a new channel?
239     if (!m_pChannel->addChannel())
240     iErrors++;
241 capela 452 // Accept Audio driver or device selection...
242     if (m_audioDevices.isEmpty()) {
243     if (!m_pChannel->setAudioDriver(AudioDriverComboBox->currentText()))
244     iErrors++;
245     } else {
246     qsamplerDevice *pDevice = m_audioDevices.at(AudioDeviceComboBox->currentItem());
247     if (pDevice == NULL)
248     iErrors++;
249     else if (!m_pChannel->setAudioDevice(pDevice->deviceID()))
250     iErrors++;
251 capela 758 else if (!m_audioRouting.isEmpty()) {
252     // Set the audio route changes...
253     qsamplerChannelRoutingMap::ConstIterator iter;
254     for (iter = m_audioRouting.begin();
255     iter != m_audioRouting.end(); ++iter) {
256     if (!m_pChannel->setAudioChannel(iter.key(), iter.data()))
257     iErrors++;
258     }
259     }
260 capela 452 }
261     // Accept MIDI driver or device selection...
262     if (m_midiDevices.isEmpty()) {
263     if (!m_pChannel->setMidiDriver(MidiDriverComboBox->currentText()))
264     iErrors++;
265     } else {
266     qsamplerDevice *pDevice = m_midiDevices.at(MidiDeviceComboBox->currentItem());
267     if (pDevice == NULL)
268     iErrors++;
269     else if (!m_pChannel->setMidiDevice(pDevice->deviceID()))
270     iErrors++;
271     }
272 capela 490 // MIDI input port number...
273     if (!m_pChannel->setMidiPort(MidiPortSpinBox->value()))
274     iErrors++;
275     // MIDI input channel...
276     if (!m_pChannel->setMidiChannel(MidiChannelComboBox->currentItem()))
277     iErrors++;
278     // Engine name...
279     if (!m_pChannel->loadEngine(EngineNameComboBox->currentText()))
280     iErrors++;
281     // Instrument file and index...
282 capela 980 const QString& sPath = InstrumentFileComboBox->currentText();
283     if (!sPath.isEmpty() && QFileInfo(sPath).exists()) {
284     if (!m_pChannel->loadInstrument(sPath, InstrumentNrComboBox->currentItem()))
285     iErrors++;
286     }
287     // MIDI intrument map...
288     if (!m_pChannel->setMidiMap(MidiMapComboBox->currentItem()))
289 capela 490 iErrors++;
290     // Show error messages?
291     if (iErrors > 0)
292     m_pChannel->appendMessagesError(tr("Some channel settings could not be set.\n\nSorry."));
293     }
294 capela 104
295 capela 490 // Save default engine name, instrument directory and history...
296     pOptions->sInstrumentDir = QFileInfo(InstrumentFileComboBox->currentText()).dirPath(true);
297     pOptions->sEngineName = EngineNameComboBox->currentText();
298     pOptions->sAudioDriver = AudioDriverComboBox->currentText();
299     pOptions->sMidiDriver = MidiDriverComboBox->currentText();
300 capela 980 pOptions->iMidiMap = MidiMapComboBox->currentItem();
301 capela 490 pOptions->saveComboBoxHistory(InstrumentFileComboBox);
302 capela 104
303 capela 490 // Just go with dialog acceptance.
304     QDialog::accept();
305 capela 104 }
306    
307    
308     // Reject settings (Cancel button slot).
309     void qsamplerChannelForm::reject (void)
310     {
311 capela 490 bool bReject = true;
312 capela 104
313 capela 490 // Check if there's any pending changes...
314     if (m_iDirtyCount > 0 && OkPushButton->isEnabled()) {
315 capela 757 switch (QMessageBox::warning(this,
316     QSAMPLER_TITLE ": " + tr("Warning"),
317 capela 490 tr("Some channel settings have been changed.\n\n"
318     "Do you want to apply the changes?"),
319     tr("Apply"), tr("Discard"), tr("Cancel"))) {
320     case 0: // Apply...
321     accept();
322     return;
323     case 1: // Discard
324     break;
325     default: // Cancel.
326     bReject = false;
327 capela 961 break;
328 capela 490 }
329     }
330 capela 104
331 capela 490 if (bReject)
332     QDialog::reject();
333 capela 104 }
334    
335    
336     // Browse and open an instrument file.
337     void qsamplerChannelForm::openInstrumentFile (void)
338     {
339 capela 961 qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
340     if (pMainForm == NULL)
341     return;
342     if (pMainForm->client() == NULL)
343     return;
344    
345     qsamplerOptions *pOptions = pMainForm->options();
346 capela 490 if (pOptions == NULL)
347     return;
348 capela 104
349 capela 490 // FIXME: the instrument file filters should be restricted,
350     // depending on the current engine.
351     QString sInstrumentFile = QFileDialog::getOpenFileName(
352 capela 757 pOptions->sInstrumentDir, // Start here.
353     tr("Instrument files") + " (*.gig *.dls)", // Filter (GIG and DLS files)
354     this, 0, // Parent and name (none)
355     QSAMPLER_TITLE ": " + tr("Instrument files") // Caption.
356 capela 490 );
357 capela 104
358 capela 490 if (sInstrumentFile.isEmpty())
359     return;
360 capela 104
361 capela 490 InstrumentFileComboBox->setCurrentText(sInstrumentFile);
362 capela 525 updateInstrumentName();
363 capela 104 }
364    
365    
366     // Refresh the actual instrument name.
367     void qsamplerChannelForm::updateInstrumentName (void)
368     {
369 capela 961 qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
370     if (pMainForm == NULL)
371     return;
372     if (pMainForm->client() == NULL)
373     return;
374    
375     qsamplerOptions *pOptions = pMainForm->options();
376 capela 490 if (pOptions == NULL)
377     return;
378 capela 341
379 capela 490 // Finally this better idea would be to use libgig
380     // to retrieve the REAL instrument names.
381     InstrumentNrComboBox->clear();
382     InstrumentNrComboBox->insertStringList(
383     qsamplerChannel::getInstrumentList(
384 capela 344 InstrumentFileComboBox->currentText(),
385     pOptions->bInstrumentNames)
386 capela 490 );
387 capela 104
388 capela 490 optionsChanged();
389 capela 104 }
390    
391 capela 961
392 capela 487 // Show device options dialog.
393 capela 490 void qsamplerChannelForm::setupDevice ( qsamplerDevice *pDevice,
394     qsamplerDevice::qsamplerDeviceType deviceTypeMode,
395     const QString& sDriverName )
396 capela 487 {
397 capela 961 qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
398     if (pMainForm == NULL)
399     return;
400     if (pMainForm->client() == NULL)
401     return;
402    
403 capela 487 // Create the device form if not already...
404     if (m_pDeviceForm == NULL) {
405     m_pDeviceForm = new qsamplerDeviceForm(this, 0,
406     WType_Dialog | WShowModal);
407 capela 488 QObject::connect(m_pDeviceForm, SIGNAL(devicesChanged()),
408 capela 490 this, SLOT(updateDevices()));
409 capela 487 }
410    
411     // Refresh the device form with selected data.
412     if (m_pDeviceForm) {
413 capela 490 m_pDeviceForm->setDeviceTypeMode(deviceTypeMode);
414 capela 961 m_pDeviceForm->refreshDevices();
415 capela 490 m_pDeviceForm->setDevice(pDevice);
416     m_pDeviceForm->setDriverName(sDriverName);
417 capela 487 m_pDeviceForm->show();
418     }
419     }
420    
421    
422 capela 488 // Refresh MIDI driver item devices.
423     void qsamplerChannelForm::selectMidiDriverItem ( const QString& sMidiDriver )
424 capela 452 {
425 capela 961 qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
426     if (pMainForm == NULL)
427     return;
428     if (pMainForm->client() == NULL)
429     return;
430    
431 capela 454 const QString sDriverName = sMidiDriver.upper();
432 capela 488
433     // Save current device id.
434 capela 759 int iDeviceID = 0;
435 capela 488 qsamplerDevice *pDevice = m_midiDevices.at(MidiDeviceComboBox->currentItem());
436     if (pDevice)
437 capela 490 iDeviceID = pDevice->deviceID();
438 capela 488
439     // Clean maplist.
440 capela 452 MidiDeviceComboBox->clear();
441 capela 488 m_midiDevices.clear();
442 capela 104
443 capela 488 // Populate with the current ones...
444 capela 452 const QPixmap& midiPixmap = QPixmap::fromMimeSource("midi2.png");
445 capela 961 int *piDeviceIDs = qsamplerDevice::getDevices(pMainForm->client(),
446 capela 452 qsamplerDevice::Midi);
447     for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {
448 capela 961 pDevice = new qsamplerDevice(qsamplerDevice::Midi, piDeviceIDs[i]);
449 capela 454 if (pDevice->driverName().upper() == sDriverName) {
450 capela 452 MidiDeviceComboBox->insertItem(midiPixmap, pDevice->deviceName());
451     m_midiDevices.append(pDevice);
452     } else {
453     delete pDevice;
454     }
455     }
456    
457 capela 488 // Do proper enabling...
458 capela 452 bool bEnabled = !m_midiDevices.isEmpty();
459 capela 759 if (bEnabled) {
460 capela 490 // Select the previous current device...
461     int iMidiItem = 0;
462     for (pDevice = m_midiDevices.first();
463     pDevice;
464     pDevice = m_midiDevices.next()) {
465     if (pDevice->deviceID() == iDeviceID) {
466 capela 488 MidiDeviceComboBox->setCurrentItem(iMidiItem);
467 capela 758 selectMidiDeviceItem(iMidiItem);
468 capela 490 break;
469     }
470 capela 488 iMidiItem++;
471     }
472 capela 759 } else {
473     MidiDeviceComboBox->insertItem(
474     tr("(New MIDI %1 device)").arg(sMidiDriver));
475 capela 488 }
476 capela 452 MidiDeviceTextLabel->setEnabled(bEnabled);
477     MidiDeviceComboBox->setEnabled(bEnabled);
478 capela 488 }
479    
480    
481     // Refresh MIDI device options slot.
482     void qsamplerChannelForm::selectMidiDriver ( const QString& sMidiDriver )
483     {
484     if (m_iDirtySetup > 0)
485 capela 490 return;
486 capela 488
487     selectMidiDriverItem(sMidiDriver);
488 capela 452 optionsChanged();
489     }
490    
491    
492 capela 488 // Select MIDI device item.
493     void qsamplerChannelForm::selectMidiDeviceItem ( int iMidiItem )
494 capela 455 {
495     qsamplerDevice *pDevice = m_midiDevices.at(iMidiItem);
496     if (pDevice) {
497 capela 462 const qsamplerDeviceParamMap& params = pDevice->params();
498 capela 455 int iPorts = params["PORTS"].value.toInt();
499     MidiPortTextLabel->setEnabled(iPorts > 0);
500     MidiPortSpinBox->setEnabled(iPorts > 0);
501     if (iPorts > 0)
502     MidiPortSpinBox->setMaxValue(iPorts - 1);
503     }
504 capela 488 }
505    
506    
507     // Select MIDI device options slot.
508     void qsamplerChannelForm::selectMidiDevice ( int iMidiItem )
509     {
510     if (m_iDirtySetup > 0)
511 capela 490 return;
512 capela 488
513     selectMidiDeviceItem(iMidiItem);
514 capela 455 optionsChanged();
515     }
516    
517    
518 capela 487 // MIDI device options.
519     void qsamplerChannelForm::setupMidiDevice (void)
520     {
521 capela 490 setupDevice(m_midiDevices.at(MidiDeviceComboBox->currentItem()),
522     qsamplerDevice::Midi, MidiDriverComboBox->currentText());
523 capela 487 }
524    
525    
526 capela 488 // Refresh Audio driver item devices.
527     void qsamplerChannelForm::selectAudioDriverItem ( const QString& sAudioDriver )
528 capela 452 {
529 capela 961 qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
530     if (pMainForm == NULL)
531     return;
532     if (pMainForm->client() == NULL)
533     return;
534    
535 capela 454 const QString sDriverName = sAudioDriver.upper();
536    
537 capela 488 // Save current device id.
538 capela 759 int iDeviceID = 0;
539 capela 488 qsamplerDevice *pDevice = m_audioDevices.at(AudioDeviceComboBox->currentItem());
540     if (pDevice)
541 capela 490 iDeviceID = pDevice->deviceID();
542 capela 488
543     // Clean maplist.
544 capela 452 AudioDeviceComboBox->clear();
545     m_audioDevices.clear();
546    
547 capela 488 // Populate with the current ones...
548 capela 452 const QPixmap& audioPixmap = QPixmap::fromMimeSource("audio2.png");
549 capela 961 int *piDeviceIDs = qsamplerDevice::getDevices(pMainForm->client(),
550 capela 452 qsamplerDevice::Audio);
551     for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {
552 capela 961 pDevice = new qsamplerDevice(qsamplerDevice::Audio, piDeviceIDs[i]);
553 capela 454 if (pDevice->driverName().upper() == sDriverName) {
554 capela 452 AudioDeviceComboBox->insertItem(audioPixmap, pDevice->deviceName());
555     m_audioDevices.append(pDevice);
556     } else {
557     delete pDevice;
558     }
559     }
560    
561 capela 488 // Do proper enabling...
562 capela 452 bool bEnabled = !m_audioDevices.isEmpty();
563 capela 759 if (bEnabled) {
564 capela 490 // Select the previous current device...
565     int iAudioItem = 0;
566     for (pDevice = m_audioDevices.first();
567     pDevice;
568     pDevice = m_audioDevices.next()) {
569     if (pDevice->deviceID() == iDeviceID) {
570 capela 488 AudioDeviceComboBox->setCurrentItem(iAudioItem);
571 capela 758 selectAudioDeviceItem(iAudioItem);
572 capela 490 break;
573     }
574 capela 488 iAudioItem++;
575     }
576 capela 759 } else {
577     AudioDeviceComboBox->insertItem(
578     tr("(New Audio %1 device)").arg(sAudioDriver));
579     AudioRoutingTable->setNumRows(0);
580 capela 488 }
581 capela 452 AudioDeviceTextLabel->setEnabled(bEnabled);
582     AudioDeviceComboBox->setEnabled(bEnabled);
583 capela 758 AudioRoutingTable->setEnabled(bEnabled);
584 capela 488 }
585    
586    
587     // Refresh Audio device options slot.
588     void qsamplerChannelForm::selectAudioDriver ( const QString& sAudioDriver )
589     {
590     if (m_iDirtySetup > 0)
591 capela 490 return;
592    
593 capela 488 selectAudioDriverItem(sAudioDriver);
594 capela 452 optionsChanged();
595     }
596    
597    
598 capela 488 // Select Audio device item.
599     void qsamplerChannelForm::selectAudioDeviceItem ( int iAudioItem )
600 capela 455 {
601     qsamplerDevice *pDevice = m_audioDevices.at(iAudioItem);
602     if (pDevice) {
603 capela 758 // Refresh the audio routing table.
604     AudioRoutingTable->refresh(pDevice, m_pChannel->audioRouting());
605     // Reset routing change map.
606     m_audioRouting.clear();
607 capela 455 }
608 capela 488 }
609    
610    
611     // Select Audio device options slot.
612     void qsamplerChannelForm::selectAudioDevice ( int iAudioItem )
613     {
614     if (m_iDirtySetup > 0)
615 capela 490 return;
616 capela 488
617     selectAudioDeviceItem(iAudioItem);
618 capela 455 optionsChanged();
619     }
620    
621    
622 capela 487 // Audio device options.
623     void qsamplerChannelForm::setupAudioDevice (void)
624     {
625 capela 490 setupDevice(m_audioDevices.at(AudioDeviceComboBox->currentItem()),
626     qsamplerDevice::Audio, AudioDriverComboBox->currentText());
627 capela 487 }
628    
629    
630 capela 758 // Audio routing change slot.
631     void qsamplerChannelForm::changeAudioRouting ( int iRow, int iCol )
632     {
633     if (m_iDirtySetup > 0)
634     return;
635     if (iRow < 0 || iCol < 0)
636     return;
637    
638     // Verify that this is a QComboTableItem (magic rtti == 1)
639     QTableItem *pItem = AudioRoutingTable->item(iRow, iCol);
640     if (pItem == NULL)
641     return;
642 capela 759 qsamplerChannelRoutingComboBox *pComboItem =
643     static_cast<qsamplerChannelRoutingComboBox*> (pItem);
644     // FIXME: Its not garanteed that we must have
645     // iAudioOut == iRow on all times forth!
646     m_audioRouting[iRow] = pComboItem->currentItem();
647    
648     // And let's get dirty...
649     optionsChanged();
650 capela 758 }
651    
652    
653 capela 488 // UPdate all device lists slot.
654     void qsamplerChannelForm::updateDevices (void)
655     {
656 capela 490 if (m_iDirtySetup > 0)
657     return;
658 capela 488
659     selectMidiDriverItem(MidiDriverComboBox->currentText());
660     selectAudioDriverItem(AudioDriverComboBox->currentText());
661     optionsChanged();
662     }
663    
664    
665 capela 104 // Dirty up settings.
666     void qsamplerChannelForm::optionsChanged (void)
667     {
668 capela 490 if (m_iDirtySetup > 0)
669     return;
670 capela 104
671 capela 490 m_iDirtyCount++;
672     stabilizeForm();
673 capela 104 }
674    
675    
676     // Stabilize current form state.
677     void qsamplerChannelForm::stabilizeForm (void)
678     {
679 capela 980 bool bValid = true;
680 capela 1016 #if 0
681 capela 980 const QString& sPath = InstrumentFileComboBox->currentText();
682     bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists();
683 capela 1016 #endif
684 capela 980 OkPushButton->setEnabled(m_iDirtyCount > 0 && bValid);
685 capela 104 }
686    
687    
688     // end of qsamplerChannelForm.ui.h

  ViewVC Help
Powered by ViewVC