/[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 149 by capela, Sat Jun 26 14:27:25 2004 UTC revision 430 by capela, Tue Mar 8 17:23:29 2005 UTC
# Line 2  Line 2 
2  //  //
3  // ui.h extension file, included from the uic-generated form implementation.  // ui.h extension file, included from the uic-generated form implementation.
4  /****************************************************************************  /****************************************************************************
5     Copyright (C) 2004, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2005, rncbc aka Rui Nuno Capela. All rights reserved.
6    
7     This program is free software; you can redistribute it and/or     This program is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License     modify it under the terms of the GNU General Public License
# Line 26  Line 26 
26  #include <qfileinfo.h>  #include <qfileinfo.h>
27  #include <qlistbox.h>  #include <qlistbox.h>
28    
29  #include "qsamplerOptions.h"  #include "qsamplerDevice.h"
 #include "qsamplerChannelStrip.h"  
30    
31  #include "config.h"  #include "config.h"
32    
# Line 53  void qsamplerChannelForm::destroy (void) Line 52  void qsamplerChannelForm::destroy (void)
52    
53    
54  // Channel dialog setup formal initializer.  // Channel dialog setup formal initializer.
55  void qsamplerChannelForm::setup ( qsamplerChannelStrip *pChannel )  void qsamplerChannelForm::setup ( qsamplerChannel *pChannel )
56  {  {
57      m_pChannel = pChannel;      m_pChannel = pChannel;
58    
# Line 63  void qsamplerChannelForm::setup ( qsampl Line 62  void qsamplerChannelForm::setup ( qsampl
62      if (m_pChannel == NULL)      if (m_pChannel == NULL)
63          return;          return;
64    
65      setCaption(m_pChannel->caption());      // It can be a brand new channel, remember?
66        bool bNew = (m_pChannel->channelID() < 0);
67        setCaption(m_pChannel->channelName());
68    
69      // Check if we're up and connected.      // Check if we're up and connected.
70      if (m_pChannel->client() == NULL)      if (m_pChannel->client() == NULL)
# Line 89  void qsamplerChannelForm::setup ( qsampl Line 90  void qsamplerChannelForm::setup ( qsampl
90      else m_pChannel->appendMessagesClient("lscp_get_available_engines");      else m_pChannel->appendMessagesClient("lscp_get_available_engines");
91    
92      // Populate Audio output type list.      // Populate Audio output type list.
93      const char **ppszAudioDrivers = ::lscp_get_available_audio_drivers(m_pChannel->client());      AudioDriverComboBox->clear();
94      if (ppszAudioDrivers) {      AudioDriverComboBox->insertStringList(
95          AudioDriverComboBox->clear();                  qsamplerDevice::getDrivers(m_pChannel->client(), qsamplerDevice::Audio));
         for (int iAudioDriver = 0; ppszAudioDrivers[iAudioDriver]; iAudioDriver++)  
             AudioDriverComboBox->insertItem(ppszAudioDrivers[iAudioDriver]);  
     }  
     else m_pChannel->appendMessagesClient("lscp_get_available_audio_drivers");  
96    
97      // Populate MIDI input type list.      // Populate MIDI input type list.
98      const char **ppszMidiDrivers = ::lscp_get_available_midi_drivers(m_pChannel->client());      MidiDriverComboBox->clear();
99      if (ppszMidiDrivers) {      MidiDriverComboBox->insertStringList(
100          MidiDriverComboBox->clear();                  qsamplerDevice::getDrivers(m_pChannel->client(), qsamplerDevice::Midi));
         for (int iMidiDriver = 0; ppszMidiDrivers[iMidiDriver]; iMidiDriver++)  
             MidiDriverComboBox->insertItem(ppszMidiDrivers[iMidiDriver]);  
     }  
     else m_pChannel->appendMessagesClient("lscp_get_available_midi_drivers");  
101    
102      // Read proper channel information,      // Read proper channel information,
103      // and populate the channel form fields.      // and populate the channel form fields.
104    
105      // Engine name...      // Engine name...
106      QString sEngineName = pChannel->engineName();      QString sEngineName = pChannel->engineName();
107        if (sEngineName.isEmpty() || bNew)
108            sEngineName = pOptions->sEngineName;
109      if (sEngineName.isEmpty())      if (sEngineName.isEmpty())
110          sEngineName = tr("(No engine)");          sEngineName = qsamplerChannel::noEngineName();
111      if (EngineNameComboBox->listBox()->findItem(sEngineName, Qt::ExactMatch) == NULL)      if (EngineNameComboBox->listBox()->findItem(sEngineName, Qt::ExactMatch) == NULL)
112          EngineNameComboBox->insertItem(sEngineName);          EngineNameComboBox->insertItem(sEngineName);
113      EngineNameComboBox->setCurrentText(sEngineName);      EngineNameComboBox->setCurrentText(sEngineName);
114      // Instrument filename and index...      // Instrument filename and index...
115      QString sInstrumentFile = pChannel->instrumentFile();      QString sInstrumentFile = pChannel->instrumentFile();
116      if (sInstrumentFile.isEmpty())      if (sInstrumentFile.isEmpty())
117          sInstrumentFile = tr("(No instrument)");          sInstrumentFile = qsamplerChannel::noInstrumentName();
118      InstrumentFileComboBox->setCurrentText(sInstrumentFile);      InstrumentFileComboBox->setCurrentText(sInstrumentFile);
119      InstrumentNrSpinBox->setValue(pChannel->instrumentNr());      InstrumentNrComboBox->clear();
120      // MIDI input...      InstrumentNrComboBox->insertStringList(
121      const QString& sMidiDriver = pChannel->midiDriver();                  qsamplerChannel::getInstrumentList(sInstrumentFile,
122                    pOptions->bInstrumentNames));
123        InstrumentNrComboBox->setCurrentItem(pChannel->instrumentNr());
124        // MIDI input driver...
125        QString sMidiDriver = pChannel->midiDriver();
126        if (sMidiDriver.isEmpty() || bNew)
127            sMidiDriver = pOptions->sMidiDriver;
128      if (!sMidiDriver.isEmpty()) {      if (!sMidiDriver.isEmpty()) {
129          if (MidiDriverComboBox->listBox()->findItem(sMidiDriver, Qt::ExactMatch) == NULL)          if (MidiDriverComboBox->listBox()->findItem(sMidiDriver, Qt::ExactMatch) == NULL)
130              MidiDriverComboBox->insertItem(sMidiDriver);              MidiDriverComboBox->insertItem(sMidiDriver);
131          MidiDriverComboBox->setCurrentText(sMidiDriver);          MidiDriverComboBox->setCurrentText(sMidiDriver);
132      }      }
133        // MIDI input port...
134      MidiPortSpinBox->setValue(pChannel->midiPort());      MidiPortSpinBox->setValue(pChannel->midiPort());
135      MidiChannelSpinBox->setValue(pChannel->midiChannel());      // MIDI input channel...
136      // Audio output...      int iMidiChannel = pChannel->midiChannel();
137      const QString& sAudioDriver = pChannel->audioDriver();      // When new, try to suggest a sensible MIDI channel...
138        if (iMidiChannel < 0)
139            iMidiChannel = (::lscp_get_channels(m_pChannel->client()) % 16);
140        MidiChannelComboBox->setCurrentItem(iMidiChannel);
141        // Audio output driver...
142        QString sAudioDriver = pChannel->audioDriver();
143        if (sAudioDriver.isEmpty() || bNew)
144            sAudioDriver = pOptions->sAudioDriver;
145      if (!sAudioDriver.isEmpty()) {      if (!sAudioDriver.isEmpty()) {
146          if (AudioDriverComboBox->listBox()->findItem(sAudioDriver, Qt::ExactMatch) == NULL)          if (AudioDriverComboBox->listBox()->findItem(sAudioDriver, Qt::ExactMatch) == NULL)
147              AudioDriverComboBox->insertItem(sAudioDriver);              AudioDriverComboBox->insertItem(sAudioDriver);
148          AudioDriverComboBox->setCurrentText(sAudioDriver);          AudioDriverComboBox->setCurrentText(sAudioDriver);
149      }      }
150            // As convenient, make it ready on stabilizeForm() for
151            // prompt acceptance, if we got the minimum required...
152            if (sEngineName != qsamplerChannel::noEngineName() &&
153                    sInstrumentFile != qsamplerChannel::noInstrumentName())
154                    m_iDirtyCount++;
155            // FIXME: These are better leave diabled...
156        MidiPortTextLabel->setEnabled(false);
157        MidiPortSpinBox->setEnabled(false);
158      // Done.      // Done.
159      m_iDirtySetup--;      m_iDirtySetup--;
160      stabilizeForm();      stabilizeForm();
# Line 157  void qsamplerChannelForm::accept (void) Line 174  void qsamplerChannelForm::accept (void)
174      // We'll go for it!      // We'll go for it!
175      if (m_iDirtyCount > 0) {      if (m_iDirtyCount > 0) {
176          int iErrors = 0;          int iErrors = 0;
177            // Are we a new channel?
178            if (!m_pChannel->addChannel())
179                iErrors++;
180          // Audio output driver type...          // Audio output driver type...
181          if (!m_pChannel->setAudioDriver(AudioDriverComboBox->currentText()))          if (!m_pChannel->setAudioDriver(AudioDriverComboBox->currentText()))
182              iErrors++;              iErrors++;
# Line 164  void qsamplerChannelForm::accept (void) Line 184  void qsamplerChannelForm::accept (void)
184          if (!m_pChannel->setMidiDriver(MidiDriverComboBox->currentText()))          if (!m_pChannel->setMidiDriver(MidiDriverComboBox->currentText()))
185              iErrors++;              iErrors++;
186          // MIDI input port number...          // MIDI input port number...
         // FIXME: Should increment error count, when properly implemented.  
187          if (!m_pChannel->setMidiPort(MidiPortSpinBox->value()))          if (!m_pChannel->setMidiPort(MidiPortSpinBox->value()))
188          /*  iErrors++ */;              iErrors++;
189          // MIDI input channel...          // MIDI input channel...
190          if (!m_pChannel->setMidiChannel(MidiChannelSpinBox->value()))          if (!m_pChannel->setMidiChannel(MidiChannelComboBox->currentItem()))
191              iErrors++;              iErrors++;
192          // Engine name...          // Engine name...
193          if (!m_pChannel->loadEngine(EngineNameComboBox->currentText()))          if (!m_pChannel->loadEngine(EngineNameComboBox->currentText()))
194              iErrors++;              iErrors++;
195          // Instrument file and index...          // Instrument file and index...
196          if (!m_pChannel->loadInstrument(InstrumentFileComboBox->currentText(), InstrumentNrSpinBox->value()))          if (!m_pChannel->loadInstrument(InstrumentFileComboBox->currentText(), InstrumentNrComboBox->currentItem()))
197              iErrors++;              iErrors++;
198          // Show error messages?          // Show error messages?
199          if (iErrors > 0)          if (iErrors > 0)
200              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."));
201      }      }
202    
203      // Save default instrument directory and history...      // Save default engine name, instrument directory and history...
204      pOptions->sInstrumentDir = QFileInfo(InstrumentFileComboBox->currentText()).dirPath(true);      pOptions->sInstrumentDir = QFileInfo(InstrumentFileComboBox->currentText()).dirPath(true);
205        pOptions->sEngineName  = EngineNameComboBox->currentText();
206        pOptions->sAudioDriver = AudioDriverComboBox->currentText();
207        pOptions->sMidiDriver  = MidiDriverComboBox->currentText();
208      pOptions->saveComboBoxHistory(InstrumentFileComboBox);      pOptions->saveComboBoxHistory(InstrumentFileComboBox);
209    
210      // Just go with dialog acceptance.      // Just go with dialog acceptance.
# Line 196  void qsamplerChannelForm::reject (void) Line 218  void qsamplerChannelForm::reject (void)
218      bool bReject = true;      bool bReject = true;
219    
220      // Check if there's any pending changes...      // Check if there's any pending changes...
221      if (m_iDirtyCount > 0) {      if (m_iDirtyCount > 0 && OkPushButton->isEnabled()) {
222          switch (QMessageBox::warning(this, tr("Warning"),          switch (QMessageBox::warning(this, tr("Warning"),
223              tr("Some channel settings have been changed.\n\n"              tr("Some channel settings have been changed.\n\n"
224                 "Do you want to apply the changes?"),                 "Do you want to apply the changes?"),
# Line 242  void qsamplerChannelForm::openInstrument Line 264  void qsamplerChannelForm::openInstrument
264  // Refresh the actual instrument name.  // Refresh the actual instrument name.
265  void qsamplerChannelForm::updateInstrumentName (void)  void qsamplerChannelForm::updateInstrumentName (void)
266  {  {
267      // FIXME: A better idea would be to use libgig      qsamplerOptions *pOptions = m_pChannel->options();
268      // to retrieve the REAL instrument name.      if (pOptions == NULL)
269      InstrumentNameTextLabel->setText(QFileInfo(InstrumentFileComboBox->currentText()).fileName()          return;
270          + " [" + QString::number(InstrumentNrSpinBox->value()) + "]");  
271        // Finally this better idea would be to use libgig
272        // to retrieve the REAL instrument names.
273        InstrumentNrComboBox->clear();
274        InstrumentNrComboBox->insertStringList(
275            qsamplerChannel::getInstrumentList(
276                            InstrumentFileComboBox->currentText(),
277                            pOptions->bInstrumentNames)
278        );
279    
280      optionsChanged();      optionsChanged();
281  }  }

Legend:
Removed from v.149  
changed lines
  Added in v.430

  ViewVC Help
Powered by ViewVC