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

Diff of /qsampler/trunk/src/qsamplerChannelStrip.ui.h

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

revision 303 by capela, Fri Nov 19 10:18:59 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 22  Line 22 
22    
23  #include <qvalidator.h>  #include <qvalidator.h>
24  #include <qmessagebox.h>  #include <qmessagebox.h>
25    #include <qdragobject.h>
26  #include <qfileinfo.h>  #include <qfileinfo.h>
27  #include <qtooltip.h>  #include <qtooltip.h>
28  #include <qpopupmenu.h>  #include <qpopupmenu.h>
29  #include <qobjectlist.h>  #include <qobjectlist.h>
30    #include <qurl.h>
31    
32  #include <math.h>  #include <math.h>
33    
# Line 34  Line 36 
36    
37  #include "config.h"  #include "config.h"
38    
39    // Channel status/usage usage limit control.
40    #define QSAMPLER_ERROR_LIMIT    3
41    
42    
43  // Kind of constructor.  // Kind of constructor.
44  void qsamplerChannelStrip::init (void)  void qsamplerChannelStrip::init (void)
# Line 41  void qsamplerChannelStrip::init (void) Line 46  void qsamplerChannelStrip::init (void)
46      // Initialize locals.      // Initialize locals.
47      m_pChannel     = NULL;      m_pChannel     = NULL;
48      m_iDirtyChange = 0;      m_iDirtyChange = 0;
49            m_iErrorCount  = 0;
50    
51      // Try to restore normal window positioning.      // Try to restore normal window positioning.
52      adjustSize();      adjustSize();
# Line 57  void qsamplerChannelStrip::destroy (void Line 63  void qsamplerChannelStrip::destroy (void
63  }  }
64    
65    
66    // Drag'n'drop file handler.
67    bool qsamplerChannelStrip::decodeDragFile ( const QMimeSource *pEvent, QString& sInstrumentFile )
68    {
69            if (m_pChannel == NULL)
70                    return false;
71            if (QTextDrag::canDecode(pEvent)) {
72                    QString sText;
73                    if (QTextDrag::decode(pEvent, sText)) {
74                            QStringList files = QStringList::split('\n', sText);
75                            for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) {
76                                    *iter = QUrl((*iter).stripWhiteSpace().replace(QRegExp("^file:"), QString::null)).path();
77                                    if (qsamplerChannel::isInstrumentFile(*iter)) {
78                                            sInstrumentFile = *iter;
79                                            return true;
80                                    }
81                            }
82                    }
83            }
84            // Fail.
85            return false;
86    }
87    
88    
89    // Window drag-n-drop event handlers.
90    void qsamplerChannelStrip::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )
91    {
92            QString sInstrumentFile;
93            pDragEnterEvent->accept(decodeDragFile(pDragEnterEvent, sInstrumentFile));
94    }
95    
96    
97    void qsamplerChannelStrip::dropEvent ( QDropEvent* pDropEvent )
98    {
99            QString sInstrumentFile;
100    
101            if (decodeDragFile(pDropEvent, sInstrumentFile)) {
102                    // Go and set the dropped instrument filename...
103                    m_pChannel->setInstrument(sInstrumentFile, 0);
104                    // Open up the channel dialog.
105                    channelSetup();
106            }
107    }
108    
109    
110  // Channel strip setup formal initializer.  // Channel strip setup formal initializer.
111  void qsamplerChannelStrip::setup ( qsamplerChannel *pChannel )  void qsamplerChannelStrip::setup ( qsamplerChannel *pChannel )
112  {  {
# Line 67  void qsamplerChannelStrip::setup ( qsamp Line 117  void qsamplerChannelStrip::setup ( qsamp
117    
118      // Set the new one...      // Set the new one...
119      m_pChannel = pChannel;      m_pChannel = pChannel;
120        
121      // Stabilize this around.      // Stabilize this around.
122      updateChannelInfo();      updateChannelInfo();
123    
124            // We'll accept drops from now on...
125            if (m_pChannel)
126                    setAcceptDrops(true);
127  }  }
128    
129  // Channel secriptor accessor.  // Channel secriptor accessor.
# Line 123  void qsamplerChannelStrip::setDisplayBac Line 177  void qsamplerChannelStrip::setDisplayBac
177  }  }
178    
179    
180    // Maximum volume slider accessors.
181    void qsamplerChannelStrip::setMaxVolume ( int iMaxVolume )
182    {
183        m_iDirtyChange++;
184        VolumeSlider->setRange(0, iMaxVolume);
185        VolumeSpinBox->setRange(0, iMaxVolume);
186        m_iDirtyChange--;
187    }
188    
189    
190  // Channel setup dialog slot.  // Channel setup dialog slot.
191  bool qsamplerChannelStrip::channelSetup (void)  bool qsamplerChannelStrip::channelSetup (void)
192  {  {
193      bool bResult = m_pChannel->channelSetup(this);          if (m_pChannel == NULL)
194                    return false;
195                    
196            // Invoke the channel setup dialog.
197            bool bResult = m_pChannel->channelSetup(this);
198            // Notify that thie channel has changed.
199            if (bResult)
200                    emit channelChanged(this);
201    
202      if (bResult)          return bResult;
         emit channelChanged(this);  
   
     return bResult;  
203  }  }
204    
205    
206  // Update whole channel info state.  // Channel reset slot.
207  bool qsamplerChannelStrip::updateChannelInfo (void)  bool qsamplerChannelStrip::channelReset (void)
208  {  {
209      if (m_pChannel == NULL)          if (m_pChannel == NULL)
210          return false;                  return false;
           
     // Update strip caption.  
     QString sText = m_pChannel->channelName();  
     setCaption(sText);  
     ChannelSetupPushButton->setText(sText);  
211    
212      // Check if we're up and connected.          // Invoke the channel reset method.
213      if (m_pChannel->client() == NULL)          bool bResult = m_pChannel->channelReset();
214          return false;          // Notify that thie channel has changed.
215            if (bResult)
216                    emit channelChanged(this);
217    
218      // Read actual channel information.          return bResult;
219      m_pChannel->updateChannelInfo();  }
   
     // Set some proper display values.  
     const QString sIndent = " ";  
220    
     // Engine name...  
     if (m_pChannel->engineName().isEmpty())  
         EngineNameTextLabel->setText(sIndent + tr("(No engine)"));  
     else  
         EngineNameTextLabel->setText(sIndent + m_pChannel->engineName());  
221    
222      // Instrument name...  // Update the channel instrument name.
223      if (m_pChannel->instrumentFile().isEmpty())  bool qsamplerChannelStrip::updateInstrumentName ( bool bForce )
224          InstrumentNameTextLabel->setText(sIndent + tr("(No instrument)"));  {
225      else          if (m_pChannel == NULL)
226          InstrumentNameTextLabel->setText(sIndent + qsamplerChannel::getInstrumentName(m_pChannel->instrumentFile(), m_pChannel->instrumentNr()));                  return false;
227    
228      // Instrument status...          // Do we refersh the actual name?
229      int iInstrumentStatus = m_pChannel->instrumentStatus();          if (bForce)
230      if (iInstrumentStatus < 0) {                  m_pChannel->updateInstrumentName();
         InstrumentStatusTextLabel->setPaletteForegroundColor(Qt::red);  
         InstrumentStatusTextLabel->setText(tr("ERR%1").arg(iInstrumentStatus));  
     } else {  
         InstrumentStatusTextLabel->setPaletteForegroundColor(iInstrumentStatus < 100 ? Qt::yellow : Qt::green);  
         InstrumentStatusTextLabel->setText(QString::number(iInstrumentStatus) + "%");  
     }  
231    
232      // MIDI Port/Channel...          // Instrument name...
233      if (m_pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL)          if (m_pChannel->instrumentName().isEmpty())
234          MidiPortChannelTextLabel->setText(QString("%1 / *").arg(m_pChannel->midiPort()));                  InstrumentNameTextLabel->setText(' ' + qsamplerChannel::noInstrumentName());
235      else          else
236          MidiPortChannelTextLabel->setText(QString("%1 / %2").arg(m_pChannel->midiPort()).arg(m_pChannel->midiChannel() + 1));                  InstrumentNameTextLabel->setText(' ' + m_pChannel->instrumentName());
237    
238      // And update the both GUI volume elements.          return true;    
     return updateChannelVolume();  
239  }  }
240    
241    
# Line 218  bool qsamplerChannelStrip::updateChannel Line 268  bool qsamplerChannelStrip::updateChannel
268      VolumeSlider->setValue(iVolume);      VolumeSlider->setValue(iVolume);
269      VolumeSpinBox->setValue(iVolume);      VolumeSpinBox->setValue(iVolume);
270      m_iDirtyChange--;      m_iDirtyChange--;
271        
272      return true;      return true;
273  }  }
274    
275    
276  // Update whole channel usage state.  // Update whole channel info state.
277  bool qsamplerChannelStrip::updateChannelUsage (void)  bool qsamplerChannelStrip::updateChannelInfo (void)
278  {  {
279      if (m_pChannel == NULL)      if (m_pChannel == NULL)
280          return false;          return false;
281            
282            // Check for error limit/recycle...
283            if (m_iErrorCount > QSAMPLER_ERROR_LIMIT)
284                    return true;
285    
286        // Update strip caption.
287        QString sText = m_pChannel->channelName();
288        setCaption(sText);
289        ChannelSetupPushButton->setText(sText);
290    
291        // Check if we're up and connected.
292      if (m_pChannel->client() == NULL)      if (m_pChannel->client() == NULL)
293          return false;          return false;
294    
295      // Update whole channel status info,      // Read actual channel information.
296      // if instrument load is still pending...      m_pChannel->updateChannelInfo();
297      if (m_pChannel->instrumentStatus() < 100) {  
298          updateChannelInfo();      // Engine name...
299          // Check (updated) status again...      if (m_pChannel->engineName().isEmpty())
300          if (m_pChannel->instrumentStatus() < 100)          EngineNameTextLabel->setText(' ' + qsamplerChannel::noEngineName());
301              return false;      else
302          // Once we get a complete instrument load,          EngineNameTextLabel->setText(' ' + m_pChannel->engineName());
303          // we'll try an implied channel reset...  
304          m_pChannel->resetChannel();          // Instrument name...
305            updateInstrumentName(false);
306    
307        // MIDI Port/Channel...
308        if (m_pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL)
309            MidiPortChannelTextLabel->setText(QString("%1 / *").arg(m_pChannel->midiPort()));
310        else
311            MidiPortChannelTextLabel->setText(QString("%1 / %2").arg(m_pChannel->midiPort()).arg(m_pChannel->midiChannel() + 1));
312    
313        // Instrument status...
314        int iInstrumentStatus = m_pChannel->instrumentStatus();
315        if (iInstrumentStatus < 0) {
316            InstrumentStatusTextLabel->setPaletteForegroundColor(Qt::red);
317            InstrumentStatusTextLabel->setText(tr("ERR%1").arg(iInstrumentStatus));
318            m_iErrorCount++;
319            return false;
320      }      }
321            // All seems normal...
322      // Check again that we're clean.      InstrumentStatusTextLabel->setPaletteForegroundColor(iInstrumentStatus < 100 ? Qt::yellow : Qt::green);
323      if (m_pChannel->instrumentStatus() < 100)      InstrumentStatusTextLabel->setText(QString::number(iInstrumentStatus) + '%');
324        m_iErrorCount = 0;
325    
326        // And update the both GUI volume elements;
327        // return success if, and only if, intrument is fully loaded...
328        return updateChannelVolume() && (iInstrumentStatus == 100);
329    }
330    
331    
332    // Update whole channel usage state.
333    bool qsamplerChannelStrip::updateChannelUsage (void)
334    {
335        if (m_pChannel == NULL)
336            return false;
337        if (m_pChannel->client() == NULL)
338          return false;          return false;
339    
340            // This only makes sense on fully loaded channels...
341            if (m_pChannel->instrumentStatus() < 100)
342                return false;
343                
344      // Get current channel voice count.      // Get current channel voice count.
345      int iVoiceCount  = ::lscp_get_channel_voice_count(m_pChannel->client(), m_pChannel->channelID());      int iVoiceCount  = ::lscp_get_channel_voice_count(m_pChannel->client(), m_pChannel->channelID());
346      // Get current stream count.      // Get current stream count.
# Line 299  void qsamplerChannelStrip::contextMenuEv Line 393  void qsamplerChannelStrip::contextMenuEv
393  }  }
394    
395    
 // Maximum volume slider accessors.  
 void qsamplerChannelStrip::setMaxVolume ( int iMaxVolume )  
 {  
     m_iDirtyChange++;  
     VolumeSlider->setRange(0, iMaxVolume);  
     VolumeSpinBox->setRange(0, iMaxVolume);  
     m_iDirtyChange--;  
 }  
   
   
396  // end of qsamplerChannelStrip.ui.h  // end of qsamplerChannelStrip.ui.h

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

  ViewVC Help
Powered by ViewVC