/[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 2387 by capela, Sat Dec 29 00:21:11 2012 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-2012, 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    
36  #define MIDI_OFF_COLOR                  Qt::darkGreen  #if QT_VERSION >= 0x050000
37  #define MIDI_ON_COLOR                   Qt::green  #include <QMimeData>
38    #endif
39    
40  // Channel status/usage usage limit control.  // Channel status/usage usage limit control.
41  #define QSAMPLER_ERROR_LIMIT    3  #define QSAMPLER_ERROR_LIMIT    3
# Line 57  namespace QSampler { Line 60  namespace QSampler {
60  // QSampler::ChannelStrip -- Channel strip form implementation.  // QSampler::ChannelStrip -- Channel strip form implementation.
61  //  //
62    
63    // MIDI activity pixmap common resources.
64    int      ChannelStrip::g_iMidiActivityRefCount = 0;
65    QPixmap *ChannelStrip::g_pMidiActivityLedOn    = NULL;
66    QPixmap *ChannelStrip::g_pMidiActivityLedOff   = NULL;
67    
68  // Channel strip activation/selection.  // Channel strip activation/selection.
69  ChannelStrip *ChannelStrip::g_pSelectedStrip = NULL;  ChannelStrip *ChannelStrip::g_pSelectedStrip = NULL;
70    
# Line 70  ChannelStrip::ChannelStrip ( QWidget* pP Line 78  ChannelStrip::ChannelStrip ( QWidget* pP
78          m_iDirtyChange = 0;          m_iDirtyChange = 0;
79          m_iErrorCount  = 0;          m_iErrorCount  = 0;
80    
81            if (++g_iMidiActivityRefCount == 1) {
82                    g_pMidiActivityLedOn  = new QPixmap(":/images/ledon1.png");
83                    g_pMidiActivityLedOff = new QPixmap(":/images/ledoff1.png");
84            }
85    
86            m_ui.MidiActivityLabel->setPixmap(*g_pMidiActivityLedOff);
87    
88    #ifndef CONFIG_EVENT_CHANNEL_MIDI
89            m_ui.MidiActivityLabel->setToolTip("MIDI activity (disabled)");
90    #endif
91    
92            m_pMidiActivityTimer = new QTimer(this);
93            m_pMidiActivityTimer->setSingleShot(true);
94    
95            QObject::connect(m_pMidiActivityTimer,
96                    SIGNAL(timeout()),
97                    SLOT(midiActivityLedOff())
98            );
99    
100          // Try to restore normal window positioning.          // Try to restore normal window positioning.
101          adjustSize();          adjustSize();
102    
# Line 95  ChannelStrip::ChannelStrip ( QWidget* pP Line 122  ChannelStrip::ChannelStrip ( QWidget* pP
122                  SIGNAL(clicked()),                  SIGNAL(clicked()),
123                  SLOT(channelFxEdit()));                  SLOT(channelFxEdit()));
124    
         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  
   
