/[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 1691 by schoenebeck, Thu Feb 14 22:31:26 2008 UTC revision 2108 by capela, Thu Jul 15 08:03:32 2010 UTC
# Line 1  Line 1 
1  // qsamplerChannelStrip.cpp  // qsamplerChannelStrip.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2010, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007, 2008 Christian Schoenebeck     Copyright (C) 2007, 2008 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 29  Line 29 
29    
30  #include <QMessageBox>  #include <QMessageBox>
31  #include <QDragEnterEvent>  #include <QDragEnterEvent>
32    #include <QFileInfo>
33    #include <QTimer>
34  #include <QUrl>  #include <QUrl>
35    
 #define MIDI_OFF_COLOR                  Qt::darkGreen  
 #define MIDI_ON_COLOR                   Qt::green  
36    
37  // Channel status/usage usage limit control.  // Channel status/usage usage limit control.
38  #define QSAMPLER_ERROR_LIMIT    3  #define QSAMPLER_ERROR_LIMIT    3
# Line 57  namespace QSampler { Line 57  namespace QSampler {
57  // QSampler::ChannelStrip -- Channel strip form implementation.  // QSampler::ChannelStrip -- Channel strip form implementation.
58  //  //
59    
60    // MIDI activity pixmap common resources.
61    int      ChannelStrip::g_iMidiActivityRefCount = 0;
62    QPixmap *ChannelStrip::g_pMidiActivityLedOn    = NULL;
63    QPixmap *ChannelStrip::g_pMidiActivityLedOff   = NULL;
64    
65  // Channel strip activation/selection.  // Channel strip activation/selection.
66  ChannelStrip *ChannelStrip::g_pSelectedStrip = NULL;  ChannelStrip *ChannelStrip::g_pSelectedStrip = NULL;
67    
# Line 70  ChannelStrip::ChannelStrip ( QWidget* pP Line 75  ChannelStrip::ChannelStrip ( QWidget* pP
75          m_iDirtyChange = 0;          m_iDirtyChange = 0;
76          m_iErrorCount  = 0;          m_iErrorCount  = 0;
77    
78            if (++g_iMidiActivityRefCount == 1) {
79                    g_pMidiActivityLedOn  = new QPixmap(":/images/ledon1.png");
80                    g_pMidiActivityLedOff = new QPixmap(":/images/ledoff1.png");
81            }
82    
83            m_ui.MidiActivityLabel->setPixmap(*g_pMidiActivityLedOff);
84    
85    #ifndef CONFIG_EVENT_CHANNEL_MIDI
86            m_ui.MidiActivityLabel->setToolTip("MIDI activity (disabled)");
87    #endif
88    
89            m_pMidiActivityTimer = new QTimer(this);
90            m_pMidiActivityTimer->setSingleShot(true);
91    
92            QObject::connect(m_pMidiActivityTimer,
93                    SIGNAL(timeout()),
94                    SLOT(midiActivityLedOff())
95            );
96    
97          // Try to restore normal window positioning.          // Try to restore normal window positioning.
98          adjustSize();          adjustSize();
99    
# Line 95  ChannelStrip::ChannelStrip ( QWidget* pP Line 119  ChannelStrip::ChannelStrip ( QWidget* pP
119                  SIGNAL(clicked()),                  SIGNAL(clicked()),
120                  SLOT(channelFxEdit()));                  SLOT(channelFxEdit()));
121    
         pMidiActivityTimer = new QTimer(this);  
         pMidiActivityTimer->setSingleShot(true);  
         QObject::connect(  
                 pMidiActivityTimer, SIGNAL(timeout()),  
                 this, SLOT(midiDataCeased())  
         );  
   
 #if CONFIG_LSCP_CHANNEL_MIDI  
         m_ui.MidiActivityLabel->setPalette(MIDI_OFF_COLOR);  
         m_ui.MidiActivityLabel->setAutoFillBackground(true);  
 #else  
         m_ui.MidiActivityLabel->setText("X");  
         m_ui.MidiActivityLabel->setTooltip("MIDI Activity Disabled");  
 #endif  
   
