/[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 1464 by capela, Thu Nov 1 17:14:21 2007 UTC revision 1637 by capela, Mon Jan 7 20:00:13 2008 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    
 #include <math.h>  
   
31  // Channel status/usage usage limit control.  // Channel status/usage usage limit control.
32  #define QSAMPLER_ERROR_LIMIT    3  #define QSAMPLER_ERROR_LIMIT    3
33    
34  namespace QSampler {  // Needed for lroundf()
35    #include <math.h>
36    
37    #ifndef CONFIG_ROUND
38    static inline long lroundf ( float x )
39    {
40            if (x >= 0.0f)
41                    return long(x + 0.5f);
42            else
43                    return long(x - 0.5f);
44    }
45    #endif
46    
 ChannelStrip::ChannelStrip(QWidget* parent, Qt::WFlags f) : QWidget(parent, f) {  
     ui.setupUi(this);  
47    
48      // Initialize locals.  namespace QSampler {
     m_pChannel     = NULL;  
     m_iDirtyChange = 0;  
     m_iErrorCount  = 0;  
49    
50      // Try to restore normal window positioning.  //-------------------------------------------------------------------------
51      adjustSize();  // QSampler::ChannelStrip -- Channel strip form implementation.
52    //
53    
54    // Channel strip activation/selection.
55    ChannelStrip *ChannelStrip::g_pSelectedStrip = NULL;
56    
57    ChannelStrip::ChannelStrip ( QWidget* pParent, Qt::WindowFlags wflags )
58            : QWidget(pParent, wflags)
59    {
60            m_ui.setupUi(this);
61    
62            // Initialize locals.
63            m_pChannel     = NULL;
64            m_iDirtyChange = 0;
65            m_iErrorCount  = 0;
66    
67            // Try to restore normal window positioning.
68            adjustSize();
69    
70            QObject::connect(m_ui.ChannelSetupPushButton,
71                    SIGNAL(clicked()),
72                    SLOT(channelSetup()));
73            QObject::connect(m_ui.ChannelMutePushButton,
74                    SIGNAL(toggled(bool)),
75                    SLOT(channelMute(bool)));
76            QObject::connect(m_ui.ChannelSoloPushButton,
77                    SIGNAL(toggled(bool)),
78                    SLOT(channelSolo(bool)));
79            QObject::connect(m_ui.VolumeSlider,
80                    SIGNAL(valueChanged(int)),
81                    SLOT(volumeChanged(int)));
82            QObject::connect(m_ui.VolumeSpinBox,
83                    SIGNAL(valueChanged(int)),
84                    SLOT(volumeChanged(int)));
85            QObject::connect(m_ui.ChannelEditPushButton,
86                    SIGNAL(clicked()),
87                    SLOT(channelEdit()));
88    
89            setSelected(false);
90  }  }
91    
92  ChannelStrip::~ChannelStrip() {  
93      // Destroy existing channel descriptor.  ChannelStrip::~ChannelStrip (void)
94      if (m_pChannel)  {
95          delete m_pChannel;          setSelected(false);
96      m_pChannel = NULL;  
97            // Destroy existing channel descriptor.
98            if (m_pChannel)
99                    delete m_pChannel;
100            m_pChannel = NULL;
101  }  }
102    
103    
104  // Drag'n'drop file handler.  // Window drag-n-drop event handlers.
105  bool ChannelStrip::decodeDragFile ( const QMimeSource *pEvent, QString& sInstrumentFile )  void ChannelStrip::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )
106  {  {
107          if (m_pChannel == NULL)          if (m_pChannel == NULL)
108                  return false;                  return;
109          if (Q3TextDrag::canDecode(pEvent)) {  
110                  QString sText;          bool bAccept = false;
111                  if (Q3TextDrag::decode(pEvent, sText)) {  
112                          QStringList files = QStringList::split('\n', sText);          if (pDragEnterEvent->source() == NULL) {
113                          for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) {                  const QMimeData *pMimeData = pDragEnterEvent->mimeData();
114                                  *iter = QUrl((*iter).stripWhiteSpace().replace(QRegExp("^file:"), QString::null)).path();                  if (pMimeData && pMimeData->hasUrls()) {
115                                  if (qsamplerChannel::isInstrumentFile(*iter)) {                          QListIterator<QUrl> iter(pMimeData->urls());
116                                          sInstrumentFile = *iter;                          while (iter.hasNext()) {
117                                          return true;                                  const QString& sFilename = iter.next().toLocalFile();
118                                    if (!sFilename.isEmpty()) {
119                                            bAccept = Channel::isInstrumentFile(sFilename);
120                                            break;
121                                  }                                  }
122                          }                          }
123                  }                  }
124          }          }
         // Fail.  
         return false;  
 }  
   
125    
126  // Window drag-n-drop event handlers.          if (bAccept)
127  void ChannelStrip::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )                  pDragEnterEvent->accept();
128  {          else
129          QString sInstrumentFile;                  pDragEnterEvent->ignore();
         pDragEnterEvent->accept(decodeDragFile(pDragEnterEvent, sInstrumentFile));  
130  }  }
131    
132    
133  void ChannelStrip::dropEvent ( QDropEvent* pDropEvent )  void ChannelStrip::dropEvent ( QDropEvent* pDropEvent )
134  {  {
135          QString sInstrumentFile;          if (m_pChannel == NULL)
136                    return;
137    
138            if (pDropEvent->source())
139                    return;
140    
141          if (decodeDragFile(pDropEvent, sInstrumentFile)) {          const QMimeData *pMimeData = pDropEvent->mimeData();
142                  // Go and set the dropped instrument filename...          if (pMimeData && pMimeData->hasUrls()) {
143                  m_pChannel->setInstrument(sInstrumentFile, 0);                  QStringList files;
144                  // Open up the channel dialog.                  QListIterator<QUrl> iter(pMimeData->urls());
145                  channelSetup();                  while (iter.hasNext()) {
146                            const QString& sFilename = iter.next().toLocalFile();
147                            if (!sFilename.isEmpty()) {
148                                    // Go and set the dropped instrument filename...
149                                    m_pChannel->setInstrument(sFilename, 0);
150                                    // Open up the channel dialog.
151                                    channelSetup();
152                                    break;
153                            }
154                    }
155          }          }
156  }  }
157    
158    
159  // Channel strip setup formal initializer.  // Channel strip setup formal initializer.
160  void ChannelStrip::setup ( qsamplerChannel *pChannel )  void ChannelStrip::setup ( Channel *pChannel )
161  {  {
162      // Destroy any previous channel descriptor;          // Destroy any previous channel descriptor;
163      // (remember that once setup we own it!)          // (remember that once setup we own it!)
164      if (m_pChannel)          if (m_pChannel)
165          delete m_pChannel;                  delete m_pChannel;
166    
167      // Set the new one...          // Set the new one...
168      m_pChannel = pChannel;          m_pChannel = pChannel;
169    
170      // Stabilize this around.          // Stabilize this around.
171      updateChannelInfo();          updateChannelInfo();
172    
173          // We'll accept drops from now on...          // We'll accept drops from now on...
174          if (m_pChannel)          if (m_pChannel)
175                  setAcceptDrops(true);                  setAcceptDrops(true);
176  }  }
177    
178    
179  // Channel secriptor accessor.  // Channel secriptor accessor.
180  qsamplerChannel *ChannelStrip::channel (void)  Channel *ChannelStrip::channel (void) const
181  {  {
182      return m_pChannel;          return m_pChannel;
183  }  }
184    
185    
186  // Messages view font accessors.  // Messages view font accessors.
187  QFont ChannelStrip::displayFont (void)  QFont ChannelStrip::displayFont (void) const
188  {  {
189      return ui.EngineNameTextLabel->font();          return m_ui.EngineNameTextLabel->font();
190  }  }
191    
192  void ChannelStrip::setDisplayFont ( const QFont & font )  void ChannelStrip::setDisplayFont ( const QFont & font )
193  {  {
194      ui.EngineNameTextLabel->setFont(font);          m_ui.EngineNameTextLabel->setFont(font);
195      ui.MidiPortChannelTextLabel->setFont(font);          m_ui.MidiPortChannelTextLabel->setFont(font);
196      ui.InstrumentNameTextLabel->setFont(font);          m_ui.InstrumentNameTextLabel->setFont(font);
197      ui.InstrumentStatusTextLabel->setFont(font);          m_ui.InstrumentStatusTextLabel->setFont(font);
198  }  }
199    
200    
201  // Channel display background effect.  // Channel display background effect.
202  void ChannelStrip::setDisplayEffect ( bool bDisplayEffect )  void ChannelStrip::setDisplayEffect ( bool bDisplayEffect )
203  {  {
204      QPixmap pm =          QPalette pal;
205          (bDisplayEffect) ?          pal.setColor(QPalette::Foreground, Qt::yellow);
206              QPixmap(":/qsampler/pixmaps/displaybg1.png") : QPixmap();          m_ui.EngineNameTextLabel->setPalette(pal);
207      setDisplayBackground(pm);          m_ui.MidiPortChannelTextLabel->setPalette(pal);
208  }          pal.setColor(QPalette::Foreground, Qt::green);
209            if (bDisplayEffect) {
210                    QPixmap pm(":/icons/displaybg1.png");
211  // Update main display background pixmap.                  pal.setBrush(QPalette::Background, QBrush(pm));
212  void ChannelStrip::setDisplayBackground ( const QPixmap& pm )          } else {
213  {                  pal.setColor(QPalette::Background, Qt::black);
214      // Set the main origin...          }
215      ui.ChannelInfoFrame->setPaletteBackgroundPixmap(pm);          m_ui.ChannelInfoFrame->setPalette(pal);
216            m_ui.InstrumentNameTextLabel->setPalette(pal);
217      // Iterate for every child text label...          m_ui.StreamVoiceCountTextLabel->setPalette(pal);
     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);  
218  }  }
219    
220    
221  // Maximum volume slider accessors.  // Maximum volume slider accessors.
222  void ChannelStrip::setMaxVolume ( int iMaxVolume )  void ChannelStrip::setMaxVolume ( int iMaxVolume )
223  {  {
224      m_iDirtyChange++;          m_iDirtyChange++;
225      ui.VolumeSlider->setRange(0, iMaxVolume);          m_ui.VolumeSlider->setRange(0, iMaxVolume);
226      ui.VolumeSpinBox->setRange(0, iMaxVolume);          m_ui.VolumeSpinBox->setRange(0, iMaxVolume);
227      m_iDirtyChange--;          m_iDirtyChange--;
228  }  }
229    
230    
# Line 263  bool ChannelStrip::updateInstrumentName Line 314  bool ChannelStrip::updateInstrumentName
314    
315          // Instrument name...          // Instrument name...
316          if (m_pChannel->instrumentName().isEmpty()) {          if (m_pChannel->instrumentName().isEmpty()) {
317                  if (m_pChannel->instrumentStatus() >= 0)                  if (m_pChannel->instrumentStatus() >= 0) {
318                          ui.InstrumentNameTextLabel->setText(' ' + qsamplerChannel::loadingInstrument());                          m_ui.InstrumentNameTextLabel->setText(
319                  else                                  ' ' + Channel::loadingInstrument());
320                          ui.InstrumentNameTextLabel->setText(' ' + qsamplerChannel::noInstrumentName());                  } else {
321          } else                          m_ui.InstrumentNameTextLabel->setText(
322                  ui.InstrumentNameTextLabel->setText(' ' + m_pChannel->instrumentName());                                  ' ' + Channel::noInstrumentName());
323                    }
324            } else {
325                    m_ui.InstrumentNameTextLabel->setText(
326                            ' ' + m_pChannel->instrumentName());
327            }
328    
329          return true;          return true;
330  }  }
# Line 277  bool ChannelStrip::updateInstrumentName Line 333  bool ChannelStrip::updateInstrumentName
333  // Do the dirty volume change.  // Do the dirty volume change.
334  bool ChannelStrip::updateChannelVolume (void)  bool ChannelStrip::updateChannelVolume (void)
335  {  {
336      if (m_pChannel == NULL)          if (m_pChannel == NULL)
337          return false;                  return false;
   
     // Convert...  
 #ifdef CONFIG_ROUND  
     int iVolume = (int) ::round(100.0 * m_pChannel->volume());  
 #else  
     double fIPart = 0.0;  
     double fFPart = ::modf(100.0 * m_pChannel->volume(), &fIPart);  
     int iVolume = (int) fIPart;  
     if (fFPart >= +0.5)  
         iVolume++;  
     else  
     if (fFPart <= -0.5)  
         iVolume--;  
 #endif  
338    
339      // And clip...          // Convert...
340      if (iVolume < 0)          int iVolume = ::lroundf(100.0f * m_pChannel->volume());
341          iVolume = 0;          // And clip...
342            if (iVolume < 0)
343      // Flag it here, to avoid infinite recursion.                  iVolume = 0;
344      m_iDirtyChange++;  
345      ui.VolumeSlider->setValue(iVolume);          // Flag it here, to avoid infinite recursion.
346      ui.VolumeSpinBox->setValue(iVolume);          m_iDirtyChange++;
347      m_iDirtyChange--;          m_ui.VolumeSlider->setValue(iVolume);
348            m_ui.VolumeSpinBox->setValue(iVolume);
349            m_iDirtyChange--;
350    
351      return true;          return true;
352  }  }
353    
354    
355  // Update whole channel info state.  // Update whole channel info state.
356  bool ChannelStrip::updateChannelInfo (void)  bool ChannelStrip::updateChannelInfo (void)
357  {  {
358      if (m_pChannel == NULL)          if (m_pChannel == NULL)
359          return false;                  return false;
360    
361          // Check for error limit/recycle...          // Check for error limit/recycle...
362          if (m_iErrorCount > QSAMPLER_ERROR_LIMIT)          if (m_iErrorCount > QSAMPLER_ERROR_LIMIT)
363                  return true;                  return true;
364    
365      // Update strip caption.          // Update strip caption.
366      QString sText = m_pChannel->channelName();          QString sText = m_pChannel->channelName();
367      setCaption(sText);          setWindowTitle(sText);
368      ui.ChannelSetupPushButton->setText(sText);          m_ui.ChannelSetupPushButton->setText('&' + sText);
369    
370      // Check if we're up and connected.          // Check if we're up and connected.
371          MainForm* pMainForm = MainForm::getInstance();          MainForm* pMainForm = MainForm::getInstance();
372          if (pMainForm->client() == NULL)          if (pMainForm->client() == NULL)
373                  return false;                  return false;
374    
375      // Read actual channel information.          // Read actual channel information.
376      m_pChannel->updateChannelInfo();          m_pChannel->updateChannelInfo();
377    
378      // Engine name...          // Engine name...
379      if (m_pChannel->engineName().isEmpty())          if (m_pChannel->engineName().isEmpty()) {
380          ui.EngineNameTextLabel->setText(' ' + qsamplerChannel::noEngineName());                  m_ui.EngineNameTextLabel->setText(
381      else                          ' ' + Channel::noEngineName());
382          ui.EngineNameTextLabel->setText(' ' + m_pChannel->engineName());          } else {
383                    m_ui.EngineNameTextLabel->setText(
384                            ' ' + m_pChannel->engineName());
385            }
386    
387          // Instrument name...          // Instrument name...
388          updateInstrumentName(false);          updateInstrumentName(false);
389    
390      // MIDI Port/Channel...          // MIDI Port/Channel...
391          QString sMidiPortChannel = QString::number(m_pChannel->midiPort()) + " / ";          QString sMidiPortChannel = QString::number(m_pChannel->midiPort()) + " / ";
392          if (m_pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL)          if (m_pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL)
393                  sMidiPortChannel += tr("All");                  sMidiPortChannel += tr("All");
394          else          else
395                  sMidiPortChannel += QString::number(m_pChannel->midiChannel() + 1);                  sMidiPortChannel += QString::number(m_pChannel->midiChannel() + 1);
396          ui.MidiPortChannelTextLabel->setText(sMidiPortChannel);          m_ui.MidiPortChannelTextLabel->setText(sMidiPortChannel);
397    
398      // Instrument status...          // Common palette...
399      int iInstrumentStatus = m_pChannel->instrumentStatus();          QPalette pal;
400      if (iInstrumentStatus < 0) {          const QColor& rgbFore = pal.color(QPalette::Foreground);
401          ui.InstrumentStatusTextLabel->setPaletteForegroundColor(Qt::red);  
402          ui.InstrumentStatusTextLabel->setText(tr("ERR%1").arg(iInstrumentStatus));          // Instrument status...
403          m_iErrorCount++;          int iInstrumentStatus = m_pChannel->instrumentStatus();
404          return false;          if (iInstrumentStatus < 0) {
405      }                  pal.setColor(QPalette::Foreground, Qt::red);
406      // All seems normal...                  m_ui.InstrumentStatusTextLabel->setPalette(pal);
407      ui.InstrumentStatusTextLabel->setPaletteForegroundColor(iInstrumentStatus < 100 ? Qt::yellow : Qt::green);                  m_ui.InstrumentStatusTextLabel->setText(
408      ui.InstrumentStatusTextLabel->setText(QString::number(iInstrumentStatus) + '%');                          tr("ERR%1").arg(iInstrumentStatus));
409      m_iErrorCount = 0;                  m_iErrorCount++;
410                    return false;
411            }
412            // All seems normal...
413            pal.setColor(QPalette::Foreground,
414                    iInstrumentStatus < 100 ? Qt::yellow : Qt::green);
415            m_ui.InstrumentStatusTextLabel->setPalette(pal);
416            m_ui.InstrumentStatusTextLabel->setText(
417                    QString::number(iInstrumentStatus) + '%');
418            m_iErrorCount = 0;
419    
420  #ifdef CONFIG_MUTE_SOLO  #ifdef CONFIG_MUTE_SOLO
421      // Mute/Solo button state coloring...          // Mute/Solo button state coloring...
422      const QColor& rgbNormal = ChannelSetupPushButton->paletteBackgroundColor();          bool bMute = m_pChannel->channelMute();
423      bool bMute = m_pChannel->channelMute();          const QColor& rgbButton = pal.color(QPalette::Button);
424      ChannelMutePushButton->setPaletteBackgroundColor(bMute ? Qt::yellow : rgbNormal);          pal.setColor(QPalette::Foreground, rgbFore);
425      ChannelMutePushButton->setDown(bMute);          pal.setColor(QPalette::Button, bMute ? Qt::yellow : rgbButton);
426      bool bSolo = m_pChannel->channelSolo();          m_ui.ChannelMutePushButton->setPalette(pal);
427      ChannelSoloPushButton->setPaletteBackgroundColor(bSolo ? Qt::cyan : rgbNormal);          m_ui.ChannelMutePushButton->setDown(bMute);
428      ChannelSoloPushButton->setDown(bSolo);          bool bSolo = m_pChannel->channelSolo();
429            pal.setColor(QPalette::Button, bSolo ? Qt::cyan : rgbButton);  
430            m_ui.ChannelSoloPushButton->setPalette(pal);
431            m_ui.ChannelSoloPushButton->setDown(bSolo);
432  #else  #else
433          ui.ChannelMutePushButton->setEnabled(false);          m_ui.ChannelMutePushButton->setEnabled(false);
434          ui.ChannelSoloPushButton->setEnabled(false);          m_ui.ChannelSoloPushButton->setEnabled(false);
435  #endif  #endif
436    
437      // And update the both GUI volume elements;          // And update the both GUI volume elements;
438      // return success if, and only if, intrument is fully loaded...          // return success if, and only if, intrument is fully loaded...
439      return updateChannelVolume() && (iInstrumentStatus == 100);          return updateChannelVolume() && (iInstrumentStatus == 100);
440  }  }
441    
442    
443  // Update whole channel usage state.  // Update whole channel usage state.
444  bool ChannelStrip::updateChannelUsage (void)  bool ChannelStrip::updateChannelUsage (void)
445  {  {
446      if (m_pChannel == NULL)          if (m_pChannel == NULL)
447          return false;                  return false;
448    
449          MainForm *pMainForm = MainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
450          if (pMainForm->client() == NULL)          if (pMainForm->client() == NULL)
# Line 393  bool ChannelStrip::updateChannelUsage (v Line 452  bool ChannelStrip::updateChannelUsage (v
452    
453          // This only makes sense on fully loaded channels...          // This only makes sense on fully loaded channels...
454          if (m_pChannel->instrumentStatus() < 100)          if (m_pChannel->instrumentStatus() < 100)
455              return false;                  return false;
456    
457      // Get current channel voice count.          // Get current channel voice count.
458      int iVoiceCount  = ::lscp_get_channel_voice_count(pMainForm->client(), m_pChannel->channelID());          int iVoiceCount  = ::lscp_get_channel_voice_count(
459      // Get current stream count.                  pMainForm->client(), m_pChannel->channelID());
460      int iStreamCount = ::lscp_get_channel_stream_count(pMainForm->client(), m_pChannel->channelID());  // Get current stream count.
461      // Get current channel buffer fill usage.          int iStreamCount = ::lscp_get_channel_stream_count(
462      // As benno has suggested this is the percentage usage                  pMainForm->client(), m_pChannel->channelID());
463      // of the least filled buffer stream...          // Get current channel buffer fill usage.
464      int iStreamUsage = ::lscp_get_channel_stream_usage(pMainForm->client(), m_pChannel->channelID());;          // As benno has suggested this is the percentage usage
465            // of the least filled buffer stream...
466      // Update the GUI elements...          int iStreamUsage = ::lscp_get_channel_stream_usage(
467      ui.StreamUsageProgressBar->setValue(iStreamUsage);                  pMainForm->client(), m_pChannel->channelID());;
468      ui.StreamVoiceCountTextLabel->setText(QString("%1 / %2").arg(iStreamCount).arg(iVoiceCount));  
469            // Update the GUI elements...
470            m_ui.StreamUsageProgressBar->setValue(iStreamUsage);
471            m_ui.StreamVoiceCountTextLabel->setText(
472                    QString("%1 / %2").arg(iStreamCount).arg(iVoiceCount));
473    
474      // We're clean.          // We're clean.
475      return true;          return true;
476  }  }
477    
478    
479  // Volume change slot.  // Volume change slot.
480  void ChannelStrip::volumeChanged ( int iVolume )  void ChannelStrip::volumeChanged ( int iVolume )
481  {  {
482      if (m_pChannel == NULL)          if (m_pChannel == NULL)
483          return;                  return;
484    
485      // Avoid recursion.          // Avoid recursion.
486      if (m_iDirtyChange > 0)          if (m_iDirtyChange > 0)
487          return;                  return;
488    
489      // Convert and clip.          // Convert and clip.
490      float fVolume = (float) iVolume / 100.0;          float fVolume = (float) iVolume / 100.0f;
491      if (fVolume < 0.001)          if (fVolume < 0.001f)
492          fVolume = 0.0;                  fVolume = 0.0f;
493    
494      // Update the GUI elements.          // Update the GUI elements.
495      if (m_pChannel->setVolume(fVolume)) {          if (m_pChannel->setVolume(fVolume)) {
496          updateChannelVolume();                  updateChannelVolume();
497          emit channelChanged(this);                  emit channelChanged(this);
498      }          }
499  }  }
500    
501    
502  // Context menu event handler.  // Context menu event handler.
503  void ChannelStrip::contextMenuEvent( QContextMenuEvent *pEvent )  void ChannelStrip::contextMenuEvent( QContextMenuEvent *pEvent )
504  {  {
505      if (m_pChannel == NULL)          if (m_pChannel == NULL)
506          return;                  return;
507    
508      // We'll just show up the main form's edit menu (thru qsamplerChannel).          // We'll just show up the main form's edit menu (thru qsamplerChannel).
509      m_pChannel->contextMenuEvent(pEvent);          m_pChannel->contextMenuEvent(pEvent);
510  }  }
511    
512    
# Line 453  void ChannelStrip::resetErrorCount (void Line 516  void ChannelStrip::resetErrorCount (void
516          m_iErrorCount = 0;          m_iErrorCount = 0;
517  }  }
518    
519    
520    // Channel strip activation/selection.
521    void ChannelStrip::setSelected ( bool bSelected )
522    {
523            if (bSelected) {
524                    if (g_pSelectedStrip == this)
525                            return;
526                    if (g_pSelectedStrip)
527                            g_pSelectedStrip->setSelected(false);
528                    g_pSelectedStrip = this;
529            } else {
530                    if (g_pSelectedStrip == this)
531                            g_pSelectedStrip = NULL;
532            }
533    
534            QPalette pal;
535            if (bSelected) {
536                    const QColor& color = pal.midlight().color();
537                    pal.setColor(QPalette::Background, color.dark(150));
538                    pal.setColor(QPalette::Foreground, color.light(150));
539            }
540            QWidget::setPalette(pal);
541    }
542    
543    
544    bool ChannelStrip::isSelected (void) const
545    {
546            return (this == g_pSelectedStrip);
547    }
548    
549    
550  } // namespace QSampler  } // namespace QSampler
551    
552    

Legend:
Removed from v.1464  
changed lines
  Added in v.1637

  ViewVC Help
Powered by ViewVC