/[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 2570 by capela, Wed May 21 16:56:18 2014 UTC revision 3555 by capela, Tue Aug 13 10:19:32 2019 UTC
# Line 1  Line 1 
1  // qsamplerChannelStrip.cpp  // qsamplerChannelStrip.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2014, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2019, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007, 2008, 2014 Christian Schoenebeck     Copyright (C) 2007, 2008, 2014 Christian Schoenebeck
6    
7     This program is free software; you can redistribute it and/or     This program is free software; you can redistribute it and/or
# Line 34  Line 34 
34  #include <QUrl>  #include <QUrl>
35  #include <QMenu>  #include <QMenu>
36    
37  #if QT_VERSION >= 0x050000  #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
38  #include <QMimeData>  #include <QMimeData>
39  #endif  #endif
40    
# Line 63  namespace QSampler { Line 63  namespace QSampler {
63    
64  // MIDI activity pixmap common resources.  // MIDI activity pixmap common resources.
65  int      ChannelStrip::g_iMidiActivityRefCount = 0;  int      ChannelStrip::g_iMidiActivityRefCount = 0;
66  QPixmap *ChannelStrip::g_pMidiActivityLedOn    = NULL;  QPixmap *ChannelStrip::g_pMidiActivityLedOn    = nullptr;
67  QPixmap *ChannelStrip::g_pMidiActivityLedOff   = NULL;  QPixmap *ChannelStrip::g_pMidiActivityLedOff   = nullptr;
68    
69  // Channel strip activation/selection.  // Channel strip activation/selection.
70  ChannelStrip *ChannelStrip::g_pSelectedStrip = NULL;  ChannelStrip *ChannelStrip::g_pSelectedStrip = nullptr;
71    
72  ChannelStrip::ChannelStrip ( QWidget* pParent, Qt::WindowFlags wflags )  ChannelStrip::ChannelStrip ( QWidget* pParent, Qt::WindowFlags wflags )
73          : QWidget(pParent, wflags)          : QWidget(pParent, wflags)
# Line 75  ChannelStrip::ChannelStrip ( QWidget* pP Line 75  ChannelStrip::ChannelStrip ( QWidget* pP
75          m_ui.setupUi(this);          m_ui.setupUi(this);
76    
77          // Initialize locals.          // Initialize locals.
78          m_pChannel     = NULL;          m_pChannel     = nullptr;
79          m_iDirtyChange = 0;          m_iDirtyChange = 0;
80          m_iErrorCount  = 0;          m_iErrorCount  = 0;
81          m_instrumentListPopupMenu = NULL;          m_instrumentListPopupMenu = nullptr;
82    
83          if (++g_iMidiActivityRefCount == 1) {          if (++g_iMidiActivityRefCount == 1) {
84                  g_pMidiActivityLedOn  = new QPixmap(":/images/ledon1.png");                  g_pMidiActivityLedOn  = new QPixmap(":/images/ledon1.png");
# Line 111  ChannelStrip::ChannelStrip ( QWidget* pP Line 111  ChannelStrip::ChannelStrip ( QWidget* pP
111          QObject::connect(m_ui.ChannelSoloPushButton,          QObject::connect(m_ui.ChannelSoloPushButton,
112                  SIGNAL(toggled(bool)),                  SIGNAL(toggled(bool)),
113                  SLOT(channelSolo(bool)));                  SLOT(channelSolo(bool)));
114          QObject::connect(m_ui.VolumeSlider,          QObject::connect(m_ui.ChannelVolumeSlider,
115                  SIGNAL(valueChanged(int)),                  SIGNAL(valueChanged(int)),
116                  SLOT(volumeChanged(int)));                  SLOT(volumeChanged(int)));
117          QObject::connect(m_ui.VolumeSpinBox,          QObject::connect(m_ui.ChannelVolumeSpinBox,
118                  SIGNAL(valueChanged(int)),                  SIGNAL(valueChanged(int)),
119                  SLOT(volumeChanged(int)));                  SLOT(volumeChanged(int)));
120          QObject::connect(m_ui.ChannelEditPushButton,          QObject::connect(m_ui.ChannelEditPushButton,
121                  SIGNAL(clicked()),                  SIGNAL(clicked()),
122                  SLOT(channelEdit()));                  SLOT(channelEdit()));
123          QObject::connect(m_ui.FxPushButton,          QObject::connect(m_ui.ChannelFxPushButton,
124                  SIGNAL(clicked()),                  SIGNAL(clicked()),
125                  SLOT(channelFxEdit()));                  SLOT(channelFxEdit()));
126    
# Line 135  ChannelStrip::~ChannelStrip (void) Line 135  ChannelStrip::~ChannelStrip (void)
135          // Destroy existing channel descriptor.          // Destroy existing channel descriptor.
136          if (m_pChannel)          if (m_pChannel)
137                  delete m_pChannel;                  delete m_pChannel;
138          m_pChannel = NULL;          m_pChannel = nullptr;
139    
140          if (--g_iMidiActivityRefCount == 0) {          if (--g_iMidiActivityRefCount == 0) {
141                  if (g_pMidiActivityLedOn)                  if (g_pMidiActivityLedOn)
142                          delete g_pMidiActivityLedOn;                          delete g_pMidiActivityLedOn;
143                  g_pMidiActivityLedOn = NULL;                  g_pMidiActivityLedOn = nullptr;
144                  if (g_pMidiActivityLedOff)                  if (g_pMidiActivityLedOff)
145                          delete g_pMidiActivityLedOff;                          delete g_pMidiActivityLedOff;
146                  g_pMidiActivityLedOff = NULL;                  g_pMidiActivityLedOff = nullptr;
147          }          }
148  }  }
149    
# Line 151  ChannelStrip::~ChannelStrip (void) Line 151  ChannelStrip::~ChannelStrip (void)
151  // Window drag-n-drop event handlers.  // Window drag-n-drop event handlers.
152  void ChannelStrip::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )  void ChannelStrip::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )
153  {  {
154          if (m_pChannel == NULL)          if (m_pChannel == nullptr)
155                  return;                  return;
156    
157          bool bAccept = false;          bool bAccept = false;
158    
159          if (pDragEnterEvent->source() == NULL) {          if (pDragEnterEvent->source() == nullptr) {
160                  const QMimeData *pMimeData = pDragEnterEvent->mimeData();                  const QMimeData *pMimeData = pDragEnterEvent->mimeData();
161                  if (pMimeData && pMimeData->hasUrls()) {                  if (pMimeData && pMimeData->hasUrls()) {
162                          QListIterator<QUrl> iter(pMimeData->urls());                          QListIterator<QUrl> iter(pMimeData->urls());
# Line 180  void ChannelStrip::dragEnterEvent ( QDra Line 180  void ChannelStrip::dragEnterEvent ( QDra
180    
181  void ChannelStrip::dropEvent ( QDropEvent* pDropEvent )  void ChannelStrip::dropEvent ( QDropEvent* pDropEvent )
182  {  {
183          if (m_pChannel == NULL)          if (m_pChannel == nullptr)
184                  return;                  return;
185    
186          if (pDropEvent->source())          if (pDropEvent->source())
# Line 237  QFont ChannelStrip::displayFont (void) c Line 237  QFont ChannelStrip::displayFont (void) c
237          return m_ui.EngineNameTextLabel->font();          return m_ui.EngineNameTextLabel->font();
238  }  }
239    
240    
241  void ChannelStrip::setDisplayFont ( const QFont & font )  void ChannelStrip::setDisplayFont ( const QFont & font )
242  {  {
243          m_ui.EngineNameTextLabel->setFont(font);          m_ui.EngineNameTextLabel->setFont(font);
# Line 272  void ChannelStrip::setDisplayEffect ( bo Line 273  void ChannelStrip::setDisplayEffect ( bo
273  void ChannelStrip::setMaxVolume ( int iMaxVolume )  void ChannelStrip::setMaxVolume ( int iMaxVolume )
274  {  {
275          m_iDirtyChange++;          m_iDirtyChange++;
276          m_ui.VolumeSlider->setRange(0, iMaxVolume);          m_ui.ChannelVolumeSlider->setRange(0, iMaxVolume);
277          m_ui.VolumeSpinBox->setRange(0, iMaxVolume);          m_ui.ChannelVolumeSpinBox->setRange(0, iMaxVolume);
278          m_iDirtyChange--;          m_iDirtyChange--;
279  }  }
280    
# Line 281  void ChannelStrip::setMaxVolume ( int iM Line 282  void ChannelStrip::setMaxVolume ( int iM
282  // Channel setup dialog slot.  // Channel setup dialog slot.
283  bool ChannelStrip::channelSetup (void)  bool ChannelStrip::channelSetup (void)
284  {  {
285          if (m_pChannel == NULL)          if (m_pChannel == nullptr)
286                  return false;                  return false;
287    
288          // Invoke the channel setup dialog.          // Invoke the channel setup dialog.
289          bool bResult = m_pChannel->channelSetup(this);          const bool bResult = m_pChannel->channelSetup(this);
290          // Notify that this channel has changed.          // Notify that this channel has changed.
291          if (bResult)          if (bResult)
292                  emit channelChanged(this);                  emit channelChanged(this);
# Line 297  bool ChannelStrip::channelSetup (void) Line 298  bool ChannelStrip::channelSetup (void)
298  // Channel mute slot.  // Channel mute slot.
299  bool ChannelStrip::channelMute ( bool bMute )  bool ChannelStrip::channelMute ( bool bMute )
300  {  {
301          if (m_pChannel == NULL)          if (m_pChannel == nullptr)
302                  return false;                  return false;
303    
304          // Invoke the channel mute method.          // Invoke the channel mute method.
305          bool bResult = m_pChannel->setChannelMute(bMute);          const bool bResult = m_pChannel->setChannelMute(bMute);
306          // Notify that this channel has changed.          // Notify that this channel has changed.
307          if (bResult)          if (bResult)
308                  emit channelChanged(this);                  emit channelChanged(this);
# Line 313  bool ChannelStrip::channelMute ( bool bM Line 314  bool ChannelStrip::channelMute ( bool bM
314  // Channel solo slot.  // Channel solo slot.
315  bool ChannelStrip::channelSolo ( bool bSolo )  bool ChannelStrip::channelSolo ( bool bSolo )
316  {  {
317          if (m_pChannel == NULL)          if (m_pChannel == nullptr)
318                  return false;                  return false;
319    
320          // Invoke the channel solo method.          // Invoke the channel solo method.
321          bool bResult = m_pChannel->setChannelSolo(bSolo);          const bool bResult = m_pChannel->setChannelSolo(bSolo);
322          // Notify that this channel has changed.          // Notify that this channel has changed.
323          if (bResult)          if (bResult)
324                  emit channelChanged(this);                  emit channelChanged(this);
# Line 329  bool ChannelStrip::channelSolo ( bool bS Line 330  bool ChannelStrip::channelSolo ( bool bS
330  // Channel edit slot.  // Channel edit slot.
331  void ChannelStrip::channelEdit (void)  void ChannelStrip::channelEdit (void)
332  {  {
333          if (m_pChannel == NULL)          if (m_pChannel == nullptr)
334                  return;                  return;
335    
336          m_pChannel->editChannel();          m_pChannel->editChannel();
# Line 363  bool ChannelStrip::channelFxEdit (void) Line 364  bool ChannelStrip::channelFxEdit (void)
364          return bResult;          return bResult;
365  }  }
366    
367    
368  // Channel reset slot.  // Channel reset slot.
369  bool ChannelStrip::channelReset (void)  bool ChannelStrip::channelReset (void)
370  {  {
371          if (m_pChannel == NULL)          if (m_pChannel == nullptr)
372                  return false;                  return false;
373    
374          // Invoke the channel reset method.          // Invoke the channel reset method.
375          bool bResult = m_pChannel->channelReset();          const bool bResult = m_pChannel->channelReset();
376          // Notify that this channel has changed.          // Notify that this channel has changed.
377          if (bResult)          if (bResult)
378                  emit channelChanged(this);                  emit channelChanged(this);
# Line 382  bool ChannelStrip::channelReset (void) Line 384  bool ChannelStrip::channelReset (void)
384  // Update the channel instrument name.  // Update the channel instrument name.
385  bool ChannelStrip::updateInstrumentName ( bool bForce )  bool ChannelStrip::updateInstrumentName ( bool bForce )
386  {  {
387          if (m_pChannel == NULL)          if (m_pChannel == nullptr)
388                  return false;                  return false;
389    
390          // Do we refresh the actual name?          // Do we refresh the actual name?
# Line 437  bool ChannelStrip::updateInstrumentName Line 439  bool ChannelStrip::updateInstrumentName
439    
440          if (!bShowInstrumentPopup && m_instrumentListPopupMenu) {          if (!bShowInstrumentPopup && m_instrumentListPopupMenu) {
441                  delete m_instrumentListPopupMenu;                  delete m_instrumentListPopupMenu;
442                  m_instrumentListPopupMenu = NULL;                  m_instrumentListPopupMenu = nullptr;
443          }          }
444    
445          return true;          return true;
446  }  }
447    
448    
449  void ChannelStrip::instrumentListPopupItemClicked ( QAction *action )  void ChannelStrip::instrumentListPopupItemClicked ( QAction *action )
450  {  {
451          if (!action) return;          if (!action) return;
# Line 454  void ChannelStrip::instrumentListPopupIt Line 457  void ChannelStrip::instrumentListPopupIt
457          }          }
458  }  }
459    
460    
461  // Do the dirty volume change.  // Do the dirty volume change.
462  bool ChannelStrip::updateChannelVolume (void)  bool ChannelStrip::updateChannelVolume (void)
463  {  {
464          if (m_pChannel == NULL)          if (m_pChannel == nullptr)
465                  return false;                  return false;
466    
467          // Convert...          // Convert...
# Line 468  bool ChannelStrip::updateChannelVolume ( Line 472  bool ChannelStrip::updateChannelVolume (
472    
473          // Flag it here, to avoid infinite recursion.          // Flag it here, to avoid infinite recursion.
474          m_iDirtyChange++;          m_iDirtyChange++;
475          m_ui.VolumeSlider->setValue(iVolume);          m_ui.ChannelVolumeSlider->setValue(iVolume);
476          m_ui.VolumeSpinBox->setValue(iVolume);          m_ui.ChannelVolumeSpinBox->setValue(iVolume);
477          m_iDirtyChange--;          m_iDirtyChange--;
478    
479          return true;          return true;
# Line 479  bool ChannelStrip::updateChannelVolume ( Line 483  bool ChannelStrip::updateChannelVolume (
483  // Update whole channel info state.  // Update whole channel info state.
484  bool ChannelStrip::updateChannelInfo (void)  bool ChannelStrip::updateChannelInfo (void)
485  {  {
486          if (m_pChannel == NULL)          if (m_pChannel == nullptr)
487                  return false;                  return false;
488    
489          // Check for error limit/recycle...          // Check for error limit/recycle...
# Line 487  bool ChannelStrip::updateChannelInfo (vo Line 491  bool ChannelStrip::updateChannelInfo (vo
491                  return true;                  return true;
492    
493          // Update strip caption.          // Update strip caption.
494          QString sText = m_pChannel->channelName();          const QString& sText = m_pChannel->channelName();
495          setWindowTitle(sText);          setWindowTitle(sText);
496          m_ui.ChannelSetupPushButton->setText('&' + sText);          m_ui.ChannelSetupPushButton->setText('&' + sText);
497    
498          // Check if we're up and connected.          // Check if we're up and connected.
499          MainForm* pMainForm = MainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
500          if (pMainForm->client() == NULL)          if (pMainForm->client() == nullptr)
501                  return false;                  return false;
502    
503          // Read actual channel information.          // Read actual channel information.
# Line 544  bool ChannelStrip::updateChannelInfo (vo Line 548  bool ChannelStrip::updateChannelInfo (vo
548    
549  #ifdef CONFIG_MUTE_SOLO  #ifdef CONFIG_MUTE_SOLO
550          // Mute/Solo button state coloring...          // Mute/Solo button state coloring...
551          bool bMute = m_pChannel->channelMute();          const bool bMute = m_pChannel->channelMute();
552          const QColor& rgbButton = pal.color(QPalette::Button);          const QColor& rgbButton = pal.color(QPalette::Button);
553          const QColor& rgbButtonText = pal.color(QPalette::ButtonText);          const QColor& rgbButtonText = pal.color(QPalette::ButtonText);
554          pal.setColor(QPalette::Foreground, rgbFore);          pal.setColor(QPalette::Foreground, rgbFore);
# Line 552  bool ChannelStrip::updateChannelInfo (vo Line 556  bool ChannelStrip::updateChannelInfo (vo
556          pal.setColor(QPalette::ButtonText, bMute ? Qt::darkYellow : rgbButtonText);          pal.setColor(QPalette::ButtonText, bMute ? Qt::darkYellow : rgbButtonText);
557          m_ui.ChannelMutePushButton->setPalette(pal);          m_ui.ChannelMutePushButton->setPalette(pal);
558          m_ui.ChannelMutePushButton->setDown(bMute);          m_ui.ChannelMutePushButton->setDown(bMute);
559          bool bSolo = m_pChannel->channelSolo();          const bool bSolo = m_pChannel->channelSolo();
560          pal.setColor(QPalette::Button, bSolo ? Qt::cyan : rgbButton);            pal.setColor(QPalette::Button, bSolo ? Qt::cyan : rgbButton);  
561          pal.setColor(QPalette::ButtonText, bSolo ? Qt::darkCyan : rgbButtonText);          pal.setColor(QPalette::ButtonText, bSolo ? Qt::darkCyan : rgbButtonText);
562          m_ui.ChannelSoloPushButton->setPalette(pal);          m_ui.ChannelSoloPushButton->setPalette(pal);
# Line 571  bool ChannelStrip::updateChannelInfo (vo Line 575  bool ChannelStrip::updateChannelInfo (vo
575  // Update whole channel usage state.  // Update whole channel usage state.
576  bool ChannelStrip::updateChannelUsage (void)  bool ChannelStrip::updateChannelUsage (void)
577  {  {
578          if (m_pChannel == NULL)          if (m_pChannel == nullptr)
579                  return false;                  return false;
580    
581          MainForm *pMainForm = MainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
582          if (pMainForm->client() == NULL)          if (pMainForm->client() == nullptr)
583                  return false;                  return false;
584    
585          // This only makes sense on fully loaded channels...          // This only makes sense on fully loaded channels...
# Line 583  bool ChannelStrip::updateChannelUsage (v Line 587  bool ChannelStrip::updateChannelUsage (v
587                  return false;                  return false;
588    
589          // Get current channel voice count.          // Get current channel voice count.
590          int iVoiceCount  = ::lscp_get_channel_voice_count(          const int iVoiceCount  = ::lscp_get_channel_voice_count(
591                  pMainForm->client(), m_pChannel->channelID());                  pMainForm->client(), m_pChannel->channelID());
592  // Get current stream count.          // Get current stream count.
593          int iStreamCount = ::lscp_get_channel_stream_count(          const int iStreamCount = ::lscp_get_channel_stream_count(
594                  pMainForm->client(), m_pChannel->channelID());                  pMainForm->client(), m_pChannel->channelID());
595          // Get current channel buffer fill usage.          // Get current channel buffer fill usage.
596          // As benno has suggested this is the percentage usage          // As benno has suggested this is the percentage usage
597          // of the least filled buffer stream...          // of the least filled buffer stream...
598          int iStreamUsage = ::lscp_get_channel_stream_usage(          const int iStreamUsage = ::lscp_get_channel_stream_usage(
599                  pMainForm->client(), m_pChannel->channelID());;                  pMainForm->client(), m_pChannel->channelID());
600    
601          // Update the GUI elements...          // Update the GUI elements...
602          m_ui.StreamUsageProgressBar->setValue(iStreamUsage);          m_ui.StreamUsageProgressBar->setValue(iStreamUsage);
# Line 607  bool ChannelStrip::updateChannelUsage (v Line 611  bool ChannelStrip::updateChannelUsage (v
611  // Volume change slot.  // Volume change slot.
612  void ChannelStrip::volumeChanged ( int iVolume )  void ChannelStrip::volumeChanged ( int iVolume )
613  {  {
614          if (m_pChannel == NULL)          if (m_pChannel == nullptr)
615                  return;                  return;
616    
617          // Avoid recursion.          // Avoid recursion.
# Line 630  void ChannelStrip::volumeChanged ( int i Line 634  void ChannelStrip::volumeChanged ( int i
634  // Context menu event handler.  // Context menu event handler.
635  void ChannelStrip::contextMenuEvent( QContextMenuEvent *pEvent )  void ChannelStrip::contextMenuEvent( QContextMenuEvent *pEvent )
636  {  {
637          if (m_pChannel == NULL)          if (m_pChannel == nullptr)
638                  return;                  return;
639    
640          // 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).
# Line 669  void ChannelStrip::setSelected ( bool bS Line 673  void ChannelStrip::setSelected ( bool bS
673                  g_pSelectedStrip = this;                  g_pSelectedStrip = this;
674          } else {          } else {
675                  if (g_pSelectedStrip == this)                  if (g_pSelectedStrip == this)
676                          g_pSelectedStrip = NULL;                          g_pSelectedStrip = nullptr;
677          }          }
678    
679          QPalette pal;          QPalette pal;
680          if (bSelected) {          if (bSelected) {
681                  const QColor& color = pal.midlight().color();                  const QColor& color = pal.midlight().color();
682                  pal.setColor(QPalette::Background, color.dark(150));                  pal.setColor(QPalette::Background, color.darker(150));
683                  pal.setColor(QPalette::Foreground, color.light(150));                  pal.setColor(QPalette::Foreground, color.lighter(150));
684          }          }
685          QWidget::setPalette(pal);  
686            QWidget *pParentWidget = QWidget::parentWidget();
687            if (pParentWidget)
688                    pParentWidget->setPalette(pal);
689  }  }
690    
691    

Legend:
Removed from v.2570  
changed lines
  Added in v.3555

  ViewVC Help
Powered by ViewVC