/[svn]/qsampler/trunk/src/qsamplerChannelStrip.cpp
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerChannelStrip.cpp

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

revision 1474 by schoenebeck, Mon Nov 5 20:47:38 2007 UTC revision 1507 by capela, Wed Nov 21 23:22:18 2007 UTC
# Line 20  Line 20 
20    
21  *****************************************************************************/  *****************************************************************************/
22    
23    #include "qsamplerAbout.h"
24  #include "qsamplerChannelStrip.h"  #include "qsamplerChannelStrip.h"
25    
26  #include "qsamplerMainForm.h"  #include "qsamplerMainForm.h"
27    
28  #include <q3dragobject.h>  #include <QDragEnterEvent>
   
29  #include <QUrl>  #include <QUrl>
30    
31  #include <math.h>  #include <math.h>
# Line 74  ChannelStrip::~ChannelStrip() { Line 74  ChannelStrip::~ChannelStrip() {
74  }  }
75    
76    
77  // Drag'n'drop file handler.  // Window drag-n-drop event handlers.
78  bool ChannelStrip::decodeDragFile ( const QMimeSource *pEvent, QString& sInstrumentFile )  void ChannelStrip::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )
79  {  {
80          if (m_pChannel == NULL)          if (m_pChannel == NULL)
81                  return false;                  return;
82          if (Q3TextDrag::canDecode(pEvent)) {  
83                  QString sText;          bool bAccept = false;
84                  if (Q3TextDrag::decode(pEvent, sText)) {  
85                          QStringList files = QStringList::split('\n', sText);          if (pDragEnterEvent->source() == NULL) {
86                          for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) {                  const QMimeData *pMimeData = pDragEnterEvent->mimeData();
87                                  *iter = QUrl((*iter).stripWhiteSpace().replace(QRegExp("^file:"), QString::null)).path();                  if (pMimeData && pMimeData->hasUrls()) {
88                                  if (qsamplerChannel::isInstrumentFile(*iter)) {                          QListIterator<QUrl> iter(pMimeData->urls());
89                                          sInstrumentFile = *iter;                          while (iter.hasNext()) {
90                                          return true;                                  const QString& sFilename = iter.next().toLocalFile();
91                                    if (!sFilename.isEmpty()) {
92                                            bAccept = qsamplerChannel::isInstrumentFile(sFilename);
93                                            break;
94                                  }                                  }
95                          }                          }
96                  }                  }
97          }          }
         // Fail.  
         return false;  
 }  
   