122          setSelected(false);          setSelected(false);
123  }  }
124    
# Line 122  ChannelStrip::~ChannelStrip (void) Line 131  ChannelStrip::~ChannelStrip (void)
131          if (m_pChannel)          if (m_pChannel)
132                  delete m_pChannel;                  delete m_pChannel;
133          m_pChannel = NULL;          m_pChannel = NULL;
134    
135            if (--g_iMidiActivityRefCount == 0) {
136                    if (g_pMidiActivityLedOn)
137                            delete g_pMidiActivityLedOn;
138                    g_pMidiActivityLedOn = NULL;
139                    if (g_pMidiActivityLedOff)
140                            delete g_pMidiActivityLedOff;
141                    g_pMidiActivityLedOff = NULL;
142            }
143  }  }
144    
145    
# Line 140  void ChannelStrip::dragEnterEvent ( QDra Line 158  void ChannelStrip::dragEnterEvent ( QDra
158                          while (iter.hasNext()) {                          while (iter.hasNext()) {
159                                  const QString& sFilename = iter.next().toLocalFile();                                  const QString& sFilename = iter.next().toLocalFile();
160                                  if (!sFilename.isEmpty()) {                                  if (!sFilename.isEmpty()) {
161                                          bAccept = Channel::isInstrumentFile(sFilename);                                  //      bAccept = Channel::isDlsInstrumentFile(sFilename);
162                                            bAccept = QFileInfo(sFilename).exists();
163                                          break;                                          break;
164                                  }                                  }
165                          }                          }
# Line 231  void ChannelStrip::setDisplayEffect ( bo Line 250  void ChannelStrip::setDisplayEffect ( bo
250          m_ui.MidiPortChannelTextLabel->setPalette(pal);          m_ui.MidiPortChannelTextLabel->setPalette(pal);
251          pal.setColor(QPalette::Foreground, Qt::green);          pal.setColor(QPalette::Foreground, Qt::green);
252          if (bDisplayEffect) {          if (bDisplayEffect) {
253                  QPixmap pm(":/icons/displaybg1.png");                  QPixmap pm(":/images/displaybg1.png");
254                  pal.setBrush(QPalette::Background, QBrush(pm));                  pal.setBrush(QPalette::Background, QBrush(pm));
255          } else {          } else {
256                  pal.setColor(QPalette::Background, Qt::black);                  pal.setColor(QPalette::Background, Qt::black);
# Line 472  bool ChannelStrip::updateChannelInfo (vo Line 491  bool ChannelStrip::updateChannelInfo (vo
491          // Mute/Solo button state coloring...          // Mute/Solo button state coloring...
492          bool bMute = m_pChannel->channelMute();          bool bMute = m_pChannel->channelMute();
493          const QColor& rgbButton = pal.color(QPalette::Button);          const QColor& rgbButton = pal.color(QPalette::Button);
494            const QColor& rgbButtonText = pal.color(QPalette::ButtonText);
495          pal.setColor(QPalette::Foreground, rgbFore);          pal.setColor(QPalette::Foreground, rgbFore);
496          pal.setColor(QPalette::Button, bMute ? Qt::yellow : rgbButton);          pal.setColor(QPalette::Button, bMute ? Qt::yellow : rgbButton);
497            pal.setColor(QPalette::ButtonText, bMute ? Qt::darkYellow : rgbButtonText);
498          m_ui.ChannelMutePushButton->setPalette(pal);          m_ui.ChannelMutePushButton->setPalette(pal);
499          m_ui.ChannelMutePushButton->setDown(bMute);          m_ui.ChannelMutePushButton->setDown(bMute);
500          bool bSolo = m_pChannel->channelSolo();          bool bSolo = m_pChannel->channelSolo();
501          pal.setColor(QPalette::Button, bSolo ? Qt::cyan : rgbButton);            pal.setColor(QPalette::Button, bSolo ? Qt::cyan : rgbButton);  
502            pal.setColor(QPalette::ButtonText, bSolo ? Qt::darkCyan : rgbButtonText);
503          m_ui.ChannelSoloPushButton->setPalette(pal);          m_ui.ChannelSoloPushButton->setPalette(pal);
504          m_ui.ChannelSoloPushButton->setDown(bSolo);          m_ui.ChannelSoloPushButton->setDown(bSolo);
505  #else  #else
# Line 549  void ChannelStrip::volumeChanged ( int i Line 571  void ChannelStrip::volumeChanged ( int i
571          }          }
572  }  }
573    
 void ChannelStrip::midiArrived() {  
         m_ui.MidiActivityLabel->setPalette(MIDI_ON_COLOR);  
         pMidiActivityTimer->start(50);  
 }  
574    
575  // Context menu event handler.  // Context menu event handler.
576  void ChannelStrip::contextMenuEvent( QContextMenuEvent *pEvent )  void ChannelStrip::contextMenuEvent( QContextMenuEvent *pEvent )
# Line 564  void ChannelStrip::contextMenuEvent( QCo Line 582  void ChannelStrip::contextMenuEvent( QCo
582          m_pChannel->contextMenuEvent(pEvent);          m_pChannel->contextMenuEvent(pEvent);
583  }  }
584    
585  void ChannelStrip::midiDataCeased() {  
586          m_ui.MidiActivityLabel->setPalette(MIDI_OFF_COLOR);  void ChannelStrip::midiActivityLedOn (void)
587    {
588            m_ui.MidiActivityLabel->setPixmap(*g_pMidiActivityLedOn);
589            m_pMidiActivityTimer->start(100);
590    }
591    
592    
593    void ChannelStrip::midiActivityLedOff (void)
594    {
595            m_ui.MidiActivityLabel->setPixmap(*g_pMidiActivityLedOff);
596  }  }
597    
598    
599  // Error count hackish accessors.  // Error count hackish accessors.
600  void ChannelStrip::resetErrorCount (void)  void ChannelStrip::resetErrorCount (void)
601  {  {

Legend:
Removed from v.1691  
changed lines
  Added in v.2108

  ViewVC Help
Powered by ViewVC