125          setSelected(false);          setSelected(false);
126  }  }
127    
# Line 122  ChannelStrip::~ChannelStrip (void) Line 134  ChannelStrip::~ChannelStrip (void)
134          if (m_pChannel)          if (m_pChannel)
135                  delete m_pChannel;                  delete m_pChannel;
136          m_pChannel = NULL;          m_pChannel = NULL;
137    
138            if (--g_iMidiActivityRefCount == 0) {
139                    if (g_pMidiActivityLedOn)
140                            delete g_pMidiActivityLedOn;
141                    g_pMidiActivityLedOn = NULL;
142                    if (g_pMidiActivityLedOff)
143                            delete g_pMidiActivityLedOff;
144                    g_pMidiActivityLedOff = NULL;
145            }
146  }  }
147    
148    
# Line 140  void ChannelStrip::dragEnterEvent ( QDra Line 161  void ChannelStrip::dragEnterEvent ( QDra
161                          while (iter.hasNext()) {                          while (iter.hasNext()) {
162                                  const QString& sFilename = iter.next().toLocalFile();                                  const QString& sFilename = iter.next().toLocalFile();
163                                  if (!sFilename.isEmpty()) {                                  if (!sFilename.isEmpty()) {
164                                          bAccept = Channel::isInstrumentFile(sFilename);                                  //      bAccept = Channel::isDlsInstrumentFile(sFilename);
165                                            bAccept = QFileInfo(sFilename).exists();
166                                          break;                                          break;
167                                  }                                  }
168                          }                          }
# Line 231  void ChannelStrip::setDisplayEffect ( bo Line 253  void ChannelStrip::setDisplayEffect ( bo
253          m_ui.MidiPortChannelTextLabel->setPalette(pal);          m_ui.MidiPortChannelTextLabel->setPalette(pal);
254          pal.setColor(QPalette::Foreground, Qt::green);          pal.setColor(QPalette::Foreground, Qt::green);
255          if (bDisplayEffect) {          if (bDisplayEffect) {
256                  QPixmap pm(":/icons/displaybg1.png");                  QPixmap pm(":/images/displaybg1.png");
257                  pal.setBrush(QPalette::Background, QBrush(pm));                  pal.setBrush(QPalette::Background, QBrush(pm));
258          } else {          } else {
259                  pal.setColor(QPalette::Background, Qt::black);                  pal.setColor(QPalette::Background, Qt::black);
# Line 472  bool ChannelStrip::updateChannelInfo (vo Line 494  bool ChannelStrip::updateChannelInfo (vo
494          // Mute/Solo button state coloring...          // Mute/Solo button state coloring...
495          bool bMute = m_pChannel->channelMute();          bool bMute = m_pChannel->channelMute();
496          const QColor& rgbButton = pal.color(QPalette::Button);          const QColor& rgbButton = pal.color(QPalette::Button);
497            const QColor& rgbButtonText = pal.color(QPalette::ButtonText);
498          pal.setColor(QPalette::Foreground, rgbFore);          pal.setColor(QPalette::Foreground, rgbFore);
499          pal.setColor(QPalette::Button, bMute ? Qt::yellow : rgbButton);          pal.setColor(QPalette::Button, bMute ? Qt::yellow : rgbButton);
500            pal.setColor(QPalette::ButtonText, bMute ? Qt::darkYellow : rgbButtonText);
501          m_ui.ChannelMutePushButton->setPalette(pal);          m_ui.ChannelMutePushButton->setPalette(pal);
502          m_ui.ChannelMutePushButton->setDown(bMute);          m_ui.ChannelMutePushButton->setDown(bMute);
503          bool bSolo = m_pChannel->channelSolo();          bool bSolo = m_pChannel->channelSolo();
504          pal.setColor(QPalette::Button, bSolo ? Qt::cyan : rgbButton);            pal.setColor(QPalette::Button, bSolo ? Qt::cyan : rgbButton);  
505            pal.setColor(QPalette::ButtonText, bSolo ? Qt::darkCyan : rgbButtonText);
506          m_ui.ChannelSoloPushButton->setPalette(pal);          m_ui.ChannelSoloPushButton->setPalette(pal);
507          m_ui.ChannelSoloPushButton->setDown(bSolo);          m_ui.ChannelSoloPushButton->setDown(bSolo);
508  #else  #else
# Line 549  void ChannelStrip::volumeChanged ( int i Line 574  void ChannelStrip::volumeChanged ( int i
574          }          }
575  }  }
576    
 void ChannelStrip::midiArrived() {  
         m_ui.MidiActivityLabel->setPalette(MIDI_ON_COLOR);  
         pMidiActivityTimer->start(50);  
 }  
577    
578  // Context menu event handler.  // Context menu event handler.
579  void ChannelStrip::contextMenuEvent( QContextMenuEvent *pEvent )  void ChannelStrip::contextMenuEvent( QContextMenuEvent *pEvent )
# Line 564  void ChannelStrip::contextMenuEvent( QCo Line 585  void ChannelStrip::contextMenuEvent( QCo
585          m_pChannel->contextMenuEvent(pEvent);          m_pChannel->contextMenuEvent(pEvent);
586  }  }
587    
588  void ChannelStrip::midiDataCeased() {  
589          m_ui.MidiActivityLabel->setPalette(MIDI_OFF_COLOR);  void ChannelStrip::midiActivityLedOn (void)
590    {
591            m_ui.MidiActivityLabel->setPixmap(*g_pMidiActivityLedOn);
592            m_pMidiActivityTimer->start(100);
593    }
594    
595    
596    void ChannelStrip::midiActivityLedOff (void)
597    {
598            m_ui.MidiActivityLabel->setPixmap(*g_pMidiActivityLedOff);
599  }  }
600    
601    
602  // Error count hackish accessors.  // Error count hackish accessors.
603  void ChannelStrip::resetErrorCount (void)  void ChannelStrip::resetErrorCount (void)
604  {  {

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

  ViewVC Help
Powered by ViewVC