/[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 2038 by capela, Thu Jan 7 18:42:26 2010 UTC revision 2569 by schoenebeck, Tue May 20 20:04:19 2014 UTC
# Line 1  Line 1 
1  // qsamplerChannelStrip.cpp  // qsamplerChannelStrip.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2010, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2014, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007, 2008 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
8     modify it under the terms of the GNU General Public License     modify it under the terms of the GNU General Public License
# Line 29  Line 29 
29    
30  #include <QMessageBox>  #include <QMessageBox>
31  #include <QDragEnterEvent>  #include <QDragEnterEvent>
32    #include <QFileInfo>
33  #include <QTimer>  #include <QTimer>
34  #include <QUrl>  #include <QUrl>
35    #include <QMenu>
36    
37    #if QT_VERSION >= 0x050000
38    #include <QMimeData>
39    #endif
40    
41  // Channel status/usage usage limit control.  // Channel status/usage usage limit control.
42  #define QSAMPLER_ERROR_LIMIT    3  #define QSAMPLER_ERROR_LIMIT    3
# Line 73  ChannelStrip::ChannelStrip ( QWidget* pP Line 78  ChannelStrip::ChannelStrip ( QWidget* pP
78          m_pChannel     = NULL;          m_pChannel     = NULL;
79          m_iDirtyChange = 0;          m_iDirtyChange = 0;
80          m_iErrorCount  = 0;          m_iErrorCount  = 0;
81            m_instrumentListPopupMenu = NULL;
82    
83          if (++g_iMidiActivityRefCount == 1) {          if (++g_iMidiActivityRefCount == 1) {
84                  g_pMidiActivityLedOn  = new QPixmap(":/icons/ledon1.png");                  g_pMidiActivityLedOn  = new QPixmap(":/images/ledon1.png");
85                  g_pMidiActivityLedOff = new QPixmap(":/icons/ledoff1.png");                  g_pMidiActivityLedOff = new QPixmap(":/images/ledoff1.png");
86          }          }
87    
88          m_ui.MidiActivityLabel->setPixmap(*g_pMidiActivityLedOff);          m_ui.MidiActivityLabel->setPixmap(*g_pMidiActivityLedOff);
# Line 157  void ChannelStrip::dragEnterEvent ( QDra Line 163  void ChannelStrip::dragEnterEvent ( QDra
163                          while (iter.hasNext()) {                          while (iter.hasNext()) {
164                                  const QString& sFilename = iter.next().toLocalFile();                                  const QString& sFilename = iter.next().toLocalFile();
165                                  if (!sFilename.isEmpty()) {                                  if (!sFilename.isEmpty()) {
166                                          bAccept = Channel::isInstrumentFile(sFilename);                                  //      bAccept = Channel::isDlsInstrumentFile(sFilename);
167                                            bAccept = QFileInfo(sFilename).exists();
168                                          break;                                          break;
169                                  }                                  }
170                          }                          }
# Line 234  void ChannelStrip::setDisplayFont ( cons Line 241  void ChannelStrip::setDisplayFont ( cons
241  {  {
242          m_ui.EngineNameTextLabel->setFont(font);          m_ui.EngineNameTextLabel->setFont(font);
243          m_ui.MidiPortChannelTextLabel->setFont(font);          m_ui.MidiPortChannelTextLabel->setFont(font);
244          m_ui.InstrumentNameTextLabel->setFont(font);          m_ui.InstrumentNamePushButton->setFont(font);
245            m_ui.InstrumentNamePushButton->setFont(font);
246          m_ui.InstrumentStatusTextLabel->setFont(font);          m_ui.InstrumentStatusTextLabel->setFont(font);
247  }  }
248    
# Line 244  void ChannelStrip::setDisplayEffect ( bo Line 252  void ChannelStrip::setDisplayEffect ( bo
252  {  {
253          QPalette pal;          QPalette pal;
254          pal.setColor(QPalette::Foreground, Qt::yellow);          pal.setColor(QPalette::Foreground, Qt::yellow);
255            pal.setColor(QPalette::ButtonText, Qt::yellow);
256          m_ui.EngineNameTextLabel->setPalette(pal);          m_ui.EngineNameTextLabel->setPalette(pal);
257          m_ui.MidiPortChannelTextLabel->setPalette(pal);          m_ui.MidiPortChannelTextLabel->setPalette(pal);
258          pal.setColor(QPalette::Foreground, Qt::green);          pal.setColor(QPalette::Foreground, Qt::green);
259          if (bDisplayEffect) {          if (bDisplayEffect) {
260                  QPixmap pm(":/icons/displaybg1.png");                  QPixmap pm(":/images/displaybg1.png");
261                  pal.setBrush(QPalette::Background, QBrush(pm));                  pal.setBrush(QPalette::Background, QBrush(pm));
262          } else {          } else {
263                  pal.setColor(QPalette::Background, Qt::black);                  pal.setColor(QPalette::Background, Qt::black);
264          }          }
265          m_ui.ChannelInfoFrame->setPalette(pal);          m_ui.ChannelInfoFrame->setPalette(pal);
266          m_ui.InstrumentNameTextLabel->setPalette(pal);          m_ui.InstrumentNamePushButton->setPalette(pal);
267          m_ui.StreamVoiceCountTextLabel->setPalette(pal);          m_ui.StreamVoiceCountTextLabel->setPalette(pal);
268  }  }
269    
# Line 383  bool ChannelStrip::updateInstrumentName Line 392  bool ChannelStrip::updateInstrumentName
392          // Instrument name...          // Instrument name...
393          if (m_pChannel->instrumentName().isEmpty()) {          if (m_pChannel->instrumentName().isEmpty()) {
394                  if (m_pChannel->instrumentStatus() >= 0) {                  if (m_pChannel->instrumentStatus() >= 0) {
395                          m_ui.InstrumentNameTextLabel->setText(                          m_ui.InstrumentNamePushButton->setText(
396                                  ' ' + Channel::loadingInstrument());                                  ' ' + Channel::loadingInstrument());
397                  } else {                  } else {
398                          m_ui.InstrumentNameTextLabel->setText(                          m_ui.InstrumentNamePushButton->setText(
399                                  ' ' + Channel::noInstrumentName());                                  ' ' + Channel::noInstrumentName());
400                  }                  }
401          } else {          } else {
402                  m_ui.InstrumentNameTextLabel->setText(                  m_ui.InstrumentNamePushButton->setText(
403                          ' ' + m_pChannel->instrumentName());                          ' ' + m_pChannel->instrumentName());
404          }          }
405            
406            bool bShowInstrumentPopup = false;
407    
408            // Instrument list popup (for fast switching among sounds of the same file)
409            if (!m_pChannel->instrumentFile().isEmpty()) {
410                    QStringList instruments = Channel::getInstrumentList(
411                            m_pChannel->instrumentFile(), true
412                    );
413                    if (!instruments.isEmpty()) {
414                            bShowInstrumentPopup = true;
415                            if (!m_instrumentListPopupMenu) {
416                                    m_instrumentListPopupMenu = new QMenu(m_ui.InstrumentNamePushButton);
417                                    m_instrumentListPopupMenu->setTitle(tr("Instruments"));
418                                    m_instrumentListPopupMenu->setMinimumWidth(118); // for cosmetical reasons, should have at least the width of the instrument name label
419                                    m_ui.InstrumentNamePushButton->setMenu(m_instrumentListPopupMenu);
420                                    QObject::connect(
421                                            m_instrumentListPopupMenu, SIGNAL(triggered(QAction*)),
422                                            this, SLOT(instrumentListPopupItemClicked(QAction*))
423                                    );
424                            } else m_instrumentListPopupMenu->clear();
425    
426                            for (int i = 0; i < instruments.size(); ++i) {
427                                    QAction* action =
428                                            m_instrumentListPopupMenu->addAction(instruments.at(i));
429                                    action->setData(i);
430                                    if (i == m_pChannel->instrumentNr()) {
431                                            action->setCheckable(true);
432                                            action->setChecked(true);
433                                    }
434                            }
435                    }
436            }
437    
438            if (!bShowInstrumentPopup && m_instrumentListPopupMenu) {
439                    delete m_instrumentListPopupMenu;
440                    m_instrumentListPopupMenu = NULL;
441            }
442    
443          return true;          return true;
444  }  }
445    
446    void ChannelStrip::instrumentListPopupItemClicked (QAction* action)
447    {
448            if (!action) return;
449    
450            QVariant data = action->data();
451            if (data.isValid() && !m_pChannel->instrumentFile().isEmpty()) {
452                    m_pChannel->loadInstrument(m_pChannel->instrumentFile(), data.toInt());
453                    emit channelChanged(this);
454            }
455    }
456    
457  // Do the dirty volume change.  // Do the dirty volume change.
458  bool ChannelStrip::updateChannelVolume (void)  bool ChannelStrip::updateChannelVolume (void)
# Line 489  bool ChannelStrip::updateChannelInfo (vo Line 545  bool ChannelStrip::updateChannelInfo (vo
545          // Mute/Solo button state coloring...          // Mute/Solo button state coloring...
546          bool bMute = m_pChannel->channelMute();          bool bMute = m_pChannel->channelMute();
547          const QColor& rgbButton = pal.color(QPalette::Button);          const QColor& rgbButton = pal.color(QPalette::Button);
548            const QColor& rgbButtonText = pal.color(QPalette::ButtonText);
549          pal.setColor(QPalette::Foreground, rgbFore);          pal.setColor(QPalette::Foreground, rgbFore);
550          pal.setColor(QPalette::Button, bMute ? Qt::yellow : rgbButton);          pal.setColor(QPalette::Button, bMute ? Qt::yellow : rgbButton);
551            pal.setColor(QPalette::ButtonText, bMute ? Qt::darkYellow : rgbButtonText);
552          m_ui.ChannelMutePushButton->setPalette(pal);          m_ui.ChannelMutePushButton->setPalette(pal);
553          m_ui.ChannelMutePushButton->setDown(bMute);          m_ui.ChannelMutePushButton->setDown(bMute);
554          bool bSolo = m_pChannel->channelSolo();          bool bSolo = m_pChannel->channelSolo();
555          pal.setColor(QPalette::Button, bSolo ? Qt::cyan : rgbButton);            pal.setColor(QPalette::Button, bSolo ? Qt::cyan : rgbButton);  
556            pal.setColor(QPalette::ButtonText, bSolo ? Qt::darkCyan : rgbButtonText);
557          m_ui.ChannelSoloPushButton->setPalette(pal);          m_ui.ChannelSoloPushButton->setPalette(pal);
558          m_ui.ChannelSoloPushButton->setDown(bSolo);          m_ui.ChannelSoloPushButton->setDown(bSolo);
559  #else  #else

Legend:
Removed from v.2038  
changed lines
  Added in v.2569

  ViewVC Help
Powered by ViewVC