/[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 161 by capela, Tue Jun 29 21:55:30 2004 UTC revision 409 by capela, Thu Feb 24 12:10:54 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    
 #include "qsamplerOptions.h"  
 #include "qsamplerChannelStrip.h"  
   
29  #include "config.h"  #include "config.h"
30    
31    
# Line 53  void qsamplerChannelForm::destroy (void) Line 50  void qsamplerChannelForm::destroy (void)
50    
51    
52  // Channel dialog setup formal initializer.  // Channel dialog setup formal initializer.
53  void qsamplerChannelForm::setup ( qsamplerChannelStrip *pChannel )  void qsamplerChannelForm::setup ( qsamplerChannel *pChannel )
54  {  {
55      m_pChannel = pChannel;      m_pChannel = pChannel;
56    
# Line 63  void qsamplerChannelForm::setup ( qsampl Line 60  void qsamplerChannelForm::setup ( qsampl
60      if (m_pChannel == NULL)      if (m_pChannel == NULL)
61          return;          return;
62    
63      setCaption(m_pChannel->caption());      // It can be a brand new channel, remember?
64        bool bNew = (m_pChannel->channelID() < 0);
65        setCaption(m_pChannel->channelName());
66    
67      // Check if we're up and connected.      // Check if we're up and connected.
68      if (m_pChannel->client() == NULL)      if (m_pChannel->client() == NULL)
# Line 111  void qsamplerChannelForm::setup ( qsampl Line 110  void qsamplerChannelForm::setup ( qsampl
110    
111      // Engine name...      // Engine name...
112      QString sEngineName = pChannel->engineName();      QString sEngineName = pChannel->engineName();
113        if (sEngineName.isEmpty() || bNew)
114            sEngineName = pOptions->sEngineName;
115      if (sEngineName.isEmpty())      if (sEngineName.isEmpty())
116          sEngineName = tr("(No engine)");          sEngineName = qsamplerChannel::noEngineName();
117      if (EngineNameComboBox->listBox()->findItem(sEngineName, Qt::ExactMatch) == NULL)      if (EngineNameComboBox->listBox()->findItem(sEngineName, Qt::ExactMatch) == NULL)
118          EngineNameComboBox->insertItem(sEngineName);          EngineNameComboBox->insertItem(sEngineName);
119      EngineNameComboBox->setCurrentText(sEngineName);      EngineNameComboBox->setCurrentText(sEngineName);
120      // Instrument filename and index...      // Instrument filename and index...
121      QString sInstrumentFile = pChannel->instrumentFile();      QString sInstrumentFile = pChannel->instrumentFile();
122      if (sInstrumentFile.isEmpty())      if (sInstrumentFile.isEmpty())
123          sInstrumentFile = tr("(No instrument)");          sInstrumentFile = qsamplerChannel::noInstrumentName();
124      InstrumentFileComboBox->setCurrentText(sInstrumentFile);      InstrumentFileComboBox->setCurrentText(sInstrumentFile);
125      InstrumentNrSpinBox->setValue(pChannel->instrumentNr());      InstrumentNrComboBox->clear();
126      // MIDI input...      InstrumentNrComboBox->insertStringList(
127      const QString& sMidiDriver = pChannel->midiDriver();                  qsamplerChannel::getInstrumentList(sInstrumentFile,
128                    pOptions->bInstrumentNames));
129        InstrumentNrComboBox->setCurrentItem(pChannel->instrumentNr());
130        // MIDI input driver...
131        QString sMidiDriver = pChannel->midiDriver();
132        if (sMidiDriver.isEmpty() || bNew)
133            sMidiDriver = pOptions->sMidiDriver;
134      if (!sMidiDriver.isEmpty()) {      if (!sMidiDriver.isEmpty()) {
135          if (MidiDriverComboBox->listBox()->findItem(sMidiDriver, Qt::ExactMatch) == NULL)          if (MidiDriverComboBox->listBox()->findItem(sMidiDriver, Qt::ExactMatch) == NULL)
136              MidiDriverComboBox->insertItem(sMidiDriver);              MidiDriverComboBox->insertItem(sMidiDriver);
137          MidiDriverComboBox->setCurrentText(sMidiDriver);          MidiDriverComboBox->setCurrentText(sMidiDriver);
138      }      }
139        // MIDI input port...
140      MidiPortSpinBox->setValue(pChannel->midiPort());      MidiPortSpinBox->setValue(pChannel->midiPort());
141      MidiChannelSpinBox->setValue(pChannel->midiChannel());      // MIDI input channel...
142      // Audio output...      int iMidiChannel = pChannel->midiChannel();
143      const QString& sAudioDriver = pChannel->audioDriver();      // When new, try to suggest a sensible MIDI channel...
144        if (iMidiChannel < 0)
145            iMidiChannel = (::lscp_get_channels(m_pChannel->client()) % 16);
146        MidiChannelComboBox->setCurrentItem(iMidiChannel);
147        // Audio output driver...
148        QString sAudioDriver = pChannel->audioDriver();
149        if (sAudioDriver.isEmpty() || bNew)
150            sAudioDriver = pOptions->sAudioDriver;
151      if (!sAudioDriver.isEmpty()) {      if (!sAudioDriver.isEmpty()) {
152          if (AudioDriverComboBox->listBox()->findItem(sAudioDriver, Qt::ExactMatch) == NULL)          if (AudioDriverComboBox->listBox()->findItem(sAudioDriver, Qt::ExactMatch) == NULL)
153              AudioDriverComboBox->insertItem(sAudioDriver);              AudioDriverComboBox->insertItem(sAudioDriver);
154          AudioDriverComboBox->setCurrentText(sAudioDriver);          AudioDriverComboBox->setCurrentText(sAudioDriver);
155      }      }
156            // As convenient, make it ready on stabilizeForm() for
157            // prompt acceptance, if we got the minimum required...
158            if (sEngineName != qsamplerChannel::noEngineName() &&
159                    sInstrumentFile != qsamplerChannel::noInstrumentName())
160                    m_iDirtyCount++;
161            // FIXME: These are better leave diabled...
162        MidiPortTextLabel->setEnabled(false);
163        MidiPortSpinBox->setEnabled(false);
164      // Done.      // Done.
165      m_iDirtySetup--;      m_iDirtySetup--;
166      stabilizeForm();      stabilizeForm();
# Line 157  void qsamplerChannelForm::accept (void) Line 180  void qsamplerChannelForm::accept (void)
180      // We'll go for it!      // We'll go for it!
181      if (m_iDirtyCount > 0) {      if (m_iDirtyCount > 0) {
182          int iErrors = 0;          int iErrors = 0;
183            // Are we a new channel?
184            if (!m_pChannel->addChannel())
185                iErrors++;
186          // Audio output driver type...          // Audio output driver type...
187          if (!m_pChannel->setAudioDriver(AudioDriverComboBox->currentText()))          if (!m_pChannel->setAudioDriver(AudioDriverComboBox->currentText()))
188              iErrors++;              iErrors++;
# Line 167  void qsamplerChannelForm::accept (void) Line 193  void qsamplerChannelForm::accept (void)
193          if (!m_pChannel->setMidiPort(MidiPortSpinBox->value()))          if (!m_pChannel->setMidiPort(MidiPortSpinBox->value()))
194              iErrors++;              iErrors++;
195          // MIDI input channel...          // MIDI input channel...
196          if (!m_pChannel->setMidiChannel(MidiChannelSpinBox->value()))          if (!m_pChannel->setMidiChannel(MidiChannelComboBox->currentItem()))
197              iErrors++;              iErrors++;
198          // Engine name...          // Engine name...
199          if (!m_pChannel->loadEngine(EngineNameComboBox->currentText()))          if (!m_pChannel->loadEngine(EngineNameComboBox->currentText()))
200              iErrors++;              iErrors++;
201          // Instrument file and index...          // Instrument file and index...
202          if (!m_pChannel->loadInstrument(InstrumentFileComboBox->currentText(), InstrumentNrSpinBox->value()))          if (!m_pChannel->loadInstrument(InstrumentFileComboBox->currentText(), InstrumentNrComboBox->currentItem()))
203              iErrors++;              iErrors++;
204          // Show error messages?          // Show error messages?
205          if (iErrors > 0)          if (iErrors > 0)
206              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."));
207      }      }
208    
209      // Save default instrument directory and history...      // Save default engine name, instrument directory and history...
210      pOptions->sInstrumentDir = QFileInfo(InstrumentFileComboBox->currentText()).dirPath(true);      pOptions->sInstrumentDir = QFileInfo(InstrumentFileComboBox->currentText()).dirPath(true);
211        pOptions->sEngineName  = EngineNameComboBox->currentText();
212        pOptions->sAudioDriver = AudioDriverComboBox->currentText();
213        pOptions->sMidiDriver  = MidiDriverComboBox->currentText();
214      pOptions->saveComboBoxHistory(InstrumentFileComboBox);      pOptions->saveComboBoxHistory(InstrumentFileComboBox);
215    
216      // Just go with dialog acceptance.      // Just go with dialog acceptance.
# Line 195  void qsamplerChannelForm::reject (void) Line 224  void qsamplerChannelForm::reject (void)
224      bool bReject = true;      bool bReject = true;
225    
226      // Check if there's any pending changes...      // Check if there's any pending changes...
227      if (m_iDirtyCount > 0) {      if (m_iDirtyCount > 0 && OkPushButton->isEnabled()) {
228          switch (QMessageBox::warning(this, tr("Warning"),          switch (QMessageBox::warning(this, tr("Warning"),
229              tr("Some channel settings have been changed.\n\n"              tr("Some channel settings have been changed.\n\n"
230                 "Do you want to apply the changes?"),                 "Do you want to apply the changes?"),
# Line 241  void qsamplerChannelForm::openInstrument Line 270  void qsamplerChannelForm::openInstrument
270  // Refresh the actual instrument name.  // Refresh the actual instrument name.
271  void qsamplerChannelForm::updateInstrumentName (void)  void qsamplerChannelForm::updateInstrumentName (void)
272  {  {
273      // FIXME: A better idea would be to use libgig      qsamplerOptions *pOptions = m_pChannel->options();
274      // to retrieve the REAL instrument name.      if (pOptions == NULL)
275      InstrumentNameTextLabel->setText(QFileInfo(InstrumentFileComboBox->currentText()).fileName()          return;
276          + " [" + QString::number(InstrumentNrSpinBox->value()) + "]");  
277        // Finally this better idea would be to use libgig
278        // to retrieve the REAL instrument names.
279        InstrumentNrComboBox->clear();
280        InstrumentNrComboBox->insertStringList(
281            qsamplerChannel::getInstrumentList(
282                            InstrumentFileComboBox->currentText(),
283                            pOptions->bInstrumentNames)
284        );
285    
286      optionsChanged();      optionsChanged();
287  }  }

Legend:
Removed from v.161  
changed lines
  Added in v.409

  ViewVC Help
Powered by ViewVC