98    
99  // Window drag-n-drop event handlers.          if (bAccept)
100  void ChannelStrip::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )                  pDragEnterEvent->accept();
101  {          else
102          QString sInstrumentFile;                  pDragEnterEvent->ignore();
         pDragEnterEvent->accept(decodeDragFile(pDragEnterEvent, sInstrumentFile));  
103  }  }
104    
105    
106  void ChannelStrip::dropEvent ( QDropEvent* pDropEvent )  void ChannelStrip::dropEvent ( QDropEvent* pDropEvent )
107  {  {
108          QString sInstrumentFile;          if (m_pChannel == NULL)
109                    return;
110    
111            if (pDropEvent->source())
112                    return;
113    
114          if (decodeDragFile(pDropEvent, sInstrumentFile)) {          const QMimeData *pMimeData = pDropEvent->mimeData();
115                  // Go and set the dropped instrument filename...          if (pMimeData && pMimeData->hasUrls()) {
116                  m_pChannel->setInstrument(sInstrumentFile, 0);                  QStringList files;
117                  // Open up the channel dialog.                  QListIterator<QUrl> iter(pMimeData->urls());
118                  channelSetup();                  while (iter.hasNext()) {
119                            const QString& sFilename = iter.next().toLocalFile();
120                            if (!sFilename.isEmpty()) {
121                                    // Go and set the dropped instrument filename...
122                                    m_pChannel->setInstrument(sFilename, 0);
123                                    // Open up the channel dialog.
124                                    channelSetup();
125                                    break;
126                            }
127                    }
128          }          }
129  }  }
130    
# Line 162  void ChannelStrip::setDisplayFont ( cons Line 173  void ChannelStrip::setDisplayFont ( cons
173  // Channel display background effect.  // Channel display background effect.
174  void ChannelStrip::setDisplayEffect ( bool bDisplayEffect )  void ChannelStrip::setDisplayEffect ( bool bDisplayEffect )
175  {  {
176      QPixmap pm =          QPalette pal;
177          (bDisplayEffect) ?          pal.setColor(QPalette::Foreground, Qt::yellow);
178              QPixmap(":/icons/displaybg1.png") : QPixmap();          ui.EngineNameTextLabel->setPalette(pal);
179      setDisplayBackground(pm);          ui.MidiPortChannelTextLabel->setPalette(pal);
180  }          pal.setColor(QPalette::Foreground, Qt::green);
181            if (bDisplayEffect) {
182                    QPixmap pm(":/icons/displaybg1.png");
183  // Update main display background pixmap.                  pal.setBrush(QPalette::Background, QBrush(pm));
184  void ChannelStrip::setDisplayBackground ( const QPixmap& pm )          } else {
185  {                  pal.setColor(QPalette::Background, Qt::black);
186      // Set the main origin...          }
187      ui.ChannelInfoFrame->setPaletteBackgroundPixmap(pm);          ui.ChannelInfoFrame->setPalette(pal);
188            ui.StreamVoiceCountTextLabel->setPalette(pal);
     // Iterate for every child text label...  
     QList<QObject*> list = ui.ChannelInfoFrame->queryList("QLabel");  
     for (QList<QObject*>::iterator iter = list.begin(); iter != list.end(); iter++) {  
         static_cast<QLabel*>(*iter)->setPaletteBackgroundPixmap(pm);  
     }  
   
     // And this standalone too.  
     ui.StreamVoiceCountTextLabel->setPaletteBackgroundPixmap(pm);  
189  }  }
190    
191    
# Line 339  bool ChannelStrip::updateChannelInfo (vo Line 342  bool ChannelStrip::updateChannelInfo (vo
342    
343      // Update strip caption.      // Update strip caption.
344      QString sText = m_pChannel->channelName();      QString sText = m_pChannel->channelName();
345      setCaption(sText);      setWindowTitle(sText);
346      ui.ChannelSetupPushButton->setText(sText);      ui.ChannelSetupPushButton->setText(sText);
347    
348      // Check if we're up and connected.      // Check if we're up and connected.
# Line 367  bool ChannelStrip::updateChannelInfo (vo Line 370  bool ChannelStrip::updateChannelInfo (vo
370                  sMidiPortChannel += QString::number(m_pChannel->midiChannel() + 1);                  sMidiPortChannel += QString::number(m_pChannel->midiChannel() + 1);
371          ui.MidiPortChannelTextLabel->setText(sMidiPortChannel);          ui.MidiPortChannelTextLabel->setText(sMidiPortChannel);
372    
373            // Common palette...
374            QPalette pal;
375            const QColor& rgbFore = pal.color(QPalette::Foreground);
376    
377      // Instrument status...      // Instrument status...
378      int iInstrumentStatus = m_pChannel->instrumentStatus();      int iInstrumentStatus = m_pChannel->instrumentStatus();
379      if (iInstrumentStatus < 0) {      if (iInstrumentStatus < 0) {
380          ui.InstrumentStatusTextLabel->setPaletteForegroundColor(Qt::red);                  pal.setColor(QPalette::Foreground, Qt::red);
381                    ui.InstrumentStatusTextLabel->setPalette(pal);
382          ui.InstrumentStatusTextLabel->setText(tr("ERR%1").arg(iInstrumentStatus));          ui.InstrumentStatusTextLabel->setText(tr("ERR%1").arg(iInstrumentStatus));
383          m_iErrorCount++;          m_iErrorCount++;
384          return false;          return false;
385      }      }
386      // All seems normal...      // All seems normal...
387      ui.InstrumentStatusTextLabel->setPaletteForegroundColor(iInstrumentStatus < 100 ? Qt::yellow : Qt::green);          pal.setColor(QPalette::Foreground,
388                    iInstrumentStatus < 100 ? Qt::yellow : Qt::green);
389        ui.InstrumentStatusTextLabel->setPalette(pal);
390      ui.InstrumentStatusTextLabel->setText(QString::number(iInstrumentStatus) + '%');      ui.InstrumentStatusTextLabel->setText(QString::number(iInstrumentStatus) + '%');
391      m_iErrorCount = 0;      m_iErrorCount = 0;
392    
393  #ifdef CONFIG_MUTE_SOLO  #ifdef CONFIG_MUTE_SOLO
394      // Mute/Solo button state coloring...      // Mute/Solo button state coloring...
     const QColor& rgbNormal = ChannelSetupPushButton->paletteBackgroundColor();  
395      bool bMute = m_pChannel->channelMute();      bool bMute = m_pChannel->channelMute();
396      ChannelMutePushButton->setPaletteBackgroundColor(bMute ? Qt::yellow : rgbNormal);          const QColor& rgbButton = pal.color(QPalette::Button);
397      ChannelMutePushButton->setDown(bMute);          pal.setColor(QPalette::Foreground, rgbFore);
398            pal.setColor(QPalette::Button, bMute ? Qt::yellow : rgbButton);
399            ui.ChannelMutePushButton->setPalette(pal);
400            ui.ChannelMutePushButton->setDown(bMute);
401      bool bSolo = m_pChannel->channelSolo();      bool bSolo = m_pChannel->channelSolo();
402      ChannelSoloPushButton->setPaletteBackgroundColor(bSolo ? Qt::cyan : rgbNormal);          pal.setColor(QPalette::Button, bSolo ? Qt::cyan : rgbButton);  
403      ChannelSoloPushButton->setDown(bSolo);          ui.ChannelSoloPushButton->setPalette(pal);
404            ui.ChannelSoloPushButton->setDown(bSolo);
405  #else  #else
406          ui.ChannelMutePushButton->setEnabled(false);          ui.ChannelMutePushButton->setEnabled(false);
407          ui.ChannelSoloPushButton->setEnabled(false);          ui.ChannelSoloPushButton->setEnabled(false);
# Line 416  bool ChannelStrip::updateChannelUsage (v Line 429  bool ChannelStrip::updateChannelUsage (v
429    
430      // Get current channel voice count.      // Get current channel voice count.
431      int iVoiceCount  = ::lscp_get_channel_voice_count(pMainForm->client(), m_pChannel->channelID());      int iVoiceCount  = ::lscp_get_channel_voice_count(pMainForm->client(), m_pChannel->channelID());
432      // Get current stream count.     // Get current stream count.
433      int iStreamCount = ::lscp_get_channel_stream_count(pMainForm->client(), m_pChannel->channelID());      int iStreamCount = ::lscp_get_channel_stream_count(pMainForm->client(), m_pChannel->channelID());
434      // Get current channel buffer fill usage.      // Get current channel buffer fill usage.
435      // As benno has suggested this is the percentage usage      // As benno has suggested this is the percentage usage

Legend:
Removed from v.1474  
changed lines
  Added in v.1507

  ViewVC Help
Powered by ViewVC