--- qsampler/trunk/src/qsamplerChannelStrip.cpp 2007/11/23 10:51:37 1514 +++ qsampler/trunk/src/qsamplerChannelStrip.cpp 2008/02/14 22:31:26 1691 @@ -2,7 +2,7 @@ // /**************************************************************************** Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved. - Copyright (C) 2007, Christian Schoenebeck + Copyright (C) 2007, 2008 Christian Schoenebeck This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -25,9 +25,15 @@ #include "qsamplerMainForm.h" +#include "qsamplerChannelFxForm.h" + +#include #include #include +#define MIDI_OFF_COLOR Qt::darkGreen +#define MIDI_ON_COLOR Qt::green + // Channel status/usage usage limit control. #define QSAMPLER_ERROR_LIMIT 3 @@ -47,10 +53,13 @@ namespace QSampler { +//------------------------------------------------------------------------- +// QSampler::ChannelStrip -- Channel strip form implementation. +// + // Channel strip activation/selection. ChannelStrip *ChannelStrip::g_pSelectedStrip = NULL; - ChannelStrip::ChannelStrip ( QWidget* pParent, Qt::WindowFlags wflags ) : QWidget(pParent, wflags) { @@ -63,7 +72,6 @@ // Try to restore normal window positioning. adjustSize(); - setSelected(false); QObject::connect(m_ui.ChannelSetupPushButton, SIGNAL(clicked()), @@ -83,11 +91,33 @@ QObject::connect(m_ui.ChannelEditPushButton, SIGNAL(clicked()), SLOT(channelEdit())); + QObject::connect(m_ui.FxPushButton, + SIGNAL(clicked()), + SLOT(channelFxEdit())); + + 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 + + setSelected(false); } ChannelStrip::~ChannelStrip (void) { + setSelected(false); + // Destroy existing channel descriptor. if (m_pChannel) delete m_pChannel; @@ -110,7 +140,7 @@ while (iter.hasNext()) { const QString& sFilename = iter.next().toLocalFile(); if (!sFilename.isEmpty()) { - bAccept = qsamplerChannel::isInstrumentFile(sFilename); + bAccept = Channel::isInstrumentFile(sFilename); break; } } @@ -151,7 +181,7 @@ // Channel strip setup formal initializer. -void ChannelStrip::setup ( qsamplerChannel *pChannel ) +void ChannelStrip::setup ( Channel *pChannel ) { // Destroy any previous channel descriptor; // (remember that once setup we own it!) @@ -171,7 +201,7 @@ // Channel secriptor accessor. -qsamplerChannel *ChannelStrip::channel (void) const +Channel *ChannelStrip::channel (void) const { return m_pChannel; } @@ -207,6 +237,7 @@ pal.setColor(QPalette::Background, Qt::black); } m_ui.ChannelInfoFrame->setPalette(pal); + m_ui.InstrumentNameTextLabel->setPalette(pal); m_ui.StreamVoiceCountTextLabel->setPalette(pal); } @@ -278,6 +309,33 @@ m_pChannel->editChannel(); } +bool ChannelStrip::channelFxEdit (void) +{ + MainForm *pMainForm = MainForm::getInstance(); + if (!pMainForm || !channel()) + return false; + + pMainForm->appendMessages(QObject::tr("channel fx sends...")); + + bool bResult = false; + +#if CONFIG_FXSEND + ChannelFxForm *pChannelFxForm = + new ChannelFxForm(channel(), parentWidget()); + if (pChannelFxForm) { + //pChannelForm->setup(this); + bResult = pChannelFxForm->exec(); + delete pChannelFxForm; + } +#else // CONFIG_FXSEND + QMessageBox::critical(this, + QSAMPLER_TITLE ": " + tr("Unavailable"), + tr("Sorry, QSampler was built without FX send support!\n\n" + "(Make sure you have a recent liblscp when recompiling QSampler)")); +#endif // CONFIG_FXSEND + + return bResult; +} // Channel reset slot. bool ChannelStrip::channelReset (void) @@ -309,10 +367,10 @@ if (m_pChannel->instrumentName().isEmpty()) { if (m_pChannel->instrumentStatus() >= 0) { m_ui.InstrumentNameTextLabel->setText( - ' ' + qsamplerChannel::loadingInstrument()); + ' ' + Channel::loadingInstrument()); } else { m_ui.InstrumentNameTextLabel->setText( - ' ' + qsamplerChannel::noInstrumentName()); + ' ' + Channel::noInstrumentName()); } } else { m_ui.InstrumentNameTextLabel->setText( @@ -371,7 +429,7 @@ // Engine name... if (m_pChannel->engineName().isEmpty()) { m_ui.EngineNameTextLabel->setText( - ' ' + qsamplerChannel::noEngineName()); + ' ' + Channel::noEngineName()); } else { m_ui.EngineNameTextLabel->setText( ' ' + m_pChannel->engineName()); @@ -491,6 +549,10 @@ } } +void ChannelStrip::midiArrived() { + m_ui.MidiActivityLabel->setPalette(MIDI_ON_COLOR); + pMidiActivityTimer->start(50); +} // Context menu event handler. void ChannelStrip::contextMenuEvent( QContextMenuEvent *pEvent ) @@ -502,6 +564,9 @@ m_pChannel->contextMenuEvent(pEvent); } +void ChannelStrip::midiDataCeased() { + m_ui.MidiActivityLabel->setPalette(MIDI_OFF_COLOR); +} // Error count hackish accessors. void ChannelStrip::resetErrorCount (void)