/[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 1514 by capela, Fri Nov 23 10:51:37 2007 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, 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
8     modify it under the terms of the GNU General Public License     modify it under the terms of the GNU General Public License
# Line 25  Line 25 
25    
26  #include "qsamplerMainForm.h"  #include "qsamplerMainForm.h"
27    
28    #include "qsamplerChannelFxForm.h"
29    
30    #include <QMessageBox>
31  #include <QDragEnterEvent>  #include <QDragEnterEvent>
32    #include <QFileInfo>
33    #include <QTimer>
34  #include <QUrl>  #include <QUrl>
35    
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
39    
# Line 47  static inline long lroundf ( float x ) Line 53  static inline long lroundf ( float x )
53    
54  namespace QSampler {  namespace QSampler {
55    
56    //-------------------------------------------------------------------------
57    // 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    
   
68  ChannelStrip::ChannelStrip ( QWidget* pParent, Qt::WindowFlags wflags )  ChannelStrip::ChannelStrip ( QWidget* pParent, Qt::WindowFlags wflags )
69          : QWidget(pParent, wflags)          : QWidget(pParent, wflags)
70  {  {
# Line 61  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();
         setSelected(false);  
99    
100          QObject::connect(m_ui.ChannelSetupPushButton,          QObject::connect(m_ui.ChannelSetupPushButton,
101                  SIGNAL(clicked()),                  SIGNAL(clicked()),
# Line 83  ChannelStrip::ChannelStrip ( QWidget* pP Line 115  ChannelStrip::ChannelStrip ( QWidget* pP
115          QObject::connect(m_ui.ChannelEditPushButton,          QObject::connect(m_ui.ChannelEditPushButton,
116                  SIGNAL(clicked()),                  SIGNAL(clicked()),
117                  SLOT(channelEdit()));                  SLOT(channelEdit()));
118            QObject::connect(m_ui.FxPushButton,
119                    SIGNAL(clicked()),
120                    SLOT(channelFxEdit()));
121    
122            setSelected(false);
123  }  }
124    
125    
126  ChannelStrip::~ChannelStrip (void)  ChannelStrip::~ChannelStrip (void)
127  {  {
128            setSelected(false);
129    
130          // Destroy existing channel descriptor.          // Destroy existing channel descriptor.
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 110  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 = qsamplerChannel::isInstrumentFile(sFilename);                                  //      bAccept = Channel::isDlsInstrumentFile(sFilename);
162                                            bAccept = QFileInfo(sFilename).exists();
163                                          break;                                          break;
164                                  }                                  }
165                          }                          }
# Line 151  void ChannelStrip::dropEvent ( QDropEven Line 200  void ChannelStrip::dropEvent ( QDropEven
200    
201    
202  // Channel strip setup formal initializer.  // Channel strip setup formal initializer.
203  void ChannelStrip::setup ( qsamplerChannel *pChannel )  void ChannelStrip::setup ( Channel *pChannel )
204  {  {
205          // Destroy any previous channel descriptor;          // Destroy any previous channel descriptor;
206          // (remember that once setup we own it!)          // (remember that once setup we own it!)
# Line 171  void ChannelStrip::setup ( qsamplerChann Line 220  void ChannelStrip::setup ( qsamplerChann
220    
221    
222  // Channel secriptor accessor.  // Channel secriptor accessor.
223  qsamplerChannel *ChannelStrip::channel (void) const  Channel *ChannelStrip::channel (void) const
224  {  {
225          return m_pChannel;          return m_pChannel;
226  }  }
# Line 201  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);
257          }          }
258          m_ui.ChannelInfoFrame->setPalette(pal);          m_ui.ChannelInfoFrame->setPalette(pal);
259            m_ui.InstrumentNameTextLabel->setPalette(pal);
260          m_ui.StreamVoiceCountTextLabel->setPalette(pal);          m_ui.StreamVoiceCountTextLabel->setPalette(pal);
261  }  }
262    
# Line 278  void ChannelStrip::channelEdit (void) Line 328  void ChannelStrip::channelEdit (void)
328          m_pChannel->editChannel();          m_pChannel->editChannel();
329  }  }
330    
331    bool ChannelStrip::channelFxEdit (void)
332    {
333            MainForm *pMainForm = MainForm::getInstance();
334            if (!pMainForm || !channel())
335                    return false;
336    
337            pMainForm->appendMessages(QObject::tr("channel fx sends..."));
338    
339            bool bResult = false;
340    
341    #if CONFIG_FXSEND
342            ChannelFxForm *pChannelFxForm =
343                    new ChannelFxForm(channel(), parentWidget());
344            if (pChannelFxForm) {
345                    //pChannelForm->setup(this);
346                    bResult = pChannelFxForm->exec();
347                    delete pChannelFxForm;
348            }
349    #else // CONFIG_FXSEND
350            QMessageBox::critical(this,
351                    QSAMPLER_TITLE ": " + tr("Unavailable"),
352                            tr("Sorry, QSampler was built without FX send support!\n\n"
353                               "(Make sure you have a recent liblscp when recompiling QSampler)"));
354    #endif // CONFIG_FXSEND
355    
356            return bResult;
357    }
358    
359  // Channel reset slot.  // Channel reset slot.
360  bool ChannelStrip::channelReset (void)  bool ChannelStrip::channelReset (void)
# Line 309  bool ChannelStrip::updateInstrumentName Line 386  bool ChannelStrip::updateInstrumentName
386          if (m_pChannel->instrumentName().isEmpty()) {          if (m_pChannel->instrumentName().isEmpty()) {
387                  if (m_pChannel->instrumentStatus() >= 0) {                  if (m_pChannel->instrumentStatus() >= 0) {
388                          m_ui.InstrumentNameTextLabel->setText(                          m_ui.InstrumentNameTextLabel->setText(
389                                  ' ' + qsamplerChannel::loadingInstrument());                                  ' ' + Channel::loadingInstrument());
390                  } else {                  } else {
391                          m_ui.InstrumentNameTextLabel->setText(                          m_ui.InstrumentNameTextLabel->setText(
392                                  ' ' + qsamplerChannel::noInstrumentName());                                  ' ' + Channel::noInstrumentName());
393                  }                  }
394          } else {          } else {
395                  m_ui.InstrumentNameTextLabel->setText(                  m_ui.InstrumentNameTextLabel->setText(
# Line 371  bool ChannelStrip::updateChannelInfo (vo Line 448  bool ChannelStrip::updateChannelInfo (vo
448          // Engine name...          // Engine name...
449          if (m_pChannel->engineName().isEmpty()) {          if (m_pChannel->engineName().isEmpty()) {
450                  m_ui.EngineNameTextLabel->setText(                  m_ui.EngineNameTextLabel->setText(
451                          ' ' + qsamplerChannel::noEngineName());                          ' ' + Channel::noEngineName());
452          } else {          } else {
453                  m_ui.EngineNameTextLabel->setText(                  m_ui.EngineNameTextLabel->setText(
454                          ' ' + m_pChannel->engineName());                          ' ' + m_pChannel->engineName());
# Line 414  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 503  void ChannelStrip::contextMenuEvent( QCo Line 583  void ChannelStrip::contextMenuEvent( QCo
583  }  }
584    
585    
586    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.1514  
changed lines
  Added in v.2108

  ViewVC Help
Powered by ViewVC