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 |
29 |
|
|
30 |
#include <QMessageBox> |
#include <QMessageBox> |
31 |
#include <QDragEnterEvent> |
#include <QDragEnterEvent> |
32 |
|
#include <QTimer> |
33 |
#include <QUrl> |
#include <QUrl> |
34 |
|
|
|
#define MIDI_OFF_COLOR Qt::darkGreen |
|
|
#define MIDI_ON_COLOR Qt::green |
|
35 |
|
|
36 |
// Channel status/usage usage limit control. |
// Channel status/usage usage limit control. |
37 |
#define QSAMPLER_ERROR_LIMIT 3 |
#define QSAMPLER_ERROR_LIMIT 3 |
56 |
// QSampler::ChannelStrip -- Channel strip form implementation. |
// QSampler::ChannelStrip -- Channel strip form implementation. |
57 |
// |
// |
58 |
|
|
59 |
|
// MIDI activity pixmap common resources. |
60 |
|
int ChannelStrip::g_iMidiActivityRefCount = 0; |
61 |
|
QPixmap *ChannelStrip::g_pMidiActivityLedOn = NULL; |
62 |
|
QPixmap *ChannelStrip::g_pMidiActivityLedOff = NULL; |
63 |
|
|
64 |
// Channel strip activation/selection. |
// Channel strip activation/selection. |
65 |
ChannelStrip *ChannelStrip::g_pSelectedStrip = NULL; |
ChannelStrip *ChannelStrip::g_pSelectedStrip = NULL; |
66 |
|
|
74 |
m_iDirtyChange = 0; |
m_iDirtyChange = 0; |
75 |
m_iErrorCount = 0; |
m_iErrorCount = 0; |
76 |
|
|
77 |
|
if (++g_iMidiActivityRefCount == 1) { |
78 |
|
g_pMidiActivityLedOn = new QPixmap(":/icons/ledon1.png"); |
79 |
|
g_pMidiActivityLedOff = new QPixmap(":/icons/ledoff1.png"); |
80 |
|
} |
81 |
|
|
82 |
|
m_ui.MidiActivityLabel->setPixmap(*g_pMidiActivityLedOff); |
83 |
|
|
84 |
|
#ifndef CONFIG_EVENT_CHANNEL_MIDI |
85 |
|
m_ui.MidiActivityLabel->setToolTip("MIDI activity (disabled)"); |
86 |
|
#endif |
87 |
|
|
88 |
|
m_pMidiActivityTimer = new QTimer(this); |
89 |
|
m_pMidiActivityTimer->setSingleShot(true); |
90 |
|
|
91 |
|
QObject::connect(m_pMidiActivityTimer, |
92 |
|
SIGNAL(timeout()), |
93 |
|
SLOT(midiActivityLedOff()) |
94 |
|
); |
95 |
|
|
96 |
// Try to restore normal window positioning. |
// Try to restore normal window positioning. |
97 |
adjustSize(); |
adjustSize(); |
98 |
|
|
118 |
SIGNAL(clicked()), |
SIGNAL(clicked()), |
119 |
SLOT(channelFxEdit())); |
SLOT(channelFxEdit())); |
120 |
|
|
|
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 |
|
|
|
|
121 |
setSelected(false); |
setSelected(false); |
122 |
} |
} |
123 |
|
|
130 |
if (m_pChannel) |
if (m_pChannel) |
131 |
delete m_pChannel; |
delete m_pChannel; |
132 |
m_pChannel = NULL; |
m_pChannel = NULL; |
133 |
|
|
134 |
|
if (--g_iMidiActivityRefCount == 0) { |
135 |
|
if (g_pMidiActivityLedOn) |
136 |
|
delete g_pMidiActivityLedOn; |
137 |
|
g_pMidiActivityLedOn = NULL; |
138 |
|
if (g_pMidiActivityLedOff) |
139 |
|
delete g_pMidiActivityLedOff; |
140 |
|
g_pMidiActivityLedOff = NULL; |
141 |
|
} |
142 |
} |
} |
143 |
|
|
144 |
|
|
489 |
// Mute/Solo button state coloring... |
// Mute/Solo button state coloring... |
490 |
bool bMute = m_pChannel->channelMute(); |
bool bMute = m_pChannel->channelMute(); |
491 |
const QColor& rgbButton = pal.color(QPalette::Button); |
const QColor& rgbButton = pal.color(QPalette::Button); |
492 |
|
const QColor& rgbButtonText = pal.color(QPalette::ButtonText); |
493 |
pal.setColor(QPalette::Foreground, rgbFore); |
pal.setColor(QPalette::Foreground, rgbFore); |
494 |
pal.setColor(QPalette::Button, bMute ? Qt::yellow : rgbButton); |
pal.setColor(QPalette::Button, bMute ? Qt::yellow : rgbButton); |
495 |
|
pal.setColor(QPalette::ButtonText, bMute ? Qt::darkYellow : rgbButtonText); |
496 |
m_ui.ChannelMutePushButton->setPalette(pal); |
m_ui.ChannelMutePushButton->setPalette(pal); |
497 |
m_ui.ChannelMutePushButton->setDown(bMute); |
m_ui.ChannelMutePushButton->setDown(bMute); |
498 |
bool bSolo = m_pChannel->channelSolo(); |
bool bSolo = m_pChannel->channelSolo(); |
499 |
pal.setColor(QPalette::Button, bSolo ? Qt::cyan : rgbButton); |
pal.setColor(QPalette::Button, bSolo ? Qt::cyan : rgbButton); |
500 |
|
pal.setColor(QPalette::ButtonText, bSolo ? Qt::darkCyan : rgbButtonText); |
501 |
m_ui.ChannelSoloPushButton->setPalette(pal); |
m_ui.ChannelSoloPushButton->setPalette(pal); |
502 |
m_ui.ChannelSoloPushButton->setDown(bSolo); |
m_ui.ChannelSoloPushButton->setDown(bSolo); |
503 |
#else |
#else |
569 |
} |
} |
570 |
} |
} |
571 |
|
|
|
void ChannelStrip::midiArrived() { |
|
|
m_ui.MidiActivityLabel->setPalette(MIDI_ON_COLOR); |
|
|
pMidiActivityTimer->start(50); |
|
|
} |
|
572 |
|
|
573 |
// Context menu event handler. |
// Context menu event handler. |
574 |
void ChannelStrip::contextMenuEvent( QContextMenuEvent *pEvent ) |
void ChannelStrip::contextMenuEvent( QContextMenuEvent *pEvent ) |
580 |
m_pChannel->contextMenuEvent(pEvent); |
m_pChannel->contextMenuEvent(pEvent); |
581 |
} |
} |
582 |
|
|
583 |
void ChannelStrip::midiDataCeased() { |
|
584 |
m_ui.MidiActivityLabel->setPalette(MIDI_OFF_COLOR); |
void ChannelStrip::midiActivityLedOn (void) |
585 |
|
{ |
586 |
|
m_ui.MidiActivityLabel->setPixmap(*g_pMidiActivityLedOn); |
587 |
|
m_pMidiActivityTimer->start(100); |
588 |
|
} |
589 |
|
|
590 |
|
|
591 |
|
void ChannelStrip::midiActivityLedOff (void) |
592 |
|
{ |
593 |
|
m_ui.MidiActivityLabel->setPixmap(*g_pMidiActivityLedOff); |
594 |
} |
} |
595 |
|
|
596 |
|
|
597 |
// Error count hackish accessors. |
// Error count hackish accessors. |
598 |
void ChannelStrip::resetErrorCount (void) |
void ChannelStrip::resetErrorCount (void) |
599 |
{ |
{ |