/[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 264 by capela, Wed Sep 29 13:12:45 2004 UTC revision 751 by capela, Fri Aug 19 17:10:16 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>
30    #include <qurl.h>
31    
32  #include <math.h>  #include <math.h>
33    
# Line 33  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)
45  {  {
46      // Initialize locals.      // Initialize locals.
     m_pMainForm    = NULL;  
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 ( qsamplerMainForm *pMainForm, int iChannelID )  void qsamplerChannelStrip::setup ( qsamplerChannel *pChannel )
112  {  {
113      // Set main form reference.      // Destroy any previous channel descriptor;
114      m_pMainForm = pMainForm;      // (remember that once setup we own it!)
       
     // Destroy any previous channel descriptor.  
115      if (m_pChannel)      if (m_pChannel)
116          delete m_pChannel;          delete m_pChannel;
117    
118      // Create a new one...      // Set the new one...
119      m_pChannel = new qsamplerChannel(pMainForm);      m_pChannel = pChannel;
120      // And set appropriate settings.  
121      if (m_pChannel) {      // Stabilize this around.
122          m_pChannel->setChannelID(iChannelID);      updateChannelInfo();
123          m_iDirtyChange = 0;  
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 98  void qsamplerChannelStrip::setDisplayFon Line 148  void qsamplerChannelStrip::setDisplayFon
148  }  }
149    
150    
151  // Channel setup dialog slot.  // Channel display background effect.
152  void qsamplerChannelStrip::channelSetup (void)  void qsamplerChannelStrip::setDisplayEffect ( bool bDisplayEffect )
153  {  {
154      showChannelSetup(false);      QPixmap pm;
155        if (bDisplayEffect)
156            pm = QPixmap::fromMimeSource("displaybg1.png");
157        setDisplayBackground(pm);
158  }  }
159    
160    
161  // Channel setup dialog.  // Update main display background pixmap.
162  void qsamplerChannelStrip::showChannelSetup ( bool bNew )  void qsamplerChannelStrip::setDisplayBackground ( const QPixmap& pm )
163  {  {
164      qsamplerChannelForm *pChannelForm = new qsamplerChannelForm(this);      // Set the main origin...
165      if (pChannelForm) {      ChannelInfoFrame->setPaletteBackgroundPixmap(pm);
166          pChannelForm->setup(m_pChannel, bNew);  
167          if (pChannelForm->exec()) {      // Iterate for every child text label...
168              updateChannelInfo();      QObjectList *pList = ChannelInfoFrame->queryList("QLabel");
169              emit channelChanged(this);      if (pList) {
170          }          for (QLabel *pLabel = (QLabel *) pList->first(); pLabel; pLabel = (QLabel *) pList->next())
171          delete pChannelForm;              pLabel->setPaletteBackgroundPixmap(pm);
172            delete pList;
173      }      }
174    
175        // And this standalone too.
176        StreamVoiceCountTextLabel->setPaletteBackgroundPixmap(pm);
177  }  }
178    
179    
180  // Update whole channel info state.  // Maximum volume slider accessors.
181  void qsamplerChannelStrip::updateChannelInfo (void)  void qsamplerChannelStrip::setMaxVolume ( int iMaxVolume )
182  {  {
183      if (m_pChannel == NULL)      m_iDirtyChange++;
184          return;      VolumeSlider->setRange(0, iMaxVolume);
185                VolumeSpinBox->setRange(0, iMaxVolume);
186      // Update strip caption.      m_iDirtyChange--;
187      QString sText = tr("Channel %1").arg(m_pChannel->channelID());  }
     setCaption(sText);  
     ChannelSetupPushButton->setText(sText);  
188    
     // Check if we're up and connected.  
     if (m_pChannel->client() == NULL)  
         return;  
189    
190      // Read actual channel information.  // Channel setup dialog slot.
191      m_pChannel->updateChannelInfo();  bool qsamplerChannelStrip::channelSetup (void)
192    {
193            if (m_pChannel == NULL)
194                    return false;
195                    
196            // Invoke the channel setup dialog.
197            bool bResult = m_pChannel->channelSetup(this);
198            // Notify that this channel has changed.
199            if (bResult)
200                    emit channelChanged(this);
201    
202      // Set some proper display values.          return bResult;
203      const QString sIndent = " ";  }
204    
     // Engine name...  
     if (m_pChannel->engineName().isEmpty())  
         EngineNameTextLabel->setText(sIndent + tr("(No engine)"));  
     else  
         EngineNameTextLabel->setText(sIndent + m_pChannel->engineName());  
205    
206      // Instrument name...  // Channel mute slot.
207      if (m_pChannel->instrumentFile().isEmpty())  bool qsamplerChannelStrip::channelMute ( bool bMute )
208          InstrumentNameTextLabel->setText(sIndent + tr("(No instrument)"));  {
209      else          if (m_pChannel == NULL)
210          InstrumentNameTextLabel->setText(sIndent + QString("%1 [%2]")                  return false;
             .arg(QFileInfo(m_pChannel->instrumentFile()).fileName()).arg(m_pChannel->instrumentNr()));  
211    
212      // Instrument status...          // Invoke the channel mute method.
213      int iInstrumentStatus = m_pChannel->instrumentStatus();          bool bResult = m_pChannel->setChannelMute(bMute);
214      if (iInstrumentStatus < 0) {          // Notify that this channel has changed.
215          InstrumentStatusTextLabel->setPaletteForegroundColor(Qt::red);          if (bResult)
216          InstrumentStatusTextLabel->setText(tr("ERR%1").arg(iInstrumentStatus));                  emit channelChanged(this);
217      } else {  
218          InstrumentStatusTextLabel->setPaletteForegroundColor(iInstrumentStatus < 100 ? Qt::yellow : Qt::green);          return bResult;
219          InstrumentStatusTextLabel->setText(QString::number(iInstrumentStatus) + "%");  }
     }  
220    
     // MIDI Port/Channel...  
     if (m_pChannel->midiChannel() > 0)  
         MidiPortChannelTextLabel->setText(QString("%1 / %2").arg(m_pChannel->midiPort()).arg(m_pChannel->midiChannel()));  
     else  
         MidiPortChannelTextLabel->setText(QString("%1 / *").arg(m_pChannel->midiPort()));  
221    
222      // And update the both GUI volume elements.  // Channel solo slot.
223      updateChannelVolume();  bool qsamplerChannelStrip::channelSolo ( bool bSolo )
224    {
225            if (m_pChannel == NULL)
226                    return false;
227    
228            // Invoke the channel solo method.
229            bool bResult = m_pChannel->setChannelSolo(bSolo);
230            // Notify that this channel has changed.
231            if (bResult)
232                    emit channelChanged(this);
233    
234            return bResult;
235    }
236    
237    
238    // Channel reset slot.
239    bool qsamplerChannelStrip::channelReset (void)
240    {
241            if (m_pChannel == NULL)
242                    return false;
243    
244            // Invoke the channel reset method.
245            bool bResult = m_pChannel->channelReset();
246            // Notify that this channel has changed.
247            if (bResult)
248                    emit channelChanged(this);
249    
250            return bResult;
251    }
252    
253    
254    // Update the channel instrument name.
255    bool qsamplerChannelStrip::updateInstrumentName ( bool bForce )
256    {
257            if (m_pChannel == NULL)
258                    return false;
259    
260            // Do we refresh the actual name?
261            if (bForce)
262                    m_pChannel->updateInstrumentName();
263    
264            // Instrument name...
265            if (m_pChannel->instrumentName().isEmpty()) {
266                    if (m_pChannel->instrumentStatus() >= 0)
267                            InstrumentNameTextLabel->setText(' ' + qsamplerChannel::loadingInstrument());
268                    else
269                            InstrumentNameTextLabel->setText(' ' + qsamplerChannel::noInstrumentName());
270            } else
271                    InstrumentNameTextLabel->setText(' ' + m_pChannel->instrumentName());
272    
273            return true;    
274  }  }
275    
276    
277  // Do the dirty volume change.  // Do the dirty volume change.
278  void qsamplerChannelStrip::updateChannelVolume (void)  bool qsamplerChannelStrip::updateChannelVolume (void)
279  {  {
280      if (m_pChannel == NULL)      if (m_pChannel == NULL)
281          return;          return false;
282    
283      // Convert...      // Convert...
284  #ifdef CONFIG_ROUND  #ifdef CONFIG_ROUND
# Line 204  void qsamplerChannelStrip::updateChannel Line 303  void qsamplerChannelStrip::updateChannel
303      VolumeSlider->setValue(iVolume);      VolumeSlider->setValue(iVolume);
304      VolumeSpinBox->setValue(iVolume);      VolumeSpinBox->setValue(iVolume);
305      m_iDirtyChange--;      m_iDirtyChange--;
306    
307        return true;
308  }  }
309    
310    
311  // Update whole channel usage state.  // Update whole channel info state.
312  void qsamplerChannelStrip::updateChannelUsage (void)  bool qsamplerChannelStrip::updateChannelInfo (void)
313  {  {
314      if (m_pChannel == NULL)      if (m_pChannel == NULL)
315          return;          return false;
316    
317            // Check for error limit/recycle...
318            if (m_iErrorCount > QSAMPLER_ERROR_LIMIT)
319                    return true;
320    
321        // Update strip caption.
322        QString sText = m_pChannel->channelName();
323        setCaption(sText);
324        ChannelSetupPushButton->setText(sText);
325    
326        // Check if we're up and connected.
327      if (m_pChannel->client() == NULL)      if (m_pChannel->client() == NULL)
328          return;          return false;
329    
330        // Read actual channel information.
331        m_pChannel->updateChannelInfo();
332    
333        // Engine name...
334        if (m_pChannel->engineName().isEmpty())
335            EngineNameTextLabel->setText(' ' + qsamplerChannel::noEngineName());
336        else
337            EngineNameTextLabel->setText(' ' + m_pChannel->engineName());
338    
339            // Instrument name...
340            updateInstrumentName(false);
341    
342      // Conditionally update whole channel status info.      // MIDI Port/Channel...
343      if (m_pChannel->instrumentStatus() >= 0 && m_pChannel->instrumentStatus() < 100) {      if (m_pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL)
344          updateChannelInfo();          MidiPortChannelTextLabel->setText(QString("%1 / *").arg(m_pChannel->midiPort()));
345          // Once we get a complete instrument load, try a implied reset channel....      else
346          if (m_pChannel->instrumentStatus() == 100)          MidiPortChannelTextLabel->setText(QString("%1 / %2").arg(m_pChannel->midiPort()).arg(m_pChannel->midiChannel() + 1));
347              m_pChannel->resetChannel();  
348        // Instrument status...
349        int iInstrumentStatus = m_pChannel->instrumentStatus();
350        if (iInstrumentStatus < 0) {
351            InstrumentStatusTextLabel->setPaletteForegroundColor(Qt::red);
352            InstrumentStatusTextLabel->setText(tr("ERR%1").arg(iInstrumentStatus));
353            m_iErrorCount++;
354            return false;
355      }      }
356      // Leave, if we still have an erroneus or incomplete instrument load.      // All seems normal...
357      if (m_pChannel->instrumentStatus() < 100)      InstrumentStatusTextLabel->setPaletteForegroundColor(iInstrumentStatus < 100 ? Qt::yellow : Qt::green);
358          return;      InstrumentStatusTextLabel->setText(QString::number(iInstrumentStatus) + '%');
359        m_iErrorCount = 0;
360    
361    #ifdef CONFIG_MUTE_SOLO
362        // Mute/Solo button state coloring...
363        const QColor& rgbNormal = ChannelSetupPushButton->paletteBackgroundColor();
364        bool bMute = m_pChannel->channelMute();
365        ChannelMutePushButton->setPaletteBackgroundColor(bMute ? Qt::red : rgbNormal);
366        ChannelMutePushButton->setDown(bMute);
367        bool bSolo = m_pChannel->channelSolo();
368        ChannelSoloPushButton->setPaletteBackgroundColor(bSolo ? Qt::yellow : rgbNormal);
369        ChannelSoloPushButton->setDown(bSolo);
370    #else
371            ChannelMutePushButton->setEnabled(false);
372            ChannelSoloPushButton->setEnabled(false);
373    #endif
374    
375        // And update the both GUI volume elements;
376        // return success if, and only if, intrument is fully loaded...
377        return updateChannelVolume() && (iInstrumentStatus == 100);
378    }
379    
380    
381    // Update whole channel usage state.
382    bool qsamplerChannelStrip::updateChannelUsage (void)
383    {
384        if (m_pChannel == NULL)
385            return false;
386        if (m_pChannel->client() == NULL)
387            return false;
388    
389            // This only makes sense on fully loaded channels...
390            if (m_pChannel->instrumentStatus() < 100)
391                return false;
392    
393      // Get current channel voice count.      // Get current channel voice count.
394      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());
# Line 238  void qsamplerChannelStrip::updateChannel Line 402  void qsamplerChannelStrip::updateChannel
402      // Update the GUI elements...      // Update the GUI elements...
403      StreamUsageProgressBar->setProgress(iStreamUsage);      StreamUsageProgressBar->setProgress(iStreamUsage);
404      StreamVoiceCountTextLabel->setText(QString("%1 / %2").arg(iStreamCount).arg(iVoiceCount));      StreamVoiceCountTextLabel->setText(QString("%1 / %2").arg(iStreamCount).arg(iVoiceCount));
405    
406        // We're clean.
407        return true;
408  }  }
409    
410    
# Line 267  void qsamplerChannelStrip::volumeChanged Line 434  void qsamplerChannelStrip::volumeChanged
434  // Context menu event handler.  // Context menu event handler.
435  void qsamplerChannelStrip::contextMenuEvent( QContextMenuEvent *pEvent )  void qsamplerChannelStrip::contextMenuEvent( QContextMenuEvent *pEvent )
436  {  {
437      if (m_pMainForm == NULL)      if (m_pChannel == NULL)
438          return;          return;
439            
440      // We'll just show up the main form's edit menu.      // We'll just show up the main form's edit menu (thru qsamplerChannel).
441      m_pMainForm->contextMenuEvent(pEvent);      m_pChannel->contextMenuEvent(pEvent);
442  }  }
443    
444    
445  // Maximum volume slider accessors.  // Error count hackish accessors.
446  void qsamplerChannelStrip::setMaxVolume ( int iMaxVolume )  void qsamplerChannelStrip::resetErrorCount (void)
447  {  {
448      m_iDirtyChange++;          m_iErrorCount = 0;
     VolumeSlider->setRange(0, iMaxVolume);  
     VolumeSpinBox->setRange(0, iMaxVolume);  
     m_iDirtyChange--;  
449  }  }
450    
451    

Legend:
Removed from v.264  
changed lines
  Added in v.751

  ViewVC Help
Powered by ViewVC